Switch
The Switch module is a generic module that can be used to create and load instrument drivers that do not match any of the more specific device modules.
Typical instruments
Typical instruments are ones where the main task is to apply a value rather than reading values.
- Motor
- Relais or switching matrix
- Lamp
- Digital or analog outputs
- Filter wheel
- Optical chopper
- Tunable laser
GUI
The Switch module has two tabs:
- Setup: the fields "Driver", "Port" and "Channel" (only shown if the driver defines channels), the section "Sweep" with "Sweep mode" and "Sweep value", the section "Parameters" with the fields defined by the driver, and the section "Test".
- Sweep values: the SweepEditor and the SweepBox. Select "SweepEditor" or "SweepBox" in the field "Sweep value" to use the values defined in this tab.
The section 'Test' can be used to apply a value according to the current Sweep mode. Enter the value in the field "Value" and press "Apply", or press "Stop" to stop the instrument. The Test section can only be used if no measurement is running, e.g. to test the instrument or to adjust the setup.
Driver programming
The module Switch has the standard fields 'Label', 'Device', 'Port', and 'Channel'. Further parameters can be arbitrarily chosen and will be presented in the section 'Parameters'. How to create drivers and define custom user input fields is described on the page Driver Programming.
Apply & Stop buttons
In the 'Test' section of the module, there are the buttons "Apply" and "Stop" that can be used to do basic communication tests with the driver. These buttons trigger a series of semantic standard functions so that each driver automatically supports these buttons if semantic standard functions are correctly filled. As the programmer of the driver, you have to make sure that after calling these functions, the new set value is either applied or the instrument is stopped.
Apply triggers the following functions:
- connect
- initialize
- configure
- poweron
- signin
- start
- apply
- disconnect
Because 'configure' is used, the parameters of the Parameters section are applied at the beginning. The value that is applied in "apply" is taken from the field "Value" right next to the Apply button. It is handed over as text in self.value, so the driver may need to convert it, e.g. with float().
Stop triggers the following functions:
- connect
- signout
- unconfigure
- poweroff
- deinitialize
- disconnect
Return Values
For devices that do not perform measurements (e.g., a switching matrix), it can still be beneficial to return the applied value (self.value) in the call method. This ensures that the set values are recorded in the measurement results, providing a reference for which values were applied.