Siemens¶
Use it when:
- the source code comes from Siemens/TIA
- you need Siemens-style local references and formatting expectations
- you are preparing
.sclimport/export workflows
Compatibility Baseline¶
Siemens SCL Compatibility (Deliverable 3)¶
This document defines the Siemens SCL v1 compatibility baseline for trust-syntax,
trust-hir, trust-ide, and trust-lsp.
Scope¶
- Vendor profile:
vendor_profile = "siemens" - Focus: syntax, formatting, and diagnostics compatibility improvements for common Siemens SCL authoring patterns
- Example project:
examples/siemens_scl_v1/
Supported SCL Subset (v1)¶
1) #-prefixed local references¶
The parser accepts Siemens-style # prefixes for local and instance references in:
- expressions (
#input + 1) - assignment/call statements (
#counter := #counter + 1;,#fb(Enable := #pulse);) FORloop control variables (FOR #i := 0 TO 3 DO ... END_FOR;)
Malformed # usage reports a targeted parse diagnostic:
- `expected identifier after '#'
2) Siemens formatting defaults¶
With vendor_profile = "siemens" the formatter defaults to:
- 2-space indent
- uppercase keywords
- compact operator spacing
- aligned
END_*keywords
3) Siemens diagnostic defaults¶
With vendor_profile = "siemens" default warning behavior is:
W004(missing ELSE): disabledW005(implicit conversion): disabled- other warning categories remain enabled unless overridden in config
Known Gaps / Deviations¶
- This is language/tooling compatibility, not full TIA project parity.
- Siemens project metadata and hardware configuration semantics are out of scope.
- Siemens-specific pragmas/attributes are parsed as pragmas (trivia), not executed semantics.
Related Runtime Export Path¶
For direct Siemens source handoff to TIA via external source files:
trust-runtime plcopen export --target siemensemits a.sclbundle sidecar.- Tutorial:
docs/guides/SIEMENS_TIA_SCL_IMPORT_TUTORIAL.md
See docs/IEC_DEVIATIONS.md for the formal deviation record.
Regression Coverage¶
- Parser coverage:
crates/trust-syntax/tests/parser_expressions.rscrates/trust-syntax/tests/parser_statements.rscrates/trust-syntax/tests/parser_error_recovery.rs- LSP coverage:
crates/trust-lsp/src/handlers/tests/formatting_and_navigation.rscrates/trust-lsp/src/handlers/tests/core.rs- Runtime/example compile coverage:
crates/trust-runtime/tests/tutorial_examples.rs
TIA Import Tutorial¶
Siemens TIA Import Tutorial (Direct .scl Export)¶
This tutorial shows the practical Siemens flow:
- Export from truST as Siemens target.
- Import generated
.sclfiles into TIA Portal. - Generate blocks and finish manual mapping steps.
Prerequisites¶
trust-runtimebuilt and available on PATH.- A truST ST project with
src/. - TIA Portal project where blocks will be imported.
Step 1: Export Siemens Target¶
Run export with Siemens target:
trust-runtime plcopen export --project <project-dir> --target siemens --json
Example:
trust-runtime plcopen export --project examples/siemens_scl_v1 --target siemens --json
Step 2: Check Generated Artifacts¶
Siemens export writes:
- PLCopen XML:
interop/plcopen.siemens.xml - Source map:
interop/plcopen.siemens.xml.source-map.json - Adapter report:
interop/plcopen.siemens.xml.adapter-report.json - Siemens SCL bundle directory:
interop/plcopen.siemens.xml.scl/ - Siemens SCL files:
interop/plcopen.siemens.xml.scl/*.scl
Notes about generated SCL:
PROGRAMdeclarations are exported asORGANIZATION_BLOCK "<name>".FUNCTION/FUNCTION_BLOCKare exported as SCL source blocks.TYPEdeclarations are exported in000_types.scl.- Configuration/resource/task/program-instance wiring is migration metadata and still needs manual OB/task mapping in TIA.
Step 3: Import .scl Files in TIA Portal¶
In TIA Portal:
- Open your target TIA project.
- In the project tree, locate your CPU and open
External source files. - Right-click
External source files->Add new external file.... - Select all
.sclfiles from: <project-dir>/interop/plcopen.siemens.xml.scl/- Confirm import.
Step 4: Generate Blocks from Imported Sources¶
- In
External source files, select imported.sclfiles. - Right-click ->
Generate blocks from source. - Resolve any naming collisions if prompted.
- Open generated blocks and run compile.
Step 5: Apply Manual Mapping from Adapter Report¶
Open:
<project-dir>/interop/plcopen.siemens.xml.adapter-report.json
Use adapter_diagnostics[] and adapter_manual_steps[] to finish:
- OB/task scheduling mapping.
%I/%Q/%Maddress reconciliation.- Retain/commissioning behavior checks.
- Vendor-library semantic review beyond symbol-level mapping.
Troubleshooting¶
- No
.sclfiles generated: - Ensure the project has importable ST declarations (
PROGRAM,FUNCTION,FUNCTION_BLOCK,TYPE). - TIA import accepted source but block generation failed:
- Open the failing source in TIA error view and fix syntax/runtime-model differences.
- Task/program wiring missing after block generation:
- Expected. Apply manual mapping using the adapter report checklist.
Scope Reminder¶
This flow is for direct source import convenience. It does not generate native TIA project archives and does not auto-generate hardware topology or safety metadata.