Keithley707#
Controls a Keithley 707B switching mainframe from Python scripts. Provides relay switching on the switch matrix. This class inherits from MeasmaticDevice.
property columns#
Returns the number of columns of the switch matrix, as determined from the detected cards and the card configuration. Raises an error if the matrix is not configured (for example because no cards were detected).
Returns#
| Type | Description |
|---|---|
| int | The number of columns of the switch matrix. |
Example#
matrix = measmatic.get_device('device-switch')
columns = matrix.columns
property configuration#
Returns the configuration of the device.
Returns#
| Type | Description |
|---|---|
| Any | The device configuration, an Atv.Framework.Devices.Configuration.KeithleyTspDeviceConfigurationBase. |
Example#
matrix = measmatic.get_device('device-switch')
config = matrix.configuration
property is_tsp_master#
Returns whether this device is the master of its TSP link, that is whether it is its own master node.
Returns#
| Type | Description |
|---|---|
| bool | True if this device is the TSP master, otherwise False . |
Example#
matrix = measmatic.get_device('device-switch')
is_master = matrix.is_tsp_master
property lua_syntax#
Returns the Lua syntax variant used for this device.
Returns#
| Type | Description |
|---|---|
| Any | The Lua syntax, an Atv.Framework.Devices.Enumerations.KeithleyTspLuaSyntax value. |
Example#
matrix = measmatic.get_device('device-switch')
syntax = matrix.lua_syntax
property master_node#
Returns the TSP master of this device. If no master was set, the device itself is its master.
Returns#
| Type | Description |
|---|---|
| Any | The master device, an Atv.Framework.Devices.Contracts.IKeithleyTspDevice. |
Example#
matrix = measmatic.get_device('device-switch')
master = matrix.master_node
property model#
Returns the Keithley model that was detected from the identification string of the device.
Returns#
| Type | Description |
|---|---|
| Any | The model, an Atv.Framework.Devices.Enumerations.KeithleyModel value. |
Example#
matrix = measmatic.get_device('device-switch')
model = matrix.model
property number_of_slots#
Returns the number of card slots of the Keithley 707B mainframe.
Returns#
| Type | Description |
|---|---|
| int | The number of card slots (6). |
Example#
matrix = measmatic.get_device('device-switch')
slots = matrix.number_of_slots
property revision#
Returns the firmware version of the device as reported by its identification string.
Returns#
| Type | Description |
|---|---|
| str | The firmware version. |
Example#
matrix = measmatic.get_device('device-switch')
firmware = matrix.revision
property rows#
Returns the number of rows of the switch matrix, as determined from the detected cards and the card configuration. Raises an error if the matrix is not configured (for example because no cards were detected).
Returns#
| Type | Description |
|---|---|
| int | The number of rows of the switch matrix. |
Example#
matrix = measmatic.get_device('device-switch')
rows = matrix.rows
property serial_number#
Returns the serial number of the device as reported by its identification string.
Returns#
| Type | Description |
|---|---|
| str | The serial number. |
Example#
matrix = measmatic.get_device('device-switch')
serial = matrix.serial_number
property switch_cards#
Returns the switch cards that were detected in the slots of the mainframe.
Returns#
| Type | Description |
|---|---|
| Any | The detected cards, an iterable of Atv.Framework.Devices.Switch.Contracts.IKeithleySwitchCard. |
Example#
matrix = measmatic.get_device('device-switch')
for card in matrix.switch_cards:
print(card.SlotId, card.ModelName)
property tsp_node_number#
Returns the TSP node number of this device, as given in its configuration (0 if there is none).
Returns#
| Type | Description |
|---|---|
| int | The TSP node number. |
Example#
matrix = measmatic.get_device('device-switch')
node = matrix.tsp_node_number
property tsp_nodes#
Returns the devices that were added to this device as TSP nodes.
Returns#
| Type | Description |
|---|---|
| Any | The TSP node devices, an iterable of Atv.Framework.Devices.Contracts.IKeithleyTspDevice. |
Example#
matrix = measmatic.get_device('device-switch')
for node in matrix.tsp_nodes:
print(node.TspNodeNumber)
method add_node(nodeDevice: Any)#
Adds another TSP device as node to this device, which then acts as TSP master. The node must have a valid TSP node number that is not yet used, must not have nodes itself and takes over the communicator of this device.
Parameters#
| Name | Description |
|---|---|
| nodeDevice | The device to add, an Atv.Framework.Devices.Contracts.IKeithleyTspDevice. |
Example#
matrix = measmatic.get_device('device-switch')
node = measmatic.get_device('device-switch-node')
matrix.add_node(node)
method change_tsp_node_number(newTspNodeNumber: int)#
Changes the TSP node number of the device to the given value.
Parameters#
| Name | Description |
|---|---|
| newTspNodeNumber | The new TSP node number for the device. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.change_tsp_node_number(2)
method check_errors()#
Intended to check the error list of the device. On the Keithley 707B this is currently not implemented and does nothing.
Example#
matrix = measmatic.get_device('device-switch')
matrix.check_errors()
method check_ok(response: str, funcName: str)#
Checks a response of a Lua function and raises an error if it does not contain OK .
Parameters#
| Name | Description |
|---|---|
| response | The response received from the device. |
| funcName | The name of the function, used in the error message. |
Example#
matrix = measmatic.get_device('device-switch')
response, _ = matrix.execute_lua_function('my_function')
matrix.check_ok(response, 'my_function')
method clear_stop()#
Intended to reset the stop flag inside the device. On the Keithley 707B this does nothing.
Example#
matrix = measmatic.get_device('device-switch')
matrix.clear_stop()
method close_relay(row: int, column: int)#
Closes a relay of the switch matrix, then waits for the configured switching delay. Raises an error if the row or column does not exist.
Parameters#
| Name | Description |
|---|---|
| row | Row of the relay in the switch matrix, starting at 1. |
| column | Column of the relay in the switch matrix, starting at 1. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.close_relay(2, 5)
method close_relay(relay: Any)#
Closes the relay described by the given relay object. Its DesiredState is ignored.
Parameters#
| Name | Description |
|---|---|
| relay | The relay to switch, an instance of Atv.Framework.Devices.Switch.Model.SwitchRelay (its Row and Column |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relay = SwitchRelay()
relay.Row = 2
relay.Column = 5
matrix.close_relay(relay)
method close_relay(relayList: Any)#
Closes several relays with a single channel command, then waits for the configured switching delay. Does nothing for an empty list.
Parameters#
| Name | Description |
|---|---|
| relayList | The relays to switch, a Python list of Atv.Framework.Devices.Switch.Model.SwitchRelay objects. |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relays = []
for column in (1, 2):
relay = SwitchRelay()
relay.Row = 1
relay.Column = column
relays.append(relay)
matrix.close_relay(relays)
method configure_pseudo_card(pseudoCardList: Any)#
Configures several pseudo cards in the switch, which allows the use of the switch in demo mode without real cards. Each card is configured like with the single-card overload.
Parameters#
| Name | Description |
|---|---|
| pseudoCardList | The pseudo cards, a list of Atv.Framework.Devices.Switch.PseudoCard. |
Example#
from Atv.Framework.Devices.Switch import PseudoCard
matrix = measmatic.get_device('device-switch')
card = PseudoCard()
card.TspNodeNumber = 1
card.Slot = 1
card.CardType = 3730
matrix.configure_pseudo_card([card])
method configure_pseudo_card(pseudoCard: Any)#
Configures a pseudo card in the switch, which allows the use of the switch in demo mode without a real card. The slot must be between 1 and 6 and the card type must be a supported multiplexer (3720 to 3724) or matrix (3730 to 3732) card.
Parameters#
| Name | Description |
|---|---|
| pseudoCard | The pseudo card configuration, an Atv.Framework.Devices.Switch.PseudoCard (TspNodeNumber, Slot and |
Example#
from Atv.Framework.Devices.Switch import PseudoCard
matrix = measmatic.get_device('device-switch')
card = PseudoCard()
card.TspNodeNumber = 1
card.Slot = 1
card.CardType = 3730
matrix.configure_pseudo_card(card)
method execute_lua_function(functionName: str, response: Any, responseCount: int = 1, *args: Any)#
Calls a Lua function on the device and reads the given number of response lines. The arguments are converted to text and inserted unchanged into the call, so string arguments must contain their own Lua quotes.
Parameters#
| Name | Description |
|---|---|
| functionName | The name of the Lua function. |
| response | Out parameter, returned as part of the result tuple. |
| responseCount | The number of response lines to read. Default: 1 |
| args | The arguments of the function call. |
Returns#
| Type | Description |
|---|---|
| str | The first response line, or an empty string if no response was requested. |
| str | All response lines that were read. |
Example#
matrix = measmatic.get_device('device-switch')
first, responses = matrix.execute_lua_function('print', 1, '"hello"')
method execute_script(scriptName: str, reader: Any, checkErrors: bool = False)#
Loads a Lua script from a reader into the device under the given name and runs it. Optionally checks the error list afterwards.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| reader | A System.IO.TextReader that provides the script lines. |
| checkErrors | Whether the error list of the device is checked after the script ran. Default: false |
Example#
from System.IO import StringReader
matrix = measmatic.get_device('device-switch')
matrix.execute_script('myscript', StringReader('print(1)'), True)
method execute_script_file(scriptName: str, fileName: str, checkErrors: bool = False)#
Loads a Lua script from a file into the device under the given name and runs it. Optionally checks the error list afterwards.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| fileName | The path of the script file. |
| checkErrors | Whether the error list of the device is checked after the script ran. Default: false |
Example#
matrix = measmatic.get_device('device-switch')
matrix.execute_script_file('myscript', 'C:/scripts/myscript.lua', True)
method execute_script_string(scriptName: str, script: str, checkErrors: bool = False)#
Loads a Lua script given as text into the device under the given name and runs it. Optionally checks the error list afterwards.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| script | The Lua source code. |
| checkErrors | Whether the error list of the device is checked after the script ran. Default: false |
Example#
matrix = measmatic.get_device('device-switch')
matrix.execute_script_string('myscript', 'print(1)', True)
method get_switch_card(slot: int)#
Returns the card that was detected in the given slot.
Parameters#
| Name | Description |
|---|---|
| slot | The slot number, starting at 1. |
Returns#
| Type | Description |
|---|---|
| Any | The card in the slot, an Atv.Framework.Devices.Switch.Contracts.IKeithleySwitchCard, or |
None if no card was detected in that slot. |
Example#
matrix = measmatic.get_device('device-switch')
card = matrix.get_switch_card(1)
method is_tsp_node_number_occupied(tspNodeNumber: int)#
Checks whether the given node number is used by a device on the TSP link. The check is done by a query to the TSP master and is independent of the configuration.
Parameters#
| Name | Description |
|---|---|
| tspNodeNumber | The TSP node number to check. |
Returns#
| Type | Description |
|---|---|
| bool | True if the node number is used, otherwise False . |
Example#
matrix = measmatic.get_device('device-switch')
occupied = matrix.is_tsp_node_number_occupied(2)
method load_script(scriptName: str, reader: Any)#
Loads a Lua script from a reader into the device under the given name, without running it. Empty lines are skipped and the reader is closed afterwards.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| reader | A System.IO.TextReader that provides the script lines. |
Example#
from System.IO import StringReader
matrix = measmatic.get_device('device-switch')
matrix.load_script('myscript', StringReader('print(1)'))
method load_script_file(scriptName: str, fileName: str)#
Loads a Lua script from a file into the device under the given name, without running it.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| fileName | The path of the script file. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.load_script_file('myscript', 'C:/scripts/myscript.lua')
method load_script_string(scriptName: str, script: str)#
Loads a Lua script given as text into the device under the given name, without running it.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
| script | The Lua source code. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.load_script_string('myscript', 'print(1)')
method node_exists(tspNodeNumber: int)#
Checks by a query whether a TSP node with the given number exists.
Parameters#
| Name | Description |
|---|---|
| tspNodeNumber | The TSP node number to look up. |
Returns#
| Type | Description |
|---|---|
| bool | True if the TSP node exists, otherwise False . |
Example#
matrix = measmatic.get_device('device-switch')
exists = matrix.node_exists(2)
method node_prefix()#
Returns the prefix that must be put in front of commands so that they run on this TSP node instead of the master: an empty string for the master, otherwise node[N]. with the node number N.
Returns#
| Type | Description |
|---|---|
| str | The command prefix. |
Example#
matrix = measmatic.get_device('device-switch')
prefix = matrix.node_prefix()
method open_all()#
Opens all channels of all slots, then waits for the configured switching delay.
Example#
matrix = measmatic.get_device('device-switch')
matrix.open_all()
method open_relay(row: int, column: int)#
Opens a relay of the switch matrix, then waits for the configured switching delay. Raises an error if the row or column does not exist.
Parameters#
| Name | Description |
|---|---|
| row | Row of the relay in the switch matrix, starting at 1. |
| column | Column of the relay in the switch matrix, starting at 1. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.open_relay(2, 5)
method open_relay(relay: Any)#
Opens the relay described by the given relay object. Its DesiredState is ignored.
Parameters#
| Name | Description |
|---|---|
| relay | The relay to switch, an instance of Atv.Framework.Devices.Switch.Model.SwitchRelay (its Row and Column |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relay = SwitchRelay()
relay.Row = 2
relay.Column = 5
matrix.open_relay(relay)
method open_relay(relayList: Any)#
Opens several relays with a single channel command, then waits for the configured switching delay. Does nothing for an empty list.
Parameters#
| Name | Description |
|---|---|
| relayList | The relays to switch, a Python list of Atv.Framework.Devices.Switch.Model.SwitchRelay objects. |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relays = []
for column in (1, 2):
relay = SwitchRelay()
relay.Row = 1
relay.Column = column
relays.append(relay)
matrix.open_relay(relays)
method request_stop()#
Asks a running Lua script to stop by writing a stop flag to the device. The stop is cooperative: the script has to check the flag.
Example#
matrix = measmatic.get_device('device-switch')
matrix.request_stop()
method run_script(scriptName: str)#
Runs a Lua script that was loaded into the device before.
Parameters#
| Name | Description |
|---|---|
| scriptName | The name of the script in the device. |
Example#
matrix = measmatic.get_device('device-switch')
matrix.run_script('myscript')
method scan_tsp_bus()#
Scans the TSP link for devices and returns the numbers of all nodes found (1 to 64).
Returns#
| Type | Description |
|---|---|
| Any | The node numbers found, an iterable of integers. |
Example#
matrix = measmatic.get_device('device-switch')
nodes = list(matrix.scan_tsp_bus())
method switch_relay(relay: Any)#
Switches a relay according to its desired state: opens it if DesiredState is Open, closes it if DesiredState is Closed, and does nothing otherwise.
Parameters#
| Name | Description |
|---|---|
| relay | The relay to switch, an instance of Atv.Framework.Devices.Switch.Model.SwitchRelay. Its Row and Column |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relay = SwitchRelay()
relay.Row = 2
relay.Column = 5
relay.DesiredState = RelayState.Closed # Atv.Framework.Devices.Switch.Enumeration.RelayState
matrix.switch_relay(relay)
method switch_relay(relayList: Any, switchingOrder: Any = ...)#
Switches several relays according to their desired states. Relays with DesiredState Open are opened and relays with DesiredState Closed are closed, in the given order. Does nothing for an empty list.
Parameters#
| Name | Description |
|---|---|
| relayList | The relays to switch, a Python list of Atv.Framework.Devices.Switch.Model.SwitchRelay objects. |
| switchingOrder | Order in which relays are switched if the list contains relays to open and to close, a Default: ... |
Example#
from Atv.Framework.Devices.Switch.Model import SwitchRelay
matrix = measmatic.get_device('device-switch')
relays = []
for column in (1, 2):
relay = SwitchRelay()
relay.Row = 1
relay.Column = column
relay.DesiredState = RelayState.Closed # Atv.Framework.Devices.Switch.Enumeration.RelayState
relays.append(relay)
matrix.switch_relay(relays)
method to_log_string()#
Returns a string with information about the device (name, model, TSP node and serial number) for logging.
Returns#
| Type | Description |
|---|---|
| str | The descriptive string. |
Example#
matrix = measmatic.get_device('device-switch')
text = matrix.to_log_string()