1// ExampleDeviceSettings instantiates a deviceSettings module and performs a save
2// and load of device settings. The LabOne UI uses this module to save and
3// load the device settings.
4public static void ExampleDeviceSettings(string dev = DEFAULT_DEVICE) // Timeout(15000)
5{
6 ziDotNET daq = connect(dev);
7 resetDeviceToDefault(daq, dev);
8 ziModule settings = daq.deviceSettings();
9 // First save the current device settings
10 settings.setString("device", dev);
11 settings.setString("command", "save");
12 settings.setString("filename", "test_settings");
13 settings.setString("path", Environment.CurrentDirectory);
14 settings.execute();
15 while (!settings.finished())
16 {
17 System.Threading.Thread.Sleep(100);
18 }
19 // Remember the current device parameter for later comparison
20 String path = String.Format("/{0}/oscs/0/freq", dev);
21 Double originalValue = daq.getDouble(path);
22 // Change the parameter
23 daq.setDouble(path, 2 * originalValue);
24 // Load device settings from file
25 settings.setString("device", dev);
26 settings.setString("command", "load");
27 settings.setString("filename", "test_settings");
28 settings.setString("path", Environment.CurrentDirectory);
29 settings.execute();
30 while (!settings.finished())
31 {
32 System.Threading.Thread.Sleep(100);
33 }
34 // Check the restored parameter
35 Double newValue = daq.getDouble(path);
36
37 AssertEqual(originalValue, newValue);
38
39 settings.clear(); // Release module resources. Especially important if modules are created
40 // inside a loop to prevent excessive resource consumption.
41 daq.disconnect();
42}