working
This commit is contained in:
@@ -87,8 +87,6 @@ class nodeClass {
|
||||
}
|
||||
};
|
||||
|
||||
console.log(`position vs child for ${this.name} is ${this.config.functionality.positionVsParent} the distance is ${this.config.functionality.distance}`);
|
||||
|
||||
// Utility for formatting outputs
|
||||
this._output = new outputUtils();
|
||||
}
|
||||
@@ -154,17 +152,34 @@ class nodeClass {
|
||||
*/
|
||||
_attachInputHandler() {
|
||||
this.node.on('input', (msg, send, done) => {
|
||||
switch (msg.topic) {
|
||||
case 'simulator': this.source.toggleSimulation(); break;
|
||||
case 'outlierDetection': this.source.toggleOutlierDetection(); break;
|
||||
case 'calibrate': this.source.calibrate(); break;
|
||||
case 'measurement':
|
||||
if (typeof msg.payload === 'number') {
|
||||
this.source.inputValue = parseFloat(msg.payload);
|
||||
}
|
||||
break;
|
||||
try {
|
||||
switch (msg.topic) {
|
||||
case 'simulator':
|
||||
this.source.toggleSimulation();
|
||||
break;
|
||||
case 'outlierDetection':
|
||||
this.source.toggleOutlierDetection();
|
||||
break;
|
||||
case 'calibrate':
|
||||
this.source.calibrate();
|
||||
break;
|
||||
case 'measurement':
|
||||
if (typeof msg.payload === 'number' || (typeof msg.payload === 'string' && msg.payload.trim() !== '')) {
|
||||
const parsed = Number(msg.payload);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
this.source.inputValue = parsed;
|
||||
} else {
|
||||
this.source.logger?.warn(`Invalid numeric measurement payload: ${msg.payload}`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.source.logger?.warn(`Unknown topic: ${msg.topic}`);
|
||||
}
|
||||
} catch (error) {
|
||||
this.source.logger?.error(`Input handler failure: ${error.message}`);
|
||||
}
|
||||
done();
|
||||
if (typeof done === 'function') done();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,7 +190,7 @@ class nodeClass {
|
||||
this.node.on('close', (done) => {
|
||||
clearInterval(this._tickInterval);
|
||||
//clearInterval(this._statusInterval);
|
||||
done();
|
||||
if (typeof done === 'function') done();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const EventEmitter = require('events');
|
||||
const {logger,configUtils,configManager,MeasurementContainer} = require('generalFunctions');
|
||||
|
||||
/**
|
||||
* Measurement domain model.
|
||||
* Handles scaling, smoothing, outlier filtering and emits normalized measurement output.
|
||||
*/
|
||||
class Measurement {
|
||||
constructor(config={}) {
|
||||
|
||||
@@ -506,7 +510,10 @@ class Measurement {
|
||||
}
|
||||
|
||||
toggleOutlierDetection() {
|
||||
this.config.outlierDetection = !this.config.outlierDetection;
|
||||
// Keep the outlier configuration shape stable and only toggle the enabled flag.
|
||||
const currentState = Boolean(this.config?.outlierDetection?.enabled);
|
||||
this.config.outlierDetection = this.config.outlierDetection || {};
|
||||
this.config.outlierDetection.enabled = !currentState;
|
||||
}
|
||||
|
||||
getOutput() {
|
||||
@@ -586,4 +593,4 @@ function changeInput(){
|
||||
//m.inputValue = 5;
|
||||
}
|
||||
|
||||
// */
|
||||
// */
|
||||
|
||||
Reference in New Issue
Block a user