Trait MineralInjectionTrait

Source
pub trait MineralInjectionTrait {
    // Required method
    fn inject_mineral(
        &mut self,
        balling_channels: &mut BallingChannels,
        mineral_pump: AquariumDevice,
        dosing_duration_millis: u32,
    ) -> (bool, u32);
}
Expand description

Trait for the execution of the Balling mineral dosing. This trait allows running the main control with a mock implementation for testing.

Required Methods§

Source

fn inject_mineral( &mut self, balling_channels: &mut BallingChannels, mineral_pump: AquariumDevice, dosing_duration_millis: u32, ) -> (bool, u32)

Actuates a specific peristaltic pump to inject a mineral solution into the main tank for a defined duration.

This method controls the selected mineral_pump by sending SwitchOn and SwitchOff commands to the relay manager. It runs the pump for the dosing_duration_millis or until a Quit command is received from the signal handler, allowing for early termination.

§Arguments
  • balling_channels - A mutable reference to the BallingChannels struct.
  • mineral_pump - The AquariumDevice enum variant identifying which peristaltic 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 from the signal handler during injection, indicating that the operation was interrupted. It’s false otherwise.
  • The u32 is the actual duration (in milliseconds) the pump ran before stopping or being interrupted.

Implementors§