Expand description
Function blocks for control programs (IEC 61131-3 inspired).
§Function Blocks
Reusable function blocks for control program development, inspired by the
IEC 61131-3 standard. Each block is a stateful struct that you call
cyclically (once per scan) from your ControlProgram::process_tick
implementation.
§Available Blocks
| Block | Description |
|---|---|
RTrig | Rising edge detector (false → true) |
FTrig | Falling edge detector (true → false) |
Ton | Timer On Delay — output activates after a duration |
SimpleTimer | One-shot timer for imperative start/check patterns |
StateMachine | State machine helper with automatic timer management |
BitResetOnDelay | Resets a boolean after it has been true for a duration |
RunningAverage | Accumulates values and computes their arithmetic mean |
Beeper | Audible beeper controller with configurable beep sequences |
Heartbeat | Monitors a remote heartbeat counter for connection loss |
Shutdown | Non-blocking system shutdown initiation and cancellation via IPC |
§Usage Pattern
All function blocks follow the same pattern:
- Create the block once (typically in your program struct)
- Call it every scan cycle with the current inputs
- Read its outputs to drive your logic
ⓘ
use autocore_std::fb::{RTrig, Ton};
use std::time::Duration;
struct MyProgram {
start_trigger: RTrig,
start_delay: Ton,
}
impl MyProgram {
fn new() -> Self {
Self {
start_trigger: RTrig::new(),
start_delay: Ton::new(),
}
}
}§IEC 61131-3 Naming
| IEC 61131-3 Name | Rust Name |
|---|---|
R_TRIG | RTrig |
F_TRIG | FTrig |
TON | Ton |
FB_StateMachine | StateMachine |
FB_BitResetOnDelay | BitResetOnDelay |
FB_RunningAverage | RunningAverage |
FB_Beeper | Beeper |
FB_Heartbeat | Heartbeat |
FB_Shutdown | Shutdown |
Structs§
- Beeper
- Audible Beeper Controller (FB_Beeper)
- BitReset
OnDelay - Resets a boolean value after it has been true for a specified duration.
- FTrig
- Falling Edge Trigger (F_TRIG)
- Heartbeat
- Heartbeat Monitor (FB_Heartbeat)
- RTrig
- Rising Edge Trigger (R_TRIG)
- Running
Average - Running Average (FB_RunningAverage)
- Shutdown
- Simple
Timer - Simple One-Shot Timer
- State
Machine - State Machine Helper (FB_StateMachine)
- Ton
- Timer On Delay (TON)
Traits§
- Averageable
- Trait for types that can be used with
RunningAverage.