updated valve to latest version of EVOLV eco
This commit is contained in:
381
dependencies/valveConfig.json
vendored
381
dependencies/valveConfig.json
vendored
@@ -1,381 +0,0 @@
|
|||||||
{
|
|
||||||
"general": {
|
|
||||||
"name": {
|
|
||||||
"default": "Valve",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "A human-readable name or label for this valve configuration."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"default": null,
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "A unique identifier for this configuration. If not provided, defaults to null."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unit": {
|
|
||||||
"default": "m3/h",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The default measurement unit for this configuration (e.g., 'meters', 'seconds', 'unitless')."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"logging": {
|
|
||||||
"logLevel": {
|
|
||||||
"default": "info",
|
|
||||||
"rules": {
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
{
|
|
||||||
"value": "debug",
|
|
||||||
"description": "Log messages are printed for debugging purposes."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "info",
|
|
||||||
"description": "Informational messages are printed."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "warn",
|
|
||||||
"description": "Warning messages are printed."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "error",
|
|
||||||
"description": "Error messages are printed."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
"default": true,
|
|
||||||
"rules": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Indicates whether logging is active. If true, log messages will be generated."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"functionality": {
|
|
||||||
"softwareType": {
|
|
||||||
"default": "valve",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Specified software type for this configuration."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
"default": "valveController",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Indicates the role this configuration plays within the system."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"asset": {
|
|
||||||
"uuid": {
|
|
||||||
"default": null,
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "A universally unique identifier for this asset. May be null if not assigned."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"geoLocation": {
|
|
||||||
"default": {},
|
|
||||||
"rules": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "An object representing the asset's physical coordinates or location.",
|
|
||||||
"schema": {
|
|
||||||
"x": {
|
|
||||||
"default": 0,
|
|
||||||
"rules": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "X coordinate of the asset's location."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"default": 0,
|
|
||||||
"rules": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "Y coordinate of the asset's location."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"default": 0,
|
|
||||||
"rules": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "Z coordinate of the asset's location."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"supplier": {
|
|
||||||
"default": "Unknown",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The supplier or manufacturer of the asset."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"default": "valve",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "A general classification of the asset tied to the specific software. This is not chosen from the asset dropdown menu."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"subType": {
|
|
||||||
"default": "ecdv",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "A more specific classification within 'type'. For example, 'ecdv valve'."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"model": {
|
|
||||||
"default": "Unknown",
|
|
||||||
"rules": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "A user-defined or manufacturer-defined model identifier for the asset."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"accuracy": {
|
|
||||||
"default": null,
|
|
||||||
"rules": {
|
|
||||||
"type": "number",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "The accuracy of the valve or sensor, typically as a percentage or absolute value."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"valveCurve": {
|
|
||||||
"default": {
|
|
||||||
"nq": {
|
|
||||||
"1": {
|
|
||||||
"x": [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5
|
|
||||||
],
|
|
||||||
"y": [
|
|
||||||
10,
|
|
||||||
20,
|
|
||||||
30,
|
|
||||||
40,
|
|
||||||
50
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"np": {
|
|
||||||
"1": {
|
|
||||||
"x": [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5
|
|
||||||
],
|
|
||||||
"y": [
|
|
||||||
10,
|
|
||||||
20,
|
|
||||||
30,
|
|
||||||
40,
|
|
||||||
50
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"type": "valveCurve",
|
|
||||||
"description": "All valves curves must have a 'nq' and 'np' curve. nq stands for the flow curve, np stands for the power curve. Together they form the efficiency curve."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mode": {
|
|
||||||
"current": {
|
|
||||||
"default": "auto",
|
|
||||||
"rules": {
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
{
|
|
||||||
"value": "auto",
|
|
||||||
"description": "Accepts setpoints from a parent controller and runs autonomously."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "virtualControl",
|
|
||||||
"description": "Controlled via GUI setpoints; ignores parent commands."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "fysicalControl",
|
|
||||||
"description": "Controlled via physical buttons or switches; ignores external automated commands."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "maintenance",
|
|
||||||
"description": "No active control from auto, virtual, or fysical sources."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "The operational mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"allowedActions":{
|
|
||||||
"default":{},
|
|
||||||
"rules": {
|
|
||||||
"type": "object",
|
|
||||||
"schema":{
|
|
||||||
"auto": {
|
|
||||||
"default": ["statusCheck", "execMovement", "execSequence", "emergencyStop"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Actions allowed in auto mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"virtualControl": {
|
|
||||||
"default": ["statusCheck", "execMovement", "execSequence", "emergencyStop"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Actions allowed in virtualControl mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fysicalControl": {
|
|
||||||
"default": ["statusCheck", "emergencyStop"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Actions allowed in fysicalControl mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"maintenance": {
|
|
||||||
"default": ["statusCheck"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Actions allowed in maintenance mode."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": "Information about valid command sources recognized."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"allowedSources":{
|
|
||||||
"default": {},
|
|
||||||
"rules": {
|
|
||||||
"type": "object",
|
|
||||||
"schema":{
|
|
||||||
"auto": {
|
|
||||||
"default": ["parent", "GUI", "fysical"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sources allowed in auto mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"virtualControl": {
|
|
||||||
"default": ["GUI", "fysical"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sources allowed in virtualControl mode."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fysicalControl": {
|
|
||||||
"default": ["fysical"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sources allowed in fysicalControl mode."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": "Information about valid command sources recognized."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"default": "parent",
|
|
||||||
"rules": {
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
{
|
|
||||||
"value": "parent",
|
|
||||||
"description": "Commands are received from a parent controller."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "GUI",
|
|
||||||
"description": "Commands are received from a graphical user interface."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "fysical",
|
|
||||||
"description": "Commands are received from physical buttons or switches."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Information about valid command sources recognized."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sequences":{
|
|
||||||
"default":{},
|
|
||||||
"rules": {
|
|
||||||
"type": "object",
|
|
||||||
"schema": {
|
|
||||||
"startup": {
|
|
||||||
"default": ["starting","warmingup","operational"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sequence of states for starting up."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"shutdown": {
|
|
||||||
"default": ["stopping","coolingdown","idle"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sequence of states for shutting down."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"emergencystop": {
|
|
||||||
"default": ["emergencystop","off"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sequence of states for an emergency stop."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"boot": {
|
|
||||||
"default": ["idle","starting","warmingup","operational"],
|
|
||||||
"rules": {
|
|
||||||
"type": "set",
|
|
||||||
"itemType": "string",
|
|
||||||
"description": "Sequence of states for booting up."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": "Predefined sequences of states."
|
|
||||||
|
|
||||||
},
|
|
||||||
"calculationMode": {
|
|
||||||
"default": "medium",
|
|
||||||
"rules": {
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
{
|
|
||||||
"value": "low",
|
|
||||||
"description": "Calculations run at fixed intervals (time-based)."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "medium",
|
|
||||||
"description": "Calculations run when new setpoints arrive or measured changes occur (event-driven)."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "high",
|
|
||||||
"description": "Calculations run on all event-driven info, including every movement."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "The frequency at which calculations are performed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -17,8 +17,7 @@
|
|||||||
"author": "Rene De Ren / Janneke Tack",
|
"author": "Rene De Ren / Janneke Tack",
|
||||||
"license": "SEE LICENSE",
|
"license": "SEE LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git",
|
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git"
|
||||||
"convert": "git+https://gitea.centraal.wbd-rd.nl/RnD/convert.git"
|
|
||||||
},
|
},
|
||||||
"node-red": {
|
"node-red": {
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
|||||||
294
src/nodeClass.js
Normal file
294
src/nodeClass.js
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
/**
|
||||||
|
* Encapsulates all node logic in a reusable class. In future updates we can split this into multiple generic classes and use the config to specifiy which ones to use.
|
||||||
|
* This allows us to keep the Node-RED node clean and focused on wiring up the UI and event handlers.
|
||||||
|
*/
|
||||||
|
const { outputUtils, configManager } = require('generalFunctions');
|
||||||
|
const Specific = require("./specificClass");
|
||||||
|
|
||||||
|
|
||||||
|
class nodeClass {
|
||||||
|
/**
|
||||||
|
* Create a MeasurementNode.
|
||||||
|
* @param {object} uiConfig - Node-RED node configuration.
|
||||||
|
* @param {object} RED - Node-RED runtime API.
|
||||||
|
* @param {object} nodeInstance - The Node-RED node instance.
|
||||||
|
* @param {string} nameOfNode - The name of the node, used for
|
||||||
|
*/
|
||||||
|
constructor(uiConfig, RED, nodeInstance, nameOfNode) {
|
||||||
|
|
||||||
|
// Preserve RED reference for HTTP endpoints if needed
|
||||||
|
this.node = nodeInstance;
|
||||||
|
this.RED = RED;
|
||||||
|
this.name = nameOfNode;
|
||||||
|
this.source = null; // Will hold the specific class instance
|
||||||
|
this.config = null; // Will hold the merged configuration
|
||||||
|
|
||||||
|
// Load default & UI config
|
||||||
|
this._loadConfig(uiConfig,this.node);
|
||||||
|
|
||||||
|
// Instantiate core Measurement class
|
||||||
|
this._setupSpecificClass(uiConfig);
|
||||||
|
|
||||||
|
// Wire up event and lifecycle handlers
|
||||||
|
this._bindEvents();
|
||||||
|
this._registerChild();
|
||||||
|
this._startTickLoop();
|
||||||
|
this._attachInputHandler();
|
||||||
|
this._attachCloseHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load and merge default config with user-defined settings.
|
||||||
|
* @param {object} uiConfig - Raw config from Node-RED UI.
|
||||||
|
*/
|
||||||
|
_loadConfig(uiConfig,node) {
|
||||||
|
|
||||||
|
// Merge UI config over defaults
|
||||||
|
this.config = {
|
||||||
|
general: {
|
||||||
|
name: uiConfig.name,
|
||||||
|
id: node.id, // node.id is for the child registration process
|
||||||
|
unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
|
||||||
|
logging: {
|
||||||
|
enabled: uiConfig.enableLog,
|
||||||
|
logLevel: uiConfig.logLevel
|
||||||
|
}
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
uuid: uiConfig.assetUuid, //need to add this later to the asset model
|
||||||
|
tagCode: uiConfig.assetTagCode, //need to add this later to the asset model
|
||||||
|
supplier: uiConfig.supplier,
|
||||||
|
category: uiConfig.category, //add later to define as the software type
|
||||||
|
type: uiConfig.assetType,
|
||||||
|
model: uiConfig.model,
|
||||||
|
unit: uiConfig.unit
|
||||||
|
},
|
||||||
|
functionality: {
|
||||||
|
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Utility for formatting outputs
|
||||||
|
this._output = new outputUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate the core logic and store as source.
|
||||||
|
*/
|
||||||
|
_setupSpecificClass(uiConfig) {
|
||||||
|
const vconfig = this.config;
|
||||||
|
|
||||||
|
// need extra state for this
|
||||||
|
const stateConfig = {
|
||||||
|
general: {
|
||||||
|
logging: {
|
||||||
|
enabled: vconfig.eneableLog,
|
||||||
|
logLevel: vconfig.logLevel
|
||||||
|
}
|
||||||
|
},
|
||||||
|
movement: {
|
||||||
|
speed: Number(uiConfig.speed)
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
starting: Number(uiConfig.startup),
|
||||||
|
warmingup: Number(uiConfig.warmup),
|
||||||
|
stopping: Number(uiConfig.shutdown),
|
||||||
|
coolingdown: Number(uiConfig.cooldown)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.source = new Specific(vconfig, stateConfig);
|
||||||
|
|
||||||
|
//store in node
|
||||||
|
this.node.source = this.source; // Store the source in the node instance for easy access
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind Measurement events to Node-RED status updates. Using internal emitter. --> REMOVE LATER WE NEED ONLY COMPLETE CHILDS AND THEN CHECK FOR UPDATES
|
||||||
|
*/
|
||||||
|
_bindEvents() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateNodeStatus() {
|
||||||
|
const v = this.source;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const mode = v.currentMode; // modus is bijv. auto, manual, etc.
|
||||||
|
const state = v.state.getCurrentState(); //is bijv. operational, idle, off, etc.
|
||||||
|
const flow = Math.round(v.measurements.type("flow").variant("measured").position("downstream").getCurrentValue());
|
||||||
|
let deltaP = v.measurements.type("pressure").variant("predicted").position("delta").getCurrentValue();
|
||||||
|
if (deltaP !== null) {
|
||||||
|
deltaP = parseFloat(deltaP.toFixed(0));
|
||||||
|
} //afronden op 4 decimalen indien geen "null"
|
||||||
|
if(isNaN(deltaP)) {
|
||||||
|
deltaP = "∞";
|
||||||
|
}
|
||||||
|
const roundedPosition = Math.round(v.state.getCurrentPosition() * 100) / 100;
|
||||||
|
let symbolState;
|
||||||
|
switch(state){
|
||||||
|
case "off":
|
||||||
|
symbolState = "⬛";
|
||||||
|
break;
|
||||||
|
case "idle":
|
||||||
|
symbolState = "⏸️";
|
||||||
|
break;
|
||||||
|
case "operational":
|
||||||
|
symbolState = "⏵️";
|
||||||
|
break;
|
||||||
|
case "starting":
|
||||||
|
symbolState = "⏯️";
|
||||||
|
break;
|
||||||
|
case "warmingup":
|
||||||
|
symbolState = "🔄";
|
||||||
|
break;
|
||||||
|
case "accelerating":
|
||||||
|
symbolState = "⏩";
|
||||||
|
break;
|
||||||
|
case "stopping":
|
||||||
|
symbolState = "⏹️";
|
||||||
|
break;
|
||||||
|
case "coolingdown":
|
||||||
|
symbolState = "❄️";
|
||||||
|
break;
|
||||||
|
case "decelerating":
|
||||||
|
symbolState = "⏪";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let status;
|
||||||
|
switch (state) {
|
||||||
|
case "off":
|
||||||
|
status = { fill: "red", shape: "dot", text: `${mode}: OFF` };
|
||||||
|
break;
|
||||||
|
case "idle":
|
||||||
|
status = { fill: "blue", shape: "dot", text: `${mode}: ${symbolState}` };
|
||||||
|
break;
|
||||||
|
case "operational":
|
||||||
|
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
||||||
|
break;
|
||||||
|
case "starting":
|
||||||
|
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
||||||
|
break;
|
||||||
|
case "warmingup":
|
||||||
|
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
||||||
|
break;
|
||||||
|
case "accelerating":
|
||||||
|
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar` }; //deltaP toegevoegd
|
||||||
|
break;
|
||||||
|
case "stopping":
|
||||||
|
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
||||||
|
break;
|
||||||
|
case "coolingdown":
|
||||||
|
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
||||||
|
break;
|
||||||
|
case "decelerating":
|
||||||
|
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} - ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = { fill: "grey", shape: "dot", text: `${mode}: ${symbolState}` };
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
} catch (error) {
|
||||||
|
node.error("Error in updateNodeStatus: " + error.message);
|
||||||
|
return { fill: "red", shape: "ring", text: "Status Error" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register this node as a child upstream and downstream.
|
||||||
|
* Delayed to avoid Node-RED startup race conditions.
|
||||||
|
*/
|
||||||
|
_registerChild() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.node.send([
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ topic: 'registerChild', payload: this.node.id , positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' },
|
||||||
|
]);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the periodic tick loop.
|
||||||
|
*/
|
||||||
|
_startTickLoop() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._tickInterval = setInterval(() => this._tick(), 1000);
|
||||||
|
|
||||||
|
// Update node status on nodered screen every second ( this is not the best way to do this, but it works for now)
|
||||||
|
this._statusInterval = setInterval(() => {
|
||||||
|
const status = this._updateNodeStatus();
|
||||||
|
this.node.status(status);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a single tick: update measurement, format and send outputs.
|
||||||
|
*/
|
||||||
|
_tick() {
|
||||||
|
//this.source.tick();
|
||||||
|
|
||||||
|
const raw = this.source.getOutput();
|
||||||
|
const processMsg = this._output.formatMsg(raw, this.config, 'process');
|
||||||
|
const influxMsg = this._output.formatMsg(raw, this.config, 'influxdb');
|
||||||
|
|
||||||
|
// Send only updated outputs on ports 0 & 1
|
||||||
|
this.node.send([processMsg, influxMsg]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach the node's input handler, routing control messages to the class.
|
||||||
|
*/
|
||||||
|
_attachInputHandler() {
|
||||||
|
this.node.on('input', (msg, send, done) => {
|
||||||
|
const v = this.source;
|
||||||
|
switch(msg.topic) {
|
||||||
|
case 'registerChild':
|
||||||
|
const childId = msg.payload;
|
||||||
|
const childObj = this.RED.nodes.getNode(childId);
|
||||||
|
v.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
||||||
|
break;
|
||||||
|
case 'setMode':
|
||||||
|
v.setMode(msg.payload);
|
||||||
|
break;
|
||||||
|
case 'execSequence':
|
||||||
|
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
||||||
|
v.handleInput(seqSource, seqAction, parameter);
|
||||||
|
break;
|
||||||
|
case 'execMovement':
|
||||||
|
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
||||||
|
v.handleInput(mvSource, mvAction, Number(setpoint));
|
||||||
|
break;
|
||||||
|
case 'emergencystop':
|
||||||
|
const { source: esSource, action: esAction } = msg.payload;
|
||||||
|
v.handleInput(esSource, esAction);
|
||||||
|
break;
|
||||||
|
case 'showcurve':
|
||||||
|
v.showCurve();
|
||||||
|
send({ topic : "Showing curve" , payload: v.showCurve() });
|
||||||
|
break;
|
||||||
|
case 'updateFlow': //Als nieuwe flow van header node dan moet deltaP weer opnieuw worden berekend en doorgegeven aan header node
|
||||||
|
v.updateFlow(msg.payload.variant, msg.payload.value, msg.payload.position);
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up timers and intervals when Node-RED stops the node.
|
||||||
|
*/
|
||||||
|
_attachCloseHandler() {
|
||||||
|
this.node.on('close', (done) => {
|
||||||
|
clearInterval(this._tickInterval);
|
||||||
|
clearInterval(this._statusInterval);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = nodeClass;
|
||||||
@@ -1,3 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* @file valve.js
|
||||||
|
*
|
||||||
|
* Permission is hereby granted to any person obtaining a copy of this software
|
||||||
|
* and associated documentation files (the "Software"), to use it for personal
|
||||||
|
* or non-commercial purposes, with the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. **No Copying or Redistribution**: The Software or any of its parts may not
|
||||||
|
* be copied, merged, distributed, sublicensed, or sold without explicit
|
||||||
|
* prior written permission from the author.
|
||||||
|
*
|
||||||
|
* 2. **Commercial Use**: Any use of the Software for commercial purposes requires
|
||||||
|
* a valid license, obtainable only with the explicit consent of the author.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* Ownership of this code remains solely with the original author. Unauthorized
|
||||||
|
* use of this Software is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Author:
|
||||||
|
* - Rene De Ren
|
||||||
|
* Email:
|
||||||
|
* - r.de.ren@brabantsedelta.nl
|
||||||
|
*
|
||||||
|
* Future Improvements:
|
||||||
|
* - Time-based stability checks
|
||||||
|
* - Warmup handling
|
||||||
|
* - Dynamic outlier detection thresholds
|
||||||
|
* - Dynamic smoothing window and methods
|
||||||
|
* - Alarm and threshold handling
|
||||||
|
* - Maintenance mode
|
||||||
|
* - Historical data and trend analysis
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @file valveClass.js
|
* @file valveClass.js
|
||||||
*
|
*
|
||||||
@@ -6,34 +45,34 @@
|
|||||||
....
|
....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//load local dependencies
|
||||||
//load local dependencies #NOTE: Vul hier nog de juiste dependencies in als meer nodig of sommige niet nodig
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const Logger = require('../../generalFunctions/helper/logger');
|
const {loadCurve,logger,configUtils,configManager,state, nrmse, MeasurementContainer, predict, interpolation , childRegistrationUtils} = require('generalFunctions');
|
||||||
const State = require('../../generalFunctions/helper/state/state');
|
|
||||||
const Predict = require('../../predict/dependencies/predict/predict_class');
|
|
||||||
const { MeasurementContainer } = require('../../generalFunctions/helper/measurements/index');
|
|
||||||
|
|
||||||
//load all config modules #NOTE: Vul hier nog de juiste dependencies in als meer nodig of sommige niet nodig
|
|
||||||
const defaultConfig = require('./valveConfig.json');
|
|
||||||
const ConfigUtils = require('../../generalFunctions/helper/configUtils');
|
|
||||||
|
|
||||||
//load registration utility #NOTE: Vul hier nog de juiste dependencies in als meer nodig of sommige niet nodig
|
|
||||||
const ChildRegistrationUtils = require('../../generalFunctions/helper/childRegistrationUtils');
|
|
||||||
|
|
||||||
class Valve {
|
class Valve {
|
||||||
constructor(valveConfig = {}, stateConfig = {}) {
|
constructor(valveConfig = {}, stateConfig = {}) {
|
||||||
this.emitter = new EventEmitter(); // nodig voor ontvangen en uitvoeren van events emit() en on() --> Zien als internet berichten (niet bedraad in node-red)
|
//basic setup
|
||||||
this.configUtils = new ConfigUtils(defaultConfig); // nodig voor het ophalen van de default configuaratie
|
this.emitter = new EventEmitter(); // nodig voor ontvangen en uitvoeren van events emit() --> Zien als internet berichten (niet bedraad in node-red)
|
||||||
this.config = this.configUtils.initConfig(valveConfig); //valve configurations die bij invoer in node-red worden gegeven
|
|
||||||
|
this.logger = new logger(valveConfig.general.logging.enabled,valveConfig.general.logging.logLevel, valveConfig.general.name);
|
||||||
|
this.configManager = new configManager();
|
||||||
|
this.defaultConfig = this.configManager.getConfig('valve'); // Load default config for rotating machine ( use software type name ? )
|
||||||
|
this.configUtils = new configUtils(this.defaultConfig);
|
||||||
|
|
||||||
|
// Load a specific curve
|
||||||
|
this.model = valveConfig.asset.model; // Get the model from the valveConfig
|
||||||
|
this.curve = this.model ? loadCurve(this.model) : null;
|
||||||
|
|
||||||
|
//Init config and check if it is valid
|
||||||
|
this.config = this.configUtils.initConfig(valveConfig);
|
||||||
|
|
||||||
// Initialize measurements
|
// Initialize measurements
|
||||||
this.measurements = new MeasurementContainer();
|
this.measurements = new MeasurementContainer();
|
||||||
this.child = {}; // object to hold child information so we know on what to subscribe
|
this.child = {}; // object to hold child information so we know on what to subscribe
|
||||||
|
|
||||||
// Init after config is set
|
// Init after config is set
|
||||||
this.logger = new Logger(this.config.general.logging.enabled, this.config.general.logging.logLevel, this.config.general.name);
|
this.state = new state(stateConfig, this.logger); // Init State manager and pass logger
|
||||||
this.state = new State(stateConfig, this.logger); // Init State manager and pass logger
|
|
||||||
this.state.stateManager.currentState = "operational"; // Set default state to operational
|
this.state.stateManager.currentState = "operational"; // Set default state to operational
|
||||||
|
|
||||||
this.kv = 0; //default
|
this.kv = 0; //default
|
||||||
@@ -48,11 +87,10 @@ class Valve {
|
|||||||
this.updatePosition()}); //To update deltaP
|
this.updatePosition()}); //To update deltaP
|
||||||
|
|
||||||
|
|
||||||
this.childRegistrationUtils = new ChildRegistrationUtils(this); // Child registration utility
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
||||||
|
this.vCurve = this.curve[1.204]; // specificy the desired density RECALC THIS AUTOMTICALLY BASED ON DENSITY OF AIR LATER OLIFANT!!
|
||||||
//replace v_curve loadspecs with config file afterwards !!!!!!!!!!
|
this.predictKv = new predict({curve:this.vCurve}); // load valve size (x : ctrl , y : kv relationship)
|
||||||
this.vCurve = this.loadSpecs().v_curve
|
console.log(`PredictKv initialized with curve: ${JSON.stringify(this.predictKv)}`);
|
||||||
this.predictKv = new Predict({curve:this.vCurve}); // load valve size (x : ctrl , y : kv relationship)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------- Config -------- //
|
// -------- Config -------- //
|
||||||
@@ -187,7 +225,24 @@ class Valve {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMeasurement(variant, subType, value, position) {
|
||||||
|
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
|
||||||
|
switch (subType) {
|
||||||
|
case "pressure":
|
||||||
|
// Update pressure measurement
|
||||||
|
//this.updatePressure(variant,value,position);
|
||||||
|
break;
|
||||||
|
case "flow":
|
||||||
|
this.updateFlow(variant,value,position);
|
||||||
|
break;
|
||||||
|
case "power":
|
||||||
|
// Update power measurement
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.logger.error(`Type '${subType}' not recognized for measured update.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Omdat met zeer kleine getallen wordt gewerkt en er kwadraten in de formule zitten kan het zijn dat we alles *1000 moeten doen
|
// NOTE: Omdat met zeer kleine getallen wordt gewerkt en er kwadraten in de formule zitten kan het zijn dat we alles *1000 moeten doen
|
||||||
updateDeltaPKlep(q,kv,downstreamP,rho,temp){
|
updateDeltaPKlep(q,kv,downstreamP,rho,temp){
|
||||||
@@ -218,15 +273,25 @@ class Valve {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Als er een nieuwe flow door de klep komt doordat de pompen harder zijn gaan pompen, dan update deze functie dit ook in de valve attributes en measurements
|
// Als er een nieuwe flow door de klep komt doordat de machines harder zijn gaan werken, dan update deze functie dit ook in de valve attributes en measurements
|
||||||
//NOTE: samenvoegen met updateFlow als header node er is
|
updateFlow(variant,value,position) {
|
||||||
updateFlowKlep(q){
|
|
||||||
//q must be in Nm3/h
|
switch (variant) {
|
||||||
// Opslaan in measurement container van valve object
|
case ("measured"):
|
||||||
this.measurements.type("flow").variant("predicted").position("downstream").value(q);
|
// put value in measurements
|
||||||
this.logger.info('FlowKlep updated to: ' + q);
|
this.measurements.type("flow").variant("measured").position(position).value(value);
|
||||||
this.logger.info('Calculating new deltaP based on new flow');
|
const downStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
||||||
this.updateDeltaPKlep(q,this.kv,this.downstreamP,this.rho,this.T); //update deltaP based on new flow
|
this.updateDeltaPKlep(value,this.kv,downStreamP,this.rho,this.T); //update deltaP based on new flow
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ("predicted"):
|
||||||
|
this.logger.debug('not doing anythin yet');
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
this.logger.warn(`Unrecognized variant '${variant}' for flow update.`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePosition() { //update alle parameters nadat er een verandering is geweest in stand van klep
|
updatePosition() { //update alle parameters nadat er een verandering is geweest in stand van klep
|
||||||
@@ -234,11 +299,10 @@ class Valve {
|
|||||||
|
|
||||||
this.logger.debug('Calculating new deltaP');
|
this.logger.debug('Calculating new deltaP');
|
||||||
const currentPosition = this.state.getCurrentPosition();
|
const currentPosition = this.state.getCurrentPosition();
|
||||||
const currentFlow = this.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue(); // haal de flow op uit de measurement containe
|
const currentFlow = this.measurements.type("flow").variant("measured").position("downstream").getCurrentValue(); // haal de flow op uit de measurement containe
|
||||||
|
const downstreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); // haal de downstream pressure op uit de measurement container
|
||||||
//const valveSize = 125; //NOTE: nu nog hardcoded maar moet een attribute van de valve worden
|
//const valveSize = 125; //NOTE: nu nog hardcoded maar moet een attribute van de valve worden
|
||||||
this.predictKv.fDimension = 125; //load valve size by defining fdimension in predict class
|
this.predictKv.fDimension = 125; //load valve size by defining fdimension in predict class
|
||||||
//const vCurve = this.loadSpecs().v_curve[valveSize]; // haal de curve op van de valve
|
|
||||||
//const Spline = require('cubic-spline'); // spline library -> nodig om kv waarde te benaderen op curve
|
|
||||||
const x = currentPosition; // dit is de positie van de klep waarvoor we delta P willen berekenen
|
const x = currentPosition; // dit is de positie van de klep waarvoor we delta P willen berekenen
|
||||||
const y = this.predictKv.y(x); // haal de waarde van kv op uit de spline
|
const y = this.predictKv.y(x); // haal de waarde van kv op uit de spline
|
||||||
|
|
||||||
@@ -247,7 +311,8 @@ class Valve {
|
|||||||
this.kv = 0.1; //minimum waarde voor kv
|
this.kv = 0.1; //minimum waarde voor kv
|
||||||
}
|
}
|
||||||
this.logger.debug(`Kv value for position valve ${x} is ${this.kv}`); // log de waarde van kv
|
this.logger.debug(`Kv value for position valve ${x} is ${this.kv}`); // log de waarde van kv
|
||||||
this.updateDeltaPKlep(currentFlow,this.kv,this.downstreamP,this.rho,this.T); //update deltaP
|
|
||||||
|
this.updateDeltaPKlep(currentFlow,this.kv,downstreamP,this.rho,this.T); //update deltaP
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
318
valve.html
318
valve.html
@@ -1,275 +1,117 @@
|
|||||||
<!--<script src="resources/wbd-valve/unit_class.js"></script>-->
|
|
||||||
<script type="module">
|
|
||||||
import * as menuUtils from "/generalFunctions/helper/menuUtils.js"; //CHANGED to import the menuUtils module
|
|
||||||
|
|
||||||
RED.nodes.registerType('valve',{
|
<script src="/valve/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
|
||||||
category: 'digital twin',
|
<script src="/valve/configData.js"></script> <!-- Load the config script for node information -->
|
||||||
color: '#e4a363',
|
|
||||||
|
<script>
|
||||||
|
RED.nodes.registerType("valve", {
|
||||||
|
category: "EVOLV",
|
||||||
|
color: "#e4a363", // color for the node based on the S88 schema
|
||||||
defaults: {
|
defaults: {
|
||||||
|
|
||||||
// Define default properties
|
// Define default properties
|
||||||
name: { value: "", required: true },
|
name: { value: "" }, // use asset category as name
|
||||||
|
|
||||||
|
// Define specific properties
|
||||||
|
speed: { value: 1, required: true },
|
||||||
|
|
||||||
|
//define asset properties
|
||||||
|
uuid: { value: "" },
|
||||||
|
supplier: { value: "" },
|
||||||
|
category: { value: "" },
|
||||||
|
assetType: { value: "" },
|
||||||
|
model: { value: "" },
|
||||||
|
unit: { value: "" },
|
||||||
|
|
||||||
|
//logger properties
|
||||||
enableLog: { value: false },
|
enableLog: { value: false },
|
||||||
logLevel: { value: "error" },
|
logLevel: { value: "error" },
|
||||||
|
|
||||||
// Define specific properties
|
//physicalAspect
|
||||||
/* NOT USED
|
positionVsParent: { value: "" },
|
||||||
speed: { value: 1, required: true },
|
positionIcon: { value: "" },
|
||||||
startup: { value: 0 },
|
|
||||||
warmup: { value: 0 },
|
|
||||||
shutdown: { value: 0 },
|
|
||||||
cooldown: { value: 0 },
|
|
||||||
*/
|
|
||||||
|
|
||||||
//define general asset properties
|
|
||||||
supplier: { value: "" }, // laten staan als voorbeeld
|
|
||||||
/*NOT USED
|
|
||||||
subType: { value: "" },
|
|
||||||
model: { value: "" },
|
|
||||||
unit: { value: "" },*/
|
|
||||||
|
|
||||||
//define specific asset properties
|
|
||||||
/*NOT USED
|
|
||||||
valveCurve : { value: {}},*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//inputs en outputs voor node
|
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 4,
|
outputs: 3,
|
||||||
inputLabels: ["Valve Input"],
|
inputLabels: ["Input"],
|
||||||
outputLabels: ["proces", "dbase", "upstream parent", "downstream parent"],
|
outputLabels: ["process", "dbase", "parent"],
|
||||||
icon: "font-awesome/fa-sliders", //CHANGED to other icon from Font Awesome 4
|
icon: "font-awesome/fa-tachometer",
|
||||||
|
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || "Valve"; //CHANGED to Valve
|
return this.positionIcon + " " + this.assetType || "valve";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Prepare for opening bewerkingsinterface van node in de Node-RED editor
|
oneditprepare: function() {
|
||||||
oneditprepare: function () {
|
const waitForMenuData = () => {
|
||||||
const node = this;
|
if (window.EVOLV?.nodes?.measurement?.initEditor) {
|
||||||
|
window.EVOLV.nodes.measurement.initEditor(this);
|
||||||
console.log("Valve Node: Edit Prepare"); //CHANGED to Valve Node
|
} else {
|
||||||
|
setTimeout(waitForMenuData, 50);
|
||||||
const elements = {
|
}
|
||||||
// Basic fields
|
|
||||||
name: document.getElementById("node-input-name"),
|
|
||||||
// specific fields
|
|
||||||
/*NOT USED
|
|
||||||
speed: document.getElementById("node-input-speed"),
|
|
||||||
startup: document.getElementById("node-input-startup"),
|
|
||||||
warmup: document.getElementById("node-input-warmup"),
|
|
||||||
shutdown: document.getElementById("node-input-shutdown"),
|
|
||||||
cooldown: document.getElementById("node-input-cooldown"),*/
|
|
||||||
// Logging fields
|
|
||||||
logCheckbox: document.getElementById("node-input-enableLog"),
|
|
||||||
logLevelSelect: document.getElementById("node-input-logLevel"),
|
|
||||||
rowLogLevel: document.getElementById("row-logLevel"),
|
|
||||||
// Asset fields
|
|
||||||
supplier: document.getElementById("node-input-supplier"),
|
|
||||||
/*NOT USED
|
|
||||||
subType: document.getElementById("node-input-subType"),
|
|
||||||
model: document.getElementById("node-input-model"),
|
|
||||||
unit: document.getElementById("node-input-unit"), */
|
|
||||||
};
|
};
|
||||||
|
// Wait for the menu data to be ready before initializing the editor
|
||||||
|
waitForMenuData();
|
||||||
|
|
||||||
const projecSettingstURL = "http://localhost:1880/generalFunctions/settings/projectSettings.json"; //volgens mij hoeft deze niet aangepast?
|
// THIS IS NODE SPECIFIC --------------- Initialize the dropdowns and other specific UI elements -------------- this should be derived from the config in the future (make config based menu)
|
||||||
|
document.getElementById("node-input-speed");
|
||||||
try{
|
//------------------- END OF CUSTOM config UI ELEMENTS ------------------- //
|
||||||
|
|
||||||
// Fetch project settings
|
|
||||||
menuUtils.fetchProjectData(projecSettingstURL)
|
|
||||||
.then((projectSettings) => {
|
|
||||||
|
|
||||||
//assign to node vars
|
|
||||||
node.configUrls = projectSettings.configUrls;
|
|
||||||
|
|
||||||
const { cloudConfigURL, localConfigURL } = menuUtils.getSpecificConfigUrl("valve",node.configUrls.cloud.taggcodeAPI); //CHANGED to valve
|
|
||||||
node.configUrls.cloud.config = cloudConfigURL; // first call
|
|
||||||
node.configUrls.local.config = localConfigURL; // backup call
|
|
||||||
|
|
||||||
node.locationId = projectSettings.locationId;
|
|
||||||
node.uuid = projectSettings.uuid;
|
|
||||||
|
|
||||||
// Gets the ID of the active workspace (Flow)
|
|
||||||
const activeFlowId = RED.workspaces.active(); //fetches active flow id
|
|
||||||
node.processId = activeFlowId;
|
|
||||||
|
|
||||||
// UI elements
|
|
||||||
menuUtils.initBasicToggles(elements);
|
|
||||||
menuUtils.fetchAndPopulateDropdowns(node.configUrls, elements, node); // function for all assets
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}catch(e){
|
|
||||||
console.log("Error fetching project settings", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(node.d){
|
|
||||||
//this means node is disabled
|
|
||||||
console.log("Current status of node is disabled");
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
oneditsave: function () {
|
oneditsave: function () {
|
||||||
const node = this;
|
const node = this;
|
||||||
|
|
||||||
console.log(`------------ Saving changes to node ------------`);
|
// Validate asset properties using the asset menu
|
||||||
console.log(`${node.uuid}`);
|
if (window.EVOLV?.nodes?.valve?.assetMenu?.saveEditor) {
|
||||||
|
success = window.EVOLV.nodes.valve.assetMenu.saveEditor(this);
|
||||||
|
}
|
||||||
|
|
||||||
//save basic properties
|
// Validate logger properties using the logger menu
|
||||||
["name", "supplier"].forEach( //CHANGED to only save the properties we have now
|
if (window.EVOLV?.nodes?.valve?.loggerMenu?.saveEditor) {
|
||||||
(field) => {
|
success = window.EVOLV.nodes.valve.loggerMenu.saveEditor(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save position field
|
||||||
|
if (window.EVOLV?.nodes?.valve?.positionMenu?.saveEditor) {
|
||||||
|
window.EVOLV.nodes.valve.positionMenu.saveEditor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
["speed"].forEach((field) => {
|
||||||
const element = document.getElementById(`node-input-${field}`);
|
const element = document.getElementById(`node-input-${field}`);
|
||||||
if (element) {
|
const value = parseFloat(element?.value) || 0;
|
||||||
node[field] = element.value || "";
|
console.log(`----------------> Saving ${field}: ${value}`);
|
||||||
}
|
node[field] = value;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const logLevelElement = document.getElementById("node-input-logLevel");
|
|
||||||
node.logLevel = logLevelElement ? logLevelElement.value || "info" : "info";
|
|
||||||
|
|
||||||
if (!node.unit) {
|
|
||||||
RED.notify("Unit selection is required.", "error");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.subType && !node.unit) {
|
|
||||||
RED.notify("Unit must be set when specifying a subtype.", "error");
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
// Fetch project settings
|
|
||||||
menuUtils.apiCall(node,node.configUrls)
|
|
||||||
.then((response) => {
|
|
||||||
|
|
||||||
//save response to node information
|
|
||||||
node.assetId = response.asset_id;
|
|
||||||
node.assetTagNumber = response.asset_tag_number;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log("Error during API call", error);
|
|
||||||
});
|
});
|
||||||
}catch(e){
|
|
||||||
console.log("Error saving assetID and tagnumber", e);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
</script>
|
<!-- Main UI -->
|
||||||
|
|
||||||
<!-- Main UI Template -->
|
<script type="text/html" data-template-name="valve">
|
||||||
<script type="text/html" data-template-name="valve">
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="node-input-name"
|
|
||||||
placeholder="Valve Name"
|
|
||||||
style="width:70%;"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- NOT USED
|
<!-- Node-specific controls -->
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-startup"><i class="fa fa-clock-o"></i> Startup Time</label>
|
<label for="node-input-speed"><i class="fa fa-clock-o"></i> Reaction Speed</label>
|
||||||
<input type="number" id="node-input-startup" placeholder="0" />
|
<input type="number" id="node-input-speed" style="width:60%;" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<!-- Optional Extended Fields: supplier, cat, type, model, unit -->
|
||||||
<label for="node-input-warmup"><i class="fa fa-clock-o"></i> Warmup Time</label>
|
<!-- Asset fields will be injected here -->
|
||||||
<input type="number" id="node-input-warmup" placeholder="0" />
|
<div id="asset-fields-placeholder"></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-shutdown"><i class="fa fa-clock-o"></i> Shutdown Time</label>
|
|
||||||
<input type="number" id="node-input-shutdown" placeholder="0" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-cooldown"><i class="fa fa-clock-o"></i> Cooldown Time</label>
|
|
||||||
<input type="number" id="node-input-cooldown" placeholder="0" />
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Optional Extended Fields: supplier, type, subType, model
|
|
||||||
<hr />
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-supplier"
|
|
||||||
><i class="fa fa-industry"></i> Supplier</label
|
|
||||||
>
|
|
||||||
<select id="node-input-supplier" style="width:60%;">
|
|
||||||
<option value="">(optional)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- NOT USED
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-subType"
|
|
||||||
><i class="fa fa-puzzle-piece"></i> SubType</label
|
|
||||||
>
|
|
||||||
<select id="node-input-subType" style="width:60%;">
|
|
||||||
<option value="">(optional)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-model"><i class="fa fa-wrench"></i> Model</label>
|
|
||||||
<select id="node-input-model" style="width:60%;">
|
|
||||||
<option value="">(optional)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-unit"><i class="fa fa-balance-scale"></i> Unit</label>
|
|
||||||
<select id="node-input-unit" style="width:60%;"></select>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<!-- loglevel checkbox -->
|
<!-- loglevel checkbox -->
|
||||||
<div class="form-row">
|
<div id="logger-fields-placeholder"></div>
|
||||||
<label for="node-input-enableLog"
|
|
||||||
><i class="fa fa-cog"></i> Enable Log</label
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="node-input-enableLog"
|
|
||||||
style="width:20px; vertical-align:baseline;"
|
|
||||||
/>
|
|
||||||
<span>Enable logging</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row" id="row-logLevel">
|
<!-- Position fields will be injected here -->
|
||||||
<label for="node-input-logLevel"><i class="fa fa-cog"></i> Log Level</label>
|
<div id="position-fields-placeholder"></div>
|
||||||
<select id="node-input-logLevel" style="width:60%;">
|
|
||||||
<option value="info">Info</option>
|
|
||||||
<option value="debug">Debug</option>
|
|
||||||
<option value="warn">Warn</option>
|
|
||||||
<option value="error">Error</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Help Text Template -->
|
|
||||||
<script type="text/html" data-help-name="valve">
|
<script type="text/html" data-help-name="valve">
|
||||||
<p>
|
<p><b>Valve Node</b>: Controls the flow of data through a valve-like mechanism.</p>
|
||||||
<b>Valve Node</b>: Configure the behavior of a valve
|
<p>This node is used to manage the flow of data in a process, similar to how a valve controls the flow of liquids or gases.</p>
|
||||||
used in a digital twin.
|
|
||||||
</p>
|
</script>
|
||||||
<ul>
|
|
||||||
<!-- NOT USED
|
|
||||||
<li><b>Supplier:</b> Select a supplier to populate valve options.</li>
|
|
||||||
<li><b>SubType:</b> Select a subtype if applicable to further categorize the asset.</li>
|
|
||||||
<li><b>Model:</b> Define the specific model for more granular asset configuration.</li>
|
|
||||||
<li><b>Unit:</b> Assign a unit to standardize measurements or operations.</li>
|
|
||||||
<li><b>Speed:</b> Reaction speed of the machine in response to inputs.</li>
|
|
||||||
<li><b>Startup:</b> Define the startup time for the machine.</li>
|
|
||||||
<li><b>Warmup:</b> Define the warmup time for the machine.</li>
|
|
||||||
<li><b>Shutdown:</b> Define the shutdown time for the machine.</li>
|
|
||||||
<li><b>Cooldown:</b> Define the cooldown time for the machine.</li>
|
|
||||||
-->
|
|
||||||
<li><b>Enable Log:</b> Enable or disable logging for the valve.</li>
|
|
||||||
<li><b>Log Level:</b> Set the log level (Info, Debug, Warn, Error).</li>
|
|
||||||
</ul>
|
|
||||||
</script>
|
|
||||||
|
|||||||
272
valve.js
272
valve.js
@@ -1,250 +1,40 @@
|
|||||||
module.exports = function (RED) {
|
const nameOfNode = 'valve'; // this is the name of the node, it should match the file name and the node type in Node-RED
|
||||||
function valve(config) {
|
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
|
||||||
//create node
|
const { MenuManager, configManager } = require('generalFunctions');
|
||||||
|
|
||||||
|
// This is the main entry point for the Node-RED node, it will register the node and setup the endpoints
|
||||||
|
module.exports = function(RED) {
|
||||||
|
// Register the node type
|
||||||
|
RED.nodes.registerType(nameOfNode, function(config) {
|
||||||
|
// Initialize the Node-RED node first
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
//call this => node so whenver you want to call a node function type node and the function behind it
|
// Then create your custom class and attach it
|
||||||
var node = this;
|
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Setup admin UIs
|
||||||
|
const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically
|
||||||
|
const cfgMgr = new configManager(); // this will handle the config endpoints so we can load them dynamically
|
||||||
|
|
||||||
|
// Register the different menu's for the measurement node (in the future we could automate this further by refering to the config)
|
||||||
|
RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
|
||||||
try {
|
try {
|
||||||
const Valve = require("./dependencies/valveClass"); // Importeer de valve class
|
const script = menuMgr.createEndpoint(nameOfNode, ['asset','logger','position']);
|
||||||
const OutputUtils = require("../generalFunctions/helper/outputUtils"); // Importeer de OutputUtils class
|
res.type('application/javascript').send(script);
|
||||||
|
} catch (err) {
|
||||||
const valveConfig = { // Configuratie van de valve
|
res.status(500).send(`// Error generating menu: ${err.message}`);
|
||||||
general: {
|
|
||||||
name: config.name || "Default Valve",
|
|
||||||
id: node.id,
|
|
||||||
logging: {
|
|
||||||
enabled: config.eneableLog,
|
|
||||||
logLevel: config.logLevel
|
|
||||||
}
|
|
||||||
},
|
|
||||||
asset: {
|
|
||||||
supplier: config.supplier || "Unknown",
|
|
||||||
/* NOT USED
|
|
||||||
type: config.valveType || "generic",
|
|
||||||
subType: config.subType || "generic",
|
|
||||||
model: config.model || "generic",
|
|
||||||
valveCurve: config.valveCurve */
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const stateConfig = { // Configuratie van de state
|
|
||||||
general: {
|
|
||||||
logging: {
|
|
||||||
enabled: config.eneableLog,
|
|
||||||
logLevel: config.logLevel
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* NOT USED
|
|
||||||
movement: {
|
|
||||||
speed: Number(config.speed)
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
starting: Number(config.startup),
|
|
||||||
warmingup: Number(config.warmup),
|
|
||||||
stopping: Number(config.shutdown),
|
|
||||||
coolingdown: Number(config.cooldown)
|
|
||||||
} */
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create valve instance
|
|
||||||
const v = new Valve(valveConfig, stateConfig);
|
|
||||||
|
|
||||||
// put m on node memory as source
|
|
||||||
node.source = v;
|
|
||||||
|
|
||||||
//load output utils
|
|
||||||
const output = new OutputUtils();
|
|
||||||
|
|
||||||
//Hier worden node-red statussen en metingen geupdate
|
|
||||||
function updateNodeStatus() {
|
|
||||||
try {
|
|
||||||
const mode = v.currentMode; // modus is bijv. auto, manual, etc.
|
|
||||||
const state = v.state.getCurrentState(); //is bijv. operational, idle, off, etc.
|
|
||||||
const flow = Math.round(v.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue());
|
|
||||||
let deltaP = v.measurements.type("pressure").variant("predicted").position("delta").getCurrentValue();
|
|
||||||
if (deltaP !== null) {
|
|
||||||
deltaP = parseFloat(deltaP.toFixed(0));
|
|
||||||
} //afronden op 4 decimalen indien geen "null"
|
|
||||||
if(isNaN(deltaP)) {
|
|
||||||
deltaP = "∞";
|
|
||||||
}
|
|
||||||
const roundedPosition = Math.round(v.state.getCurrentPosition() * 100) / 100;
|
|
||||||
let symbolState;
|
|
||||||
switch(state){
|
|
||||||
case "off":
|
|
||||||
symbolState = "⬛";
|
|
||||||
break;
|
|
||||||
case "idle":
|
|
||||||
symbolState = "⏸️";
|
|
||||||
break;
|
|
||||||
case "operational":
|
|
||||||
symbolState = "⏵️";
|
|
||||||
break;
|
|
||||||
case "starting":
|
|
||||||
symbolState = "⏯️";
|
|
||||||
break;
|
|
||||||
case "warmingup":
|
|
||||||
symbolState = "🔄";
|
|
||||||
break;
|
|
||||||
case "accelerating":
|
|
||||||
symbolState = "⏩";
|
|
||||||
break;
|
|
||||||
case "stopping":
|
|
||||||
symbolState = "⏹️";
|
|
||||||
break;
|
|
||||||
case "coolingdown":
|
|
||||||
symbolState = "❄️";
|
|
||||||
break;
|
|
||||||
case "decelerating":
|
|
||||||
symbolState = "⏪";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let status;
|
|
||||||
switch (state) {
|
|
||||||
case "off":
|
|
||||||
status = { fill: "red", shape: "dot", text: `${mode}: OFF` };
|
|
||||||
break;
|
|
||||||
case "idle":
|
|
||||||
status = { fill: "blue", shape: "dot", text: `${mode}: ${symbolState}` };
|
|
||||||
break;
|
|
||||||
case "operational":
|
|
||||||
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
|
||||||
break;
|
|
||||||
case "starting":
|
|
||||||
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
|
||||||
break;
|
|
||||||
case "warmingup":
|
|
||||||
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
|
||||||
break;
|
|
||||||
case "accelerating":
|
|
||||||
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar` }; //deltaP toegevoegd
|
|
||||||
break;
|
|
||||||
case "stopping":
|
|
||||||
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
|
||||||
break;
|
|
||||||
case "coolingdown":
|
|
||||||
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
|
|
||||||
break;
|
|
||||||
case "decelerating":
|
|
||||||
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} - ${roundedPosition}% | 💨${flow}m³/h | ΔP${deltaP} mbar`}; //deltaP toegevoegd
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
status = { fill: "grey", shape: "dot", text: `${mode}: ${symbolState}` };
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
} catch (error) {
|
|
||||||
node.error("Error in updateNodeStatus: " + error.message);
|
|
||||||
return { fill: "red", shape: "ring", text: "Status Error" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tick() { // versturen van output messages --> tick van tick op de klop. Is tijd based en niet event based
|
|
||||||
try {
|
|
||||||
const status = updateNodeStatus();
|
|
||||||
node.status(status);
|
|
||||||
|
|
||||||
//v.tick();
|
|
||||||
|
|
||||||
//get output
|
|
||||||
const classOutput = v.getOutput();
|
|
||||||
const dbOutput = output.formatMsg(classOutput, v.config, "influxdb");
|
|
||||||
const pOutput = output.formatMsg(classOutput, v.config, "process");
|
|
||||||
|
|
||||||
//only send output on values that changed
|
|
||||||
let msgs = [];
|
|
||||||
msgs[0] = pOutput;
|
|
||||||
msgs[1] = dbOutput;
|
|
||||||
|
|
||||||
node.send(msgs);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
node.error("Error in tick function: " + error);
|
|
||||||
node.status({ fill: "red", shape: "ring", text: "Tick Error" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register child on first output this timeout is needed because of node - red stuff
|
|
||||||
setTimeout(
|
|
||||||
() => {
|
|
||||||
|
|
||||||
/*---execute code on first start----*/
|
|
||||||
let msgs = [];
|
|
||||||
|
|
||||||
msgs[2] = { topic : "registerChild" , payload: node.id, positionVsParent: "upStream" };
|
|
||||||
msgs[3] = { topic : "registerChild" , payload: node.id, positionVsParent: "downStream" };
|
|
||||||
|
|
||||||
//send msg
|
|
||||||
node.send(msgs);
|
|
||||||
},
|
|
||||||
100
|
|
||||||
);
|
|
||||||
|
|
||||||
//declare refresh interval internal node
|
|
||||||
|
|
||||||
setTimeout(
|
|
||||||
() => {
|
|
||||||
//---execute code on first start----
|
|
||||||
this.interval_id = setInterval(function(){ tick() },1000)
|
|
||||||
},
|
|
||||||
1000
|
|
||||||
);
|
|
||||||
|
|
||||||
node.on("input", function(msg, send, done) { // Functie die wordt aangeroepen wanneer er een input wordt ontvangen
|
|
||||||
console.log("CKECK! Input received: ", msg.topic, msg.payload); // CHECKPOINT
|
|
||||||
try {
|
|
||||||
let result;
|
|
||||||
switch(msg.topic) {
|
|
||||||
case 'registerChild':
|
|
||||||
const childId = msg.payload;
|
|
||||||
const childObj = RED.nodes.getNode(childId);
|
|
||||||
v.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
|
||||||
break;
|
|
||||||
case 'setMode':
|
|
||||||
v.setMode(msg.payload);
|
|
||||||
break;
|
|
||||||
case 'execSequence':
|
|
||||||
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
|
||||||
v.handleInput(seqSource, seqAction, parameter);
|
|
||||||
break;
|
|
||||||
case 'execMovement':
|
|
||||||
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
|
||||||
v.handleInput(mvSource, mvAction, Number(setpoint));
|
|
||||||
break;
|
|
||||||
case 'emergencystop':
|
|
||||||
const { source: esSource, action: esAction } = msg.payload;
|
|
||||||
v.handleInput(esSource, esAction);
|
|
||||||
break;
|
|
||||||
case 'showcurve':
|
|
||||||
v.showCurve();
|
|
||||||
send({ topic : "Showing curve" , payload: v.showCurve() });
|
|
||||||
break;
|
|
||||||
case 'newFlow': //Als nieuwe flow van header node dan moet deltaP weer opnieuw worden berekend en doorgegeven aan header node
|
|
||||||
const { source: nfSource, action: nfAction, parameter: nfParameter } = msg.payload; //parameter is new flow, action should be "calcNewDeltaP"
|
|
||||||
v.handleInput(nfSource, nfAction, nfParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done) done();
|
|
||||||
} catch (error) {
|
|
||||||
node.error("Error processing input: " + error.message);
|
|
||||||
if (done) done(error);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
node.on('close', function(done) { // Functie die wordt aangeroepen wanneer de node wordt gesloten
|
// Endpoint to get the configuration data for the specific node
|
||||||
if (node.interval_id) clearTimeout(node.interval_id);
|
RED.httpAdmin.get(`/${nameOfNode}/configData.js`, (req, res) => {
|
||||||
if (node.tick_interval) clearInterval(node.tick_interval);
|
try {
|
||||||
if (done) done();
|
const script = cfgMgr.createEndpoint(nameOfNode);
|
||||||
|
// Send the configuration data as JSON response
|
||||||
|
res.type('application/javascript').send(script);
|
||||||
|
} catch (err) {
|
||||||
|
res.status(500).send(`// Error generating configData: ${err.message}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
node.error("Fatal error in node initialization: " + error.stack);
|
|
||||||
node.status({fill: "red", shape: "ring", text: "Fatal Error"});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
RED.nodes.registerType("valve", valve);
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user