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
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
@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
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
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