pylab_ml.base_instrument.Instrument
- class Instrument(**kwargs)[source]
Bases:
ABC,Ident,mqtt_deviceattributesThis is the abstract Instrument class.
It cannot be used directly but provides a basic set of methods & properties to override with actual instruments
- Initialization arguments of a derived class:
- addrint or str
Interface address, hostname, IP-address, PXI-slot or other address required by interface
- interfaceInterface
GPIB, USBSerial, TCPIP, PXIe, Generic.
- backendstr
Backend could be path to a DLL, custom interface item or for PyVisa backend is either ‘@ivi’ (or ‘@ni’) for NI-Library or ‘@py’ for pure python pyvisa-py backend. On default it uses ‘@ivi’ (or ‘@ni’) on win32 and ‘@py’ on other platforms.
- hostnamestr
Optional interface hostname or IP-address required by interface, when not addr, for TCPIP network instruments
- portint
Optional interface port number, for TCPIP network instruments
- instNamestr
Instrument object name passed as string for later reference in messages to user
- debugbool
Debug information
- Example: Initialization of a derived class
>>> vdd = DerivedInstrument (addr=24) # GPIB or USB address >>> vdd.init() # connect and initialize instrument if this method provided, otherwise implicitly
- init()[source]
Connect and initialize instrument if this method overidden, otherwise implicitly initialize instrument when this method not locally implemented
- setup_inst()[source]
Post init method to override with specific instrument interface initialisation
- inst.write('*RST')
Write directly to instrument, using underlying instruments command language
- ask=inst.query('
READ?’) Write and read the answer, using underlying instruments command language
- Properties:
- id
Abstract get IDN string
- Objects:
- collation
A collate_instrument.CollateInstrument singleton cataloging instruments connected
- budget
A TimeoutBudget singleton to accumulate timeout across all instrument transactions
- com
An instrument resource to generate interface instances, a singleton of LocalInstrument, PXIeInstrument, NetworkInstrument or GenericInstrument
- inst
An instance of instrument interface once a connection session to instrument is successful, i.e. a visa object with write(),read(),query() API
Methods
__init__(**kwargs)close([force])Close connection to instrument.
find_names() returns list of identifiers strings, lhs of = assignments
help()Print the docstring of the instrument class.
identify([showInstName])Identify message.
init([identify])Optional init for interlock startup after identification.
message([message])Message display.
mqtt_add(client, instrument[, liste, qos])Add the instrument to mqtt.
Remove the instrument from mqtt.
publish(topic, value)Publish topic as type='cmd' with payload=value.
publish_get(function_name, value)Publish function_name as type='get' with paylad=value.
publish_set(function_name, value)Publish function_name as type='set' with paylad=value.
reset()Reset and switch beep off.
Setup the instrument settings.
Attributes
commandQuery IDN.
Abstract for static class variable interchoices, to list interfaces statically.
mqtt_enablemqtt_listGetter for the mqtt_status.
- find_names()
find_names() returns list of identifiers strings, lhs of = assignments
- Returns:
obj_names – List of identifier strings
- Return type:
list of str
- abstract property id
Query IDN.
- abstract property interchoices
Abstract for static class variable interchoices, to list interfaces statically.
- json = <module 'json' from '/home/runner/miniconda3/envs/test/lib/python3.9/json/__init__.py'>
- mqtt_add(client, instrument, liste='#', qos=0)
Add the instrument to mqtt. Calling from base_instrument, after the instrument (device) has been create. Normally you have not to use this function, only base_instrument use it.
- Parameters:
client (mqtt_init) – The MQTT client instance to which the instrument should be added.
instrument (object) – The instrument to be added to the MQTT client.
liste (list or str) – A list of attributes for which MQTT messages should be sent. If set to “#”, all attributes will be included (default: “#”).
qos (int) – The Quality of Service level for MQTT messages (default: 0).
- Return type:
None
- mqtt_disconnect()
Remove the instrument from mqtt. Calling from base_instrument, if the instrument are closing. Normally you have not to use this function, only base_instrument use it.
- property mqtt_status
Getter for the mqtt_status.
- publish(topic, value)
Publish topic as type=’cmd’ with payload=value.
- Parameters:
topic (str) – The name of the topic to publish.
value (any) – The value to be published.
- Return type:
None
- publish_get(function_name, value)
Publish function_name as type=’get’ with paylad=value.
- Parameters:
function_name (str) – The name of the function to be published as a ‘get’ command.
value (any) – The value to be published as the payload of the ‘get’ command.
- Return type:
None
- publish_set(function_name, value)
Publish function_name as type=’set’ with paylad=value.
- Parameters:
function_name (str) – The name of the function to be published as a ‘set’ command.
value (any) – The value to be published as the payload of the ‘set’ command.
- Return type:
None