pub struct ReflexRule {
pub sensor_id: String,
pub actuator_id: String,
pub actuator_kind: ActuatorKind,
pub threshold: f64,
pub command_value: f64,
pub trigger_above: bool,
pub cooldown_secs: f64,
}Expand description
A simple reflex loop that polls sensors and triggers actuator commands when sensor values cross thresholds.
Inspired by the biological reflex arc: sensor → spinal cord → actuator, bypassing the cognitive layer for time-critical responses.
Fields§
§sensor_id: StringSensor ID to monitor.
actuator_id: StringActuator ID to trigger.
actuator_kind: ActuatorKindActuator kind for the command.
threshold: f64Threshold value. If the sensor reading exceeds this, trigger.
command_value: f64Command value to send when triggered.
trigger_above: boolWhether the trigger is value > threshold (true) or value < threshold (false).
cooldown_secs: f64Minimum interval between triggers (cooldown), in seconds.
Implementations§
Source§impl ReflexRule
impl ReflexRule
Sourcepub fn above(
sensor_id: impl Into<String>,
actuator_id: impl Into<String>,
actuator_kind: ActuatorKind,
threshold: f64,
command_value: f64,
cooldown_secs: f64,
) -> Self
pub fn above( sensor_id: impl Into<String>, actuator_id: impl Into<String>, actuator_kind: ActuatorKind, threshold: f64, command_value: f64, cooldown_secs: f64, ) -> Self
Create a new reflex rule that triggers when sensor exceeds threshold.
Sourcepub fn below(
sensor_id: impl Into<String>,
actuator_id: impl Into<String>,
actuator_kind: ActuatorKind,
threshold: f64,
command_value: f64,
cooldown_secs: f64,
) -> Self
pub fn below( sensor_id: impl Into<String>, actuator_id: impl Into<String>, actuator_kind: ActuatorKind, threshold: f64, command_value: f64, cooldown_secs: f64, ) -> Self
Create a new reflex rule that triggers when sensor drops below threshold.
Sourcepub fn is_triggered(&self, reading: &SensorReading) -> bool
pub fn is_triggered(&self, reading: &SensorReading) -> bool
Check if a sensor reading triggers this rule.
Trait Implementations§
Source§impl Clone for ReflexRule
impl Clone for ReflexRule
Source§impl Debug for ReflexRule
impl Debug for ReflexRule
Source§impl<'de> Deserialize<'de> for ReflexRule
impl<'de> Deserialize<'de> for ReflexRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ReflexRule
impl RefUnwindSafe for ReflexRule
impl Send for ReflexRule
impl Sync for ReflexRule
impl Unpin for ReflexRule
impl UnsafeUnpin for ReflexRule
impl UnwindSafe for ReflexRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more