Capstones¶
Capstones show source, runtime config, HMI files, and operator surfaces working together in one larger project.
Plant Demo¶
Docs category: docs/public/examples/capstones.md
This tutorial teaches how to navigate and debug a multi-file ST project in VS Code.
What You Learn¶
- Type + FB + Program + Configuration layering
- Cross-file navigation/refactor workflow
- Debugging a state machine through scan cycles
- Project config role (
trust-lsp.toml)
Project Structure¶
src/types.st: shared enums/structssrc/fb_pump.st:PumpControllerstate machinesrc/program.st: orchestration logic (PlantProgram)src/config.st:CONFIGURATION,TASK, program bindingtrust-lsp.toml: indexing/profile settings for editor/runtime features
Step 1: Open and Build¶
code examples/plant_demo
trust-runtime build --project examples/plant_demo --sources src
trust-runtime validate --project examples/plant_demo
Step 2: Cross-File Navigation (Exact Keystrokes)¶
- Open
src/program.st. - Hold
Ctrland clickPumpController-> lands insrc/fb_pump.st. - Press
Alt+Leftto go back. - Place cursor on
SpeedSet, pressF2, enterPumpSpeedSet. - Confirm rename preview includes all impacted references.
- Right-click
PumpState->Find All References(orShift+F12). - Verify references appear across multiple files.
Step 3: Debugger Walkthrough¶
- Open
src/fb_pump.st. - Set a breakpoint inside
CASE Status.State OF. - Press
F5(uses.vscode/launch.json). - In Runtime Panel, toggle
%IX0.0(start signal). - Step through transitions (
Idle->Starting->Running). - Inspect Variables panel and inline values for
Status.StateandRamp.
Step 4: Understand Configuration Relationship¶
Read src/config.st and map the hierarchy:
CONFIGURATIONdefines deployment root.TASKdefines scan interval/priority.PROGRAM ... WITH TASKbinds logic execution.VAR_CONFIGbinds symbols to%I/%Qaddresses.
This is the runtime wiring contract for your typed logic model.
Step 5: Guided Change Exercise¶
- In
src/fb_pump.st, change: RampTime : TIME := T#1s;->T#2s- Re-run debug.
- Observe longer time spent in
StartingbeforeRunning.
Troubleshooting¶
- If
F5fails: - confirm
trust-debugpath in.vscode/settings.json. - If no cross-file symbols:
- confirm workspace root is
examples/plant_demo. - If no runtime change on input toggles:
- confirm correct
%IX/%IWaddresses fromsrc/config.st.
OpenOT Multi-PROGRAM Logging¶
This project demonstrates the truST OpenOT authoring path with two PROGRAM
blocks publishing into one OpenOT shared-memory ring.
Fillertags a message, state enum, and level value.Qualitytags a message, integer value, audited setpoint value, and alarm.- The source has no logging calls, no
Op :=, and no user-visible OpenOT ids. - truST generates
Filler.OotProducerandQuality.OotProducer. runtime.tomldrains those generated producers withproducer_instances.trust-lsp.tomlpulls in the sibling OpenOT ST producer sources fromopen-ot-ref/st/iec61131.
Build¶
From the repository root:
trust-runtime build --project examples/openot_multi_program --sources src
This generates program.stbc in the example directory.
Run¶
trust-runtime run --project examples/openot_multi_program
The runtime publishes OpenOT records to openot-multi-program.shm using:
[runtime.openot]
enabled = true
source = "st-fb"
producer_instances = ["Filler.OotProducer", "Quality.OotProducer"]
The runtime is still the single writer to the ring. The per-program ST
producers are drained sequentially, so consumers separate the stream by
sourceId and per-source seq.
The sibling OpenOT workbench keeps the reference copy of this source shape in
open-ot-ref/examples/multi-program/.