Struct ActuateSimulator

Source
pub struct ActuateSimulator<'a> {
    config: ActuateControllinoConfig,
    actuate_simulator_channels: &'a mut ActuateSimulatorChannels,
}
Expand description

Contains trait implementation for system testing purposes.

Fields§

§config: ActuateControllinoConfig§actuate_simulator_channels: &'a mut ActuateSimulatorChannels

Implementations§

Source§

impl<'a> ActuateSimulator<'a>

Source

pub fn new( actuate_simulator_channels: &'a mut ActuateSimulatorChannels, config: ActuateControllinoConfig, ) -> Self

Creates a new ActuateSimulator instance.

This constructor initializes the simulator with an optional sender channel for TCP communication and the Controllino-specific configuration. It’s used to set up the mock actuation logic for testing purposes.

§Arguments
  • actuate_simulator_channels - A mutable reference to the struct containing the channel.
  • config - The ActuateControllinoConfig struct, providing device-to-relay mappings and other configuration relevant when simulating Controllino behavior.
§Returns

A new ActuateSimulator struct.

Trait Implementations§

Source§

impl<'a> RelayActuationTrait for ActuateSimulator<'a>

Source§

fn actuate( &mut self, internal_command: &InternalCommand, ) -> Result<(), RelayError>

Simulates relay actuation by sending a command over a channel, typically for testing.

This function translates a high-level InternalCommand (like SwitchOn or SwitchOff) into a low-level relay command (e.g., SetRelay) using the same logic as the physical Controllino actuator. The resulting command is then sent over an mpsc channel, presumably to a test harness or a TCP listener that simulates the hardware.

This implementation is intended solely for development and system testing and does not interact with physical hardware.

§Arguments
  • internal_command - The InternalCommand specifying the AquariumDevice and the desired state (SwitchOn or SwitchOff).
§Returns

An empty Result (Ok(())) if the translated command was successfully sent via the channel.

§Errors

This function will return a RelayError if any part of the simulation fails:

  • RelayError::SimulatorNotInitialized: If the simulator was created without a valid sender channel (tx_to_tcp_opt was None).
  • RelayError::IrrelevantCommand: If the provided internal_command is not one that can be translated into a relay action (e.g., RequestSignal).
  • RelayError::PulseNotAllowedForDevice: If a Pulse command is attempted for a device that doesn’t support it (propagated from get_relay_command).
  • RelayError::SimulatorSendFailed: If sending the command over the mpsc channel fails, which typically means the receiver has been dropped.
Source§

fn get_heartbeat_interval_seconds(&self) -> Option<u64>

Returns the heartbeat interval, which is not applicable for the simulator.

The simulator does not require a keep-alive signal, so this implementation always returns None.

§Returns

Always returns None.

Source§

fn heartbeat(&mut self) -> Result<(), RelayError>

Performs a heartbeat action, which is not applicable for the simulator.

This is a no-op for the simulator implementation as there is no persistent communication channel that needs to be kept alive.

§Returns

Always returns Ok(()).

§Errors

This function will never return an error.

Source§

fn flush_buffer(&mut self) -> Result<(), RelayError>

Flushes a communication buffer, which is not applicable for the simulator.

This is a no-op for the simulator implementation as there is no serial communication buffer to flush.

§Returns

Always returns Ok(()).

§Errors

This function will never return an error.

Auto Trait Implementations§

§

impl<'a> Freeze for ActuateSimulator<'a>

§

impl<'a> RefUnwindSafe for ActuateSimulator<'a>

§

impl<'a> Send for ActuateSimulator<'a>

§

impl<'a> Sync for ActuateSimulator<'a>

§

impl<'a> Unpin for ActuateSimulator<'a>

§

impl<'a> !UnwindSafe for ActuateSimulator<'a>

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