Sensor Reference
Source code reference for the collector sensor code.
collector.src.sensors.manager.SensorManager
Initializes and orchestrates the configured sensor drivers.
Attributes:
| Name | Type | Description |
|---|---|---|
collector_id |
str
|
The configured collector ID. |
drivers |
list[AbstractSensorDriver]
|
The driver instances, or an empty list if they have yet to be initialized. |
Source code in collector/src/sensors/manager.py
__init__(config_manager)
Initializes all SensorDrivers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ConfigManager
|
ConfigManager instance used to retrieve the sensor configs. |
required |
Source code in collector/src/sensors/manager.py
poll()
Polls all sensors.
If the sensor returns data, uses it to construct a CollectorRecord.
If the sensor raises an exception, uses it to construct a CollectorError.
Returns:
| Type | Description |
|---|---|
tuple[list[CollectorRecord], list[CollectorError]]
|
All recorded sensor data and caught sensor exceptions. |
Source code in collector/src/sensors/manager.py
collector.src.sensors.driver.AbstractSensorDriver
Bases: Protocol
An interface used to describe a type of sensor.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
SensorConfig
|
The parsed config object for this sensor. |
Source code in collector/src/sensors/driver.py
__init__(config)
Initialize the sensor driver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
SensorConfig
|
The parsed config object for this sensor. |
required |
poll()
Utilizes the underlying device driver to collect sensor data.
Returns:
| Type | Description |
|---|---|
SensorData
|
The data returned by the sensor. |
Raises:
| Type | Description |
|---|---|
Exception
|
Raised if the sensor fails to return data. |