autocore-std
Standard library for AutoCore control programs. Provides shared memory communication, IPC, logging, and IEC 61131-3 inspired function blocks.
Overview
autocore-std is the runtime library for control programs running alongside an AutoCore server. It handles:
- Shared Memory Communication - Zero-copy data exchange with the server
- Synchronization - Tick-based cyclic execution with proper memory barriers
- UDP Logging - Non-blocking log delivery to the server console
- Function Blocks - IEC 61131-3 inspired timers and edge triggers
Installation
Add to your Cargo.toml:
[]
= "3.3"
= "0.4"
= "1"
Quick Start
use ;
// Import the generated global memory module
use GlobalMemory;
Or use the convenience macro:
autocore_main!;
Function Blocks
RTrig - Rising Edge Trigger
Detects false-to-true transitions.
use RTrig;
let mut trigger = new;
trigger.call; // returns false
trigger.call; // returns true (rising edge!)
trigger.call; // returns false (no edge)
trigger.call; // returns false
trigger.call; // returns true (rising edge!)
FTrig - Falling Edge Trigger
Detects true-to-false transitions.
use FTrig;
let mut trigger = new;
trigger.call; // returns false
trigger.call; // returns true (falling edge!)
trigger.call; // returns false (no edge)
TON - Timer On Delay
Output becomes true after input has been true for the preset duration.
use Ton;
use Duration;
let mut timer = new;
// In your process_tick:
let done = timer.call;
// Access elapsed time
println!;
Logging
Logs are sent via UDP to the AutoCore server for display in the console.
trace!;
debug!;
info!;
warn!;
error!;
View logs with:
Configuration
use ;
use LevelFilter;
let config = RunnerConfig ;
Architecture
┌─────────────────────────────────────────────────────────────┐
│ AutoCore Server │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Shared Mem │ │ IPC Server │ │ UDP Log Listener │ │
│ │ (cyclic) │ │ (setup) │ │ (port 39101) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────────┬──────────┘ │
└─────────┼────────────────┼────────────────────┼─────────────┘
│ │ │
│ memory map │ layout query │ UDP logs
│ │ │
┌─────────┼────────────────┼────────────────────┼─────────────┐
│ ▼ ▼ ▲ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Local Copy │ │ IPC Client │ │ UDP Logger │ │
│ │ of Memory │ │ (init only) │ │ (background thread) │ │
│ └──────┬──────┘ └─────────────┘ └─────────────────────┘ │
│ │ ▲ │
│ ▼ │ │
│ ┌────────────────────────────────────────────┴──────────┐ │
│ │ ControlRunner + Your Program │ │
│ │ 1. Wait for tick signal │ │
│ │ 2. Read shared memory → local copy (acquire) │ │
│ │ 3. Execute process_tick() │ │
│ │ 4. Write local copy → shared memory (release) │ │
│ │ 5. Signal completion (optional) │ │
│ └───────────────────────────────────────────────────────┘ │
│ Control Program │
└─────────────────────────────────────────────────────────────┘
Memory Synchronization
The ControlRunner handles proper memory synchronization:
- Input Phase: Reads shared memory into a local buffer with an acquire fence
- Execute Phase: Your
process_tick()runs on the local copy - Output Phase: Writes local buffer back to shared memory with a release fence
This ensures:
- Consistent snapshot of inputs at cycle start
- Atomic commit of outputs at cycle end
- Proper visibility across process boundaries
License
Proprietary - Licensed AutoCore Users Only
This software is licensed exclusively for use with validly licensed AutoCore Server installations. This library is used to control industrial equipment - improper use may result in equipment damage, personal injury, or death.
See the LICENSE file for complete terms.
For licensing inquiries: support@automateddesign.com