MSL-Equipment

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 msl.equipment 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')
3.3

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

>>> for record in db.records():
...    print(record)
...
EquipmentRecord<Fluke|8506A|cecf2e0a>
EquipmentRecord<Oriel|66087|169b71e9>
EquipmentRecord<Kepco|JQE|baee83d4>
EquipmentRecord<Hewlett Packard|34401A|15ab8c6c>
EquipmentRecord<Arlunya|Milli Gauss|890a4c02>
EquipmentRecord<Toledo|1000|444213b7>
EquipmentRecord<Stanford Research Systems|SR850 DSP|cec817f5>
EquipmentRecord<HP|3478A|bd92c887>

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>
EquipmentRecord<HP|3478A|bd92c887>

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

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

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)
...
ConnectionRecord<HP|3478A|bd92c887>

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

>>> record = db.equipment['dmm']
>>> print(record)
EquipmentRecord<Hewlett Packard|34401A|15ab8c6c>
>>> record.is_calibration_due()
False
>>> 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'

Contents

Index