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 andConnectionRecord
’s from a Connections Database.The following table summarizes the XML elements that are used by MSL-Equipment and can be defined in a Configuration File:
XML Tag
Example Values
Description
pyvisa_library
@ivi, @py, @sim, /path/to/libvisa.so.7
The PyVISA library to use.
demo_mode
true, false, 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. The path(s) are appended to
os.environ['PATH']
and toPATH
The user is also encouraged to define their own application-specific elements within the Configuration File.
- Parameters:
path (
str
) – The path to an XML Configuration File.- Raises:
OSError – If path does not exist or if the Configuration File is invalid.
- DEMO_MODE = False
Whether to open connections in demo mode.
If enabled then the equipment does not need to be physically connected to a computer and the connection is simulated.
- Type:
- PATH = []
Paths are also appended to
os.environ['PATH']
.
- property root
Returns the root element (the first node) of the XML tree.
- Returns:
Element
– The root element.
- database()[source]
- Returns:
Database
– A reference to the equipment and connection records in the database(s) that are specified in the configuration file.
- value(tag, default=None)[source]
Gets the value associated with the specified tag in the configuration file.
The first element with name tag (relative to the
root
) is used.The value is converted to the appropriate data type if possible. Otherwise, the value will be returned as a
str
.- Parameters:
tag (
str
) – The name of an XML tag in the configuration file.default – The default value if tag cannot be found.
- Returns:
The value associated with tag or default if the tag cannot be found.
- find(tag)[source]
Find the first sub-element (from the
root
) matching tag in the configuration file.
- findall(tag)[source]
Find all matching sub-elements (from the
root
) matching tag in the configuration file.