The purpose of MSL-Equipment is to manage information about equipment that are required to perform a measurement and to connect to equipment that support computer control. Three items are used to achieve this purpose

  1. Configuration File

  2. Equipment-Register Database

  3. Connections Database

The following example uses a configuration file that specifies an equipment-register database (which contains information about all of the equipment that is available), a connections database (which contains information on how to connect to equipment that support computer control), and specifies a digital multimeter to use for a measurement (which is defined as an <equipment> XML element).

Loading the configuration file using the Config class is the main entry point

>>> from import Config
>>> cfg = Config('config.xml')

and loading the Databases is done via the database() method

>>> db = cfg.database()

You can access XML elements, attributes and values in the configuration file

>>> cfg.find('max_voltage')
<Element 'max_voltage' at ...>
>>> cfg.attrib('max_voltage')
{'unit': 'V'}
>>> cfg.value('max_voltage')

and all of the EquipmentRecord's that are contained within the Equipment-Register Database [1]

>>> for record in db.records():
...    print(record)
EquipmentRecord<Hewlett Packard|34401A|15ab8c6c>
EquipmentRecord<Arlunya|Milli Gauss|890a4c02>
EquipmentRecord<Stanford Research Systems|SR850 DSP|cec817f5>

To select the records that are from Hewlett Packard [1], specify the manufacturer as a search criteria (supports regex, so both HP and Hewlett Packard will match)

>>> for record in db.records(manufacturer='H.*P'):
...    print(record)
EquipmentRecord<Hewlett Packard|34401A|15ab8c6c>

Get the ConnectionRecord's of the equipment that can be computer controlled

>>> for conn in db.connections():
...    print(conn)
ConnectionRecord<Hewlett Packard|34401A|15ab8c6c>
ConnectionRecord<Stanford Research Systems|SR850 DSP|cec817f5>

or filter by the equipment that use GPIB as the communication bus and that are from Hewlett Packard [1]

>>> for conn in db.connections(address='GPIB', manufacturer='H.*P'):
...     print(conn)

Access the EquipmentRecord that has the specified alias dmm in the configuration file

>>> record =['dmm']
>>> print(record)
EquipmentRecord<Hewlett Packard|34401A|15ab8c6c>
>>> record.is_calibration_due()
>>> print(record.connection)
ConnectionRecord<Hewlett Packard|34401A|15ab8c6c>

Establishing a connection to the equipment is achieved by calling the connect() method of an EquipmentRecord. This will return a specific Connection subclass that contains the necessary properties and methods for communicating with the equipment.

>>> dmm = record.connect()
>>> dmm.query('*IDN?')
'Hewlett Packard,34401A,15ab8c6c,A.02.14-02.40-02.14-00.49-03-01\n'