1use nanonis_rs::scan::{AutosaveMode, ScanPropsBuilder};
2use nanonis_rs::NanonisClient;
3
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5
6 let mut client = NanonisClient::new("127.0.0.1", 6501)?;
7
8 println!("=== Scan Properties Test ===\n");
9
10 println!("1. Reading current scan properties...");
12 let props_before = client.scan_props_get()?;
13 println!(" Continuous scan: {}", props_before.continuous_scan);
14 println!(" Bouncy scan: {}", props_before.bouncy_scan);
15 println!(" Autosave: {:?}", props_before.autosave);
16 println!(" Series name: {:?}", props_before.series_name);
17 println!(" Comment: {:?}", props_before.comment);
18 println!(" Modules: {:?}", props_before.modules_names);
19 println!(" Autopaste: {:?}", props_before.autopaste);
20 println!();
21
22 println!("2. Setting new scan properties...");
24 let new_props = ScanPropsBuilder::new()
25 .continuous_scan(true) .bouncy_scan(true) .autosave(AutosaveMode::Off); client.scan_props_set(new_props)?;
30 println!(" Properties set successfully");
31 println!();
32
33 println!("3. Reading properties again to verify changes...");
35 let props_after = client.scan_props_get()?;
36 println!(" Continuous scan: {}", props_after.continuous_scan);
37 println!(" Bouncy scan: {}", props_after.bouncy_scan);
38 println!(" Autosave: {:?}", props_after.autosave);
39 println!(" Series name: {:?}", props_after.series_name);
40 println!(" Comment: {:?}", props_after.comment);
41 println!(" Modules: {:?}", props_after.modules_names);
42 println!(" Autopaste: {:?}", props_after.autopaste);
43 println!();
44
45 println!("4. Verifying changes...");
47 let mut success = true;
48
49 if !props_after.continuous_scan {
50 println!(" ✗ Continuous scan not set correctly");
51 success = false;
52 } else {
53 println!(" ✓ Continuous scan set to On");
54 }
55
56 if !props_after.bouncy_scan {
57 println!(" ✗ Bouncy scan not set correctly");
58 success = false;
59 } else {
60 println!(" ✓ Bouncy scan set to On");
61 }
62
63 if props_after.autosave != AutosaveMode::Off {
64 println!(" ✗ Autosave not set correctly");
65 success = false;
66 } else {
67 println!(" ✓ Autosave set to Off");
68 }
69
70 println!();
71 if success {
72 println!("✓ All properties changed successfully!");
73 } else {
74 println!("✗ Some properties did not change as expected");
75 }
76
77 println!("\n5. Restoring original properties...");
79 let restore = ScanPropsBuilder::new()
80 .continuous_scan(props_before.continuous_scan)
81 .bouncy_scan(props_before.bouncy_scan)
82 .autosave(props_before.autosave);
83 client.scan_props_set(restore)?;
84 println!(" Properties restored");
85
86 Ok(())
87}