Skip to main content

autocore_std/fb/
mod.rs

1//! # Function Blocks
2//!
3//! Reusable function blocks for control program development, inspired by the
4//! IEC 61131-3 standard. Each block is a stateful struct that you call
5//! cyclically (once per scan) from your [`ControlProgram::process_tick`](crate::ControlProgram::process_tick)
6//! implementation.
7//!
8//! ## Available Blocks
9//!
10//! | Block | Description |
11//! |-------|-------------|
12//! | [`RTrig`](crate::fb::RTrig) | Rising edge detector (false → true) |
13//! | [`FTrig`](crate::fb::FTrig) | Falling edge detector (true → false) |
14//! | [`Blink`](crate::fb::Blink) | Toggles output 0.5s on, 0.5s off |
15//! | [`Ton`](crate::fb::Ton) | Timer On Delay — output activates after a duration |
16//! | [`SimpleTimer`](crate::fb::SimpleTimer) | One-shot timer for imperative start/check patterns |
17//! | [`StateMachine`](crate::fb::StateMachine) | State machine helper with automatic timer management |
18//! | [`BitResetOnDelay`](crate::fb::BitResetOnDelay) | Resets a boolean after it has been true for a duration |
19//! | [`RunningAverage`](crate::fb::RunningAverage) | Accumulates values and computes their arithmetic mean |
20//! | [`Beeper`](crate::fb::Beeper) | Audible beeper controller with configurable beep sequences |
21//! | [`Heartbeat`](crate::fb::Heartbeat) | Monitors a remote heartbeat counter for connection loss |
22//! | [`Shutdown`](crate::fb::Shutdown) | Non-blocking system shutdown initiation and cancellation via IPC |
23//! | [`ni::DaqCapture`](crate::fb::ni::DaqCapture) | NI DAQ triggered capture: arm, wait, read data via IPC |
24//! | [`beckhoff::El3356`](crate::fb::beckhoff::El3356) | Beckhoff EL3356 strain-gauge terminal: peak tracking, tare, SDO calibration |
25//!
26//! ## Usage Pattern
27//!
28//! All function blocks follow the same pattern:
29//!
30//! 1. **Create** the block once (typically in your program struct)
31//! 2. **Call** it every scan cycle with the current inputs
32//! 3. **Read** its outputs to drive your logic
33//!
34//! ```ignore
35//! use autocore_std::fb::{RTrig, Ton};
36//! use std::time::Duration;
37//!
38//! struct MyProgram {
39//!     start_trigger: RTrig,
40//!     start_delay: Ton,
41//! }
42//!
43//! impl MyProgram {
44//!     fn new() -> Self {
45//!         Self {
46//!             start_trigger: RTrig::new(),
47//!             start_delay: Ton::new(),
48//!         }
49//!     }
50//! }
51//! ```
52//!
53//! ## IEC 61131-3 Naming
54//!
55//! | IEC 61131-3 Name | Rust Name |
56//! |------------------|-----------|
57//! | `R_TRIG` | [`RTrig`](crate::fb::RTrig) |
58//! | `F_TRIG` | [`FTrig`](crate::fb::FTrig) |
59//! | `TON` | [`Ton`](crate::fb::Ton) |
60//! | `FB_StateMachine` | [`StateMachine`](crate::fb::StateMachine) |
61//! | `FB_BitResetOnDelay` | [`BitResetOnDelay`](crate::fb::BitResetOnDelay) |
62//! | `FB_RunningAverage` | [`RunningAverage`](crate::fb::RunningAverage) |
63//! | `FB_Beeper` | [`Beeper`](crate::fb::Beeper) |
64//! | `FB_Heartbeat` | [`Heartbeat`](crate::fb::Heartbeat) |
65//! | `FB_Shutdown` | [`Shutdown`](crate::fb::Shutdown) |
66
67mod r_trig;
68mod f_trig;
69mod blink;
70mod ton;
71mod simple_timer;
72mod state_machine;
73mod bit_reset_on_delay;
74mod running_average;
75mod beeper;
76mod heartbeat;
77mod shutdown;
78pub mod ni;
79pub mod beckhoff;
80pub mod datastore;
81pub mod memorystore;
82pub use r_trig::RTrig;
83pub use f_trig::FTrig;
84pub use blink::Blink;
85pub use ton::Ton;
86pub use simple_timer::SimpleTimer;
87pub use state_machine::StateMachine;
88pub use bit_reset_on_delay::BitResetOnDelay;
89pub use running_average::{RunningAverage, Averageable};
90pub use beeper::Beeper;
91pub use heartbeat::Heartbeat;
92pub use shutdown::Shutdown;