forked from RnD/measurement
small adjusts
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* Author:
|
||||
* - Rene De Ren
|
||||
* Email:
|
||||
* - rene@thegoldenbasket.nl
|
||||
* - r.de.ren@brabantsedelta.nl
|
||||
*
|
||||
* Future Improvements:
|
||||
* - Time-based stability checks
|
||||
|
||||
Reference in New Issue
Block a user