forked from RnD/measurement
fix for childregistration
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* 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");
|
||||
const Measurement = require("./specificClass");
|
||||
|
||||
/**
|
||||
* Class representing a Measurement Node-RED node.
|
||||
@@ -23,7 +23,7 @@ class MeasurementNode {
|
||||
this.RED = RED;
|
||||
|
||||
// Load default & UI config
|
||||
this._loadConfig(uiConfig);
|
||||
this._loadConfig(uiConfig,this.node);
|
||||
|
||||
// Instantiate core Measurement class
|
||||
this._setupMeasurementClass();
|
||||
@@ -40,15 +40,16 @@ class MeasurementNode {
|
||||
* Load and merge default config with user-defined settings.
|
||||
* @param {object} uiConfig - Raw config from Node-RED UI.
|
||||
*/
|
||||
_loadConfig(uiConfig) {
|
||||
_loadConfig(uiConfig,node) {
|
||||
const cfgMgr = new configManager();
|
||||
this.defaultConfig = cfgMgr.getConfig("measurement");
|
||||
|
||||
console.log( uiConfig.positionVsParent);
|
||||
// Merge UI config over defaults
|
||||
this.config = {
|
||||
general: {
|
||||
name: uiConfig.name,
|
||||
id: uiConfig.id, //need to add this later use node.uuid from a single project file thats unique per location + node-red environment + node
|
||||
id: node.id, //need to add this later use node.uuid from a single project file thats unique per location + node-red environment + node
|
||||
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: {
|
||||
enabled: uiConfig.enableLog,
|
||||
@@ -78,7 +79,9 @@ class MeasurementNode {
|
||||
simulation: {
|
||||
enabled: uiConfig.simulator
|
||||
},
|
||||
positionVsParent: uiConfig.position || 'atEquipment', // default to 'atEquipment' if not set
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
|
||||
}
|
||||
};
|
||||
|
||||
// Utility for formatting outputs
|
||||
@@ -110,7 +113,7 @@ class MeasurementNode {
|
||||
this.node.send([
|
||||
null,
|
||||
null,
|
||||
{ topic: 'registerChild', payload: this.id, positionVsParent: this.config.functionality.positionVsParent }
|
||||
{ topic: 'registerChild', payload: this.config.general.id, positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' },
|
||||
]);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user