Skip to content

Decode Rockwell FBD sheets into statements - #6

Merged
DanShinde merged 1 commit into
mainfrom
feat/fbd-decode
Nov 25, 2026
Merged

DanShinde merged 1 commit into
mainfrom
feat/fbd-decode

Conversation

@DanShinde

Copy link
Copy Markdown
Owner

What

FBD routines in an .L5X were listed as one line per drawn element, with X/Y positions. That meant moving a block made a diff, and a rewired input was hard to spot. Now each sheet is decoded from its wires into one statement per output:

SHEET 1                                   // Run latch with stop
Run := (Start OR Run) AND NOT Stop
TONR JamTimer(TimerEnable := (Start OR Run) AND NOT Stop, PRE := 5000, DN => JamAlarm)
HighAlarm := Level > 80.0
Valve V1(Open := Run, Opened => V1_Open)
  • An output reference (ORef) is written as the expression wired into it.
  • Boolean blocks (BAND/BOR/BXOR/BNOT, and the AND/OR/NOT/XOR function names) and comparisons (EQU, GRT, ...) fold into the expressions that read them.
  • Every other block, function with an operand, AOI or JSR is a call with its wired input pins and the output references it writes (DN => JamAlarm).
  • Connectors (OCon/ICon) carry a signal across the sheet by name. A feedback loop is cut at the block's own output member (BOR_01.Out).
  • Layout (positions, sizes) is ignored. Text boxes become the sheet's note, so comment edits stay separate from logic.
  • SFC routines keep the one-line-per-element view.

Verified

  • uv run pytest: 68 passed (4 new in tests/test_fbd.py, covering decoding, a moved layout giving no diff, a changed operand and a feedback loop)
  • ruff check, ruff format --check, mypy: clean

Generated by Claude Code

Follow each sheet's wires to write one statement per output: an
output reference as the boolean expression wired into it, and every
block, function, AOI or JSR as a call with its wired pins. Boolean
blocks and comparisons fold into the expressions that read them,
connectors carry signals by name, feedback loops are cut, and
layout (positions, sizes) is ignored.
@DanShinde
DanShinde merged commit e3ac440 into main Nov 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant