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:
Fields§
§config: MonitorsConfigconfiguration data for monitors
lock_info_monitors_inhibited: boolinhibition flag to avoid flooding the log file with repeated messages about monitors being inhibited
lock_error_receive_refill: boolinhibition 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
impl Monitors
Sourcepub fn new(config: MonitorsConfig) -> Monitors
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 areactive.
§Returns
A new Monitors struct, ready to perform its monitoring tasks.
Sourcepub fn append_refill_monitor_view(
&mut self,
refill_monitor_view: RefillMonitorView,
)
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 newRefillMonitorViewstruct to be added to the vector.
Sourcepub fn execute(
&mut self,
_mutex_device_scheduler_monitors: Arc<Mutex<i32>>,
monitors_channels: &mut MonitorsChannels,
)
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.