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
In the context of LabOne Q, the
Session can be defined using a
and takes care of verifying the availability of the instruments
described by this class. A
Session can be run in
where no actual connection to the physical devices is attempted, but the
code is still compiled consistently with the requirements of those
## define Session object session = Session(device_setup=device_setup) ## connect the Session without emulation session.connect(do_emulation=False)
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 session.compile(exp) ## set log level to debug import logging session.log_level = logging.DEBUG ## run the experiment session.run(exp)
Zurich Instruments Toolkit¶
As the fundamental class for the instrument interface, a
be used to control individual devices and node values. This is performed
address a specific device contained in the
Using Toolkit functions is not possible if the
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
session.run(), never use subscribe/poll over
zhinst.toolkit(neither in the main script before/after
session.run(), nor in the user functions)
- When working solely with the
zhinst.toolkitand 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
and then using a toolkit command to change a specific node.
## connect to the session session.connect() ## change the amplitude of channel 1 to 1 V session.devices["device_hdawg"].awgs.outputs.amplitude(1)
A device can also be addressed using its serial number instead of its
uid. Using this descriptor,
for example, we could substitute
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
Note that this can only be done in near-time.