In this chapter, we provide a brief overview of the functionality of the Session class. A Session is the fundamental way to interact with physical and emulated devices within the LabOne Q framework. This class represents a single client session to a data server, which manages the communication between the user PC and the instruments in the QCCS system. For a more detailed description of the architecture, we refer the reader to the LabOne user manual.

In the context of LabOne Q, the Session can be defined using a DeviceSetup and takes care of verifying the availability of the instruments described by this class. A Session can be run in emulation mode, where no actual connection to the physical devices is attempted, but the code is still compiled consistently with the requirements of those devices.

# define Session object
session = Session(device_setup=device_setup)
# connect the Session without emulation

As the main endpoint for the user interaction with the QCCS, a session object holds information about the physical wiring of the devices and their calibrations properties, information about the experiment definition that can be run on the devices, and the results of executed experiments.

Using this class it is possible to run experiments, compile experiments without running them, adjust the level of logs produced during execution, and much more. A complete list of the functionalities of this class can be found in the API documentation.

# compile an experiment without running it
# set log level to debug
import logging
session.log_level = logging.DEBUG
# run the experiment

Zurich Instruments Toolkit

As the fundamental class for the instrument interface, a Session can be used to control individual devices and node values. This is performed using the zhinst.toolkit to address a specific device contained in the Session.

IMPORTANT: Using Toolkit functions is not possible if the Session was created in emulation mode, as it is impossible to address physical nodes without connecting to an instrument.

  • When LabOne Q controls devices by running an experiment via, never use subscribe/poll over zhinst.toolkit (neither in the main script before/after, nor in the user functions)

  • When working solely with the zhinst.toolkit and only getting the initial connection via LabOne Q session, use subscribe/poll as you need it.

To address a device, we can use its uid as defined in the descriptor, and then using a toolkit command to change a specific node.

# connect to the session
# change the amplitude of channel 1 to 1 V

A device can also be addressed using its serial number instead of its uid. Using this descriptor, for example, we could substitute device_hdawg with DEV8000 to produce an identical result.

Using this functionality, a Session can be used to change, or even sweep, a node of a device inside an Experiment definition, as described in the chapter Callback Functions and 3rd-Party Devices. Note that this can only be done in near-time.