Difference between revisions of "Open Control Architecture"
Line 1: | Line 1: | ||
== Basic Architecture == | |||
{{Block | Controls software is written in [[Node-RED]]. }}[[File:Nr1.png]]{{Block |Software works through packets of data (messages) passing along virtual (and real) wires, from one node to another. | {{Block | Controls software is written in [[Node-RED]]. }}[[File:Nr1.png]]{{Block |Software works through packets of data (messages) passing along virtual (and real) wires, from one node to another. | ||
Line 7: | Line 8: | ||
* any point (server or device) in the communications network}}[[File:Topology6a.png|center|750x750px]]{{Block | Each instance of Node-RED has an identifier, stored under '''''global.node''''' }} | * any point (server or device) in the communications network}}[[File:Topology6a.png|center|750x750px]]{{Block | Each instance of Node-RED has an identifier, stored under '''''global.node''''' }} | ||
== Communications == | |||
{{Block | Communications between systems is performed using [[MQTT]] using a standardised 5 level topic structure. '''''network''' / '''node''' / '''device''' / '''group''' / '''key'''.'' | {{Block | Communications between systems is performed using [[MQTT]] using a standardised 5 level topic structure. '''''network''' / '''node''' / '''device''' / '''group''' / '''key'''.'' | ||
<br> | <br> | ||
Line 29: | Line 31: | ||
[[File:Handler0.png]] | [[File:Handler0.png]] | ||
== Handling Data == | |||
{{Block |Within Node-RED a [[Message Handler Node]] is used to handle data generated locally. | {{Block |Within Node-RED a [[Message Handler Node]] is used to handle data generated locally. | ||
[[File:Handleroptions.png|right|frameless|461x461px]] | [[File:Handleroptions.png|right|frameless|461x461px]] | ||
Line 58: | Line 59: | ||
{{Block |Cloud based instances of Node-RED, as used on this Wiki, are often used to pull together data from various MQTT brokers into one place.}} | {{Block |Cloud based instances of Node-RED, as used on this Wiki, are often used to pull together data from various MQTT brokers into one place.}} | ||
[[File:Handlercloud.png|center]] | [[File:Handlercloud.png|center]] | ||
== Data Groups & Attributes == | |||
{{Block | The topic group is used to define the type of data. Values include: | {{Block | The topic group is used to define the type of data. Values include: | ||
*'''''dat''''' (operational data) | *'''''dat''''' (operational data) | ||
Line 70: | Line 73: | ||
*'''''pcdb''''' (pcdb data) | *'''''pcdb''''' (pcdb data) | ||
*'''''design''''' (preloaded design data) }} | *'''''design''''' (preloaded design data) }} | ||
{{Block | Attributes for data may be loaded from a central index (GitHub hosted), providing additional information such as units and descriptions. This is to avoid the need to locally describe data, and to assist in compatibility. }}{{Block | Within Node-RED, data and attributes are stored within the '''''global.readings''''' object. | {{Block | Attributes for data may be loaded from a central index (GitHub hosted), providing additional information such as units and descriptions. This is to avoid the need to locally describe data, and to assist in compatibility. }} | ||
== Node-RED Global Objects == | |||
{{Block | Within Node-RED, data and attributes are stored within the '''''global.readings''''' object. | |||
The current data can be viewed in the data explorer. | The current data can be viewed in the data explorer. |
Revision as of 00:14, 5 June 2022
Basic Architecture
A node can be:
- a function block within Node-RED
- an instance of Node-RED
- any point (server or device) in the communications network
Communications
myNetwork/plantroomNode/plantroomNode/system/title= "Main Plantroom Controller"
block1/blk1node/blk1node/system/title= "Block 1 Controller"
Adding a prefix to sub-networks ensures networks remain unique on a higher level server. E.g. There may be two unconnected networks with sub-networks called "block1".
myNetwork-block1/blk1node/blk1node/system/title= "Block 1 Controller"
anotherNetwork-block1/blk1node/blk1node/system/title= "Block 1 Controller"
Handling Data
- The Node has two outputs - one for local traffic, and one for external traffic.
- Report by exception rules are applied to external traffic.
- The Node formats topics to the five level standard, adding group and device if missing.
- The Node stores data into global.readings, along with any attributes within the incoming message, as well as timestamps.
- Additional routing can be performed within Node-RED, including selection of retained vs fire & forget routes.
Handler Nodes use a configuration node to store setup information including network and node identities.
Data Groups & Attributes
- dat (operational data)
- stat (statistics and status)
- settings (persistent settings)
- cmd (a command)
- set (command to change a setting)
- system (software and networking)
- meter (meter data)
- alarm (alarms and warnings)
- ana (analogue readings)
- pcdb (pcdb data)
- design (preloaded design data)
Node-RED Global Objects
The current data can be viewed in the data explorer.
Settings have a type, may have maximum and minimum values, units and a title. Certain types require additional fields such as select from a list settings.
The snapshot below shows a variety of setting types including numeric/text values, html, or JSON objects and arrays.
e.g. a message with a topic myNetwork/node123/myDevice/dat/outputTemperature would be stored in (global).readings.myNetwork.myDevice.dat.outputTemperature.value
Internally, message topics can be truncated and the network and node will be filled in. The data group will be assumed to be "dat" if not supplied, representing operational data.
e.g. a message with a topic setpoint would be stored in (global).readings.local.myNode.dat.setpoint.value
The following code could be used to read data and its attributes for output.
var localNetworkId = global.get("localNetworkId"); var node = global.get("node"); var reading = global.get("readings." + localNetworkId + "." + node + ".dat.outputTemperature"); var output = "The value of " + reading.title + " is " + reading.value + reading.units; // "The value of Output Temperature is 35°C