ExampleDeviceSettingsΒΆ

 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
// ExampleDeviceSettings instantiates a deviceSettings module and performs a save
// and load of device settings. The LabOne UI uses this module to save and
// load the device settings.
public static void ExampleDeviceSettings(string dev = DEFAULT_DEVICE) // Timeout(15000)
{
  ziDotNET daq = connect(dev);
  resetDeviceToDefault(daq, dev);
  ziModule settings = daq.deviceSettings();
  // First save the current device settings
  settings.setString("device", dev);
  settings.setString("command", "save");
  settings.setString("filename", "test_settings");
  settings.setString("path", Environment.CurrentDirectory);
  settings.execute();
  while (!settings.finished())
  {
    System.Threading.Thread.Sleep(100);
  }
  // Remember the current device parameter for later comparison
  String path = String.Format("/{0}/oscs/0/freq", dev);
  Double originalValue = daq.getDouble(path);
  // Change the parameter
  daq.setDouble(path, 2 * originalValue);
  // Load device settings from file
  settings.setString("device", dev);
  settings.setString("command", "load");
  settings.setString("filename", "test_settings");
  settings.setString("path", Environment.CurrentDirectory);
  settings.execute();
  while (!settings.finished())
  {
    System.Threading.Thread.Sleep(100);
  }
  // Check the restored parameter
  Double newValue = daq.getDouble(path);

  AssertEqual(originalValue, newValue);

  settings.clear();  // Release module resources. Especially important if modules are created
                     // inside a loop to prevent excessive resource consumption.
  daq.disconnect();
}