Skip to content

Python Core API General Functions

Connect\Disconnect

connect()

Initiate the connection to the data server.

Important

During the object initialization the connection is already established. It is therefore not necessary to call this function unless one actively disconnects from the data server with the disconnect method.

connectDevice(dev, interface, params=None)

Connect with the data server to a specified device.

The device must be visible to the server. If the device is already connected the call will be ignored. The function will block until the device is connected and the device is ready to use.

Parameters:

Name Type Description Default
dev str

Device serial.

required
interface Literal['USB', 'PCIe', '1GbE']

Device interface.

required
params Optional[str]

Optional interface parameters string.

None

disconnect()

Disconnects from the data server.

Important

During the destruction the connection is closed properly. This function therefore does not need to be called in normal usage.

disconnectDevice(dev)

Disconnect a device from the data server.

This function will return immediately. The disconnection of the device may not yet be finished.

Parameters:

Name Type Description Default
dev str

Device serial string of device to disconnect.

required

Node Info

help(path)

Prints a well-formatted description of a node.

HF2 devices do not support this functionality.

Parameters:

Name Type Description Default
path str

Path for which the nodes should be listed. The path may contain wildcards so that the returned nodes do not necessarily have to have the same parents.

required

listNodes(path, *, flags=None, recursive=False, absolute=False, leavesonly=False, settingsonly=False, streamingonly=False, subscribedonly=False, basechannelonly=False, getonly=False, excludevectors=False, excludestreaming=False)

This function returns a list of node names found at the specified path.

Parameters:

Name Type Description Default
path str

Path for which the nodes should be listed. The path may contain wildcards so that the returned nodes do not necessarily have to have the same parents.

required
flags Optional[Union[ziListEnum, int]]

Flags specifying how the selected nodes are listed (see zhinst.core.ziListEnum). Flags can also specified by the keyword arguments below.

None
recursive bool

Returns the nodes recursively (default: False)

False
absolute bool

Returns absolute paths (default: True)

False
leavesonly bool

Returns only nodes that are leaves, which means they are at the outermost level of the tree (default: False).

False
settingsonly bool

Returns only nodes which are marked as setting (default: False).

False
streamingonly bool

Returns only streaming nodes (default: False).

False
subscribedonly bool

Returns only subscribed nodes (default: False).

False
basechannelonly bool

Return only one instance of a node in case of multiple channels (default: False).

False
getonly bool

Return only nodes that can be used in a get request

False
excludestreaming bool

Exclude streaming nodes (default: False).

False
excludevectors bool

Exclude vector nodes (default: False).

False

Returns:

Type Description
List[str]

List of node names.

listNodesJSON(path, *, flags=None, recursive=False, absolute=False, leavesonly=False, settingsonly=False, streamingonly=False, subscribedonly=False, basechannelonly=False, getonly=False, excludevectors=False, excludestreaming=False)

Returns a list of nodes with description found at the specified path.

HF2 devices do not support this functionality.

Parameters:

Name Type Description Default
path str

Path for which the nodes should be listed. The path may contain wildcards so that the returned nodes do not necessarily have to have the same parents.

required
flags Optional[Union[ziListEnum, int]]

Flags specifying how the selected nodes are listed (see zhinst.core.ziListEnum). Flags can also specified by the keyword arguments below. They are the same as for listNodes(), except that recursive, absolute, and leavesonly are enforced.

None
settingsonly bool

Returns only nodes which are marked as setting (default: False).

False
streamingonly bool

Returns only streaming nodes (default: False).

False
subscribedonly bool

Returns only subscribed nodes (default: False).

False
basechannelonly bool

Return only one instance of a node in case of multiple channels (default: False).

False
getonly bool

Return only nodes that can be used in a get request

False
excludestreaming bool

Exclude streaming nodes (default: False).

False
excludevectors bool

Exclude vector nodes (default: False).

False

Returns:

Type Description
List[str]

JSON dictionary nodepath:information

Info

getConnectionAPILevel()

