Compare commits

...

1 Commits

Author SHA1 Message Date
znetsixe
b4803e5e9b small adjusts 2025-06-25 17:25:13 +02:00
5 changed files with 18 additions and 19 deletions

View File

@@ -4,7 +4,7 @@
<script>
RED.nodes.registerType("measurement", {
category: "digital twin",
category: "EVOLV",
color: "#e4a363",
defaults: {
@@ -41,7 +41,7 @@
inputs: 1,
outputs: 3,
inputLabels: ["Measurement Input"],
inputLabels: ["Input"],
outputLabels: ["process", "dbase", "parent"],
icon: "font-awesome/fa-tachometer",

View File

@@ -14,14 +14,14 @@ module.exports = function(RED) {
RED.nodes.createNode(this, config);
// Then create your custom class and attach it
this.nodeClass = new nodeClass(config, RED, 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
console.log(`Loading endpoint for ${nameOfNode} menu...`);
//console.log(`Loading endpoint for ${nameOfNode} menu...`);
// 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('/measurement/menu.js', (req, res) => {
@@ -33,7 +33,7 @@ module.exports = function(RED) {
}
});
console.log(`Loading endpoint for ${nameOfNode} config...`);
//console.log(`Loading endpoint for ${nameOfNode} config...`);
// Endpoint to get the configuration data for the specific node
RED.httpAdmin.get(`/measurement/configData.js`, (req, res) => {
@@ -46,5 +46,5 @@ module.exports = function(RED) {
}
});
console.log(`Measurement node '${nameOfNode}' registered.`);
//console.log(`Measurement node '${nameOfNode}' registered.`);
};

View File

@@ -17,8 +17,7 @@
"author": "Rene De Ren",
"license": "SEE LICENSE",
"dependencies": {
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git",
"convert": "git+https://gitea.centraal.wbd-rd.nl/RnD/convert.git"
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git"
},
"node-red": {
"nodes": {

View File

@@ -5,28 +5,29 @@
* 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 Measurement = require("./specificClass");
const Specific = require("./specificClass");
/**
* Class representing a Measurement Node-RED node.
*/
class MeasurementNode {
class nodeClass {
/**
* Create a MeasurementNode.
* @param {object} uiConfig - Node-RED node configuration.
* @param {object} RED - Node-RED runtime API.
*/
constructor(uiConfig, RED, nodeInstance) {
constructor(uiConfig, RED, nodeInstance, nameOfNode) {
// Preserve RED reference for HTTP endpoints if needed
this.node = nodeInstance;
this.RED = RED;
this.name = nameOfNode;
// Load default & UI config
this._loadConfig(uiConfig,this.node);
// Instantiate core Measurement class
this._setupMeasurementClass();
this._setupSpecificClass();
// Wire up event and lifecycle handlers
this._bindEvents();
@@ -42,13 +43,12 @@ class MeasurementNode {
*/
_loadConfig(uiConfig,node) {
const cfgMgr = new configManager();
this.defaultConfig = cfgMgr.getConfig("measurement");
this.defaultConfig = cfgMgr.getConfig(this.name);
console.log( uiConfig.positionVsParent);
// Merge UI config over defaults
this.config = {
general: {
name: uiConfig.name,
name: this.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: {
@@ -92,8 +92,8 @@ class MeasurementNode {
/**
* Instantiate the core Measurement logic and store as source.
*/
_setupMeasurementClass() {
this.source = new Measurement(this.config);
_setupSpecificClass() {
this.source = new Specific(this.config);
}
/**
@@ -172,4 +172,4 @@ class MeasurementNode {
}
}
module.exports = MeasurementNode;
module.exports = nodeClass;

View File

@@ -26,7 +26,7 @@
* Author:
* - Rene De Ren
* Email:
* - rene@thegoldenbasket.nl
* - r.de.ren@brabantsedelta.nl
*
* Future Improvements:
* - Time-based stability checks