generic updates completed for now

This commit is contained in:
znetsixe
2025-07-01 15:25:07 +02:00
parent 85eb1eb4a6
commit a6dfbec5d0
9 changed files with 97 additions and 1408 deletions

View File

@@ -1,5 +1,5 @@
/**
* measurement.class.js
* node 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.
@@ -7,9 +7,6 @@
const { outputUtils, configManager } = require('generalFunctions');
const Specific = require("./specificClass");
/**
* Class representing a Node-RED node.
*/
class nodeClass {
/**
* Create a Node.
@@ -79,27 +76,32 @@ class nodeClass {
* Instantiate the core Measurement logic and store as source.
*/
_setupSpecificClass() {
const machineConfig = this.config;
// need extra state for this
const stateConfig = {
general: {
logging: {
enabled: config.eneableLog,
logLevel: config.logLevel
enabled: machineConfig.eneableLog,
logLevel: machineConfig.logLevel
}
},
movement: {
speed: Number(config.speed)
speed: Number(machineConfig.speed)
},
time: {
starting: Number(config.startup),
warmingup: Number(config.warmup),
stopping: Number(config.shutdown),
coolingdown: Number(config.cooldown)
starting: Number(machineConfig.startup),
warmingup: Number(machineConfig.warmup),
stopping: Number(machineConfig.shutdown),
coolingdown: Number(machineConfig.cooldown)
}
};
this.source = new Specific(this.config, stateConfig);
this.source = new Specific(machineConfig, stateConfig);
//store in node
this.node.source = this.source; // Store the source in the node instance for easy access
}
/**
@@ -223,7 +225,7 @@ class nodeClass {
* Execute a single tick: update measurement, format and send outputs.
*/
_tick() {
this.source.tick();
//this.source.tick();
const raw = this.source.getOutput();
const processMsg = this._output.formatMsg(raw, this.config, 'process');
@@ -242,6 +244,7 @@ class nodeClass {
const m = this.source;
switch(msg.topic) {
case 'registerChild':
// Register this node as a child of the parent node
const childId = msg.payload;
const childObj = this.RED.nodes.getNode(childId);
m.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);