quarchpy.qis package¶
Submodules¶
quarchpy.qis.qisFuncs module¶
Contains general functions for starting and stopping QIS processes
- quarchpy.qis.qisFuncs.GetQisModuleSelection(QisConnection)¶
Prints a list of modules for user selection
Deprecated since version 2.0.12: Use the module selection functions of the QisInterface class instead
- quarchpy.qis.qisFuncs.checkAndCloseQis(host='127.0.0.1', port=9722)¶
- quarchpy.qis.qisFuncs.check_remote_qis(host='127.0.0.1', port=9722, timeout=0)¶
Checks if a local or specified instance of QIS is running and responding This continues to scan until qis is found or a timeout is hit.
- Returns:
is_running – True if QIS is running and responding
- Return type:
bool
- quarchpy.qis.qisFuncs.closeQis(host='127.0.0.1', port=9722)¶
Helper function to close an instance of QIS. By default this is the local version, but an address can be specified for remote systems.
- Parameters:
host (str, optional) – Host IP address if not localhost
port (str, optional) – QIS connection port if set to a value other than the default
- quarchpy.qis.qisFuncs.isQisRunning()¶
Checks if a local instance of QIS is running and responding :returns: is_running – True if QIS is running and responding :rtype: bool
- quarchpy.qis.qisFuncs.isQisRunningAndResponding(timeout=2)¶
checks if qis is running and responding to a $version
- quarchpy.qis.qisFuncs.reader(stream, q, source, lock, stop_flag)¶
Used to read output and place it in a queue for multithreaded reading :param stream: :param q: :param source: :param lock: The lock for the queue :param stop_flag: Flag to exit the loop and close the thread :return: None
- quarchpy.qis.qisFuncs.startLocalQis(terminal=False, headless=False, args=None, timeout=20)¶
Executes QIS on the local system, using the version contained within quarchpy
- Parameters:
terminal (bool, optional) – True if QIS terminal should be shown on startup
headless (bool, optional) – True if app should be run in headless mode for non graphical environments
args (list[str], optional) – List of additional parameters to be supplied to QIS on the command line
Module contents¶
- class quarchpy.qis.QisInterface(host='127.0.0.1', port=9722, connectionMessage=True)¶
Bases:
object
- GetQisModuleSelection(favouriteOnly=True, additionalOptions=['rescan', 'all con types', 'ip scan'], scan=True)¶
Fuction used to list the available deviced to QIS and present them to the user for selection.
Returns myDeviceID - Str the connection string used to connect to the selected device.
- add_header_to_buffer(outBuffer, return_b_array, stream_header_size, temp_dict)¶
- add_header_to_byte_array(return_b_array, stream_header_size, temp_dict, tree, is_digital=False)¶
- averageStripes(leftover, streamAverage, newStripes, f, remainingStripes=[])¶
- avgStringFromPwr(avgPwrTwo)¶
- closeConnection(sock=None, conString=None)¶
- connect(connectionMessage=True)¶
Connect() tries to open a socket on the host and port specified in the objects variables If successful it returns the backends welcome string. If it fails it returns a string saying unable to connect The backend should be running and host and port set before running this function. Normally it should be called at the beggining of talking to the backend and left open until finished talking when the disconnect() function should be ran
Param: connectionMessage: boolean, optional
Set to False if you don’t want a warning message to appear when an instance is already running on that port. Useful when using isQisRunning() from qisFuncs
- convertStreamAverage(streamAveraging)¶
- create_dir_structure(module, directory=None)¶
Creates the QPS directory structure and (empty) files to be written to
I’ve put a bunch of try-except just to be sure the directory is correctly created. ( There’s probably a better way of doing this than this )
- Param:
module: String - Module string
- Param:
directory: String - Name of directory for QPS stream (defaults to default recording location if invalid)
- Returns:
success: Boolean - Was the file structure created successfully?
- create_index_file()¶
Create the necessary index file for QPS data000.idx
For future revisions, this should be updated if there are file limits on each data file Current implementation assumes only 1 of each data file are made.
No Return./
- create_index_file_digitals()¶
Create the necessary index file for QPS data101.idx
For future revisions, this should be updated if there are file limits on each data file Current implementation assumes only 1 of each data file are made.
No Return.
- create_qps_directory(directory)¶
- create_qps_file(module)¶
Creates the end QPS file that is used to open QPS
- Parameters:
module – Module QTL number that was used for the stream
- Returns:
- deviceDictSetup(module)¶
- deviceMulti(device)¶
- disconnect()¶
- getDeviceList(sock=None)¶
- getStreamXmlHeader(device, sock=None)¶
- get_list_details(sock=None)¶
- interruptList()¶
- isXmlHeader(headerText)¶
- qis_scan_devices(scan=True, favouriteOnly=True, ipAddress=None)¶
- receiveText(sock)¶
- rxBytes(sock)¶
- scanIP(ipAddress)¶
Triggers QIS to look at a specific IP address for a quarch module
- Parameters:
QisConnection (QpsInterface) – The interface to the instance of QPS you would like to use for the scan.
ipAddress (str) – The IP address of the module you are looking for eg ‘192.168.123.123’
sleep (int, optional) – This optional variable sleeps to allow the network to scan for the module before allowing new commands to be sent to QIS.
- sendAndReceiveCmd(sock=None, cmd='$help', device='', readUntilCursor=True, betweenCommandDelay=0.0)¶
- sendAndReceiveText(sock, sentText='$help', device='', readUntilCursor=True)¶
- sendCmd(device='', cmd='$help', sock=None, readUntilCursor=True, betweenCommandDelay=0.0, expectedResponse=True)¶
Send command is used to send a command to QIS and as far as I can see it has no difference than sendAndReceiveCmd
- sendCommand(cmd, device='', timeout=20, sock=None, readUntilCursor=True, betweenCommandDelay=0.0, expectedResponse=True)¶
Send command is used to send a command to QIS and as far as I can see it has no difference than sendAndReceiveCmd
- sendText(sock, message='$help', device='')¶
- sortFavourite(foundDevices)¶
- startStream(module, fileName, fileMaxMB, streamName, streamAverage, releaseOnData, separator, streamDuration=None, inMemoryData=None)¶
- startStreamQPS(module, fileName, fileMaxMB, streamName, streamAverage, releaseOnData, separator)¶
- startStreamThread(module, fileName, fileMaxMB, streamName, streamAverage, releaseOnData, separator, streamDuration=None, inMemoryData=None)¶
- startStreamThreadQPS(module, fileName, fileMaxMB, streamName, streamAverage, releaseOnData, separator)¶
- stopStream(module, blocking=True)¶
- streamBufferStatus(device, sock=None)¶
- streamGetStripesText(sock, device, numStripes=4096, skipStatusCheck=False)¶
- streamHeaderAverage(device, sock=None)¶
- streamHeaderFormat(device, sock=None)¶
- streamHeaderVersion(device, sock=None)¶
- streamInterrupt()¶
- streamRunningStatus(device, sock=None)¶
- waitStop()¶
- write_b_array_to_idx_file(f, return_b_array)¶
- write_stripe_to_files_HD(stripe)¶
- write_stripe_to_files_PAM(stripe)¶
- class quarchpy.qis.StreamHeaderInfo(stream_header=None)¶
Bases:
object
Holds the raw header information data and allows access to its various elements in a simple way
- data_valid = False¶
- device_channels = []¶
- device_groups = []¶
- device_period = None¶
- get_device_period()¶
Returns the sample rate of the stream (of the fastest group for multi-rate streams)
- Returns:
device_period – Sample rate time object including time unit
- Return type:
TimeValue
- get_header_version()¶
Returns the header version number
- Returns:
header_version – Version number of the stream text header data
- Return type:
int
- header_raw_xml = None¶
- header_version = None¶
- init_from_qis_device(open_qis_device)¶
Sets up the info class from a quaech device that is attached via QIS and so the header can be requested direct from the instrument
- Parameters:
open_qis_device (quarchDevice) – Open connection to a quarch streaming device via QIS
- init_from_stream_header(stream_header)¶
Sets up the info class from stream header text, as supplied from the QIS stream text header command
- Parameters:
stream_header (str) – Stream header text data
- quarchpy.qis.checkAndCloseQis(host='127.0.0.1', port=9722)¶
- quarchpy.qis.closeQis(host='127.0.0.1', port=9722)¶
Helper function to close an instance of QIS. By default this is the local version, but an address can be specified for remote systems.
- Parameters:
host (str, optional) – Host IP address if not localhost
port (str, optional) – QIS connection port if set to a value other than the default
- quarchpy.qis.isQisRunning()¶
Checks if a local instance of QIS is running and responding :returns: is_running – True if QIS is running and responding :rtype: bool
- quarchpy.qis.startLocalQis(terminal=False, headless=False, args=None, timeout=20)¶
Executes QIS on the local system, using the version contained within quarchpy
- Parameters:
terminal (bool, optional) – True if QIS terminal should be shown on startup
headless (bool, optional) – True if app should be run in headless mode for non graphical environments
args (list[str], optional) – List of additional parameters to be supplied to QIS on the command line