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

View File

@@ -14,14 +14,14 @@ module.exports = function(RED) {
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);
// Then create your custom class and attach it // 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 // Setup admin UIs
const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically 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 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) // 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) => { 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 // Endpoint to get the configuration data for the specific node
RED.httpAdmin.get(`/measurement/configData.js`, (req, res) => { 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", "author": "Rene De Ren",
"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": {

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. * 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 Measurement = require("./specificClass"); const Specific = require("./specificClass");
/** /**
* Class representing a Measurement Node-RED node. * Class representing a Measurement Node-RED node.
*/ */
class MeasurementNode { class nodeClass {
/** /**
* Create a MeasurementNode. * Create a MeasurementNode.
* @param {object} uiConfig - Node-RED node configuration. * @param {object} uiConfig - Node-RED node configuration.
* @param {object} RED - Node-RED runtime API. * @param {object} RED - Node-RED runtime API.
*/ */
constructor(uiConfig, RED, nodeInstance) { constructor(uiConfig, RED, nodeInstance, nameOfNode) {
// Preserve RED reference for HTTP endpoints if needed // Preserve RED reference for HTTP endpoints if needed
this.node = nodeInstance; this.node = nodeInstance;
this.RED = RED; this.RED = RED;
this.name = nameOfNode;
// Load default & UI config // Load default & UI config
this._loadConfig(uiConfig,this.node); this._loadConfig(uiConfig,this.node);
// Instantiate core Measurement class // Instantiate core Measurement class
this._setupMeasurementClass(); this._setupSpecificClass();
// Wire up event and lifecycle handlers // Wire up event and lifecycle handlers
this._bindEvents(); this._bindEvents();
@@ -42,13 +43,12 @@ class MeasurementNode {
*/ */
_loadConfig(uiConfig,node) { _loadConfig(uiConfig,node) {
const cfgMgr = new configManager(); const cfgMgr = new configManager();
this.defaultConfig = cfgMgr.getConfig("measurement"); this.defaultConfig = cfgMgr.getConfig(this.name);
console.log( uiConfig.positionVsParent);
// Merge UI config over defaults // Merge UI config over defaults
this.config = { this.config = {
general: { general: {
name: uiConfig.name, name: this.name,
id: node.id, // node.id is for the child registration process 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) 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: { logging: {
@@ -92,8 +92,8 @@ class MeasurementNode {
/** /**
* Instantiate the core Measurement logic and store as source. * Instantiate the core Measurement logic and store as source.
*/ */
_setupMeasurementClass() { _setupSpecificClass() {
this.source = new Measurement(this.config); 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: * Author:
* - Rene De Ren * - Rene De Ren
* Email: * Email:
* - rene@thegoldenbasket.nl * - r.de.ren@brabantsedelta.nl
* *
* Future Improvements: * Future Improvements:
* - Time-based stability checks * - Time-based stability checks