Proxies
- class proxies.HealthStatuses(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Enumerated types representing the health status of the sensor in accordance with the OpenAPI specification detailed in AppMAIS/api/openapi.yaml
- CRITICAL = 2
- NA = -1
- OK = 0
- UNKNOWN = -2
- WARNING = 1
- class proxies.SettingSectionProxy(setting_section_name: str, section_type: ConfigurationSections, beemon_config: Config, logger: Logger | Logger)[source]
- _abc_impl = <_abc._abc_data object>
- _set_global_settings_with_section_overrides() Tuple[timezone, str, str, datetime, datetime, int, int, bool, List[str]] [source]
Retrieves the global settings from the [global] section of the beemon-config.ini file and then overrides any settings that are present in the section that this class is representing.
- Returns:
pytz_time_zone (
datetime.tzinfo
): The timezone to whichcapture_window_start_time
andcapture_window_end_time
should be converted to when populating the recording start time queues.root_upload_dir (str): The absolute path to the upload directory on the specified
'host'
machine in the['ftp']
setting of thebeemon-config.ini
. This parameter is not expected to be overridden on a per-sensor basis.local_output_dir (str): The absolute path to the temporary data storage location on the Raspberry Pi to which data will be written prior to being uploaded to the specified
'host'
. This parameter is not expected to be overridden on a per-sensor basis.capture_window_start_datetime (:class:datetime.datetime`): A
datetime
aware object which specifies what time to start recording data from all sensors. Note that this parameter may be overridden on a per-sensor basis.capture_window_end_datetime (
datetime.datetime
): Adatetime
aware object which specifies what time to start recording data from all sensors. Note that this parameter may be overridden on a per-sensor basis.capture_duration_seconds (int): How long each sensor should be instructed to record for (if applicable) in seconds. Note that this parameter may be overridden on a per-sensor basis.
capture_interval_seconds (int): How long to wait (in seconds) before instructing all sensors to record again for the duration specified by
capture_duration_seconds
. Note that this parameter may be overridden on a per-sensor basis.auto_start (bool): Whether all sensors should be instructed to automatically record at the specified
capture_window_start_time
. If this flag is disabled, then recording commands are expected to be issued manually. Note that this parameter may be overridden on a per-sensor basis.overridden_settings (List[str]): A list of all global settings that are overridden in the specific settings section.
- Return type:
Tuple[
datetime.tzinfo
, str, str,datetime.datetime
,datetime.datetime
, int, int, bool]- Raises:
NotImplementedError – This method will raise a
NotImplementedError
in the event that the specifiedpytz_time_zone
in thebeemon-config.ini
does not yet have a corresponding datetime conversion method indatetimeutils
.
- _update_setting_on_proxy(setting_name: str, value: str | int | float | bool)[source]
Updates a setting on the proxy object, to keep the settings on the object and in the configuration file in sync. If updating the
pytz_time_zone
, then thecapture_window_start_time
andcapture_window_end_time
will be updated to reflect the new timezone as well.
- configuration_values() Dict[str, str] [source]
Retrieves the configuration values for the section. This method retrieves only the values that are present in the configuration file, not including any default values or values that are retrieved from the [global] section of the beemon-config.ini file. Should add any values that are present in the configuration file, as well as unpacking all of
self._overridden_settings
for all settings that override the global values.
- get_settings_section() Dict[str, str | int | float | bool] [source]
Retrieves a particular setting section from the
beemon-config.ini
file.
- property pytz_time_zone: timezone
- abstract settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- update_setting(setting: str, value: str | int | float | bool)[source]
Updates a setting in the beemon-config.ini under a particular section.
- update_settings_section(settings: Dict[str, str | int | float | bool])[source]
Updates multiple settings in the
beemon-config.ini
under a particular section.
- update_settings_section_in_memory(settings: Dict[str, str | int | float | bool])[source]
Updates the settings in memory for a particular section. This method is useful for updating the settings in memory without writing to the configuration file. Be Careful when using this method, as any crash could cause the settings changes to be lost. This should only be used when attempting a bulk write, with the
Config
write method called as soon as all changes are staged.
- class proxies.SensorProxy(setting_section_name: str, section_type: ConfigurationSections, beemon_config: Config, logger: Logger | Logger)[source]
-
- get_all_recording_start_times_within_window(capture_window_start_time: datetime, capture_window_end_time: datetime, capture_duration_seconds: float, capture_interval_seconds: float) List[datetime] [source]
Computes the maximum number of recordings which can occur between the the range of datetime objects (inclusive), given that each recording has the specified interval of:
capture_interval_seconds
. This method then returns a list of datetime objects (non-naive and EDT timezone aware) which constitute the times at which recording should begin in order to successfully record a maximum number of times between the supplied range of times.- Parameters:
capture_window_start_time (datetime) – The starting datetime (non-naive and inclusive) at which the first recording session (of
capture_duration_seconds
length in seconds) is to begin at.capture_window_end_time (datetime) – The ending datetime (non-naive and inclusive) at which the last recording session (of
capture_duration_seconds
length in seconds) is to begin at.capture_duration_seconds (float) – The length/duration that each recording session between
capture_window_start_time
andcapture_window_end_time
should be. This method will produce the times which recording commands should be issued to all registeredSensor
concrete subclass objects.capture_interval_seconds (float) – How frequently to initialize recording sessions. For instance, a value of
120.0
seconds indicates that recording should be performed every two minutes fromcapture_window_start_time
tocapture_window_end_time
(inclusive) for a duration ofcapture_duration_seconds
.
- Returns:
Todo
Docstring.
- Return type:
- get_closest_previous_recording_start_time(a_time: datetime) datetime | None [source]
Returns the closest previous recording start time (inclusive) to the specified time. This can be useful for determining if a sensor should be currently recording.
- get_closest_recording_start_time(a_time: datetime)[source]
Returns the closest recording start time to the current time (inclusive).
- Returns:
The closest recording start time to the current time.
- Return type:
- get_closest_recording_time_with_tolerance(time: datetime, tolerance_seconds: int)[source]
Returns the closest recording time to the specified time within a tolerance of
tolerance_seconds
. This can be useful for determining the closest recording time if the sensor is already recording.Todo
Docstrings.
- get_elapsed_recording_start_times(a_time: datetime, inclusive: bool) List[datetime | None] [source]
Returns all recording start times for the sensor that were to have occurred before the specified time. This method is optionally exclusive, in which case it will not return a recording start time that occurred at the specified time.
- Parameters:
a_time (datetime) – The time to compare against the recording start times (exclusive).
inclusive (bool) – If True, the recording start time that occurred at the specified time will be included in the returned list. If False, the recording start time that occurred at the specified time will not be included in the returned list.
- Returns:
A list of recording start times that have occurred before the provided time. The returned list will be empty if there are no recording start times that have occurred before the provided time.
- Return type:
List[Optional[datetime]]
- get_health_status() HealthStatuses [source]
Returns the health status of the sensor by reading the CSV in the output directory of the sensor. The health status of the sensor is defined in the OpenAPI specification detailed in AppMAIS/api/openapi.yaml.
- Returns:
The health status of the sensor.
- Return type:
- get_last_n_successful_recording_values(num_recording_values: int, sensor_data_dict: Dict[str, float | Dict[str, float]] | None = None) List[float | Dict[str, float]] [source]
Retrieves the last
num_recording_values
successful recording values from the sensor’s CSV file.- Parameters:
num_recording_values (int) – The number of recording values to retrieve from the sensor’s CSV file.
sensor_data_dict (Optional[Dict[str, Union[float, Dict[str, float]]]]) – The dictionary of the sensor’s CSV file data. If
None
, then the CSV file will be read. Provided as an argument such that this method can be called multiple times without having to re-read the CSV file.
- Returns:
Ordered list of last
num_recording_values
recordings. This is based on the number of anticipated recordings, so any missed or non-existent recordings will mean less thannum_recording_values
values will be returned. Ordered by most recent first.- Return type:
- get_number_of_successful_recordings_on_date(date: ~.datetime.date) int [source]
Retrieves the number of successful (non None) recordings present in the sensor’s CSV file for the specified date.
- abstract read_csv(date: ~.datetime.date) Dict[str, Any] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- class proxies.GlobalProxy(beemon_config: Config, logger: Logger | Logger)[source]
- settings() Dict[str, str | int | float | bool] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.SFTPProxy(beemon_config: Config, logger: Logger | Logger)[source]
-
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.DashboardProxy(beemon_config: Config, logger: Logger | Logger)[source]
-
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.LogProxy(beemon_config: Config, logger: Logger | Logger)[source]
-
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.AudioProxy(beemon_config: Config, logger: Logger | Logger)[source]
-
- read_csv(date: ~.datetime.date) Dict[str, bool | None] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, int | bool] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.VideoProxy(beemon_config: Config, logger: Logger | Logger)[source]
-
- read_csv(date: ~.datetime.date) Dict[str, float | None] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, int | bool] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.AirQualityProxy(beemon_config: Config, logger: Logger | Logger)[source]
- read_csv(date: ~.datetime.date) Dict[str, Any] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.TempProxy(beemon_config: Config, logger: Logger | Logger)[source]
- read_csv(date: ~.datetime.date) Dict[str, Dict[str, float | None]] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.ScaleProxy(beemon_config: Config, logger: Logger | Logger)[source]
- read_csv(date: ~.datetime.date) Dict[str, float | None] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, float] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]
- class proxies.CPUProxy(beemon_config: Config, logger: Logger | Logger)[source]
- read_csv(date: ~.datetime.date) Dict[str, float | None] | None [source]
Reads the CSV file for the sensor on the specified date and returns the rows of the CSV in a dictionary, indexed by the recording time.
- settings() Dict[str, Any] [source]
Retrieves the settings for the section. This method retrieves all the settings for the section, including any default values or values that are retrieved from the [global] section of the beemon-config.ini file.
- Returns:
The key-value pairs of ‘setting_name’: ‘setting_value’.
- Return type:
Dict[str, any]