Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Modbus handling #32

Merged
merged 12 commits into from
Dec 29, 2024
Merged

Conversation

albireox
Copy link
Member

@albireox albireox commented Dec 29, 2024

This is a major refactor of how the Modbus and ModbusRegister classes work:

  • Performance has been greatly improved, with Modbus.get_all() going from taking ~0.6 seconds to under 0.1. The main change is that the register and coil blocks are now read completely, in chunks as large as the device will accept, as opposed to before, when we would read each variable with one read command (although the connection was not closed in between).
  • The caching mechanism has been improved and now works as expected. The default cache timeout is 1 second.
  • The PLC variable list has been updated and now matches Felipe's list.
  • Various renamings of methods and variables.
  • Added a low-level modbus actor command to read/set Modbus variables (even those not defined in the PLC list).
  • Improved the simulator to better handle overrides and events that trigger a change in the internal state of the context.
  • Improve the engineering mode commands.
  • Improve test coverage.

@albireox albireox requested a review from mmingyeong as a code owner December 29, 2024 06:57
Copy link

codecov bot commented Dec 29, 2024

Codecov Report

Attention: Patch coverage is 81.70732% with 45 lines in your changes missing coverage. Please review.

Project coverage is 82.0%. Comparing base (d32b54c) to head (a2e6fd1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
python/lvmecp/modbus.py 77.1% 10 Missing and 12 partials ⚠️
python/lvmecp/safety.py 16.7% 4 Missing and 6 partials ⚠️
python/lvmecp/actor/commands/engineering.py 81.0% 2 Missing and 2 partials ⚠️
python/lvmecp/actor/commands/modbus.py 93.5% 2 Missing and 2 partials ⚠️
python/lvmecp/actor/actor.py 50.0% 1 Missing ⚠️
python/lvmecp/dome.py 95.7% 1 Missing ⚠️
python/lvmecp/hvac.py 50.0% 1 Missing ⚠️
python/lvmecp/module.py 90.0% 1 Missing ⚠️
python/lvmecp/plc.py 83.4% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main     #32      +/-   ##
========================================
+ Coverage   70.8%   82.0%   +11.2%     
========================================
  Files         18      19       +1     
  Lines        832     929      +97     
  Branches     116     134      +18     
========================================
+ Hits         589     761     +172     
+ Misses       186     103      -83     
- Partials      57      65       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@albireox albireox merged commit b0c7349 into main Dec 29, 2024
6 checks passed
@albireox albireox deleted the albireox-refactor-plc-connection branch December 29, 2024 15:41
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