Returns ziAPI level used for the active connection.

DEPRECATED, use api_level.

Returns:

Type Description
Literal[0, 1, 4, 5, 6]

ziAPI level used for the active connection.

revision()

Get the revision number of the Python interface of Zurich Instruments.

Returns:

Type Description
int

Revision number.

version()

Get version string of the Python interface of Zurich Instruments.

Logging

getDebugLogpath()

Path where logfiles are stored.

Note, it will return an empty string if the path has not been set or logging has not been enabled via setDebugLevel().

Returns:

Type Description
str

Path to directory where logfiles are stored.

setDebugLevel(severity)

Enables debug log and sets the debug level.

Resets the debug levels for individual sinks.

Parameters:

Name Type Description Default
severity Literal[0, 1, 2, 3, 4, 5, 6]

Debug level (trace:0, debug:1, info:2, status:3, warning:4, error:5, fatal:6).

required

setDebugLevelConsole(severity)

Enables debug log and sets the debug level for the console output.

Parameters:

Name Type Description Default
severity Literal[0, 1, 2, 3, 4, 5, 6]

Debug level (trace:0, debug:1, info:2, status:3, warning:4, error:5, fatal:6).

required

setDebugLevelFile(severity)

Enables debug log and sets the debug level for the file output.

Parameters:

Name Type Description Default
severity Literal[0, 1, 2, 3, 4, 5, 6]

Debug level (trace:0, debug:1, info:2, status:3, warning:4, error:5, fatal:6).

required

setDebugLogpath(path)

Sets the path where logfiles are stored.

Note, it will restart logging if it was already enabled via setDebugLevel().

Parameters:

Name Type Description Default
path str

Path to directory where logfiles are stored.

required

writeDebugLog(severity, message)

Outputs message to the debug log (if enabled).

Parameters:

Name Type Description Default
severity Literal[0, 1, 2, 3, 4, 5, 6]

Debug level (trace:0, debug:1, info:2, status:3, warning:4, error:5, fatal:6). message: Message to output to the log.

required

logOff()

Disables logging of commands sent to a server.

logOn(flags, filename, style=2)

Enables logging of commands sent to a server.

Parameters:

Name Type Description Default
flags int

Flags (LOG_NONE: 0x00000000 LOG_SET_DOUBLE: 0x00000001 LOG_SET_INT: 0x00000002 LOG_SET_BYTE: 0x00000004 LOG_SET_STRING: 0x00000008 LOG_SYNC_SET_DOUBLE: 0x00000010 LOG_SYNC_SET_INT: 0x00000020 LOG_SYNC_SET_BYTE: 0x00000040 LOG_SYNC_SET_STRING: 0x00000080 LOG_GET_DOUBLE: 0x00000100 LOG_GET_INT: 0x00000200 LOG_GET_BYTE: 0x00000400 LOG_GET_STRING: 0x00000800 LOG_GET_DEMOD: 0x00001000 LOG_GET_DIO: 0x00002000 LOG_GET_AUXIN: 0x00004000 LOG_GET_COMPLEX: 0x00008000 LOG_LISTNODES: 0x00010000 LOG_SUBSCRIBE: 0x00020000 LOG_UNSUBSCRIBE: 0x00040000 LOG_GET_AS_EVENT: 0x00080000 LOG_UPDATE: 0x00100000 LOG_POLL_EVENT: 0x00200000 LOG_POLL: 0x00400000 LOG_ALL : 0xffffffff)

required
filename str

Log file name.

required
style Literal[0, 1, 2]

Log style (LOG_STYLE_TELNET: 0, LOG_STYLE_MATLAB: 1, LOG_STYLE_PYTHON: 2 (default)).

2

Synchronization

sync()

Synchronize all data paths. Ensures that get and poll commands return data which was recorded after the setting changes in front of the sync command. This sync command replaces the functionality of all syncSet, flush, and echoDevice commands.

Warning

This blocks until all devices connected to the data server report a ready state! This can take up to a minute.