Config¤
A configuration file is useful when you want to perform a measurement.
Config
¤
Config(source: XMLSource)
Load a configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
XMLSource
|
required |
Source code in src/msl/equipment/config.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
equipment
property
¤
equipment: ConfigEquipment
Returns the <equipment/> elements in the configuration file like a sequence of Equipment items.
Using the returned object you can access Equipment items by index (based on the order that
<equipment/> elements are defined in the configuration file), by the eid attribute value or
by the name attribute value. You can also iterate over the Equipment items in the sequence.
See here for examples.
registers
property
¤
attrib
¤
Get the attributes of the first matching element by tag name or path.
If possible, the value is converted to a bool (true or false case-insensitive),
an int or a float, otherwise the value remains a str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Either an element tag name or an XPath. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, bool | float | str]
|
The attributes of the matching |
Source code in src/msl/equipment/config.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
find
¤
Find the first matching element by tag name or path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Either an element tag name or an XPath. |
required |
Returns:
| Type | Description |
|---|---|
Element[str] | None
|
The element or |
Source code in src/msl/equipment/config.py
134 135 136 137 138 139 140 141 142 143 | |
findall
¤
Find all matching sub-elements by tag name or path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Either an element tag name or an XPath. |
required |
Returns:
| Type | Description |
|---|---|
list[Element[str]]
|
All matching elements in document order. |
Source code in src/msl/equipment/config.py
145 146 147 148 149 150 151 152 153 154 | |
value
¤
Gets the value (text) associated with the first matching element.
If possible, the value is converted to a bool (true or false case-insensitive),
an int or a float, otherwise the value remains a str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Either an element tag name or an XPath. |
required |
default
|
bool | float | str | None
|
The default value if an element cannot be found. |
None
|
Returns:
| Type | Description |
|---|---|
bool | float | str | None
|
The value of the element or |
Source code in src/msl/equipment/config.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
ConfigEquipment
¤
ConfigEquipment(cfg: Config)
Access <equipment/> elements in a configuration file like a sequence of Equipment items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
Config
|
The configuration instance. |
required |
Source code in src/msl/equipment/config.py
227 228 229 230 231 232 233 234 235 236 237 238 239 | |