pub struct MineralInjection;Expand description
Struct implements the MineralInjectionTrait for executing the Balling mineral dosing. It also contains state attributes for the actuators. Thread communication is as follows:
Implementations§
Source§impl MineralInjection
impl MineralInjection
Sourcepub fn new() -> MineralInjection
pub fn new() -> MineralInjection
Provide a struct of type MineralInjection
Sourcefn send_and_confirm(
&self,
balling_channels: &mut BallingChannels,
command: InternalCommand,
action_description: &str,
)
fn send_and_confirm( &self, balling_channels: &mut BallingChannels, command: InternalCommand, action_description: &str, )
Sends a command to the relay manager and handles the response. Logs an error if either the send or receive operation fails.
Trait Implementations§
Source§impl MineralInjectionTrait for MineralInjection
impl MineralInjectionTrait for MineralInjection
Source§fn inject_mineral(
&mut self,
balling_channels: &mut BallingChannels,
mineral_pump: AquariumDevice,
dosing_duration_millis: u32,
) -> (bool, u32)
fn inject_mineral( &mut self, balling_channels: &mut BallingChannels, mineral_pump: AquariumDevice, dosing_duration_millis: u32, ) -> (bool, u32)
Switches on one of the peristaltic pumps for a defined period, or until a Quit command is received.
This implementation for inject_mineral controls the specified mineral_pump.
It sends a SwitchOn command to the relay manager, then enters a loop
to keep the pump active for dosing_duration_millis. During this period,
it continuously checks for a Quit command from the signal handler,
allowing for immediate termination. Once the duration is met or a Quit
command is received, it sends a SwitchOff command to the pump.
§Arguments
balling_channels- A mutable reference to theBallingChannelsstruct.mineral_pump- TheAquariumDevicevariant identifying which pump to actuate.dosing_duration_millis- The target duration (in milliseconds) for which the pump should run.
§Returns
A tuple (bool, u32):
- The
boolistrueif aQuitcommand was received during injection; otherwisefalse. - The
u32is the actual duration (in milliseconds) the pump ran before stopping or being interrupted.
Source§impl ProcessExternalRequestTrait for MineralInjection
impl ProcessExternalRequestTrait for MineralInjection
Source§fn process_external_request(
&mut self,
rx_from_signal_handler: &mut AquaReceiver<InternalCommand>,
_: Option<&mut AquaReceiver<InternalCommand>>,
) -> (bool, bool, bool)
fn process_external_request( &mut self, rx_from_signal_handler: &mut AquaReceiver<InternalCommand>, _: Option<&mut AquaReceiver<InternalCommand>>, ) -> (bool, bool, bool)
Checks for and processes new commands relevant to the Mineral Injection module from external channels.
This is the specialized implementation of ProcessExternalRequestTrait for MineralInjection.
It delegates directly to process_external_request_without_messaging, indicating
that the MineralInjection module only processes commands from the signal handler
and ignores any input from a messaging channel.
§Arguments
rx_from_signal_handler- A reference to the receiver end of the channel for commands originating from the signal handler._- This parameter is ignored, as theMineralInjectionmodule does not process messages from a messaging channel.
§Returns
A tuple (bool, bool, bool) indicating the status of commands received:
- The first
boolistrueif aQuitcommand was received; otherwisefalse. - The second
boolis alwaysfalse(no “Start” commands processed). - The third
boolis alwaysfalse(no “Stop” commands processed).