standaardisation of EVOLV eco

This commit is contained in:
znetsixe
2025-06-24 10:48:40 +02:00
parent d05d521408
commit 0f855a8d2f
2 changed files with 49 additions and 21 deletions

View File

@@ -1,7 +1,8 @@
/**
* measurement.class.js
*
* Encapsulates all Measurement node logic in a reusable class.
* 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 Measurement = require("../dependencies/measurement/measurement");
@@ -12,17 +13,17 @@ const Measurement = require("../dependencies/measurement/measurement");
class MeasurementNode {
/**
* Create a MeasurementNode.
* @param {object} config - Node-RED node configuration.
* @param {object} uiConfig - Node-RED node configuration.
* @param {object} RED - Node-RED runtime API.
*/
constructor(config, RED, nodeInstance) {
constructor(uiConfig, RED, nodeInstance) {
// Preserve RED reference for HTTP endpoints if needed
this.node = nodeInstance;
this.RED = RED;
// Load default & UI config
this._loadConfig(config);
this._loadConfig(uiConfig);
// Instantiate core Measurement class
this._setupMeasurementClass();
@@ -57,8 +58,10 @@ class MeasurementNode {
asset: {
tagCode: uiConfig.assetTagCode,
supplier: uiConfig.supplier,
subType: uiConfig.subType,
model: uiConfig.model
category: uiConfig.category,
type: uiConfig.assetType,
model: uiConfig.model,
unit: uiConfig.unit
},
scaling: {
enabled: uiConfig.scaling,
@@ -89,7 +92,7 @@ class MeasurementNode {
}
/**
* Bind Measurement events to Node-RED status updates.
* Bind Measurement events to Node-RED status updates. Using internal emitter.
*/
_bindEvents() {
this.source.emitter.on('mAbs', (val) => {