Struct MineralInjection

Source
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:

graph LR mineral_injection[Mineral injection] --> relay_manager[Relay Manager] relay_manager --> mineral_injection signal_handler[Signal handler] --> mineral_injection

Implementations§

Source§

impl MineralInjection

Source

pub fn new() -> MineralInjection

Provide a struct of type MineralInjection

Source

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

Source§

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 the BallingChannels struct.
  • mineral_pump - The AquariumDevice variant 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 bool is true if a Quit command was received during injection; otherwise false.
  • The u32 is the actual duration (in milliseconds) the pump ran before stopping or being interrupted.
Source§

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)

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 the MineralInjection module does not process messages from a messaging channel.
§Returns

A tuple (bool, bool, bool) indicating the status of commands received:

  • The first bool is true if a Quit command was received; otherwise false.
  • The second bool is always false (no “Start” commands processed).
  • The third bool is always false (no “Stop” commands processed).

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