Datapoint
Data structures for sensor measurements and actuation events.
This module defines the datapoint classes used throughout the system to represent sensor readings and watering events. All data flowing to the database passes through these structures.
Confidence
dataclass
¶
Statistical confidence specification for a measurement.
Attributes:
| Name | Type | Description |
|---|---|---|
interval |
float
|
The uncertainty interval (e.g. 0.2 for ± 0.2). |
level |
float
|
The confidence level as a fraction (e.g. 0.95 for 95%). |
Source code in pt/controller_3/src/plant_controller/datapoint.py
str_representation()
¶
Datapoint
¶
Bases: ABC
Abstract base class for all data that gets written to the database.
Subclasses must implement to_point to produce a dict compatible
with the InfluxDB line protocol structure used by DatabaseClient.
Source code in pt/controller_3/src/plant_controller/datapoint.py
to_point(unit)
abstractmethod
¶
Convert this datapoint to an InfluxDB-compatible dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str
|
Name of the physical unit this data belongs to. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with 'measurement', 'tags', 'fields', and 'time' keys. |
Source code in pt/controller_3/src/plant_controller/datapoint.py
format_for_table_name(physical_unit, parameter)
staticmethod
¶
Generate the database table (measurement) name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
physical_unit
|
str
|
Name of the unit (e.g. 'basil_1'). |
required |
parameter
|
str
|
Name of the parameter (e.g. 'temperature'). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Lowercase string in the form ' |
Source code in pt/controller_3/src/plant_controller/datapoint.py
Measurement
¶
Bases: Datapoint
A single sensor measurement datapoint.
Attributes:
| Name | Type | Description |
|---|---|---|
parameter |
Name of the measured parameter. |
|
value |
The measured value. |
|
units |
Unit string (e.g. '°C', '%', 'photons/s'). |
|
confidence |
Optional uncertainty specification. |
|
time |
Timestamp of the measurement (defaults to now). |
Source code in pt/controller_3/src/plant_controller/datapoint.py
to_point(unit)
¶
Convert to InfluxDB point dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str
|
Name of the physical unit this measurement belongs to. |
required |
Source code in pt/controller_3/src/plant_controller/datapoint.py
WateringEvent
¶
Bases: Datapoint
A record of a watering actuation event.
Attributes:
| Name | Type | Description |
|---|---|---|
dosage |
Amount of water pumped in milliliters. |
|
time |
Timestamp of the event (defaults to now). |
Source code in pt/controller_3/src/plant_controller/datapoint.py
to_point(unit)
¶
Convert to InfluxDB point dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str
|
Name of the physical unit this event belongs to. |
required |