thegridelectric / gw-scada-spaceheat-python

GridWorks SCADA for space heating
MIT License
5 stars 2 forks source link

Replace houses.json with hardware-layout.json and HardwareLayout objects #118

Closed anschweitzer closed 2 years ago

anschweitzer commented 2 years ago

Replace houses.json with hardware-layout.json and HardwareLayout objects.

Summary of changes:

  1. houses.json moved to $HOME/.config/gridworks/scada/hardware-layout.json and only contains a single config.
  2. Storage locations are based on the xdg base directory specification:
    • Config is found at $HOME/.config/gridworks/scada/hardware-layout.json
    • Output is written to $HOME/.local/share/gridworks/scada
    • Logs are written to $HOME/.local/state/gridworks/scada/log
  3. A new config.Paths member of the ScadaSettings object represents this arrangement. Observe with:
    pip install rich-cli
    python -c "import rich; import config; rich.print(config.ScadaSettings())"
  4. Scripts will load the hardware layout from the file at settings.paths.hardware_layout into a new HardwareLayout object.
    • The HardwareLayout object is passed to all actor constructors separately from settings.
    • The HardwareLayout object has a copy of all ShNodes by alias.
    • layout.node("a.s") replaces ShNode.by_alias["a.s"]. ShNode.by_alias has been removed.
    • Components and Cacs and ShNode id -> instances are still stored in class attributes.
    • load_house is now a thin wrapper around data_classes.hardware_layout.
    • HardwareLayout contains many cached properties formerly in ActorBase, Scada, CloudBase, Nodes etc.
    • The majority of code lines changes are simply accessing these routines through the HardwareLayout object.
  5. Actors now receive an node alias, not a node. This is less typing for the caller.

To try changes, copy test/config/hardware-layout.json or your actual hardware layout to:

$HOME/.config/gridworks/scada/hardware-layout.json
codecov[bot] commented 2 years ago

Codecov Report

Merging #118 (f7927c8) into main (75854cc) will increase coverage by 0.29%. The diff coverage is 93.05%.

@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   94.09%   94.38%   +0.29%     
==========================================
  Files         219      220       +1     
  Lines       11317    11370      +53     
==========================================
+ Hits        10649    10732      +83     
+ Misses        668      638      -30     
Impacted Files Coverage Δ
gw_spaceheat/actors2/__init__.py 100.00% <ø> (ø)
gw_spaceheat/actors2/actor_interface.py 70.00% <0.00%> (ø)
gw_spaceheat/actors2/boolean_actuator.py 94.28% <ø> (-0.16%) :arrow_down:
test/test_scripts.py 37.14% <20.00%> (-1.75%) :arrow_down:
gw_spaceheat/command_line_utils.py 60.81% <50.00%> (+0.53%) :arrow_up:
gw_spaceheat/actors2/scada_interface.py 85.71% <80.00%> (-3.18%) :arrow_down:
gw_spaceheat/actors/cloud_base.py 83.60% <83.33%> (+5.37%) :arrow_up:
gw_spaceheat/actors2/scada2.py 84.73% <84.37%> (+0.29%) :arrow_up:
gw_spaceheat/data_classes/hardware_layout.py 87.95% <87.95%> (ø)
test/utils.py 90.36% <93.33%> (ø)
... and 38 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more