msl.equipment.config module

Load an XML Configuration File.

class msl.equipment.config.Config(path)[source]

Bases: object

Load an XML Configuration File.

This function is used to set the configuration constants to use for the Python runtime and it allows you to access EquipmentRecord’s from an Equipment-Register Database and ConnectionRecord’s from a Connections Database.

MSL-Equipment constants that can be defined in a Configuration File:

Name Example Values Description
pyvisa_library @ni, @py, @sim, /path/to/libvisa.so.7 The PyVISA backend library to use.
demo_mode true, false Whether to open connections in demo mode.
path /path/to/SDKs, D:/images A path that contains external resources. Accepts a recursive=”true” attribute. Appends the path(s) to os.environ['PATH'] and to PATH

Also, the user is encouraged to define their own application-specific constants within the configuration file.

Parameters:path (str) – The path to an XML Configuration File.
Raises:IOError – If path does not exist or if the Configuration File is invalid.
DEMO_MODE = False

Whether to open connections in demo mode.

The equipment does not need to be physically connected to a computer.

Type:bool
PATH = []

Paths are also appended to os.environ['PATH'].

Type:list of str
PyVISA_LIBRARY = '@ni'

The PyVISA backend library to use.

Type:str
database()[source]
Returns:Database – A reference to the equipment and connection records in the database(s) that are specified in the configuration file.
find(tag)[source]

Find the first sub-element (from the root()) matching tag in the configuration file.

Parameters:tag (str) – The name of an XML tag in the configuration file.
Returns:Element or None – The first sub-element or None if the tag cannot be found.
findall(tag)[source]

Find all matching sub-elements (from the root()) matching tag in the configuration file.

Parameters:tag (str) – The name of an XML tag in the configuration file.
Returns:list of Element – All matching elements in document order.
path

The path to the configuration file.

Type:str
root

Returns the root element (the first node) of the XML tree.

Returns:Element – The root element.
value(tag, default=None)[source]

Gets the value associated with the specified tag in the configuration file.

Parameters:
  • tag (str) – The name of an XML tag in the configuration file.
  • default (str, optional) – The default value if tag cannot be found.
Returns:

The value associated with tag or default if the tag cannot be found.