quarchpy.device package

Submodules

quarchpy.device.device module

quarchpy.device.device.checkModuleFormat(ConString)
quarchpy.device.device.getQuarchDevice(connectionTarget, ConType='PY', timeout='5')

creates a quarch device to be returned. Handles sub devices in quarch arrays.

class quarchpy.device.device.quarchDevice(ConString, ConType='PY', timeout='5')

Bases: object

Allows 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.

closeConnection()

Closes the connection to the module, freeing the module for other uses. This should always be called whern you are finished with a device.

getRuntime(command='conf:runtimes?')
Parameters

command – can be overridden to ask for PAM fixture runtime

Returns

openConnection()

Opens the connection to the module. This will be open by default on creation of quarchDevice but this allows re-opening if required.

resetDevice(timeout=10)

Issues a power-on-reset command to the device. Attempts to recover the connection to the module after reset. Function halts until the timeout is complete or the module is found

Parameters

timeout (int) – Number of seconds to wait for the module to re-enumerate and become available

Returns

result – True if the device was found and reconnected, false if it was not and we timed out

Return type

bool

sendAndVerifyCommand(commandString, responseExpected='OK', exception=True)

Sends a command to the device and verifies the response is as expected. This is a simple wrapper of sendCommand and helps write cleaner code in test scripts.

Parameters
  • commandString (str, optional) – The text command to send to the device

  • commandString – The expected text response from the module.

  • exception (bool, optional) – If True, an exception is raised on mismatch. If False, we just return False

Returns

result – True if we matched the response, False if we did not

Return type

bool

Raises

ValueError – If the response does not match AND the exception parameter is set to True

sendBinaryCommand(cmd)
sendCommand(CommandString, expectedResponse=True)

Executes a text based command on the device. This is the primary way of controlling a device. The full command set available to use is found in the technical manual for the device.

Parameters

CommandString (str) – The text based command string to send to the device

Returns

command_response – The response text from the module. Multiline responses will be seperated with LF. Some commands do not return a response and None will be returned

Return type

str or None

quarchpy.device.quarchArray module

quarchpy.device.quarchArray.isThisAnArrayController(moduleString)
class quarchpy.device.quarchArray.quarchArray(baseDevice)

Bases: quarchpy.device.device.quarchDevice

getSubDevice(port)
scanSubModules()
class quarchpy.device.quarchArray.subDevice(baseDevice, port)

Bases: quarchpy.device.device.quarchDevice

sendCommand(CommandString, expectedResponse=True)

Executes a text based command on the device. This is the primary way of controlling a device. The full command set available to use is found in the technical manual for the device.

Parameters

CommandString (str) – The text based command string to send to the device

Returns

command_response – The response text from the module. Multiline responses will be seperated with LF. Some commands do not return a response and None will be returned

Return type

str or None

quarchpy.device.quarchPPM module

class quarchpy.device.quarchPPM.quarchPPM(originObj)

Bases: quarchpy.device.device.quarchDevice

setupPowerOutput()
startStream(fileName='streamData.txt', fileMaxMB=2000, streamName='Stream With No Name', streamAverage=None, releaseOnData=False, separator=',')
stopStream()
streamBufferStatus()
streamInterrupt()
streamResampleMode(streamCom)
streamRunningStatus()
waitStop()

quarchpy.device.quarchQPS module

quarchpy.device.quarchQPS.current_milli_time()
quarchpy.device.quarchQPS.current_second_time()
quarchpy.device.quarchQPS.qpsNowStr()
class quarchpy.device.quarchQPS.quarchQPS(quarchDevice)

Bases: quarchpy.device.device.quarchDevice

startStream(directory)
class quarchpy.device.quarchQPS.quarchStream(quarchQPS, directory)

Bases: quarchpy.device.quarchQPS.quarchQPS

addAnnotation(title, annotationTime=0, extraText='', yPos='', titleColor='', annotationColor='', annotationType='', annotationGroup='')

Adds a custom annotation to stream with given parameters.

Parameters
  • title= (str) – The title appears next to the annotation in the stream

  • extraText= (str, optional) – The additional text that can be viewed when selecting the annotation

  • yPos (str, optional) – The percetange of how high up the screen the annotation should appear 0 is the bottom and 100 the top

  • titleColor (str, optional) – The color of the text next to the annotation in hex format 000000 to FFFFFF

  • annotationColor (str, optional) – The color of the annotation marker in hex format 000000 to FFFFFF

  • annotationGroup (str, optional) – The group the annotation belongs to

  • annotationTime (int, optional) – The time in milliseconds after the start of the stream at which the annotation should be placed. 0 will plot the annotation live at the most recent sample

Returns

command_response – The response text from QPS. “ok” if annotation successfully added

Return type

str or None

addComment(title, commentTime=0, extraText='', yPos='', titleColor='', commentColor='', annotationType='', annotationGroup='')
addDataPoint(channelName, groupName, dataValue, dataPointTime=0)
channels()
createChannel(channelName, channelGroup, baseUnits, usePrefix)
failCheck(newDirectory)
getStreamState()

