quarchpy.device package¶
Submodules¶
quarchpy.device.device module¶
- quarchpy.device.device.checkModuleFormat(ConString: str) bool¶
DEPRECATED - Use check_module_format instead.
Checks the basic validity of a connection string format.
Verifies presence of ‘:’, checks against allowed connection types, and validates the number of colons or sub-device format.
- Parameters:
ConString (str) – The connection string to validate.
- Returns:
True if the format seems valid, False otherwise.
- Return type:
bool
Note
Uses a specific list of allowed connection types defined within. May recursively call itself to validate controller part of sub-device strings.
- quarchpy.device.device.check_module_format(ConString: str) bool¶
Checks the basic validity of a connection string format.
Verifies presence of ‘:’, checks against allowed connection types, and validates the number of colons or sub-device format.
- Parameters:
ConString (str) – The connection string to validate.
- Returns:
True if the format seems valid, False otherwise.
- Return type:
bool
Note
Uses a specific list of allowed connection types defined within. May recursively call itself to validate controller part of sub-device strings.
- quarchpy.device.device.getQuarchDevice(connectionTarget: str, ConType: str = 'PY', timeout: str = '5') quarchDevice | subDevice¶
DEPRECATED - Use get_quarch_device instead.
Creates and returns a quarchDevice or subDevice instance.
Parses the connectionTarget, determines if it’s a standard device or a sub-device (e.g., “TYPE:ID<PORT>”), and instantiates the appropriate quarchDevice or subDevice object via the quarchArray class if needed.
- Parameters:
connectionTarget (str) – The connection string for the target device or sub-device.
ConType (str, optional) – The connection type hint (‘PY’, ‘QIS’, ‘QPS’, etc.) used when creating the base quarchDevice instance if not a sub-device. Defaults to “PY”. Note: For sub-devices, the controller connection currently defaults to “PY” internally based on original logic.
timeout (str, optional) – The connection timeout in seconds as a string. Defaults to “5”.
- Returns:
- An instance representing the connected device.
Type hinted as Any because subDevice type might vary.
- Return type:
quarchDevice | subDevice | Any
- Raises:
ImportError – If quarchArray components are needed but not found.
ValueError – If the connectionTarget format is invalid.
ConnectionError – If connecting to the device or controller fails.
RuntimeError – For other unexpected errors during connection/instantiation.
- quarchpy.device.device.get_quarch_device(connectionTarget: str, ConType: str = 'PY', timeout: str = '5', qps_instance: 'QpsInterface' | None = None, qis_instance: 'QisInterface' | None = None) quarchDevice | subDevice¶
Creates and returns a quarchDevice or subDevice instance.
Parses the connectionTarget, determines if it’s a standard device or a sub-device (e.g., “TYPE:ID<PORT>”), and instantiates the appropriate quarchDevice or subDevice object via the quarchArray class if needed.h
- Parameters:
connectionTarget (str) – The connection string for the target device or sub-device.
ConType (str, optional) – The connection type hint (‘PY’, ‘QIS’, ‘QPS’, etc.) used when creating the base quarchDevice instance if not a sub-device. Defaults to “PY”. Note: For sub-devices, the controller connection currently defaults to “PY” internally based on original logic.
timeout (str, optional) – The connection timeout in seconds as a string. Defaults to “5”.
qps_instance (Optional[QpsInterface], optional) – An optional QpsInterface instance to use for QPS connections. Defaults to None.
qis_instance (Optional[QisInterface], optional) – An optional QisInterface instance to use for QIS connections. Defaults to None.
- Returns:
- An instance representing the connected device.
Type hinted as Any because subDevice type might vary.
- Return type:
quarchDevice | subDevice | Any
- Raises:
ImportError – If quarchArray components are needed but not found.
ValueError – If the connectionTarget format is invalid.
ConnectionError – If connecting to the device or controller fails.
RuntimeError – For other unexpected errors during connection/instantiation.
- class quarchpy.device.device.quarchDevice(ConString: str, ConType: str = 'PY', timeout: str = '5', qps_instance: 'QpsInterface' | None = None, qis_instance: 'QisInterface' | None = None)¶
Bases:
objectAllows control over a Quarch device, over a wide range of underlying connection methods. This is the core class used for control of all Quarch products.
- ConString¶
The potentially modified connection string used.
- Type:
str
- ConType¶
The specified connection type (‘PY’, ‘QIS’, ‘QPS’).
- Type:
str
- timeout¶
The communication timeout in seconds.
- Type:
int
- connectionObj¶
The underlying connection object (e.g., PYConnection, QISConnection instance). None if connection failed or is closed.
- Type:
Optional[QISConnection, QPSConnection, PYConnection]
- ConCommsType¶
The actual communication type determined by the connection object (e.g., ‘USB’, ‘TCP’). Set for PY type.
- Type:
Optional[str]
- connectionName¶
The target identifier determined by the connection object (e.g., ‘QTL1234-01-001’, ‘192.168.1.100’). Set for PY type.
- Type:
Optional[str]
- connectionTypeName¶
Alias for ConCommsType. Set for PY type.
- Type:
Optional[str]
- closeConnection() str¶
DEPRECATED - Use close_connection instead.
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- getRuntime(command: str = 'conf:runtimes?') int | None¶
DEPRECATED - Use get_runtime instead.
Queries the device runtime and returns it as an integer in seconds.
Handles potential “FAIL” responses and non-numeric/non-‘s’ terminated responses.
- Parameters:
command (str, optional) – The specific command to query runtime. Defaults to “conf:runtimes?”. Can be overridden for different modules (e.g., PAM fixtures).
- Returns:
The runtime in seconds if successfully parsed, otherwise None.
- Return type:
Optional[int]
- get_runtime(command: str = 'conf:runtimes?') int | None¶
Queries the device runtime and returns it as an integer in seconds.
Handles potential “FAIL” responses and non-numeric/non-‘s’ terminated responses.
- Parameters:
command (str, optional) – The specific command to query runtime. Defaults to “conf:runtimes?”. Can be overridden for different modules (e.g., PAM fixtures).
- Returns:
The runtime in seconds if successfully parsed, otherwise None.
- Return type:
Optional[int]
- openConnection() Any¶
DEPRECATED - Use open_connection instead.
Opens or re-opens the connection to the module.
Handles reopening logic based on the connection type (PY, QIS, QPS). For PY, it recreates the connection object. For QIS/QPS, it calls the underlying connect method.
- Returns:
- For PY connections, returns the new PYConnection object.
For QIS/QPS, returns the result of the underlying connect call (could be bool or other status). Returns True for successful QIS connect.
- Return type:
Any
- Raises:
AttributeError – If the connection object is missing expected methods (connect).
ConnectionError – If reopening the connection fails.
ValueError – If the connection type is not recognized.
- open_connection() Any¶
Opens or re-opens the connection to the module.
Handles reopening logic based on the connection type (PY, QIS, QPS). For PY, it recreates the connection object. For QIS/QPS, it calls the underlying connect method.
- Returns:
- For PY connections, returns the new PYConnection object.
For QIS/QPS, returns the result of the underlying connect call (could be bool or other status). Returns True for successful QIS connect.
- Return type:
Any
- Raises:
AttributeError – If the connection object is missing expected methods (connect).
ConnectionError – If reopening the connection fails.
ValueError – If the connection type is not recognized.
- resetDevice(timeout: int = 10) bool¶
DEPRECATED - Use reset_device instead.
Issues a reset command and attempts recovery.
Sends ‘*rst’ to the device, handles connection type specifics (like closing PY connection), then attempts to reconnect within the timeout period.
- Parameters:
timeout (int, optional) – Seconds to wait for reconnection. Defaults to 10.
- Returns:
True if reset and reconnection were successful, False otherwise.
- Return type:
bool
- Raises:
ConnectionError – If sending the reset command fails initially (and connection exists).
- reset_device(timeout: int = 10) bool¶
Issues a reset command and attempts recovery.
Sends ‘*rst’ to the device, handles connection type specifics (like closing PY connection), then attempts to reconnect within the timeout period.
- Parameters:
timeout (int, optional) – Seconds to wait for reconnection. Defaults to 10.
- Returns:
True if reset and reconnection were successful, False otherwise.
- Return type:
bool
- Raises:
ConnectionError – If sending the reset command fails initially (and connection exists).
- sendAndVerifyCommand(commandString: str, responseExpected: str = 'OK', exception: bool = True) bool¶
DEPRECATED - Use send_and_verify_command instead.
Sends a command and verifies the response matches expected string.
A convenience wrapper around send_command.
- Parameters:
commandString (str) – The text command to send.
responseExpected (str, optional) – The exact string expected back from the device. Defaults to “OK”. Comparison is case-sensitive.
exception (bool, optional) – If True, raises ValueError if the response does not match. If False, returns False on mismatch. Defaults to True.
- Returns:
- True if the response matched expected_response, False otherwise
(only if exception is False).
- Return type:
bool
- Raises:
ValueError – If the response does not match expected_response and exception is True.
ConnectionError – If sending the command fails.
TimeoutError – If the device times out responding.
- sendBinaryCommand(cmd: bytes) bytes¶
DEPRECATED - Use send_binary_command instead.
Sends a binary command and reads binary response (USB only).
This method is typically used for low-level or USB-specific communication. It assumes a PY connection type with a specific underlying structure.
- Parameters:
cmd (bytes) – The binary command sequence to send.
- Returns:
The binary data read back from the device.
- Return type:
bytes
- Raises:
TypeError – If the connection type is not PY or the underlying connection object structure is unexpected.
ConnectionError – If communication fails.
- sendCommand(CommandString: str, expectedResponse: bool = True) str¶
DEPRECATED - Use send_command instead.
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
CommandString (str) – The text command to send (e.g., “*IDN?”).
expectedResponse (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
- send_and_verify_command(command_string: str, expected_response: str = 'OK', exception: bool = True) bool¶
Sends a command and verifies the response matches expected string.
A convenience wrapper around send_command.
- Parameters:
command_string (str) – The text command to send.
expected_response (str, optional) – The exact string expected back from the device. Defaults to “OK”. Comparison is case-sensitive.
exception (bool, optional) – If True, raises ValueError if the response does not match. If False, returns False on mismatch. Defaults to True.
- Returns:
- True if the response matched expected_response, False otherwise
(only if exception is False).
- Return type:
bool
- Raises:
ValueError – If the response does not match expected_response and exception is True.
ConnectionError – If sending the command fails.
TimeoutError – If the device times out responding.
- send_binary_command(cmd: bytes) bytes¶
Sends a binary command and reads binary response (USB only).
This method is typically used for low-level or USB-specific communication. It assumes a PY connection type with a specific underlying structure.
- Parameters:
cmd (bytes) – The binary command sequence to send.
- Returns:
The binary data read back from the device.
- Return type:
bytes
- Raises:
TypeError – If the connection type is not PY or the underlying connection object structure is unexpected.
ConnectionError – If communication fails.
- send_command(command_string: str, is_response_expected: bool = True) str¶
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
command_string (str) – The text command to send (e.g., “*IDN?”).
is_response_expected (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
quarchpy.device.quarchArray module¶
- quarchpy.device.quarchArray.isThisAnArrayController(moduleString)¶
- class quarchpy.device.quarchArray.quarchArray(baseDevice)¶
Bases:
quarchDevice- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- getSubDevice(port)¶
- scanSubModules()¶
- class quarchpy.device.quarchArray.subDevice(baseDevice, port)¶
Bases:
quarchDevice- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- send_command(CommandString, expectedResponse=True)¶
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
command_string (str) – The text command to send (e.g., “*IDN?”).
is_response_expected (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
quarchpy.device.quarchPPM module¶
Library for Quarch Power Modules (PPM).
This module provides the quarchPPM class for interacting with Quarch Power Modules, building upon the base quarchDevice. It includes methods for controlling power, streaming data, and managing synthetic channels.
- class quarchpy.device.quarchPPM.SyntheticChannel(number: int, function: str, enable: bool, enabled_by_default: bool, visible_by_default: bool)¶
Bases:
objectA data class representing a synthetic channel.
- number¶
The unique identifier for the synthetic channel.
- Type:
int
- function¶
The function/command defining the channel’s behavior.
- Type:
str
- enable¶
Whether the channel is currently enabled.
- Type:
bool
- enabled_by_default¶
Whether the channel is enabled by default.
- Type:
bool
- visible_by_default¶
Whether the channel is visible by default.
- Type:
bool
- class quarchpy.device.quarchPPM.quarchPPM(originObj: quarchDevice, skipDefaultSyntheticChannels: bool = False)¶
Bases:
quarchDeviceA class to represent a Quarch Power Module (PPM).
This class provides an interface for controlling Quarch PPM devices, including streaming, power control, and configuration.
- create_default_synthetic_channels() None¶
Creates default synthetic channels based on the fixture XML.
This method parses the channels from the instrument’s fixture definition and sends the necessary commands to create them. This is typically run once during initialization.
- parse_synthetic_channels_from_instrument() List[SyntheticChannel]¶
Parses synthetic channel definitions from the device’s fixture XML.
This function reads the fixture XML structure and looks for channels under the SyntheticChannels node, extracting their properties.
- Returns:
- A list of SyntheticChannel objects parsed
from the XML.
- Return type:
List[SyntheticChannel]
- send_synthetic_channels(channels: List[SyntheticChannel]) None¶
Sends commands to the device to create a set of synthetic channels.
- Parameters:
channels (List[SyntheticChannel]) – A list of SyntheticChannel objects to create on the device.
- Raises:
Exception – If the command to create a channel fails.
- setupPowerOutput() None¶
DEPRECATED: Use setup_power_output instead.
Configures and enables the module’s power output.
Checks the output mode, sets a default voltage if required (e.g., for XLC modules), and then enables the power output if it’s off.
- Raises:
ValueError – If an invalid voltage is entered by the user.
- setup_power_output() None¶
Configures and enables the module’s power output.
Checks the output mode, sets a default voltage if required (e.g., for XLC modules), and then enables the power output if it’s off.
- Raises:
ValueError – If an invalid voltage is entered by the user.
- startStream(fileName: str = 'streamData.txt', fileMaxMB: int = 200000, streamName: str = 'Stream With No Name', streamDuration: float | None = None, streamAverage: int | None = None, releaseOnData: bool = False, separator: str = ',', inMemoryData: StringIO | None = None, outputFileHandle: IO | None = None, useGzip: bool | None = None, gzipCompressLevel: int | None = 9) str¶
DEPRECATED: Use start_stream instead.
Starts a data stream from the device.
- Parameters:
fileName (str) – The name of the file to stream data to.
fileMaxMB (int) – The maximum size of the output file in megabytes.
streamDuration (Optional[float]) – The duration for the stream to run in seconds. Defaults to None (continuous).
releaseOnData (bool) – If True, releases the connection on data reception.
separator (str) – The separator character to use in the output file.
inMemoryData (Optional[StringIO]) – A StringIO object to store streamed data in memory. Defaults to None.
outputFileHandle (Optional[IO]) – An open file handle to write stream data to. Defaults to None.
useGzip (Optional[bool]) – If True, compresses the output file using gzip. Defaults to None.
gzipCompressLevel (Optional[int]) – The gzip compression level
- Returns:
The response from the device after starting the stream.
- Return type:
str
- start_stream(file_name: str = 'streamData.txt', file_max_mb: int = 200000, stream_duration: float | None = None, release_on_data: bool = False, separator: str = ',', in_memory_data: StringIO | None = None, output_file_handle: IO | None = None, use_gzip: bool | None = None, gzip_compress_level: int | None = 9) str¶
Starts a data stream from the device.
- Parameters:
file_name (str) – The name of the file to stream data to.
file_max_mb (int) – The maximum size of the output file in megabytes.
stream_duration (Optional[float]) – The duration for the stream to run in seconds. Defaults to None (continuous).
release_on_data (bool) – If True, releases the connection on data reception.
separator (str) – The separator character to use in the output file.
in_memory_data (Optional[StringIO]) – A StringIO object to store streamed data in memory. Defaults to None.
output_file_handle (Optional[IO]) – An open file handle to write stream data to. Defaults to None.
use_gzip (Optional[bool]) – If True, compresses the output file using gzip. Defaults to None.
gzip_compress_level (Optional[int]) – The gzip compression level
- Returns:
The response from the device after starting the stream.
- Return type:
str
- stopStream() str¶
DEPRECATED: Use stop_stream instead.
Stops the current data stream.
- Returns:
The response from the device after stopping the stream.
- Return type:
str
- stop_stream() str¶
Stops the current data stream.
- Returns:
The response from the device after stopping the stream.
- Return type:
str
- streamBufferStatus() str¶
DEPRECATED: Use stream_buffer_status instead.
Gets the status of the stream buffer.
- Returns:
The status of the stream buffer, typically indicating fullness.
- Return type:
str
- streamInterrupt() str¶
DEPRECATED: Use stream_interrupt instead.
Interrupts the current stream.
- Returns:
The response from the device after interrupting the stream.
- Return type:
str
- streamResampleMode(streamCom: str, group: int | None = None) str¶
DEPRECATED: Use stream_resample_mode instead.
Sets the resample mode for the stream.
- Parameters:
streamCom (str) – The resampling command. Valid options are “off”, or a time value like “10ms” or “500us”.
group (Optional[int]) – The specific group to apply the resampling mode to. If None, applies to the main stream.
- Returns:
- The device’s response, or an error message if the command is
invalid.
- Return type:
str
- streamRunningStatus() str¶
DEPRECATED: Use stream_running_status instead.
Checks if a stream is currently running.
- Returns:
The running status of the stream.
- Return type:
str
- stream_buffer_status() str¶
Gets the status of the stream buffer.
- Returns:
The status of the stream buffer, typically indicating fullness.
- Return type:
str
- stream_interrupt() str¶
Interrupts the current stream.
- Returns:
The response from the device after interrupting the stream.
- Return type:
str
- stream_resample_mode(stream_com: str, group: int | None = None) str¶
Sets the resample mode for the stream.
- Parameters:
stream_com (str) – The resampling command. Valid options are “off”, or a time value like “10ms” or “500us”.
group (Optional[int]) – The specific group to apply the resampling mode to. If None, applies to the main stream.
- Returns:
- The device’s response, or an error message if the command is
invalid.
- Return type:
str
- stream_running_status() str¶
Checks if a stream is currently running.
- Returns:
The running status of the stream.
- Return type:
str
- waitStop() str¶
DEPRECATED: Use wait_stop instead.
Waits for the current operation to stop.
- Returns:
The response from the device.
- Return type:
str
- wait_stop() str¶
Waits for the current operation to stop.
- Returns:
The response from the device.
- Return type:
str
quarchpy.device.quarchQPS module¶
- class quarchpy.device.quarchQPS.Status(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum- COMPLETE = 'COMPLETE'¶
- IN_PROGRESS = 'IN PROGRESS'¶
- OK = 'OK'¶
- OVERRUN = 'OVERRUN'¶
- STOPPED = 'STOPPED'¶
- quarchpy.device.quarchQPS.check_export_status(export_status)¶
- quarchpy.device.quarchQPS.check_stream_status(stream_status)¶
- quarchpy.device.quarchQPS.check_stream_stopped_status(stream_status)¶
- quarchpy.device.quarchQPS.current_milli_time()¶
- quarchpy.device.quarchQPS.current_second_time()¶
- quarchpy.device.quarchQPS.qpsNowStr() str¶
Gets the current time as milliseconds since the Unix epoch.
- Returns:
- The current time as a string representing milliseconds
since the epoch.
- Return type:
str
- class quarchpy.device.quarchQPS.quarchQPS(quarchDevice: quarchDevice)¶
Bases:
quarchDeviceRepresents a Quarch Power Supply (QPS) device, extending quarchDevice.
Handles interaction specific to QPS modules, including stream management.
- startStream(directory: str, unserInput: bool = True, streamDuration: str = '') quarchStream¶
DEPRECATED: Use start_stream instead.
- Parameters:
directory (str) – The target directory where stream data will be saved.
unserInput (bool, optional) – Controls user interaction on failure.
streamDuration (str, optional) – Defines the requested duration.
- Returns:
An instance of the quarchStream class.
- Return type:
- start_stream(directory: str, user_input: bool = True, stream_duration: str = '') quarchStream¶
Initializes and starts a Quarch data stream.
This method creates a quarchStream object, which handles the setup and management of the data stream for the QPS application.
- Parameters:
directory (str) – The target directory where stream data will be saved.
user_input (bool, optional) – Controls user interaction on failure. If True (default), prompts the user. If False, raises an Exception on failure.
stream_duration (str, optional) – Defines the requested duration for the stream. An empty string (default) signifies an indefinite stream.
- Returns:
An instance of the quarchStream class representing and managing the active stream.
- Return type:
- class quarchpy.device.quarchQPS.quarchStream(quarchQPS: quarchQPS, directory: str, unserInput: bool = True, streamDuration: str = '')¶
Bases:
objectManages an active data stream from a Quarch QPS device.
Instantiation automatically attempts to start the stream. Provides methods to control and monitor the stream.
- addAnnotation(title: str, annotationTime: int | str = 0, extraText: str = '', yPos: int | str = '', titleColor: str = '', annotationColor: str = '', annotationType: str = '', annotationGroup: str = '', timeFormat: str = 'unix') str¶
DEPRECATED: Use add_annotation instead.
- Parameters:
title (str) – The primary text label for the annotation.
annotationTime (Union[int, str], optional) – Timestamp. Defaults to 0 (“now”).
extraText (str, optional) – Additional text. Defaults to “”.
yPos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
titleColor (str, optional) – Hex color for the title. Defaults to “”.
annotationColor (str, optional) – Hex color for the marker. Defaults to “”.
annotationType (str, optional) – “annotate” or “comment”. Defaults to “”.
annotationGroup (str, optional) – Not used. Defaults to “”.
timeFormat (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- addComment(title: str, commentTime: int | str = 0, extraText: str = '', yPos: int | str = '', titleColor: str = '', commentColor: str = '', annotationType: str = '', annotationGroup: str = '', timeFormat: str = 'unix') str¶
DEPRECATED: Use add_comment instead.
- Parameters:
title (str) – The text label for the comment.
commentTime (Union[int, str], optional) – The timestamp. Defaults to 0.
extraText (str, optional) – Additional text. Defaults to “”.
yPos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
titleColor (str, optional) – Hex color for the title. Defaults to “”.
commentColor (str, optional) – Hex color for the comment marker. Defaults to “”.
annotationType (str, optional) – Overridden to ‘comment’. Defaults to “”.
annotationGroup (str, optional) – Not used. Defaults to “”.
timeFormat (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- addDataPoint(channelName: str, groupName: str, dataValue: int | float, dataPointTime: int | str = 0, timeFormat: str = 'unix') None¶
DEPRECATED: Use add_data_point instead.
Adds a single data point to a specified custom channel in the QPS stream.
- Parameters:
channelName (str) – The name of the custom channel to add data to.
groupName (str) – The group associated with the channel (must match creation).
dataValue (int or float) – The numeric value of the data point.
dataPointTime (int or str, optional) – The timestamp for the data point.
timeFormat (str, optional) – The format of the given time [“elapsed”|”unix”].
- add_annotation(title: str, annotation_time: int | str = 0, extra_text: str = '', y_pos: int | str = '', title_color: str = '', annotation_color: str = '', annotation_type: str = 'annotate', time_format: str = 'unix') str¶
Adds a custom annotation marker to the active QPS stream.
- Parameters:
title (str) – The primary text label for the annotation.
annotation_time (Union[int, str], optional) – When the annotation appears. Defaults to 0 (“now”).
extra_text (str, optional) – Additional text for the annotation. Defaults to “”.
y_pos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
title_color (str, optional) – Hex color for the title. Defaults to “”.
annotation_color (str, optional) – Hex color for the marker. Defaults to “”.
annotation_type (str, optional) – “annotate” or “comment”. Defaults to “annotate”.
time_format (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- add_comment(title: str, comment_time: int | str = 0, **kwargs: Any) str¶
Adds a ‘comment’ type annotation to the QPS stream.
This is a convenience wrapper for add_annotation that sets the type to ‘comment’.
- Parameters:
title (str) – The text label for the comment.
comment_time (Union[int, str], optional) – The timestamp. Defaults to 0.
**kwargs – Other arguments accepted by add_annotation.
- Returns:
The response message from the QPS device.
- Return type:
str
- add_data_point(channel_name: str, group_name: str, data_value: int | float, data_point_time: int | str = 0, time_format: str = 'unix') None¶
Adds a single data point to a specified custom channel.
- Parameters:
channel_name (str) – The name of the custom channel.
group_name (str) – The group associated with the channel.
data_value (Union[int, float]) – The numeric value of the data point.
data_point_time (Union[int, str], optional) – Timestamp for the data point. Defaults to 0 (current time).
time_format (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- channels() List[str]¶
Retrieves the list of available channels from QPS, split into a list of strings.
- Returns:
A list where each element is a channel identifier string.
- Return type:
list[str]
- createChannel(channelName: str, channelGroup: str, baseUnits: str, usePrefix: bool) str¶
DEPRECATED: Use create_channel instead.
- Parameters:
channelName (str) – The name for the new channel.
channelGroup (str) – The group to associate the channel with.
baseUnits (str) – The fundamental unit for the channel.
usePrefix (bool) – If True, allows channel prefixes.
- Returns:
The response message from the QPS device.
- Return type:
str
- create_channel(channel_name: str, channel_group: str, base_units: str, use_prefix: bool) str¶
Creates a new custom data channel on the QPS device.
- Parameters:
channel_name (str) – The name for the new channel.
channel_group (str) – The group to associate the channel with (e.g., “Voltage”).
base_units (str) – The fundamental unit for the channel (e.g., “V”, “A”).
use_prefix (bool) – If True, allows channel prefixes (e.g., ‘m’ for milli).
- Returns:
The response from the QPS device.
- Return type:
str
- failCheck(response: str, streamDuration: str) str¶
DEPRECATED: Use fail_check instead.
- Parameters:
response (str) – The response message from a stream start attempt.
streamDuration (str) – The duration for the stream, needed for retry attempts.
- Returns:
The successful response message after a retry.
- Return type:
str
- Raises:
Exception – If the response contains an unhandled failure.
- fail_check(response: str, stream_duration: str) str¶
Handles recoverable failures during stream startup.
Currently handles “Directory already exists” by prompting for a new name.
- Parameters:
response (str) – The failure response message from the server.
stream_duration (str) – The stream duration, for retrying.
- Returns:
The successful response after a retry.
- Return type:
str
- Raises:
Exception – If the failure is not a known, handled type.
- getStreamState() str¶
DEPRECATED: Use get_stream_state instead.
- Returns:
The stream state reported by the QPS application.
- Return type:
str
- get_custom_stats_range(start_time: int | str, end_time: int | str) DataFrame | None¶
Retrieves statistics from the QPS device for a specified time range.
- Parameters:
start_time (Union[int, str]) – The start time for stats calculation.
end_time (Union[int, str]) – The end time for stats calculation.
- Returns:
A DataFrame containing the stats.
- Return type:
Optional[pd.DataFrame]
- Raises:
ImportError – If the pandas library is not installed.
Exception – If the QPS command fails or data parsing fails.
- get_stats(format: str = 'df') DataFrame | List[List[str]] | None¶
Retrieves statistics from the QPS device.
- Parameters:
format (str, optional) – The desired output format (“df” for pandas DataFrame, “list” for list of lists). Defaults to “df”.
- Returns:
Statistics data in the specified format, or None if pandas is required but not found.
- Return type:
Union[pd.DataFrame, List[List[str]], None]
- Raises:
Exception – If the QPS command fails.
- get_stats_export_status() str¶
Queries the QPS device for the status of the statistics data export process.
- Returns:
The response string from QPS indicating the stats export status
- Return type:
str
- get_stream_export_status() str¶
Queries the QPS device for the status of the main stream data export process.
- Returns:
The response string from QPS indicating the stream export status
- Return type:
str
- get_stream_state() str¶
Queries the QPS application for its current stream processing state.
- Returns:
The stream state as reported by the QPS application.
- Return type:
str
- Raises:
Exception – If the command fails.
- hideAllDefaultChannels() None¶
DEPRECATED: Use hide_all_default_channels instead.
Hides a predefined list of common default QPS/PAM channels.
- hideChannel(channelSpecifier: str) str¶
DEPRECATED: Use hide_channel instead.
- Parameters:
channelSpecifier (str) – The identifier of the channel to hide.
- Returns:
The response message from the QPS device.
- Return type:
str
- hide_all_default_channels() None¶
Hides a predefined list of common default QPS/PAM channels.
Note
This list is hardcoded and might not be exhaustive for all hardware.
- hide_channel(channel_specifier: str) str¶
Hides a specified channel from the QPS stream view.
- Parameters:
channel_specifier (str) – The identifier of the channel to hide (e.g., “5v:voltage”).
- Returns:
The response from the QPS device.
- Return type:
str
- myChannels() str¶
DEPRECATED: Use channels instead.
Retrieves the list of available channels from QPS as a single raw string.
- Returns:
The raw response string from the QPS ‘$channels’ command.
- Return type:
str
- saveCSV(filePath: str, linesPerFile: int | str | None = None, cr: bool | None = None, delimiter: str | None = None, timeout: int = 180, pollTillComplete: bool = False, checkInterval: float = 0.5) str¶
DEPRECATED: Use save_csv instead.
- Parameters:
filePath (str) – The target file path on the QPS device’s filesystem.
linesPerFile (Optional[Union[int, str]], optional) – Max lines per file. Defaults to None.
cr (Optional[bool], optional) – True for CRLF, False for LF line endings. Defaults to None.
delimiter (Optional[str], optional) – Field delimiter for the CSV. Defaults to None.
timeout (int, optional) – Timeout in seconds. Defaults to 180.
pollTillComplete (bool, optional) – If True, waits for export to finish. Defaults to False.
checkInterval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
- Returns:
The initial response from the QPS device.
- Return type:
str
- save_csv(file_path: str, lines_per_file: int | str | None = None, use_cr: bool | None = None, delimiter: str | None = None, timeout: int = 180, poll_till_complete: bool = False, check_interval: float = 0.5) str¶
Commands the QPS device to save the stream data to a CSV file.
- Parameters:
file_path (str) – Target file path on the QPS device’s filesystem.
lines_per_file (Optional[Union[int, str]], optional) – Max lines per file. Defaults to None.
use_cr (Optional[bool], optional) – True for CRLF, False for LF. Defaults to None.
delimiter (Optional[str], optional) – Field delimiter for the CSV. Defaults to None.
timeout (int, optional) – Timeout in seconds. Defaults to 180.
poll_till_complete (bool, optional) – If True, waits for export to finish. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
- Returns:
The initial response from the QPS device.
- Return type:
str
- Raises:
TimeoutError – If polling is enabled and the export does not complete in time.
- showChannel(channelSpecifier: str) str¶
DEPRECATED: Use show_channel instead.
- Parameters:
channelSpecifier (str) – The identifier of the channel to show.
- Returns:
The response message from the QPS device.
- Return type:
str
- show_channel(channel_specifier: str) str¶
Shows (un-hides) a specified channel in the QPS stream view.
- Parameters:
channel_specifier (str) – The identifier of the channel to show.
- Returns:
The response from the QPS device.
- Return type:
str
- startQPSStream(newDirectory: str, streamDuration: str = '') str¶
DEPRECATED: Use start_qps_stream instead.
- Parameters:
newDirectory (str) – The path to the directory where the stream data should be saved.
streamDuration (str, optional) – The duration for which the stream should run.
- Returns:
The response message from the QPS system.
- Return type:
str
- start_qps_stream(new_directory: str, stream_duration: str = '') str¶
Sends the command to start the QPS stream.
- Parameters:
new_directory (str) – The path for the stream data.
stream_duration (str, optional) – The duration for the stream. Defaults to “”.
- Returns:
The response from the QPS system.
- Return type:
str
- stats_to_CSV(file_name: str = '', poll_till_complete: bool = False, check_interval: float = 0.5, timeout: int = 60) str¶
DEPRECATED: Use stats_to_csv instead.
- Parameters:
file_name (str, optional) – The absolute path for the CSV file. Defaults to “”.
poll_till_complete (bool, optional) – If True, polls until the export is finished. Defaults to False.
check_interval (float, optional) – Time in seconds between status checks when polling. Defaults to 0.5.
timeout (int, optional) – Max time in seconds to wait for polling. Defaults to 60.
- Returns:
The initial response message from the QPS device.
- Return type:
str
- stats_to_csv(file_name: str = '', poll_till_complete: bool = False, check_interval: float = 0.5, timeout: int = 60) str¶
Commands the QPS device to save its current statistics to a CSV file.
- Parameters:
file_name (str, optional) – Absolute path for the CSV file on the QPS device’s filesystem. Defaults to “”.
poll_till_complete (bool, optional) – If True, waits for the export to finish. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
timeout (int, optional) – Max seconds to wait for polling to complete. Defaults to 60.
- Returns:
The initial response from the QPS device.
- Return type:
str
- Raises:
Exception – If the initial QPS command fails.
TimeoutError – If polling is enabled and times out.
- stopStream(pollTillComplete: bool = False, checkInterval: float = 0.1, timeout: int = 60) str¶
DEPRECATED: Use stop_stream instead.
- Parameters:
pollTillComplete (bool, optional) – If True, waits until the QPS stream state is no longer “running”. Defaults to False.
checkInterval (float, optional) – Time in seconds between status checks when polling. Defaults to 0.1.
timeout (int, optional) – Maximum time in seconds to wait. Defaults to 60.
- Returns:
- The final checked stream status string (“STOPPED”, “OVERRUN”) if polling,
otherwise the initial response from the ‘$stop stream’ command.
- Return type:
str
- stop_stream(poll_till_complete: bool = False, check_interval: float = 0.1, timeout: int = 60) Literal[Status.OVERRUN, Status.STOPPED] | Any¶
Sends the command to stop the QPS data stream.
- Parameters:
poll_till_complete (bool, optional) – If True, waits for the stream to fully stop. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.1.
timeout (int, optional) – Max seconds to wait for polling to complete. Defaults to 60.
- Returns:
The final stream status if polling, otherwise the initial command response.
- Return type:
str
- Raises:
Exception – If the stop command itself fails.
TimeoutError – If polling is enabled and times out.
- takeSnapshot() str¶
DEPRECATED: Use take_snapshot instead.
- Returns:
The response message from the QPS device.
- Return type:
str
- take_snapshot() str¶
Triggers the QPS device to capture an immediate snapshot.
- Returns:
The response from the QPS device.
- Return type:
str
- Raises:
Exception – If the command fails.
quarchpy.device.scanDevices module¶
- quarchpy.device.scanDevices.filter_module_type(module_type_filter, found_devices)¶
Used in scandevices to filter modules by their type. Uses config files.
- Parameters:
module_type_filter – Acceptable values are ‘Cable’, ‘Card’, ‘Drive’, ‘Power’, ‘Switch’
found_devices – List of found devices passed from scan_devices
- Returns:
Returns all devices in found devices that are of ‘module filter type’
- quarchpy.device.scanDevices.getSerialNumberFromConnectionTarget(connectionTarget)¶
Takes in the connection target and returns the serial number of a module found on the standard scan.
- Parameters:
connectionTarget= (str) – The connection target of the module you would like to know the serial number of.
- Returns:
ret_val – The Serial number of the supplied device.
- Return type:
str
- quarchpy.device.scanDevices.get_connection_target(module_string, scan_dictionary=None, connection_preference=None, include_conn_type=True)¶
Takes in the connection type and serial number of a module and returns the connection target.
- Parameters:
module_string= (str) – The connection type and serial number combination eg. TCP:QTL1999-05-005.
scan_dictionary= (dict, optional) – A scan dictionary can be passed so that a scan does not need to take place on every call. This would be advised if calling this for every item in a list of serial numbers.
connection_preference= (list str, optional) – The preference of which connection type to prioratise if none it given. Defaults to “USB”, “TCP”, “SERIAL”, “REST”, “TELNET” in that order.
= (include_conn_type) – Decided whether the connection type will appear in the return value eg. TCP:192.168.1.1 vs 192.168.1.1
- Returns:
ret_val – The Connection target of the supplied device.
- Return type:
str
- quarchpy.device.scanDevices.get_user_level_serial_number(network_modules)¶
- Parameters:
network_modules –
- Returns:
- quarchpy.device.scanDevices.listDevices(scanDictionary)¶
- quarchpy.device.scanDevices.list_USB(debuPrint=False, discovered_devices: List[DiscoveredDevice] | None = None)¶
- quarchpy.device.scanDevices.list_network(target_conn='all', debugPrint=False, lanTimeout=1, ipAddressLookup=None, discovered_devices: List[DiscoveredDevice] | None = None)¶
- quarchpy.device.scanDevices.list_serial(debugPrint=False)¶
- quarchpy.device.scanDevices.lookupDevice(ipAddressLookup, mySocket, lan_modules, module_found)¶
- quarchpy.device.scanDevices.mergeDict(x, y)¶
- quarchpy.device.scanDevices.scanDevices(target_conn='all', lanTimeout=1, scanInArray=True, favouriteOnly=True, filterStr=None, module_type_filter=None, ipAddressLookup=None, discovered_devices=None)¶
- quarchpy.device.scanDevices.scan_mDNS(mdnsListener, zeroconf=None)¶
- quarchpy.device.scanDevices.userSelectDevice(scanDictionary=None, scanFilterStr=None, favouriteOnly=True, message=None, title=None, nice=False, additionalOptions=None, target_conn='all')¶
Module contents¶
- class quarchpy.device.DeviceNetworkInfo¶
Bases:
object- set_network_info_fields_from_device_info_dict(device_info: dict)¶
- class quarchpy.device.DiscoveredDevice(idn: IDNInfo | None, fixture_idn: FixtureIDNInfo | None, device_net_info: DeviceNetworkInfo | None)¶
Bases:
object- get_serial_from_device()¶
Returns:
- is_update_available()¶
Checks for firmware and FPGA updates by scraping a product webpage.
This method determines the device’s model number from its serial number, fetches the corresponding product page from a URL, and scrapes the page to find the latest available firmware and FPGA versions. It then compares these against the versions currently on the device.
An instance attribute self.is_update_required is set to True if either the firmware or FPGA version is found to be outdated.
- Returns:
True if an update is available, False otherwise.
- Return type:
bool
- populate_device_info()¶
- class quarchpy.device.FixtureIDNInfo¶
Bases:
object- set_fix_idn_info_fields_from_device_info_dict(device_info: {})¶
- class quarchpy.device.IDNInfo¶
Bases:
object- parse_idn_response(idn_response: str) bool¶
Parses the ‘*idn?’ response from the module.
- Parameters:
idn_response – The textual response containing the idn information of the module.
- Returns:
True if at least one line of the response was parsed successfully, False otherwise.
- set_idn_info_fields_from_device_info_dict(device_info: dict)¶
- quarchpy.device.decode_locate_packet(packet_fields: List[bytes]) dict¶
Parses a device location packet and returns a dictionary of its properties.
This function is designed to work with a packet that has already been split into a list of fields (byte strings). It interprets each field based on a leading code byte.
- Parameters:
packet_fields – A list of bytes objects, where each object is a field from the packet, typically prefixed with a code.
- Returns:
A dictionary containing the parsed device information.
- quarchpy.device.getQuarchDevice(connectionTarget: str, ConType: str = 'PY', timeout: str = '5') quarchDevice | subDevice¶
DEPRECATED - Use get_quarch_device instead.
Creates and returns a quarchDevice or subDevice instance.
Parses the connectionTarget, determines if it’s a standard device or a sub-device (e.g., “TYPE:ID<PORT>”), and instantiates the appropriate quarchDevice or subDevice object via the quarchArray class if needed.
- Parameters:
connectionTarget (str) – The connection string for the target device or sub-device.
ConType (str, optional) – The connection type hint (‘PY’, ‘QIS’, ‘QPS’, etc.) used when creating the base quarchDevice instance if not a sub-device. Defaults to “PY”. Note: For sub-devices, the controller connection currently defaults to “PY” internally based on original logic.
timeout (str, optional) – The connection timeout in seconds as a string. Defaults to “5”.
- Returns:
- An instance representing the connected device.
Type hinted as Any because subDevice type might vary.
- Return type:
quarchDevice | subDevice | Any
- Raises:
ImportError – If quarchArray components are needed but not found.
ValueError – If the connectionTarget format is invalid.
ConnectionError – If connecting to the device or controller fails.
RuntimeError – For other unexpected errors during connection/instantiation.
- quarchpy.device.getSerialNumberFromConnectionTarget(connectionTarget)¶
Takes in the connection target and returns the serial number of a module found on the standard scan.
- Parameters:
connectionTarget= (str) – The connection target of the module you would like to know the serial number of.
- Returns:
ret_val – The Serial number of the supplied device.
- Return type:
str
- quarchpy.device.get_connection_target(module_string, scan_dictionary=None, connection_preference=None, include_conn_type=True)¶
Takes in the connection type and serial number of a module and returns the connection target.
- Parameters:
module_string= (str) – The connection type and serial number combination eg. TCP:QTL1999-05-005.
scan_dictionary= (dict, optional) – A scan dictionary can be passed so that a scan does not need to take place on every call. This would be advised if calling this for every item in a list of serial numbers.
connection_preference= (list str, optional) – The preference of which connection type to prioratise if none it given. Defaults to “USB”, “TCP”, “SERIAL”, “REST”, “TELNET” in that order.
= (include_conn_type) – Decided whether the connection type will appear in the return value eg. TCP:192.168.1.1 vs 192.168.1.1
- Returns:
ret_val – The Connection target of the supplied device.
- Return type:
str
- quarchpy.device.get_quarch_device(connectionTarget: str, ConType: str = 'PY', timeout: str = '5', qps_instance: 'QpsInterface' | None = None, qis_instance: 'QisInterface' | None = None) quarchDevice | subDevice¶
Creates and returns a quarchDevice or subDevice instance.
Parses the connectionTarget, determines if it’s a standard device or a sub-device (e.g., “TYPE:ID<PORT>”), and instantiates the appropriate quarchDevice or subDevice object via the quarchArray class if needed.h
- Parameters:
connectionTarget (str) – The connection string for the target device or sub-device.
ConType (str, optional) – The connection type hint (‘PY’, ‘QIS’, ‘QPS’, etc.) used when creating the base quarchDevice instance if not a sub-device. Defaults to “PY”. Note: For sub-devices, the controller connection currently defaults to “PY” internally based on original logic.
timeout (str, optional) – The connection timeout in seconds as a string. Defaults to “5”.
qps_instance (Optional[QpsInterface], optional) – An optional QpsInterface instance to use for QPS connections. Defaults to None.
qis_instance (Optional[QisInterface], optional) – An optional QisInterface instance to use for QIS connections. Defaults to None.
- Returns:
- An instance representing the connected device.
Type hinted as Any because subDevice type might vary.
- Return type:
quarchDevice | subDevice | Any
- Raises:
ImportError – If quarchArray components are needed but not found.
ValueError – If the connectionTarget format is invalid.
ConnectionError – If connecting to the device or controller fails.
RuntimeError – For other unexpected errors during connection/instantiation.
- quarchpy.device.listDevices(scanDictionary)¶
- quarchpy.device.qpsNowStr() str¶
Gets the current time as milliseconds since the Unix epoch.
- Returns:
- The current time as a string representing milliseconds
since the epoch.
- Return type:
str
- class quarchpy.device.quarchArray(baseDevice)¶
Bases:
quarchDevice- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- getSubDevice(port)¶
- scanSubModules()¶
- class quarchpy.device.quarchDevice(ConString: str, ConType: str = 'PY', timeout: str = '5', qps_instance: 'QpsInterface' | None = None, qis_instance: 'QisInterface' | None = None)¶
Bases:
objectAllows control over a Quarch device, over a wide range of underlying connection methods. This is the core class used for control of all Quarch products.
- ConString¶
The potentially modified connection string used.
- Type:
str
- ConType¶
The specified connection type (‘PY’, ‘QIS’, ‘QPS’).
- Type:
str
- timeout¶
The communication timeout in seconds.
- Type:
int
- connectionObj¶
The underlying connection object (e.g., PYConnection, QISConnection instance). None if connection failed or is closed.
- Type:
Optional[QISConnection, QPSConnection, PYConnection]
- ConCommsType¶
The actual communication type determined by the connection object (e.g., ‘USB’, ‘TCP’). Set for PY type.
- Type:
Optional[str]
- connectionName¶
The target identifier determined by the connection object (e.g., ‘QTL1234-01-001’, ‘192.168.1.100’). Set for PY type.
- Type:
Optional[str]
- connectionTypeName¶
Alias for ConCommsType. Set for PY type.
- Type:
Optional[str]
- closeConnection() str¶
DEPRECATED - Use close_connection instead.
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- getRuntime(command: str = 'conf:runtimes?') int | None¶
DEPRECATED - Use get_runtime instead.
Queries the device runtime and returns it as an integer in seconds.
Handles potential “FAIL” responses and non-numeric/non-‘s’ terminated responses.
- Parameters:
command (str, optional) – The specific command to query runtime. Defaults to “conf:runtimes?”. Can be overridden for different modules (e.g., PAM fixtures).
- Returns:
The runtime in seconds if successfully parsed, otherwise None.
- Return type:
Optional[int]
- get_runtime(command: str = 'conf:runtimes?') int | None¶
Queries the device runtime and returns it as an integer in seconds.
Handles potential “FAIL” responses and non-numeric/non-‘s’ terminated responses.
- Parameters:
command (str, optional) – The specific command to query runtime. Defaults to “conf:runtimes?”. Can be overridden for different modules (e.g., PAM fixtures).
- Returns:
The runtime in seconds if successfully parsed, otherwise None.
- Return type:
Optional[int]
- openConnection() Any¶
DEPRECATED - Use open_connection instead.
Opens or re-opens the connection to the module.
Handles reopening logic based on the connection type (PY, QIS, QPS). For PY, it recreates the connection object. For QIS/QPS, it calls the underlying connect method.
- Returns:
- For PY connections, returns the new PYConnection object.
For QIS/QPS, returns the result of the underlying connect call (could be bool or other status). Returns True for successful QIS connect.
- Return type:
Any
- Raises:
AttributeError – If the connection object is missing expected methods (connect).
ConnectionError – If reopening the connection fails.
ValueError – If the connection type is not recognized.
- open_connection() Any¶
Opens or re-opens the connection to the module.
Handles reopening logic based on the connection type (PY, QIS, QPS). For PY, it recreates the connection object. For QIS/QPS, it calls the underlying connect method.
- Returns:
- For PY connections, returns the new PYConnection object.
For QIS/QPS, returns the result of the underlying connect call (could be bool or other status). Returns True for successful QIS connect.
- Return type:
Any
- Raises:
AttributeError – If the connection object is missing expected methods (connect).
ConnectionError – If reopening the connection fails.
ValueError – If the connection type is not recognized.
- resetDevice(timeout: int = 10) bool¶
DEPRECATED - Use reset_device instead.
Issues a reset command and attempts recovery.
Sends ‘*rst’ to the device, handles connection type specifics (like closing PY connection), then attempts to reconnect within the timeout period.
- Parameters:
timeout (int, optional) – Seconds to wait for reconnection. Defaults to 10.
- Returns:
True if reset and reconnection were successful, False otherwise.
- Return type:
bool
- Raises:
ConnectionError – If sending the reset command fails initially (and connection exists).
- reset_device(timeout: int = 10) bool¶
Issues a reset command and attempts recovery.
Sends ‘*rst’ to the device, handles connection type specifics (like closing PY connection), then attempts to reconnect within the timeout period.
- Parameters:
timeout (int, optional) – Seconds to wait for reconnection. Defaults to 10.
- Returns:
True if reset and reconnection were successful, False otherwise.
- Return type:
bool
- Raises:
ConnectionError – If sending the reset command fails initially (and connection exists).
- sendAndVerifyCommand(commandString: str, responseExpected: str = 'OK', exception: bool = True) bool¶
DEPRECATED - Use send_and_verify_command instead.
Sends a command and verifies the response matches expected string.
A convenience wrapper around send_command.
- Parameters:
commandString (str) – The text command to send.
responseExpected (str, optional) – The exact string expected back from the device. Defaults to “OK”. Comparison is case-sensitive.
exception (bool, optional) – If True, raises ValueError if the response does not match. If False, returns False on mismatch. Defaults to True.
- Returns:
- True if the response matched expected_response, False otherwise
(only if exception is False).
- Return type:
bool
- Raises:
ValueError – If the response does not match expected_response and exception is True.
ConnectionError – If sending the command fails.
TimeoutError – If the device times out responding.
- sendBinaryCommand(cmd: bytes) bytes¶
DEPRECATED - Use send_binary_command instead.
Sends a binary command and reads binary response (USB only).
This method is typically used for low-level or USB-specific communication. It assumes a PY connection type with a specific underlying structure.
- Parameters:
cmd (bytes) – The binary command sequence to send.
- Returns:
The binary data read back from the device.
- Return type:
bytes
- Raises:
TypeError – If the connection type is not PY or the underlying connection object structure is unexpected.
ConnectionError – If communication fails.
- sendCommand(CommandString: str, expectedResponse: bool = True) str¶
DEPRECATED - Use send_command instead.
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
CommandString (str) – The text command to send (e.g., “*IDN?”).
expectedResponse (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
- send_and_verify_command(command_string: str, expected_response: str = 'OK', exception: bool = True) bool¶
Sends a command and verifies the response matches expected string.
A convenience wrapper around send_command.
- Parameters:
command_string (str) – The text command to send.
expected_response (str, optional) – The exact string expected back from the device. Defaults to “OK”. Comparison is case-sensitive.
exception (bool, optional) – If True, raises ValueError if the response does not match. If False, returns False on mismatch. Defaults to True.
- Returns:
- True if the response matched expected_response, False otherwise
(only if exception is False).
- Return type:
bool
- Raises:
ValueError – If the response does not match expected_response and exception is True.
ConnectionError – If sending the command fails.
TimeoutError – If the device times out responding.
- send_binary_command(cmd: bytes) bytes¶
Sends a binary command and reads binary response (USB only).
This method is typically used for low-level or USB-specific communication. It assumes a PY connection type with a specific underlying structure.
- Parameters:
cmd (bytes) – The binary command sequence to send.
- Returns:
The binary data read back from the device.
- Return type:
bytes
- Raises:
TypeError – If the connection type is not PY or the underlying connection object structure is unexpected.
ConnectionError – If communication fails.
- send_command(command_string: str, is_response_expected: bool = True) str¶
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
command_string (str) – The text command to send (e.g., “*IDN?”).
is_response_expected (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
- class quarchpy.device.quarchPPM(originObj: quarchDevice, skipDefaultSyntheticChannels: bool = False)¶
Bases:
quarchDeviceA class to represent a Quarch Power Module (PPM).
This class provides an interface for controlling Quarch PPM devices, including streaming, power control, and configuration.
- create_default_synthetic_channels() None¶
Creates default synthetic channels based on the fixture XML.
This method parses the channels from the instrument’s fixture definition and sends the necessary commands to create them. This is typically run once during initialization.
- parse_synthetic_channels_from_instrument() List[SyntheticChannel]¶
Parses synthetic channel definitions from the device’s fixture XML.
This function reads the fixture XML structure and looks for channels under the SyntheticChannels node, extracting their properties.
- Returns:
- A list of SyntheticChannel objects parsed
from the XML.
- Return type:
List[SyntheticChannel]
- send_synthetic_channels(channels: List[SyntheticChannel]) None¶
Sends commands to the device to create a set of synthetic channels.
- Parameters:
channels (List[SyntheticChannel]) – A list of SyntheticChannel objects to create on the device.
- Raises:
Exception – If the command to create a channel fails.
- setupPowerOutput() None¶
DEPRECATED: Use setup_power_output instead.
Configures and enables the module’s power output.
Checks the output mode, sets a default voltage if required (e.g., for XLC modules), and then enables the power output if it’s off.
- Raises:
ValueError – If an invalid voltage is entered by the user.
- setup_power_output() None¶
Configures and enables the module’s power output.
Checks the output mode, sets a default voltage if required (e.g., for XLC modules), and then enables the power output if it’s off.
- Raises:
ValueError – If an invalid voltage is entered by the user.
- startStream(fileName: str = 'streamData.txt', fileMaxMB: int = 200000, streamName: str = 'Stream With No Name', streamDuration: float | None = None, streamAverage: int | None = None, releaseOnData: bool = False, separator: str = ',', inMemoryData: StringIO | None = None, outputFileHandle: IO | None = None, useGzip: bool | None = None, gzipCompressLevel: int | None = 9) str¶
DEPRECATED: Use start_stream instead.
Starts a data stream from the device.
- Parameters:
fileName (str) – The name of the file to stream data to.
fileMaxMB (int) – The maximum size of the output file in megabytes.
streamDuration (Optional[float]) – The duration for the stream to run in seconds. Defaults to None (continuous).
releaseOnData (bool) – If True, releases the connection on data reception.
separator (str) – The separator character to use in the output file.
inMemoryData (Optional[StringIO]) – A StringIO object to store streamed data in memory. Defaults to None.
outputFileHandle (Optional[IO]) – An open file handle to write stream data to. Defaults to None.
useGzip (Optional[bool]) – If True, compresses the output file using gzip. Defaults to None.
gzipCompressLevel (Optional[int]) – The gzip compression level
- Returns:
The response from the device after starting the stream.
- Return type:
str
- start_stream(file_name: str = 'streamData.txt', file_max_mb: int = 200000, stream_duration: float | None = None, release_on_data: bool = False, separator: str = ',', in_memory_data: StringIO | None = None, output_file_handle: IO | None = None, use_gzip: bool | None = None, gzip_compress_level: int | None = 9) str¶
Starts a data stream from the device.
- Parameters:
file_name (str) – The name of the file to stream data to.
file_max_mb (int) – The maximum size of the output file in megabytes.
stream_duration (Optional[float]) – The duration for the stream to run in seconds. Defaults to None (continuous).
release_on_data (bool) – If True, releases the connection on data reception.
separator (str) – The separator character to use in the output file.
in_memory_data (Optional[StringIO]) – A StringIO object to store streamed data in memory. Defaults to None.
output_file_handle (Optional[IO]) – An open file handle to write stream data to. Defaults to None.
use_gzip (Optional[bool]) – If True, compresses the output file using gzip. Defaults to None.
gzip_compress_level (Optional[int]) – The gzip compression level
- Returns:
The response from the device after starting the stream.
- Return type:
str
- stopStream() str¶
DEPRECATED: Use stop_stream instead.
Stops the current data stream.
- Returns:
The response from the device after stopping the stream.
- Return type:
str
- stop_stream() str¶
Stops the current data stream.
- Returns:
The response from the device after stopping the stream.
- Return type:
str
- streamBufferStatus() str¶
DEPRECATED: Use stream_buffer_status instead.
Gets the status of the stream buffer.
- Returns:
The status of the stream buffer, typically indicating fullness.
- Return type:
str
- streamInterrupt() str¶
DEPRECATED: Use stream_interrupt instead.
Interrupts the current stream.
- Returns:
The response from the device after interrupting the stream.
- Return type:
str
- streamResampleMode(streamCom: str, group: int | None = None) str¶
DEPRECATED: Use stream_resample_mode instead.
Sets the resample mode for the stream.
- Parameters:
streamCom (str) – The resampling command. Valid options are “off”, or a time value like “10ms” or “500us”.
group (Optional[int]) – The specific group to apply the resampling mode to. If None, applies to the main stream.
- Returns:
- The device’s response, or an error message if the command is
invalid.
- Return type:
str
- streamRunningStatus() str¶
DEPRECATED: Use stream_running_status instead.
Checks if a stream is currently running.
- Returns:
The running status of the stream.
- Return type:
str
- stream_buffer_status() str¶
Gets the status of the stream buffer.
- Returns:
The status of the stream buffer, typically indicating fullness.
- Return type:
str
- stream_interrupt() str¶
Interrupts the current stream.
- Returns:
The response from the device after interrupting the stream.
- Return type:
str
- stream_resample_mode(stream_com: str, group: int | None = None) str¶
Sets the resample mode for the stream.
- Parameters:
stream_com (str) – The resampling command. Valid options are “off”, or a time value like “10ms” or “500us”.
group (Optional[int]) – The specific group to apply the resampling mode to. If None, applies to the main stream.
- Returns:
- The device’s response, or an error message if the command is
invalid.
- Return type:
str
- stream_running_status() str¶
Checks if a stream is currently running.
- Returns:
The running status of the stream.
- Return type:
str
- waitStop() str¶
DEPRECATED: Use wait_stop instead.
Waits for the current operation to stop.
- Returns:
The response from the device.
- Return type:
str
- wait_stop() str¶
Waits for the current operation to stop.
- Returns:
The response from the device.
- Return type:
str
- class quarchpy.device.quarchQPS(quarchDevice: quarchDevice)¶
Bases:
quarchDeviceRepresents a Quarch Power Supply (QPS) device, extending quarchDevice.
Handles interaction specific to QPS modules, including stream management.
- startStream(directory: str, unserInput: bool = True, streamDuration: str = '') quarchStream¶
DEPRECATED: Use start_stream instead.
- Parameters:
directory (str) – The target directory where stream data will be saved.
unserInput (bool, optional) – Controls user interaction on failure.
streamDuration (str, optional) – Defines the requested duration.
- Returns:
An instance of the quarchStream class.
- Return type:
- start_stream(directory: str, user_input: bool = True, stream_duration: str = '') quarchStream¶
Initializes and starts a Quarch data stream.
This method creates a quarchStream object, which handles the setup and management of the data stream for the QPS application.
- Parameters:
directory (str) – The target directory where stream data will be saved.
user_input (bool, optional) – Controls user interaction on failure. If True (default), prompts the user. If False, raises an Exception on failure.
stream_duration (str, optional) – Defines the requested duration for the stream. An empty string (default) signifies an indefinite stream.
- Returns:
An instance of the quarchStream class representing and managing the active stream.
- Return type:
- class quarchpy.device.quarchStream(quarchQPS: quarchQPS, directory: str, unserInput: bool = True, streamDuration: str = '')¶
Bases:
objectManages an active data stream from a Quarch QPS device.
Instantiation automatically attempts to start the stream. Provides methods to control and monitor the stream.
- addAnnotation(title: str, annotationTime: int | str = 0, extraText: str = '', yPos: int | str = '', titleColor: str = '', annotationColor: str = '', annotationType: str = '', annotationGroup: str = '', timeFormat: str = 'unix') str¶
DEPRECATED: Use add_annotation instead.
- Parameters:
title (str) – The primary text label for the annotation.
annotationTime (Union[int, str], optional) – Timestamp. Defaults to 0 (“now”).
extraText (str, optional) – Additional text. Defaults to “”.
yPos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
titleColor (str, optional) – Hex color for the title. Defaults to “”.
annotationColor (str, optional) – Hex color for the marker. Defaults to “”.
annotationType (str, optional) – “annotate” or “comment”. Defaults to “”.
annotationGroup (str, optional) – Not used. Defaults to “”.
timeFormat (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- addComment(title: str, commentTime: int | str = 0, extraText: str = '', yPos: int | str = '', titleColor: str = '', commentColor: str = '', annotationType: str = '', annotationGroup: str = '', timeFormat: str = 'unix') str¶
DEPRECATED: Use add_comment instead.
- Parameters:
title (str) – The text label for the comment.
commentTime (Union[int, str], optional) – The timestamp. Defaults to 0.
extraText (str, optional) – Additional text. Defaults to “”.
yPos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
titleColor (str, optional) – Hex color for the title. Defaults to “”.
commentColor (str, optional) – Hex color for the comment marker. Defaults to “”.
annotationType (str, optional) – Overridden to ‘comment’. Defaults to “”.
annotationGroup (str, optional) – Not used. Defaults to “”.
timeFormat (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- addDataPoint(channelName: str, groupName: str, dataValue: int | float, dataPointTime: int | str = 0, timeFormat: str = 'unix') None¶
DEPRECATED: Use add_data_point instead.
Adds a single data point to a specified custom channel in the QPS stream.
- Parameters:
channelName (str) – The name of the custom channel to add data to.
groupName (str) – The group associated with the channel (must match creation).
dataValue (int or float) – The numeric value of the data point.
dataPointTime (int or str, optional) – The timestamp for the data point.
timeFormat (str, optional) – The format of the given time [“elapsed”|”unix”].
- add_annotation(title: str, annotation_time: int | str = 0, extra_text: str = '', y_pos: int | str = '', title_color: str = '', annotation_color: str = '', annotation_type: str = 'annotate', time_format: str = 'unix') str¶
Adds a custom annotation marker to the active QPS stream.
- Parameters:
title (str) – The primary text label for the annotation.
annotation_time (Union[int, str], optional) – When the annotation appears. Defaults to 0 (“now”).
extra_text (str, optional) – Additional text for the annotation. Defaults to “”.
y_pos (Union[int, str], optional) – Vertical position (0-100). Defaults to “”.
title_color (str, optional) – Hex color for the title. Defaults to “”.
annotation_color (str, optional) – Hex color for the marker. Defaults to “”.
annotation_type (str, optional) – “annotate” or “comment”. Defaults to “annotate”.
time_format (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- Returns:
The response message from the QPS device.
- Return type:
str
- add_comment(title: str, comment_time: int | str = 0, **kwargs: Any) str¶
Adds a ‘comment’ type annotation to the QPS stream.
This is a convenience wrapper for add_annotation that sets the type to ‘comment’.
- Parameters:
title (str) – The text label for the comment.
comment_time (Union[int, str], optional) – The timestamp. Defaults to 0.
**kwargs – Other arguments accepted by add_annotation.
- Returns:
The response message from the QPS device.
- Return type:
str
- add_data_point(channel_name: str, group_name: str, data_value: int | float, data_point_time: int | str = 0, time_format: str = 'unix') None¶
Adds a single data point to a specified custom channel.
- Parameters:
channel_name (str) – The name of the custom channel.
group_name (str) – The group associated with the channel.
data_value (Union[int, float]) – The numeric value of the data point.
data_point_time (Union[int, str], optional) – Timestamp for the data point. Defaults to 0 (current time).
time_format (str, optional) – “unix” or “elapsed”. Defaults to “unix”.
- channels() List[str]¶
Retrieves the list of available channels from QPS, split into a list of strings.
- Returns:
A list where each element is a channel identifier string.
- Return type:
list[str]
- createChannel(channelName: str, channelGroup: str, baseUnits: str, usePrefix: bool) str¶
DEPRECATED: Use create_channel instead.
- Parameters:
channelName (str) – The name for the new channel.
channelGroup (str) – The group to associate the channel with.
baseUnits (str) – The fundamental unit for the channel.
usePrefix (bool) – If True, allows channel prefixes.
- Returns:
The response message from the QPS device.
- Return type:
str
- create_channel(channel_name: str, channel_group: str, base_units: str, use_prefix: bool) str¶
Creates a new custom data channel on the QPS device.
- Parameters:
channel_name (str) – The name for the new channel.
channel_group (str) – The group to associate the channel with (e.g., “Voltage”).
base_units (str) – The fundamental unit for the channel (e.g., “V”, “A”).
use_prefix (bool) – If True, allows channel prefixes (e.g., ‘m’ for milli).
- Returns:
The response from the QPS device.
- Return type:
str
- failCheck(response: str, streamDuration: str) str¶
DEPRECATED: Use fail_check instead.
- Parameters:
response (str) – The response message from a stream start attempt.
streamDuration (str) – The duration for the stream, needed for retry attempts.
- Returns:
The successful response message after a retry.
- Return type:
str
- Raises:
Exception – If the response contains an unhandled failure.
- fail_check(response: str, stream_duration: str) str¶
Handles recoverable failures during stream startup.
Currently handles “Directory already exists” by prompting for a new name.
- Parameters:
response (str) – The failure response message from the server.
stream_duration (str) – The stream duration, for retrying.
- Returns:
The successful response after a retry.
- Return type:
str
- Raises:
Exception – If the failure is not a known, handled type.
- getStreamState() str¶
DEPRECATED: Use get_stream_state instead.
- Returns:
The stream state reported by the QPS application.
- Return type:
str
- get_custom_stats_range(start_time: int | str, end_time: int | str) DataFrame | None¶
Retrieves statistics from the QPS device for a specified time range.
- Parameters:
start_time (Union[int, str]) – The start time for stats calculation.
end_time (Union[int, str]) – The end time for stats calculation.
- Returns:
A DataFrame containing the stats.
- Return type:
Optional[pd.DataFrame]
- Raises:
ImportError – If the pandas library is not installed.
Exception – If the QPS command fails or data parsing fails.
- get_stats(format: str = 'df') DataFrame | List[List[str]] | None¶
Retrieves statistics from the QPS device.
- Parameters:
format (str, optional) – The desired output format (“df” for pandas DataFrame, “list” for list of lists). Defaults to “df”.
- Returns:
Statistics data in the specified format, or None if pandas is required but not found.
- Return type:
Union[pd.DataFrame, List[List[str]], None]
- Raises:
Exception – If the QPS command fails.
- get_stats_export_status() str¶
Queries the QPS device for the status of the statistics data export process.
- Returns:
The response string from QPS indicating the stats export status
- Return type:
str
- get_stream_export_status() str¶
Queries the QPS device for the status of the main stream data export process.
- Returns:
The response string from QPS indicating the stream export status
- Return type:
str
- get_stream_state() str¶
Queries the QPS application for its current stream processing state.
- Returns:
The stream state as reported by the QPS application.
- Return type:
str
- Raises:
Exception – If the command fails.
- hideAllDefaultChannels() None¶
DEPRECATED: Use hide_all_default_channels instead.
Hides a predefined list of common default QPS/PAM channels.
- hideChannel(channelSpecifier: str) str¶
DEPRECATED: Use hide_channel instead.
- Parameters:
channelSpecifier (str) – The identifier of the channel to hide.
- Returns:
The response message from the QPS device.
- Return type:
str
- hide_all_default_channels() None¶
Hides a predefined list of common default QPS/PAM channels.
Note
This list is hardcoded and might not be exhaustive for all hardware.
- hide_channel(channel_specifier: str) str¶
Hides a specified channel from the QPS stream view.
- Parameters:
channel_specifier (str) – The identifier of the channel to hide (e.g., “5v:voltage”).
- Returns:
The response from the QPS device.
- Return type:
str
- myChannels() str¶
DEPRECATED: Use channels instead.
Retrieves the list of available channels from QPS as a single raw string.
- Returns:
The raw response string from the QPS ‘$channels’ command.
- Return type:
str
- saveCSV(filePath: str, linesPerFile: int | str | None = None, cr: bool | None = None, delimiter: str | None = None, timeout: int = 180, pollTillComplete: bool = False, checkInterval: float = 0.5) str¶
DEPRECATED: Use save_csv instead.
- Parameters:
filePath (str) – The target file path on the QPS device’s filesystem.
linesPerFile (Optional[Union[int, str]], optional) – Max lines per file. Defaults to None.
cr (Optional[bool], optional) – True for CRLF, False for LF line endings. Defaults to None.
delimiter (Optional[str], optional) – Field delimiter for the CSV. Defaults to None.
timeout (int, optional) – Timeout in seconds. Defaults to 180.
pollTillComplete (bool, optional) – If True, waits for export to finish. Defaults to False.
checkInterval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
- Returns:
The initial response from the QPS device.
- Return type:
str
- save_csv(file_path: str, lines_per_file: int | str | None = None, use_cr: bool | None = None, delimiter: str | None = None, timeout: int = 180, poll_till_complete: bool = False, check_interval: float = 0.5) str¶
Commands the QPS device to save the stream data to a CSV file.
- Parameters:
file_path (str) – Target file path on the QPS device’s filesystem.
lines_per_file (Optional[Union[int, str]], optional) – Max lines per file. Defaults to None.
use_cr (Optional[bool], optional) – True for CRLF, False for LF. Defaults to None.
delimiter (Optional[str], optional) – Field delimiter for the CSV. Defaults to None.
timeout (int, optional) – Timeout in seconds. Defaults to 180.
poll_till_complete (bool, optional) – If True, waits for export to finish. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
- Returns:
The initial response from the QPS device.
- Return type:
str
- Raises:
TimeoutError – If polling is enabled and the export does not complete in time.
- showChannel(channelSpecifier: str) str¶
DEPRECATED: Use show_channel instead.
- Parameters:
channelSpecifier (str) – The identifier of the channel to show.
- Returns:
The response message from the QPS device.
- Return type:
str
- show_channel(channel_specifier: str) str¶
Shows (un-hides) a specified channel in the QPS stream view.
- Parameters:
channel_specifier (str) – The identifier of the channel to show.
- Returns:
The response from the QPS device.
- Return type:
str
- startQPSStream(newDirectory: str, streamDuration: str = '') str¶
DEPRECATED: Use start_qps_stream instead.
- Parameters:
newDirectory (str) – The path to the directory where the stream data should be saved.
streamDuration (str, optional) – The duration for which the stream should run.
- Returns:
The response message from the QPS system.
- Return type:
str
- start_qps_stream(new_directory: str, stream_duration: str = '') str¶
Sends the command to start the QPS stream.
- Parameters:
new_directory (str) – The path for the stream data.
stream_duration (str, optional) – The duration for the stream. Defaults to “”.
- Returns:
The response from the QPS system.
- Return type:
str
- stats_to_CSV(file_name: str = '', poll_till_complete: bool = False, check_interval: float = 0.5, timeout: int = 60) str¶
DEPRECATED: Use stats_to_csv instead.
- Parameters:
file_name (str, optional) – The absolute path for the CSV file. Defaults to “”.
poll_till_complete (bool, optional) – If True, polls until the export is finished. Defaults to False.
check_interval (float, optional) – Time in seconds between status checks when polling. Defaults to 0.5.
timeout (int, optional) – Max time in seconds to wait for polling. Defaults to 60.
- Returns:
The initial response message from the QPS device.
- Return type:
str
- stats_to_csv(file_name: str = '', poll_till_complete: bool = False, check_interval: float = 0.5, timeout: int = 60) str¶
Commands the QPS device to save its current statistics to a CSV file.
- Parameters:
file_name (str, optional) – Absolute path for the CSV file on the QPS device’s filesystem. Defaults to “”.
poll_till_complete (bool, optional) – If True, waits for the export to finish. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.5.
timeout (int, optional) – Max seconds to wait for polling to complete. Defaults to 60.
- Returns:
The initial response from the QPS device.
- Return type:
str
- Raises:
Exception – If the initial QPS command fails.
TimeoutError – If polling is enabled and times out.
- stopStream(pollTillComplete: bool = False, checkInterval: float = 0.1, timeout: int = 60) str¶
DEPRECATED: Use stop_stream instead.
- Parameters:
pollTillComplete (bool, optional) – If True, waits until the QPS stream state is no longer “running”. Defaults to False.
checkInterval (float, optional) – Time in seconds between status checks when polling. Defaults to 0.1.
timeout (int, optional) – Maximum time in seconds to wait. Defaults to 60.
- Returns:
- The final checked stream status string (“STOPPED”, “OVERRUN”) if polling,
otherwise the initial response from the ‘$stop stream’ command.
- Return type:
str
- stop_stream(poll_till_complete: bool = False, check_interval: float = 0.1, timeout: int = 60) Literal[Status.OVERRUN, Status.STOPPED] | Any¶
Sends the command to stop the QPS data stream.
- Parameters:
poll_till_complete (bool, optional) – If True, waits for the stream to fully stop. Defaults to False.
check_interval (float, optional) – Seconds between status checks when polling. Defaults to 0.1.
timeout (int, optional) – Max seconds to wait for polling to complete. Defaults to 60.
- Returns:
The final stream status if polling, otherwise the initial command response.
- Return type:
str
- Raises:
Exception – If the stop command itself fails.
TimeoutError – If polling is enabled and times out.
- takeSnapshot() str¶
DEPRECATED: Use take_snapshot instead.
- Returns:
The response message from the QPS device.
- Return type:
str
- take_snapshot() str¶
Triggers the QPS device to capture an immediate snapshot.
- Returns:
The response from the QPS device.
- Return type:
str
- Raises:
Exception – If the command fails.
- quarchpy.device.scanDevices(target_conn='all', lanTimeout=1, scanInArray=True, favouriteOnly=True, filterStr=None, module_type_filter=None, ipAddressLookup=None, discovered_devices=None)¶
- class quarchpy.device.subDevice(baseDevice, port)¶
Bases:
quarchDevice- close_connection() str¶
Closes the connection to the module.
Handles closing logic based on connection type (PY, QIS, QPS). Clears the internal connection object reference upon successful close.
- Returns:
“OK” on success, “FAIL” on failure or if no connection exists.
- Return type:
str
- send_command(CommandString, expectedResponse=True)¶
Executes a text command on the connected device.
Sends the command string via the appropriate underlying connection object (PY, QIS, or QPS) and returns the response. Handles QIS/QPS specific formatting or command routing as needed.
- Parameters:
command_string (str) – The text command to send (e.g., “*IDN?”).
is_response_expected (bool, optional) – If False, the method may return faster as it doesn’t wait for/read a response. Defaults to True.
- Returns:
- The response string from the device. Returns an empty string if
no response was expected or received, or if the underlying connection returned None.
- Return type:
str
- Raises:
ConnectionError – If the device is not connected, or if communication fails.
TimeoutError – If the device response times out.
NotImplementedError – If the method is called for an unsupported ConType.
- quarchpy.device.userSelectDevice(scanDictionary=None, scanFilterStr=None, favouriteOnly=True, message=None, title=None, nice=False, additionalOptions=None, target_conn='all')¶