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:
- addr (int | str):
interface address, hostname, ip-address, pxi-slot or other address required by interface
- interface (Interface):
gpib, usbserial, tcpip, pxie, generic.
- backend (str):
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.
- hostname (str):
optional interface hostname or ip-address required by interface, when not addr, for tcpip network instruments
- port (int):
optional interface port number, for tcpip network instruments
- instName (str):
Instrument object name passed as string for later reference in messages to user
- debug (bool):
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()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 paylad=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
- 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.
- Returns:
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.
- Returns:
None.
- property mqtt_status
Getter for the mqtt_status.
- publish(topic, value)
Publish topic as type=’cmd’ with paylad=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.