Add runtime typed ADS type system with self-contained tests#516
Add runtime typed ADS type system with self-contained tests#516Rock4Fun wants to merge 1 commit into
Conversation
|
Hi , I'm not against using AI for coding, but I would appreciate that if delivering a PR on something this size and significant feature change for this library that a more human written PR and or discussion is also created, as currently this PR has a few red flags for me. I appreciate that these may just be red flags and actually there is real intent behind this PR but if possible could you explain why you have done this, the purpose and the the root problem you were trying to solve. I think for a feature of this size the maintainers need to discuss its inclusion and them maintenance burden. Currently we have just recieved a AI written PR and code which looks completely AI generated, again I am not against that but want to determine the level of vetting required. |
|
Hi, thanks for the honest feedback. I understand the concern. The background is very concrete: I have a Beckhoff PLC in my house which controls shutters, heating, wind sensors and several other parts of the building automation. I want to integrate this cleanly into Home Assistant. |
|
Thank you for your reply, I understand. This is also a feature that we have wanted for a while so we don't have to manually keep structures up to date, I will look at the implementation to see how we best fit it in. |
|
I like the idea.
Seems like at least 90% of the changes concern testing. Focussing on the actual code changes could make things easier. |
Summary
This PR adds a read-only runtime typed ADS layer that can build a type system from ADS symbol and datatype uploads and decode complex PLC values without requiring hand-written
structure_def.It introduces a new
TypeSystemAPI and integrates it intoConnection, with backward-compatible aliasing.What is included
New module:
src/pyads/typed_symbols.pyADSIGRP_SYM_UPLOAD,ADSIGRP_SYM_UPLOADINFO2, fallback toADSIGRP_SYM_UPLOADINFO,ADSIGRP_SYM_DT_UPLOAD)STRING/WSTRINGread_values(..., batch=True)) with root grouping and sum-read supportConnectionAPI additions (src/pyads/connection.py)get_type_system(refresh=False, debug=False)get_typed_symbol_table()(compatibility alias)Public exports (
src/pyads/__init__.py)TypeSystemTypedSymbolTableTestserver improvements
src/pyads/testserver/advanced_handler.pySYM_UPLOADINFO2SYM_UPLOADINFOSYM_UPLOADSYM_DT_UPLOADsrc/pyads/testserver/testserver.pyPYADS_TESTSERVER_PORTTests
tests/test_typed_symbols.py(self-contained, no binary fixture files required)tests/test_typed_symbols_live.py(optional live tests, gated byPYADS_RUN_LIVE=1)tests/test_connection_class.pytests/test_symbol.pytests/test_testserver.pytests/test_plc_ams.pytests/test_plc_route.pytests/live_ads_config.example.json.gitignoreaddstests/live_ads_config.jsonValidation
Executed locally:
PYTHONPATH=src python -m pytest tests/test_typed_symbols.py tests/test_typed_symbols_live.py -q9 passed, 4 skippedPYTHONPATH=src PYADS_RUN_LIVE=1 python -m pytest tests/test_typed_symbols_live.py -q2 passed(plus targeted testserver/UDP-related tests with expected skip behavior on blocked local ports)
Notes