v0.4.0 - Cleaner surface, honest abstractions
pyrung started as a Click PLC simulator, and its early API mirrored Click's flat-memory model. Since then pyrung
has grown past Click — it has @udt, a CircuitPython codegen target, etc — but the API still
carried assumptions from the Click-only days.
v0.4.0 realigns the surface with what pyrung actually is now: a Pythonic ladder DSL with pluggable hardware
backends.
The big shifts
-
PLCreplacesPLCRunnerand is its own context manager. Enterwith PLC(logic) as plc:once and tag
reads, writes, and assertions all flow through it. Therunner.active()dance is gone. Tests shrink by roughly a
third. -
Timers and counters are UDTs.
TimerandCountership in core with.Doneand.Accfields, sized to
match typical hardware.on_delay(OvenTimer, preset=3000)replaces the two-tag form. This is how Allen-Bradley
and Siemens have modeled timers since the 80s — pyrung just didn't have UDTs when it started. Click's flat
T[i]/TD[i]layout falls out for free because the UDT counts match the hardware banks. -
Time units are IEC-mirror strings.
unit="Tms","Ts","Tm","Th","Td"— matches IEC 61131-3 time
literals and theT-prefix tag-naming convention without polluting the top-level namespace. -
Conditions have one way to AND and one way to OR.
And(...)andOr(...)replaceall_of/any_of;&
and|are gone, and so is their precedence trap. Comma insideRung(...)is still implicit AND. -
Engine and debugger internals moved off the public surface.
plc.debug.*for debugger methods,
underscore-prefixed helpers onProgramandTagMap. Autocomplete now shows what users actually need. -
One validation entry point across dialects.
program.validate(dialect="click", tag_map=mapping)and
program.validate(dialect="circuitpy", hw=hw)use the same plugin mechanism, with per-dialect shortcuts
delegating to it.
The documentation has been rewritten throughout to match.
Migration: v0.3.x was not API-stable. v0.4.0 is the first release where the API reflects a design I'm
committing to. Future changes will be additive; if anything on this surface needs to change, it'll be deprecated
first, not silently replaced. See the changelog for the full migration checklist.
Test plan
-
make testpasses (2000+ tests) -
make lintclean - Docs build without errors
- Examples run against new API