feat(plc4py/simulated): add in-process simulated PLC driver#2536
Open
Abdylreshit wants to merge 1 commit intoapache:developfrom
Open
feat(plc4py/simulated): add in-process simulated PLC driver#2536Abdylreshit wants to merge 1 commit intoapache:developfrom
Abdylreshit wants to merge 1 commit intoapache:developfrom
Conversation
Introduces a new 'simulated' driver under plc4py.drivers.simulated,
mirroring the existing Java and Go implementations. The mspec-generated
protocol code under plc4py/protocols/simulated/readwrite/ was already
present in the tree, but no Python driver consumed it; this change fills
that gap.
The driver does not open a network socket -- it dispatches read and write
requests directly to an in-memory SimulatedDevice. That makes it useful
both as a reference implementation of the driver SPI and in tests that
need a working driver without external infrastructure.
Tag format mirrors the Java/Go drivers: TYPE/name:DATA_TYPE[count]
(e.g. STATE/counter:INT, RANDOM/temperature:REAL, STDOUT/msg:STRING).
Supported tag types:
- STATE -- read/write in-memory key-value store
- RANDOM -- reads return a freshly generated random value; writes are
rejected with ACCESS_DENIED
- STDOUT -- writes are logged; reads return ACCESS_DENIED
All 19 data types from simulated.mspec are supported (BOOL, BYTE, WORD,
DWORD, LWORD, SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL,
LREAL, CHAR, WCHAR, STRING, WSTRING), both scalar and arrays.
The driver is registered via the plc4py.drivers setuptools entry point.
Adds 20 unit tests (11 tag-parser tests + 9 end-to-end connection tests
covering STATE round-trip, RANDOM reads, STDOUT writes, arrays, and
multi-tag requests). Full test suite goes from 77 passed, 36 xfailed to
97 passed, 36 xfailed -- no regressions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new `simulated` driver to `plc4py`, matching the existing Java (`plc4j/drivers/simulated`) and Go (`plc4go/internal/simulated`) implementations. The mspec-generated protocol code under `plc4py/protocols/simulated/readwrite/` was already in the tree, but no Python driver consumed it; this PR fills that gap.
The driver runs entirely in-process — it does not open a network socket and does not need an external PLC or simulator — so it is useful both as a reference implementation of the `plc4py` driver SPI and in tests that need a working driver without infrastructure.
Tag semantics
Tag format: `TYPE/name:DATA_TYPE[count]` (same as the Java and Go drivers).
All 19 data types from `simulated.mspec` are supported (`BOOL`, `BYTE`, `WORD`, `DWORD`, `LWORD`, `SINT`, `INT`, `DINT`, `LINT`, `USINT`, `UINT`, `UDINT`, `ULINT`, `REAL`, `LREAL`, `CHAR`, `WCHAR`, `STRING`, `WSTRING`), both scalar and arrays.
Files added
Also registers the new driver via `pyproject.toml` entry points:
```toml
simulated = "plc4py.drivers.simulated.SimulatedConnection:SimulatedDriverLoader"
```
Test plan