Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 1.35 KB

sensor.md

File metadata and controls

76 lines (47 loc) · 1.35 KB

sensor

This module provides the Sensor interface class.

Sensor Objects

class Sensor()

This class is the interface a Sensor should implement.

read

@abstractmethod
def read(**kwargs: dict) -> dict

Return a sensor record.

units

@abstractmethod
def units(**kwargs: dict) -> dict

Return the sensor unit mapping

SensorReader Objects

class SensorReader(Sensor)

This class is sensor wrapper with error management.

It discharges the caller from having to handle various exceptions. On a sensor read() failure, the wrapper returns None. The caller can use the time_elapsed_since_latest_record() method to know the time elapsed since it successfully retrieved a record.

read

def read(**kwargs) -> dict

Read a sensor record.

It returns an empty dictionary if the sensor read() method raises an Pyro5.errors.CommunicationError or RuntimeError exception.

time_elapsed_since_latest_record

def time_elapsed_since_latest_record() -> timedelta

Time elapsed since read() successfully retrieved a record.