msl.equipment.config module
Load an XML Configuration File.
- msl.equipment.config.XMLType
An XML-document type that can be parsed.
- class msl.equipment.config.Config(source: str | bytes | PathLike | BinaryIO | TextIO)[source]
Bases:
object
Load an XML Configuration File.
The purpose of the Configuration File is to define parameters that may be required during data acquisition and 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 which may be defined in a Configuration File:
XML Tag
Example Values
Description
demo_mode
true, false, True, False
Whether to open connections in demo mode. The value will set
DEMO_MODE
.gpib_library
/opt/gpib/libgpib.so.0
The path to a GPIB library file. Required only if you want to use a specific file. The value will set
GPIB_LIBRARY
.path
C:\Program Files\Company
A path that contains additional resources. Accepts a recursive=”true” attribute. The path(s) are appended to
PATH
and toos.environ['PATH']
. A <path> element may be specified multiple times.pyvisa_library
@ivi, @py, /opt/ni/libvisa.so.7
The PyVISA library to use. The value will set
PyVISA_LIBRARY
.You are also encouraged to define your own application-specific elements within your Configuration File.
- Parameters:
source – A filename or file object containing XML data.
- GPIB_LIBRARY: str = ''
The path to a GPIB library file.
Setting this attribute is necessary only if you want to communicate with a GPIB device and the file is not automatically found or you want to use a different file than the default file.
- DEMO_MODE: bool = 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.
- PATH: list[str] = []
Paths are also appended to
os.environ['PATH']
.
- attrib(tag_or_path: str) dict[str, Any] [source]
Get the attributes of the first matching element by tag name or path.
The values are converted to the appropriate data type if possible. For example, if the text of the element is
true
it will be converted toTrue
, otherwise the value will be kept as astr
.- Parameters:
tag_or_path – Either an element tag name or an XPath.
- Returns:
The attributes of the matching element.
- database() Database [source]
A reference to the equipment and connection records in the database(s).
- find(tag_or_path: str) Element | None [source]
Find the first matching element by tag name or path.
- Parameters:
tag_or_path – Either an element tag name or an XPath.
- Returns:
The element or
None
if no element was found.
- findall(tag_or_path: str) list[Element] [source]
Find all matching sub-elements by tag name or path.
- Parameters:
tag_or_path – Either an element tag name or an XPath.
- Returns:
All matching elements in document order.
- value(tag_or_path: str, default: Any = None) Any [source]
Gets the value (text) associated with the first matching element.
The value is converted to the appropriate data type if possible. For example, if the text of the element is
true
it will be converted toTrue
.- Parameters:
tag_or_path – Either an element tag name or an XPath.
default – The default value if an element cannot be found.
- Returns:
The value of the element or default if no element was found.