1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use super::NanonisClient;
use crate::error::NanonisError;
use crate::types::NanonisValue;
/// Interferometer controller properties.
#[derive(Debug, Clone, Copy, Default)]
pub struct InterfCtrlProps {
/// Integral gain
pub integral: f32,
/// Proportional gain
pub proportional: f32,
/// Sign (true = positive, false = negative)
pub positive_sign: bool,
}
impl NanonisClient {
// ==================== Interferometer ====================
/// Switch the interferometer controller on or off.
///
/// # Arguments
/// * `on` - True to enable, false to disable
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_on_off_set(&mut self, on: bool) -> Result<(), NanonisError> {
self.quick_send(
"Interf.CtrlOnOffSet",
vec![NanonisValue::U32(if on { 1 } else { 0 })],
vec!["I"],
vec![],
)?;
Ok(())
}
/// Get the status of the interferometer controller.
///
/// # Returns
/// True if controller is on.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_on_off_get(&mut self) -> Result<bool, NanonisError> {
let result = self.quick_send("Interf.CtrlOnOffGet", vec![], vec![], vec!["I"])?;
Ok(result[0].as_u32()? != 0)
}
/// Set the interferometer controller properties.
///
/// # Arguments
/// * `props` - Controller properties
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_props_set(&mut self, props: &InterfCtrlProps) -> Result<(), NanonisError> {
self.quick_send(
"Interf.CtrlPropsSet",
vec![
NanonisValue::F32(props.integral),
NanonisValue::F32(props.proportional),
NanonisValue::U32(if props.positive_sign { 1 } else { 0 }),
],
vec!["f", "f", "I"],
vec![],
)?;
Ok(())
}
/// Get the interferometer controller properties.
///
/// # Returns
/// Controller properties.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_props_get(&mut self) -> Result<InterfCtrlProps, NanonisError> {
let result = self.quick_send("Interf.CtrlPropsGet", vec![], vec![], vec!["f", "f", "I"])?;
Ok(InterfCtrlProps {
integral: result[0].as_f32()?,
proportional: result[1].as_f32()?,
positive_sign: result[2].as_u32()? != 0,
})
}
/// Set the W-piezo position.
///
/// The interferometer controller must be off to change this.
///
/// # Arguments
/// * `w_piezo` - W-piezo position value
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_w_piezo_set(&mut self, w_piezo: f32) -> Result<(), NanonisError> {
self.quick_send(
"Interf.WPiezoSet",
vec![NanonisValue::F32(w_piezo)],
vec!["f"],
vec![],
)?;
Ok(())
}
/// Get the W-piezo position.
///
/// # Returns
/// W-piezo position value.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_w_piezo_get(&mut self) -> Result<f32, NanonisError> {
let result = self.quick_send("Interf.WPiezoGet", vec![], vec![], vec!["f"])?;
result[0].as_f32()
}
/// Get the interferometer value.
///
/// # Returns
/// Interferometer value.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_val_get(&mut self) -> Result<f32, NanonisError> {
let result = self.quick_send("Interf.ValGet", vec![], vec![], vec!["f"])?;
result[0].as_f32()
}
/// Open the calibration panel for the interferometer controller.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_calibr_open(&mut self) -> Result<(), NanonisError> {
self.quick_send("Interf.CtrlCalibrOpen", vec![], vec![], vec![])?;
Ok(())
}
/// Reset the interferometer controller.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_reset(&mut self) -> Result<(), NanonisError> {
self.quick_send("Interf.CtrlReset", vec![], vec![], vec![])?;
Ok(())
}
/// Apply null deflection to the interferometer controller.
///
/// # Errors
/// Returns `NanonisError` if communication fails.
pub fn interf_ctrl_null_defl(&mut self) -> Result<(), NanonisError> {
self.quick_send("Interf.CtrlNullDefl", vec![], vec![], vec![])?;
Ok(())
}
}