Skip to content

sensor_reading

frog.sensor_reading ¤

Provides a class for representing physical quantities monitored by sensors.

Classes¤

SensorReading(name, value, unit) dataclass ¤

Class for representing physical quantities monitored by sensors.

Parameters:

Name Type Description Default
name str

human-readable name of the physical quantity

required
value Decimal | float

value of the physical quantity

required
unit str

unit in which the value is presented

required
Functions¤
__str__() ¤

Print a property's name, value and unit in a readable format.

Returns:

Name Type Description
str str

The name, value and unit of a property.

Source code in frog/sensor_reading.py
21
22
23
24
25
26
27
def __str__(self) -> str:
    """Print a property's name, value and unit in a readable format.

    Returns:
        str: The name, value and unit of a property.
    """
    return f"{self.name} = {self.value:.6f} {self.unit}"
val_str() ¤

Print a property's value and unit in required format.

Returns:

Name Type Description
str str

The value and unit of a property

Source code in frog/sensor_reading.py
29
30
31
32
33
34
35
def val_str(self) -> str:
    """Print a property's value and unit in required format.

    Returns:
        str: The value and unit of a property
    """
    return f"{self.value:.6f} {self.unit}"