Skip to content

Siemens

Use it when:

  • the source code comes from Siemens/TIA
  • you need Siemens-style local references and formatting expectations
  • you are preparing .scl import/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);)
  • FOR loop 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): disabled
  • W005 (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.

For direct Siemens source handoff to TIA via external source files:

  • trust-runtime plcopen export --target siemens emits a .scl bundle 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.rs
  • crates/trust-syntax/tests/parser_statements.rs
  • crates/trust-syntax/tests/parser_error_recovery.rs
  • LSP coverage:
  • crates/trust-lsp/src/handlers/tests/formatting_and_navigation.rs
  • crates/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:

  1. Export from truST as Siemens target.
  2. Import generated .scl files into TIA Portal.
  3. Generate blocks and finish manual mapping steps.

Prerequisites

  • trust-runtime built 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:

  • PROGRAM declarations are exported as ORGANIZATION_BLOCK "<name>".
  • FUNCTION/FUNCTION_BLOCK are exported as SCL source blocks.
  • TYPE declarations are exported in 000_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:

  1. Open your target TIA project.
  2. In the project tree, locate your CPU and open External source files.
  3. Right-click External source files -> Add new external file....
  4. Select all .scl files from:
  5. <project-dir>/interop/plcopen.siemens.xml.scl/
  6. Confirm import.

Step 4: Generate Blocks from Imported Sources

  1. In External source files, select imported .scl files.
  2. Right-click -> Generate blocks from source.
  3. Resolve any naming collisions if prompted.
  4. 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/%M address reconciliation.
  • Retain/commissioning behavior checks.
  • Vendor-library semantic review beyond symbol-level mapping.

Troubleshooting

  • No .scl files 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.