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 ActuateSimulatorChannelsImplementations§
Source§impl<'a> ActuateSimulator<'a>
impl<'a> ActuateSimulator<'a>
Sourcepub fn new(
actuate_simulator_channels: &'a mut ActuateSimulatorChannels,
config: ActuateControllinoConfig,
) -> Self
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- TheActuateControllinoConfigstruct, 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>
impl<'a> RelayActuationTrait for ActuateSimulator<'a>
Source§fn actuate(
&mut self,
internal_command: &InternalCommand,
) -> Result<(), RelayError>
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- TheInternalCommandspecifying theAquariumDeviceand the desired state (SwitchOnorSwitchOff).
§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_optwasNone).RelayError::IrrelevantCommand: If the providedinternal_commandis not one that can be translated into a relay action (e.g.,RequestSignal).RelayError::PulseNotAllowedForDevice: If aPulsecommand is attempted for a device that doesn’t support it (propagated fromget_relay_command).RelayError::SimulatorSendFailed: If sending the command over thempscchannel fails, which typically means the receiver has been dropped.
Source§fn get_heartbeat_interval_seconds(&self) -> Option<u64>
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.