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 is the canonical OpenOT workload for every supported persistence backend. The Structured Text is identical for every run; select the database only by choosing the corresponding TOML file.
The example logs:
- a templated message with four typed arguments and process, operating-mode, ISA-88, and PackML state transitions;
BOOL, every supported signed and unsigned integer width,REAL,LREAL, and boundedSTRINGvalues;- on-change, REAL deadband, periodic, and REAL hysteresis sampling declarations;
- an audited setpoint change with actor, reason, authorization, unit, and semantic role;
- alarm and interlock activation/clear plus acknowledgement, confirmation, shelving, suppression, service state, comment, reset, and priority change;
- recipe load/approval, material addition, and batch state;
- operator action, login, logout, security failure, and electronic signature.
There are no SQL calls or OpenOT opcodes in the application programs. truST generates and drains these producer instances into one serialized ring:
Filler.OotProducer
BatchControl.OotProducer
OperatorAudit.OotProducer
SignatureAudit.OotProducer
TypedValues.OotProducer
ConditionLifecycle.OotProducer
examples/openot_multi_program/openot-coverage-manifest.json is the
machine-readable inventory binding each event family, value type, sampling
policy, state model, condition class, message argument, and database product to
this one workload. The integration gate rejects a manifest for any other pinned
OpenOT revision or with an incomplete top-level inventory.
Select a backend¶
| Product | Configuration | Secret environment variables |
|---|---|---|
| SQLite | runtime.toml |
none |
| PostgreSQL | runtime.postgresql.toml |
TRUST_OPENOT_DATABASE_URL |
| TimescaleDB | runtime.timescaledb.toml |
TRUST_OPENOT_DATABASE_URL |
| MySQL | runtime.mysql.toml |
TRUST_OPENOT_DATABASE_URL |
| MariaDB | runtime.mariadb.toml |
TRUST_OPENOT_DATABASE_URL |
| SQL Server | runtime.sqlserver.toml |
TRUST_OPENOT_DATABASE_URL |
| InfluxDB 3 | runtime.influxdb3.toml |
TRUST_OPENOT_INFLUX_HOST, TRUST_OPENOT_INFLUX_TOKEN |
MySQL and MariaDB intentionally use the same backend = "mysql" adapter but
have separate runnable configurations and real-product verification.
To run a non-default configuration, copy the selected file to a temporary
project copy as runtime.toml; do not paste a password or token into TOML.
For example:
cp -a examples/openot_multi_program /tmp/trust-openot-postgresql-example
cp /tmp/trust-openot-postgresql-example/runtime.postgresql.toml \
/tmp/trust-openot-postgresql-example/runtime.toml
trust-runtime build --project /tmp/trust-openot-postgresql-example --sources src
trust-runtime run --project /tmp/trust-openot-postgresql-example
For SQLite, run the checked-in default directly:
trust-runtime build --project examples/openot_multi_program --sources src
trust-runtime run --project examples/openot_multi_program
sqlite3 examples/openot_multi_program/history/trust-logging.sqlite3 \
'SELECT event_name, COUNT(*) FROM event_log GROUP BY 1 ORDER BY 1;'
The build emits openot-definition.json beside the bytecode. Persistence uses
that exact definition to resolve the ring records into canonical OpenOT event,
loss, and placeholder documents. The database checkpoint advances in the same
durable transaction as its documents. See the public OpenOT database
persistence guide for backend setup, TLS, queries, restart, backup, and outage
behavior.
This is a deliberately broad conformance workload, not a production scan-time template. It instruments many event families in one resource and can take a long time per VM scan in an unoptimized development build. Measure the smaller set of attributes required by the real machine against its cycle-time budget; database commits remain on the separate host persistence thread.