forked from RnD/measurement
standaardisation of EVOLV eco
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user