Skip to main content

Translate exported SimaticML LAD/FBD blocks (TIA V21) into readable SCL plus a JSON metadata sidecar.

Project description

simaticml-decoder

Translate exported SimaticML LAD/FBD blocks (Siemens TIA Portal V21) into readability-first SCL plus a JSON metadata sidecar.

Why

A SimaticML export stores ladder logic as a FlgNet — a flat netlist of parts and wires, not line-shaped rungs. Reading that graph by hand (or by eye, from the editor) is token-heavy and error-prone: it is easy to connect the wrong variable in a large block, and a single contact's negation is one diagonal slash. This tool decodes the netlist deterministically, so what you analyse is folded logic with explicit negation and an exact write/read cross-reference — not a graph you have to trace yourself.

How it works

Three cleanly separated, independently testable phases:

Phase Module Input → Output
1. Parse parse.pymodel.py XML → faithful syntactic mirror
2. Fold fold.pyir.py model → boolean tree + assignments
3. Emit emit.py IR → SCL text + JSON sidecar

Supporting modules: instructions.py (the part catalog — data, not logic), operand.py (Access → display string), scl_reconstruct.py (SCL networks, which are reconstructed from their tokenised AST rather than folded).

Two commitments run through the design: every IR node keeps the source UId it came from (so any rendered claim is traceable to a net), and anything the folder cannot interpret is surfaced loudly rather than dropped — a silent omission in authoritative-looking SCL is the worst possible failure.

Scope

Covered: FC/FB blocks; LAD/FBD folding (series→AND, O→OR, fan-out, Negated→NOT, daisy-chained coils, structural latch detection); SCL network reconstruction; ground-truth interface types; cross-reference table; the instruction set seen in real V21 samples (Contact, Coil/SCoil/RCoil, O, Move/Add/Inc, comparisons, Rs/Sr, P/N edges, TON family, user FC/FB calls).

Deferred (parsed losslessly, rendering flagged): GRAPH/SFC and STL networks; absolute-addressing / array / Operation-template rendering. Output is readability-first, not recompilable. Live TIA Openness integration is out of scope — the tool operates on already-exported XML.

Install

pip install simaticml-decoder

For local development:

pip install -e ".[dev]"

Runtime dependencies: none (standard-library xml.etree.ElementTree). The dev extra pulls lint, test, coverage, build, and package-validation tools.

Usage

simaticml-decode BLOCK.xml --format both
# one file at a time; --format {scl,json,both}; -o OUTDIR for output location

Layout

src/simaticml_decoder/   parse · model · fold · ir · instructions · operand
                         scl_reconstruct · emit · cli
tests/                   authored separately; run by CI
.github/workflows/ci.yml ruff + pytest on push / PR

Release

Publishing is handled by GitHub Actions and PyPI Trusted Publishing. A package is published only when a vX.Y.Z tag is pushed and the release workflow passes lint, tests, coverage, version checks, package build, and twine check.

Future

Support for new YAML-like S7 PLCs export formats.


Created with Claude AI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simaticml_decoder-0.1.0.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simaticml_decoder-0.1.0-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file simaticml_decoder-0.1.0.tar.gz.

File metadata

  • Download URL: simaticml_decoder-0.1.0.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simaticml_decoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a31af04657d31f43b2ca300838b2b576f50dfabc4de565e2927e8018f3040551
MD5 34a03fea400a050daebab61bfa33786a
BLAKE2b-256 c323899f73f25d6461329eba437646d0566896643f882ef098a3ee6274caa42e

See more details on using hashes here.

Provenance

The following attestation bundles were made for simaticml_decoder-0.1.0.tar.gz:

Publisher: release.yml on Czarnak/simaticml-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simaticml_decoder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simaticml_decoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f26f1d64a339681ca1b40f89a190ca2317b51d5ca14ac7cdba443492955704d4
MD5 e0ad25845861fa97b18e47a3118acdc9
BLAKE2b-256 26473f40fd8905bf039249962f4feb134c1116bb061ba7736f37dc378ad9ec16

See more details on using hashes here.

Provenance

The following attestation bundles were made for simaticml_decoder-0.1.0-py3-none-any.whl:

Publisher: release.yml on Czarnak/simaticml-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page