Askes QPS for the stream status. QPS stream state != Module stream state. This is different from “rec stream?” cmd to the module as it will return “streaming” when the module is nolonger streaming but QPS is still receiveing stream data from the module. ei the module has stopped streaming but is emptying the stream buffer.

get_custom_stats_range(start_time, end_time)

Returns the QPS statistics information over a specific time ignoring any set annotations.

start_time =str

The time in seconds you would like the stats to start this can be in integer or sting format. or using the following format to specify daysDhours:minutes:seconds.milliseconds xxxDxx:xx:xx.xxxx

end_time =str

The time in seconds you would like the stats to stop this can be in integer or sting format or using the following format to specify daysDhours:minutes:seconds.milliseconds xxxDxx:xx:xx.xxxx

df =dataframe

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

get_stats(format='df')

Returns the QPS annotation statistics grid information as a pandas dataframe object

df =dataframe

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

hideAllDefaultChannels()
hideChannel(channelSpecifier)
myChannels()
saveCSV(filePath, linesPerFile=None, cr=None, delimiter=None)

Saves the stream to csv file at specified location

Parameters
  • filePath= (str) – The file path that ou would like the CSV file saved to.

  • linesPerFile= (str, optional) – The number of lines per CSV file. Can be any int number or “all”

  • cr (bool, optional) – Whether the end of line terminator should include a carriage return.

  • delimiter (str, optional) – The delimiter to be used by the csv file.

Returns

command_response – The response text from QPS. “ok” if command is successful or the stack trace if exception thrown

Return type

str or None

showChannel(channelSpecifier)
stats_to_CSV(file_name='')

Saves the statistics grid to a csv file

file-name=str, optional

The absolute path of the file you would like to save the csv to. If left empty then a filename will be give. Default location is the path of the executable.

command_response : str or None

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

stopStream()
stopStreamAndAllowBufferToEmpty(checkInterval=0.5)
takeSnapshot()

Triggers QPS take snapshot function and saves it in the streams directory.

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)
quarchpy.device.scanDevices.get_connection_target(module_string, scan_dictionary=None, connection_preference=None, include_conn_type=True)
quarchpy.device.scanDevices.get_user_level_serial_number(network_modules)
quarchpy.device.scanDevices.listDevices(scanDictionary)
quarchpy.device.scanDevices.list_USB(debuPrint=False)
quarchpy.device.scanDevices.list_network(target_conn='all', debugPring=False, lanTimeout=1, ipAddressLookup=None)
quarchpy.device.scanDevices.list_serial(debuPrint=False)
quarchpy.device.scanDevices.lookupDevice(ipAddressLookup, mySocket, lan_modules)
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)
quarchpy.device.scanDevices.userSelectDevice(scanDictionary=None, scanFilterStr=None, favouriteOnly=True, message=None, title=None, nice=False, additionalOptions=None, target_conn='all')

Module contents

quarchpy.device.getQuarchDevice(connectionTarget, ConType='PY', timeout='5')

creates a quarch device to be returned. Handles sub devices in quarch arrays.

quarchpy.device.getSerialNumberFromConnectionTarget(connectionTarget)
quarchpy.device.get_connection_target(module_string, scan_dictionary=None, connection_preference=None, include_conn_type=True)
quarchpy.device.listDevices(scanDictionary)
quarchpy.device.qpsNowStr()
class quarchpy.device.quarchArray(baseDevice)

Bases: quarchpy.device.device.quarchDevice

getSubDevice(port)
scanSubModules()
class quarchpy.device.quarchDevice(ConString, ConType='PY', timeout='5')

Bases: object

Allows 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.

closeConnection()

Closes the connection to the module, freeing the module for other uses. This should always be called whern you are finished with a device.

getRuntime(command='conf:runtimes?')
Parameters

command – can be overridden to ask for PAM fixture runtime

Returns

openConnection()

Opens the connection to the module. This will be open by default on creation of quarchDevice but this allows re-opening if required.

resetDevice(timeout=10)

Issues a power-on-reset command to the device. Attempts to recover the connection to the module after reset. Function halts until the timeout is complete or the module is found

Parameters

timeout (int) – Number of seconds to wait for the module to re-enumerate and become available

Returns

result – True if the device was found and reconnected, false if it was not and we timed out

Return type

bool

sendAndVerifyCommand(commandString, responseExpected='OK', exception=True)

Sends a command to the device and verifies the response is as expected. This is a simple wrapper of sendCommand and helps write cleaner code in test scripts.

Parameters
  • commandString (str, optional) – The text command to send to the device

  • commandString – The expected text response from the module.

  • exception (bool, optional) – If True, an exception is raised on mismatch. If False, we just return False

Returns

result – True if we matched the response, False if we did not

Return type

bool

Raises

ValueError – If the response does not match AND the exception parameter is set to True

sendBinaryCommand(cmd)
sendCommand(CommandString, expectedResponse=True)

Executes a text based command on the device. This is the primary way of controlling a device. The full command set available to use is found in the technical manual for the device.

Parameters

