Struct Monitors

Source
pub struct Monitors {
    config: MonitorsConfig,
    lock_info_monitors_inhibited: bool,
    lock_error_receive_refill: bool,
    refill_monitor_views: Vec<RefillMonitorView>,
}
Expand description

Contains the configuration and the implementation for the monitors. Thread communication of this component is as follows:

graph LR monitors[Monitors] --> relay_manager[Relay Manager] relay_manager --> monitors monitors --> signal_handler[Signal handler] signal_handler --> monitors messaging[Messaging] --> monitors

Fields§

§config: MonitorsConfig

configuration data for monitors

§lock_info_monitors_inhibited: bool

inhibition flag to avoid flooding the log file with repeated messages about monitors being inhibited

§lock_error_receive_refill: bool

inhibition flag to avoid flooding the log file with repeated messages about failure to receive from refill

§refill_monitor_views: Vec<RefillMonitorView>

storage of refill monitor views

Implementations§

Source§

impl Monitors

Source

pub fn new(config: MonitorsConfig) -> Monitors

Creates a new Monitors instance.

This constructor initializes the monitoring module with its specified configuration. It sets up internal “lock” flags to false by default; these flags are used to prevent repetitive error and warning messages from flooding the log during operation.

§Arguments
  • config - Configuration data for the monitors, loaded from a TOML file. This includes parameters such as whether the monitors are active.
§Returns

A new Monitors struct, ready to perform its monitoring tasks.

Source

pub fn append_refill_monitor_view( &mut self, refill_monitor_view: RefillMonitorView, )

Manages a vector of RefillMonitorView structs, ensuring it does not exceed a specified maximum length.

If the vector has reached its maximum capacity, the oldest element (at index 0) is removed before the new refill_monitor_view is appended. Otherwise, the new refill_monitor_view is simply appended.

§Arguments
  • refill_monitor_view - The new RefillMonitorView struct to be added to the vector.
Source

pub fn execute( &mut self, _mutex_device_scheduler_monitors: Arc<Mutex<i32>>, monitors_channels: &mut MonitorsChannels, )

Executes the main control loop for the monitor module.

This function runs continuously, performing periodic monitoring tasks when active. It responds to external Start and Stop commands to enable or inhibit monitoring activities. The loop also continuously checks for Quit and Terminate commands from the signal handler to ensure a graceful application shutdown.

Monitoring activities (represented by debug logs) are performed at a rate of approximately every 10 seconds, controlled by the loop_counter and sleep_duration.

§Arguments
  • _mutex_device_scheduler_monitors - (Ignored) A clone of a mutex for device scheduling. This argument is part of a common signature but is not used by this module’s logic.
  • monitors_channels - A mutable reference to the struct containing the channels.

Trait Implementations§

Source§

impl ProcessExternalRequestTrait for Monitors

Source§

fn process_external_request( &mut self, rx_from_signal_handler: &mut AquaReceiver<InternalCommand>, rx_from_messaging_opt: Option<&mut AquaReceiver<InternalCommand>>, ) -> (bool, bool, bool)

Checks for and processes new commands received from the signal handler and an optional messaging channel. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T