Skip to content

Measurand¤

Measurand dataclass ¤

Measurand(
    quantity: str,
    calibration_interval: float,
    components: tuple[Component, ...] = (),
)

Represents the measurand element in an equipment register.

Parameters:

Name Type Description Default
quantity str

The kind of quantity that is measured.

required
calibration_interval float

The number of years that may pass between a calibration or a performance check. For equipment that do not have a required and periodic interval, but are calibrated on demand, set the value to 0.

required
components tuple[Component, ...]

The components of the equipment that measure the quantity.

()

calibration_interval instance-attribute ¤

calibration_interval: float

The number of years that may pass between a calibration or a performance check.

For equipment that do not have a required and periodic interval, but are calibrated on demand, the value is 0.

components class-attribute instance-attribute ¤

components: tuple[Component, ...] = ()

The components of the equipment that measure the quantity.

quantity instance-attribute ¤

quantity: str

The kind of quantity that is measured.

from_xml classmethod ¤

from_xml(element: Element[str]) -> Measurand

Convert an XML element into a Measurand instance.

Parameters:

Name Type Description Default
element Element[str]

A measurand XML element from an equipment register.

required

Returns:

Type Description
Measurand

The Measurand instance.

Source code in src/msl/equipment/schema.py
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
@classmethod
def from_xml(cls, element: Element[str]) -> Measurand:
    """Convert an XML element into a [Measurand][msl.equipment.schema.Measurand] instance.

    Args:
        element: A [measurand][type_measurand] XML element from an equipment register.

    Returns:
        The [Measurand][msl.equipment.schema.Measurand] instance.
    """
    return cls(
        quantity=element.attrib["quantity"],
        calibration_interval=float(element.attrib["calibrationInterval"]),
        components=tuple(Component.from_xml(c) for c in element),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the Measurand class into an XML element.

Returns:

Type Description
Element[str]

The Measurand as an XML element.

Source code in src/msl/equipment/schema.py
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
def to_xml(self) -> Element[str]:
    """Convert the [Measurand][msl.equipment.schema.Measurand] class into an XML element.

    Returns:
        The [Measurand][msl.equipment.schema.Measurand] as an XML element.
    """
    attrib = {"quantity": self.quantity, "calibrationInterval": str(self.calibration_interval)}
    e = Element("measurand", attrib=attrib)
    e.extend(c.to_xml() for c in self.components)
    return e