CommandString (str) – The text based command string to send to the device

Returns

command_response – The response text from the module. Multiline responses will be seperated with LF. Some commands do not return a response and None will be returned

Return type

str or None

class quarchpy.device.quarchPPM(originObj)

Bases: quarchpy.device.device.quarchDevice

setupPowerOutput()
startStream(fileName='streamData.txt', fileMaxMB=2000, streamName='Stream With No Name', streamAverage=None, releaseOnData=False, separator=',')
stopStream()
streamBufferStatus()
streamInterrupt()
streamResampleMode(streamCom)
streamRunningStatus()
waitStop()
class quarchpy.device.quarchQPS(quarchDevice)

Bases: quarchpy.device.device.quarchDevice

startStream(directory)
class quarchpy.device.quarchStream(quarchQPS, directory)

Bases: quarchpy.device.quarchQPS.quarchQPS

addAnnotation(title, annotationTime=0, extraText='', yPos='', titleColor='', annotationColor='', annotationType='', annotationGroup='')

Adds a custom annotation to stream with given parameters.

Parameters
  • title= (str) – The title appears next to the annotation in the stream

  • extraText= (str, optional) – The additional text that can be viewed when selecting the annotation

  • yPos (str, optional) – The percetange of how high up the screen the annotation should appear 0 is the bottom and 100 the top

  • titleColor (str, optional) – The color of the text next to the annotation in hex format 000000 to FFFFFF

  • annotationColor (str, optional) – The color of the annotation marker in hex format 000000 to FFFFFF

  • annotationGroup (str, optional) – The group the annotation belongs to

  • annotationTime (int, optional) – The time in milliseconds after the start of the stream at which the annotation should be placed. 0 will plot the annotation live at the most recent sample

Returns

command_response – The response text from QPS. “ok” if annotation successfully added

Return type

str or None

addComment(title, commentTime=0, extraText='', yPos='', titleColor='', commentColor='', annotationType='', annotationGroup='')
addDataPoint(channelName, groupName, dataValue, dataPointTime=0)
channels()
createChannel(channelName, channelGroup, baseUnits, usePrefix)
failCheck(newDirectory)
getStreamState()

Askes QPS for the stream status. QPS stream state != Module stream state. This is different from “rec stream?” cmd to the module as it will return “streaming” when the module is nolonger streaming but QPS is still receiveing stream data from the module. ei the module has stopped streaming but is emptying the stream buffer.

get_custom_stats_range(start_time, end_time)

Returns the QPS statistics information over a specific time ignoring any set annotations.

start_time =str

The time in seconds you would like the stats to start this can be in integer or sting format. or using the following format to specify daysDhours:minutes:seconds.milliseconds xxxDxx:xx:xx.xxxx

end_time =str

The time in seconds you would like the stats to stop this can be in integer or sting format or using the following format to specify daysDhours:minutes:seconds.milliseconds xxxDxx:xx:xx.xxxx

df =dataframe

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

get_stats(format='df')

Returns the QPS annotation statistics grid information as a pandas dataframe object

df =dataframe

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

hideAllDefaultChannels()
hideChannel(channelSpecifier)
myChannels()
saveCSV(filePath, linesPerFile=None, cr=None, delimiter=None)

Saves the stream to csv file at specified location

Parameters
  • filePath= (str) – The file path that ou would like the CSV file saved to.

  • linesPerFile= (str, optional) – The number of lines per CSV file. Can be any int number or “all”

  • cr (bool, optional) – Whether the end of line terminator should include a carriage return.

  • delimiter (str, optional) – The delimiter to be used by the csv file.

Returns

command_response – The response text from QPS. “ok” if command is successful or the stack trace if exception thrown

Return type

str or None

showChannel(channelSpecifier)
stats_to_CSV(file_name='')

Saves the statistics grid to a csv file

file-name=str, optional

The absolute path of the file you would like to save the csv to. If left empty then a filename will be give. Default location is the path of the executable.

command_response : str or None

The response text from QPS. If successful “ok. Saving stats to : file_name” otherwise returns the exception thrown

stopStream()
stopStreamAndAllowBufferToEmpty(checkInterval=0.5)
takeSnapshot()

Triggers QPS take snapshot function and saves it in the streams directory.

quarchpy.device.scanDevices(target_conn='all', lanTimeout=1, scanInArray=True, favouriteOnly=True, filterStr=None, module_type_filter=None, ipAddressLookup=None)
class quarchpy.device.subDevice(baseDevice, port)

Bases: quarchpy.device.device.quarchDevice

sendCommand(CommandString, expectedResponse=True)

Executes a text based command on the device. This is the primary way of controlling a device. The full command set available to use is found in the technical manual for the device.

Parameters

CommandString (str) – The text based command string to send to the device

Returns

command_response – The response text from the module. Multiline responses will be seperated with LF. Some commands do not return a response and None will be returned

Return type

str or None

quarchpy.device.userSelectDevice(scanDictionary=None, scanFilterStr=None, favouriteOnly=True, message=None, title=None, nice=False, additionalOptions=None, target_conn='all')