Skip to content

Commit

Permalink
feat(wind-turbine): add node-red configuration support for main contr…
Browse files Browse the repository at this point in the history
…oller
  • Loading branch information
activeshadow committed Feb 5, 2024
1 parent 3a74097 commit 0f6301d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/python/phenix_apps/apps/wind_turbine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ spec:
speedTag: speed.high
directionTag: dir.high
directionError: 0.04
node-red:
flow: /phenix/injects/foobar/node-red-flow.json
endpoint:
host: 0.0.0.0
port: 1880
auth:
editor:
user: admin
pass: admin
ui:
user: foo
pass: bar
weather:
columns:
- name: wind_speed
Expand Down
19 changes: 19 additions & 0 deletions src/python/phenix_apps/apps/wind_turbine/wind_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from phenix_apps.apps.otsim.config import Config
from phenix_apps.apps.otsim.device import Register
from phenix_apps.apps.otsim.logic import Logic
from phenix_apps.apps.otsim.nodered import NodeRed
from phenix_apps.apps.otsim.protocols.modbus import Modbus
from phenix_apps.apps.otsim.protocols.dnp3 import DNP3

Expand Down Expand Up @@ -253,6 +254,24 @@ def __main_controller(self, node, anemo = None, yaw = None, match = None):
annotation = [{'broker': addr, 'fed-count': 1}]
self.add_annotation(node.hostname, 'helics/federate', annotation)


md = node.metadata.get('node-red', tmpl.get('node-red', None))
if md:
nodered = NodeRed()

nodered.init_xml_root(md, 'main-controller')
nodered.to_xml()

module = ET.Element('module', {'name': 'node-red'})
module.text = 'ot-sim-node-red-module {{config_file}}'

config.append_to_root(nodered.root)
config.append_to_cpu(module)

inject = nodered.needs_inject()
if inject:
self.add_inject(hostname=node.hostname, inject=inject)

md = node.metadata.get('logic', tmpl.get('logic', {}))
speed_tag = md.get('speedTag', 'speed.high')
dir_tag = md.get('directionTag', 'dir.high')
Expand Down

0 comments on commit 0f6301d

Please sign in to comment.