Skip to content

Configurators

William Wood edited this page Jul 6, 2021 · 7 revisions

Configurators

In JISA there are a set of GUI elements known as Configurator elements. These allow the user to select which out of all connected instruments (and which channel if applicable) to use for a given purpose as well as letting them define standard configuration parameters (like range settings etc).

Using these makes your program more flexible by allowing your user choose which instruments (and which channels/sensors/output on that instrument) are used to fulfil specific roles without having to change your code.

Creating a Configurator

To create a configurator, instantiate a Configurator object, providing it with a name and what type of instrument is to be configured. FOr instance, to create a Configurator for an SMU we would write:

Java

Configurator<SMU> smuConfig = new Configurator<>("Source-Drain Channel", SMU.class);

Kotlin

val smuConfig = Configurator<>("Source-Drain Channel", SMU::class.java)

Since all Connection objects are globally stored in JISA, any Configurator element you create will be able to "see" all connected instruments and provide them as a choice to the user automatically.

Connector<SMU> smuConnector1 = new Connector("SMU 1", SMU.class);
Connector<SMU> smuConnector2 = new Connector("SMU 2", SMU.class);
Connector<SMU> smuConnector3 = new Connector("SMU 3", SMU.class);
Grid           connections   = new Grid("Connections", smuConnector1, smuConnector2, smuConnector3);

Configurator<SMU> sourceDrain = new Configurator<>("Source-Drain", SMU.class);

connections.show();
sourceDrain.show();

Which would result in two windows, including the grid of Connectors:

and the SMU Configurator:

Using a Configurator

Much like how a Connector object is a visual representation of a Connection, Configurator objects are visual representations of Configuration objects. Therefore, you can extract the Configuration from a Configurator by using getConfiguration() and then the configured instrument itself by use of getInstrument():

Configurator<X>  configurator = new Configurator<>("Name", X.class);

...

Configuration<X> config       = configurator.getConfiguration();
X                inst         = config.getInstrument();

For instance, taking our previous example of an SMU based Configurator, we can extract an SMU object from our Configurator like so:

Configuration<SMU> config = sourceDrain.getConfiguration();
SMU                smu    = config.getInstrument();

// or all on one line:

SMU smu = sourceDrain.getConfiguration().getInstrument();

When we call this, the Configuration takes the SMU connected via whichever connection the user has chosen, extracts the channel (specified by the user) as its own SMU object then applies all the settings to that extracted object before returning it. If the SMU selected is not connected this will return null instead.

For example if we chose "SMU 1" and "Channel 1", we could represent this process using a diagram like so:

Therefore, this structure is useful for both allowing the user to configure standard instrument parameters but also being able to let them define whether a role is to be fulfilled by, for example, a single-channel SMU or one channel of a multi-channel SMU allowing you to generalise your code to work with any SMU configuration.

Clone this wiki locally