Compare commits
3 Commits
c037bbc73b
...
d94d5874bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d94d5874bc | ||
|
|
fa30be5e2d | ||
|
|
856477df57 |
12
package.json
12
package.json
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "basin",
|
"name": "pumpingstation",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Control module",
|
"description": "Control module",
|
||||||
"main": "basin.js",
|
"main": "pumpingStation.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node basin.js"
|
"test": "node pumpingStation.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea.centraal.wbd-rd.nl/RnD/basin.git"
|
"url": "https://gitea.centraal.wbd-rd.nl/RnD/pumpingStation.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"basin",
|
"pumpingstation",
|
||||||
"node-red",
|
"node-red",
|
||||||
"recipient",
|
"recipient",
|
||||||
"water"
|
"water"
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"node-red": {
|
"node-red": {
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"basin": "basin.js"
|
"pumpingstation": "pumpingStation.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
|
<!--
|
||||||
|
| S88-niveau | Primair (blokkleur) | Tekstkleur |
|
||||||
|
| ---------------------- | ------------------- | ---------- |
|
||||||
|
| **Area** | `#0f52a5` | wit |
|
||||||
|
| **Process Cell** | `#0c99d9` | wit |
|
||||||
|
| **Unit** | `#50a8d9` | zwart |
|
||||||
|
| **Equipment (Module)** | `#86bbdd` | zwart |
|
||||||
|
| **Control Module** | `#a9daee` | zwart |
|
||||||
|
|
||||||
<script src="/measurement/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
|
-->
|
||||||
<script src="/measurement/configData.js"></script> <!-- Load the config script for node information -->
|
<script src="/pumpingStation/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
|
||||||
|
<script src="/pumpingStation/configData.js"></script> <!-- Load the config script for node information -->
|
||||||
|
|
||||||
<script>
|
<script>//test
|
||||||
RED.nodes.registerType("measurement", {
|
RED.nodes.registerType("pumpingStation", {
|
||||||
category: "EVOLV",
|
category: "EVOLV",
|
||||||
color: "#e4a363", // color for the node based on the S88 schema
|
color: "#0c99d9", // color for the node based on the S88 schema
|
||||||
defaults: {
|
defaults: {
|
||||||
|
|
||||||
// Define default properties
|
|
||||||
name: { value: "sensor" }, // use asset category as name
|
|
||||||
|
|
||||||
// Define specific properties
|
// Define specific properties
|
||||||
scaling: { value: false },
|
scaling: { value: false },
|
||||||
i_min: { value: 0, required: true },
|
i_min: { value: 0, required: true },
|
||||||
@@ -48,16 +54,16 @@
|
|||||||
outputs: 3,
|
outputs: 3,
|
||||||
inputLabels: ["Input"],
|
inputLabels: ["Input"],
|
||||||
outputLabels: ["process", "dbase", "parent"],
|
outputLabels: ["process", "dbase", "parent"],
|
||||||
icon: "font-awesome/fa-tachometer",
|
icon: "font-awesome/fa-tint",
|
||||||
|
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.positionIcon + " " + this.assetType || "Measurement";
|
return this.positionIcon + " " + this.assetType || "pumpingStation";
|
||||||
},
|
},
|
||||||
|
|
||||||
oneditprepare: function() {
|
oneditprepare: function() {
|
||||||
const waitForMenuData = () => {
|
const waitForMenuData = () => {
|
||||||
if (window.EVOLV?.nodes?.measurement?.initEditor) {
|
if (window.EVOLV?.nodes?.pumpingStation?.initEditor) {
|
||||||
window.EVOLV.nodes.measurement.initEditor(this);
|
window.EVOLV.nodes.pumpingStation.initEditor(this);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(waitForMenuData, 50);
|
setTimeout(waitForMenuData, 50);
|
||||||
}
|
}
|
||||||
@@ -68,7 +74,7 @@
|
|||||||
// 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)
|
// 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)
|
||||||
// Populate smoothing methods dropdown
|
// Populate smoothing methods dropdown
|
||||||
const smoothMethodSelect = document.getElementById('node-input-smooth_method');
|
const smoothMethodSelect = document.getElementById('node-input-smooth_method');
|
||||||
const options = window.EVOLV?.nodes?.measurement?.config?.smoothing?.smoothMethod?.rules?.values || [];
|
const options = window.EVOLV?.nodes?.pumpingStation?.config?.smoothing?.smoothMethod?.rules?.values || [];
|
||||||
|
|
||||||
// Clear existing options
|
// Clear existing options
|
||||||
smoothMethodSelect.innerHTML = '';
|
smoothMethodSelect.innerHTML = '';
|
||||||
@@ -114,18 +120,18 @@
|
|||||||
const node = this;
|
const node = this;
|
||||||
|
|
||||||
// Validate asset properties using the asset menu
|
// Validate asset properties using the asset menu
|
||||||
if (window.EVOLV?.nodes?.measurement?.assetMenu?.saveEditor) {
|
if (window.EVOLV?.nodes?.pumpingStation?.assetMenu?.saveEditor) {
|
||||||
success = window.EVOLV.nodes.measurement.assetMenu.saveEditor(this);
|
success = window.EVOLV.nodes.pumpingStation.assetMenu.saveEditor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate logger properties using the logger menu
|
// Validate logger properties using the logger menu
|
||||||
if (window.EVOLV?.nodes?.measurement?.loggerMenu?.saveEditor) {
|
if (window.EVOLV?.nodes?.pumpingStation?.loggerMenu?.saveEditor) {
|
||||||
success = window.EVOLV.nodes.measurement.loggerMenu.saveEditor(node);
|
success = window.EVOLV.nodes.pumpingStation.loggerMenu.saveEditor(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
// save position field
|
// save position field
|
||||||
if (window.EVOLV?.nodes?.measurement?.positionMenu?.saveEditor) {
|
if (window.EVOLV?.nodes?.pumpingStation?.positionMenu?.saveEditor) {
|
||||||
window.EVOLV.nodes.measurement.positionMenu.saveEditor(this);
|
window.EVOLV.nodes.pumpingStation.positionMenu.saveEditor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save basic properties
|
// Save basic properties
|
||||||
@@ -153,7 +159,7 @@
|
|||||||
|
|
||||||
<!-- Main UI -->
|
<!-- Main UI -->
|
||||||
|
|
||||||
<script type="text/html" data-template-name="measurement">
|
<script type="text/html" data-template-name="pumpingStation">
|
||||||
|
|
||||||
<!-- Scaling Checkbox -->
|
<!-- Scaling Checkbox -->
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@@ -224,21 +230,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/html" data-help-name="measurement">
|
<script type="text/html" data-help-name="pumpingStation">
|
||||||
<p><b>Measurement Node</b>: Scales, smooths, and simulates measurement data.</p>
|
|
||||||
<p>Use this node to scale, smooth, and simulate measurement data. The node can be configured to scale input data to a specified range, smooth the data using a variety of methods, and simulate data for testing purposes.</p>
|
|
||||||
<li><b>Supplier:</b> Select a supplier to populate machine 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>Scaling:</b> Enable or disable input scaling. When enabled, you must provide the source min and max values.</li>
|
|
||||||
<li><b>Source Min/Max:</b> Define the minimum and maximum values for the input range when scaling is enabled.</li>
|
|
||||||
<li><b>Input Offset:</b> Specify an offset value to be added to the input measurement.</li>
|
|
||||||
<li><b>Process Min/Max:</b> Define the minimum and maximum values for the output range after processing.</li>
|
|
||||||
<li><b>Simulator:</b> Activate internal simulation for testing purposes.</li>
|
|
||||||
<li><b>Smoothing:</b> Select a smoothing method to apply to the measurement data.</li>
|
|
||||||
<li><b>Window:</b> Define the number of samples to use for smoothing.</li>
|
|
||||||
<li><b>Enable Log:</b> Enable or disable logging for this node.</li>
|
|
||||||
<li><b>Log Level:</b> Select the log level (Info, Debug, Warn, Error) for logging messages.</li>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const nameOfNode = 'basin'; // this is the name of the node, it should match the file name and the node type in Node-RED
|
const nameOfNode = 'pumpingStation'; // this is the name of the node, it should match the file name and the node type in Node-RED
|
||||||
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
|
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
|
||||||
const { MenuManager, configManager } = require('generalFunctions');
|
const { MenuManager, configManager } = require('generalFunctions');
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ module.exports = function(RED) {
|
|||||||
// Register the different menu's for the measurement node (in the future we could automate this further by refering to the config)
|
// 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) => {
|
RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
|
||||||
try {
|
try {
|
||||||
const script = menuMgr.createEndpoint(nameOfNode, ['logger']);
|
const script = menuMgr.createEndpoint(nameOfNode, ['logger','position']);
|
||||||
res.type('application/javascript').send(script);
|
res.type('application/javascript').send(script);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(500).send(`// Error generating menu: ${err.message}`);
|
res.status(500).send(`// Error generating menu: ${err.message}`);
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/**
|
|
||||||
* basin.class.js
|
|
||||||
*
|
|
||||||
* 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 { outputUtils, configManager } = require('generalFunctions');
|
||||||
const Specific = require("./specificClass");
|
const Specific = require("./specificClass");
|
||||||
|
|
||||||
@@ -109,7 +104,7 @@ class nodeClass {
|
|||||||
* Execute a single tick: update measurement, format and send outputs.
|
* Execute a single tick: update measurement, format and send outputs.
|
||||||
*/
|
*/
|
||||||
_tick() {
|
_tick() {
|
||||||
this.source.tick();
|
//this.source.tick();
|
||||||
|
|
||||||
const raw = this.source.getOutput();
|
const raw = this.source.getOutput();
|
||||||
const processMsg = this._output.formatMsg(raw, this.config, 'process');
|
const processMsg = this._output.formatMsg(raw, this.config, 'process');
|
||||||
@@ -125,14 +120,14 @@ class nodeClass {
|
|||||||
_attachInputHandler() {
|
_attachInputHandler() {
|
||||||
this.node.on('input', (msg, send, done) => {
|
this.node.on('input', (msg, send, done) => {
|
||||||
switch (msg.topic) {
|
switch (msg.topic) {
|
||||||
case 'simulator': this.source.toggleSimulation(); break;
|
//example
|
||||||
case 'outlierDetection': this.source.toggleOutlierDetection(); break;
|
/*case 'simulator':
|
||||||
case 'calibrate': this.source.calibrate(); break;
|
this.source.toggleSimulation();
|
||||||
case 'measurement':
|
|
||||||
if (typeof msg.payload === 'number') {
|
|
||||||
this.source.inputValue = parseFloat(msg.payload);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
this.source.handleInput(msg);
|
||||||
|
break;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const {logger,configUtils,configManager,MeasurementContainer,coolprop} = require('generalFunctions');
|
const {logger,configUtils,configManager,MeasurementContainer,coolprop} = require('generalFunctions');
|
||||||
|
|
||||||
class Basin {
|
class pumpingStation {
|
||||||
constructor(config={}) {
|
constructor(config={}) {
|
||||||
|
|
||||||
this.emitter = new EventEmitter(); // Own EventEmitter
|
this.emitter = new EventEmitter(); // Own EventEmitter
|
||||||
this.configManager = new configManager();
|
this.configManager = new configManager();
|
||||||
this.defaultConfig = this.configManager.getConfig('basin');
|
this.defaultConfig = this.configManager.getConfig('pumpingStation');
|
||||||
this.configUtils = new configUtils(this.defaultConfig);
|
this.configUtils = new configUtils(this.defaultConfig);
|
||||||
this.config = this.configUtils.initConfig(config);
|
this.config = this.configUtils.initConfig(config);
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ class Basin {
|
|||||||
windowSize: this.config.smoothing.smoothWindow
|
windowSize: this.config.smoothing.smoothWindow
|
||||||
});
|
});
|
||||||
|
|
||||||
// Basin-specific properties
|
// pumpingStation-specific properties
|
||||||
this.flowrate = null; // Function to calculate flow rate based on water level rise or fall
|
this.flowrate = null; // Function to calculate flow rate based on water level rise or fall
|
||||||
this.timeBeforeOverflow = null; // Time before the basin overflows at current inflow rate
|
this.timeBeforeOverflow = null; // Time before the basin overflows at current inflow rate
|
||||||
this.timeBeforeEmpty = null; // Time before the basin empties at current outflow rate
|
this.timeBeforeEmpty = null; // Time before the basin empties at current outflow rate
|
||||||
@@ -131,7 +131,6 @@ class Basin {
|
|||||||
this.crossSectionalArea = this.config.basin.crossSectionalArea || 1; // Default to 1 m² if not specified
|
this.crossSectionalArea = this.config.basin.crossSectionalArea || 1; // Default to 1 m² if not specified
|
||||||
}
|
}
|
||||||
|
|
||||||
measurement
|
|
||||||
|
|
||||||
getOutput() {
|
getOutput() {
|
||||||
return {
|
return {
|
||||||
@@ -140,7 +139,7 @@ class Basin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Basin;
|
module.exports = pumpingStation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user