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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
//! # nanonis-rs
//!
//! A Rust client library for communicating with Nanonis SPM systems via TCP.
//!
//! ## Quick Start
//!
//! ```no_run
//! use nanonis_rs::{NanonisClient, NanonisError};
//!
//! fn main() -> Result<(), NanonisError> {
//! let mut client = NanonisClient::new("192.168.1.100", 6501)?;
//!
//! // Get current bias voltage
//! let bias = client.bias_get()?;
//! println!("Current bias: {} V", bias);
//!
//! // Set new bias voltage
//! client.bias_set(0.5)?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Usage Pattern
//!
//! All instrument control is done through [`NanonisClient`]. Import types
//! from domain modules only when needed:
//!
//! ```no_run
//! use nanonis_rs::{NanonisClient, NanonisError};
//! use nanonis_rs::motor::{MotorDirection, MotorGroup};
//! use nanonis_rs::scan::ScanFrame;
//!
//! fn main() -> Result<(), NanonisError> {
//! let mut client = NanonisClient::new("192.168.1.100", 6501)?;
//!
//! // Motor control
//! client.motor_start_move(MotorDirection::ZPlus, 100u16, MotorGroup::Group1, true)?;
//!
//! // Scan control
//! let frame = client.scan_frame_get()?;
//! println!("Scan center: ({}, {})", frame.center.x, frame.center.y);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Streaming Data
//!
//! For continuous data acquisition, use [`TCPLoggerStream`]:
//!
//! ```no_run
//! use nanonis_rs::TCPLoggerStream;
//!
//! let mut stream = TCPLoggerStream::new("192.168.1.100", 6502)?;
//! let frame = stream.read_frame()?;
//! println!("Got {} channels", frame.data.len());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// Internal modules
// ==================== Public API ====================
pub use ;
pub use NanonisError;
pub use TCPLoggerStream;
// ==================== Protocol Constants ====================
/// Maximum valid Nanonis signal index (0-based, 128 signals total).
pub const MAX_SIGNAL_INDEX: u8 = 127;
/// Maximum valid TCP logger channel index (0-based, 24 channels total).
pub const MAX_TCP_CHANNEL: u8 = 23;
/// Nanonis internal data acquisition base rate in Hz.
///
/// This is the fundamental sampling rate of the Nanonis RT engine.
/// The effective rate seen in the TCP data stream is
/// `BASE_ACQUISITION_RATE_HZ / oversampling`.
pub const BASE_ACQUISITION_RATE_HZ: f64 = 2000.0;
// Re-export commonly used types from the internal types module
pub use ;
// ==================== Domain Type Modules ====================
//
// Import types from these modules as needed.
/// Motor control types.
///
/// ```
/// use nanonis_rs::motor::{MotorDirection, MotorGroup, MotorAxis};
/// ```
/// Scan control types.
///
/// ```
/// use nanonis_rs::scan::{ScanFrame, ScanAction, ScanDirection};
/// ```
/// Bias control types.
///
/// ```
/// use nanonis_rs::bias::PulseMode;
/// ```
/// Bias spectroscopy types.
///
/// ```
/// use nanonis_rs::bias_spectr::{BiasSpectrPropsBuilder, OptionalFlag};
/// ```
/// Z-controller types.
///
/// ```
/// use nanonis_rs::z_ctrl::{ZControllerHold, ZControllerStatus};
/// ```
/// Oscilloscope types.
///
/// ```
/// use nanonis_rs::oscilloscope::{TriggerMode, TriggerSlope, OsciData};
/// ```
/// Signal management types.
///
/// ```
/// use nanonis_rs::signals::SignalIndex;
/// ```
/// Lock-in amplifier types.
/// Piezo control types.
/// User output types.
/// TCP logger types.
/// PLL (Phase-Locked Loop) types.
/// Generic sweep types.
/// High-speed sweep types.
/// Pattern types.
/// Follow-me types.
/// Atom tracking types.
/// Kelvin controller types.
/// Spectrum analyzer types.
/// PLL signal analyzer types.
/// Generic PI controller types.
/// Marks types.
/// Data logging types.
/// Script types.
/// Interferometer types.
/// Beam deflection types.
/// OC sync types.
/// Digital lines types.
/// PI controller types.
/// Lock-in frequency sweep types.
/// Signal chart types.
/// Tip recovery types.
/// CPD compensation types.
/// Z spectroscopy types.
/// Utility types.
/// PLL frequency sweep types.
// Note: mpass, laser, and user_in modules exist in client/ but contain
// only NanonisClient impl blocks with no standalone public types.
// Their methods are available directly on NanonisClient without a module import.