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.py → model.py |
XML → faithful syntactic mirror |
| 2. Fold | fold.py → ir.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31af04657d31f43b2ca300838b2b576f50dfabc4de565e2927e8018f3040551
|
|
| MD5 |
34a03fea400a050daebab61bfa33786a
|
|
| BLAKE2b-256 |
c323899f73f25d6461329eba437646d0566896643f882ef098a3ee6274caa42e
|
Provenance
The following attestation bundles were made for simaticml_decoder-0.1.0.tar.gz:
Publisher:
release.yml on Czarnak/simaticml-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simaticml_decoder-0.1.0.tar.gz -
Subject digest:
a31af04657d31f43b2ca300838b2b576f50dfabc4de565e2927e8018f3040551 - Sigstore transparency entry: 1712014533
- Sigstore integration time:
-
Permalink:
Czarnak/simaticml-decoder@1fe48b4bdced0585af8b8bbaf9b3e17f544a2e21 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Czarnak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1fe48b4bdced0585af8b8bbaf9b3e17f544a2e21 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simaticml_decoder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simaticml_decoder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26f1d64a339681ca1b40f89a190ca2317b51d5ca14ac7cdba443492955704d4
|
|
| MD5 |
e0ad25845861fa97b18e47a3118acdc9
|
|
| BLAKE2b-256 |
26473f40fd8905bf039249962f4feb134c1116bb061ba7736f37dc378ad9ec16
|
Provenance
The following attestation bundles were made for simaticml_decoder-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Czarnak/simaticml-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simaticml_decoder-0.1.0-py3-none-any.whl -
Subject digest:
f26f1d64a339681ca1b40f89a190ca2317b51d5ca14ac7cdba443492955704d4 - Sigstore transparency entry: 1712014553
- Sigstore integration time:
-
Permalink:
Czarnak/simaticml-decoder@1fe48b4bdced0585af8b8bbaf9b3e17f544a2e21 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Czarnak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1fe48b4bdced0585af8b8bbaf9b3e17f544a2e21 -
Trigger Event:
push
-
Statement type: