Files
measurement/src/nodeClass.js
znetsixe 497f05d92c B1.3: isStable real threshold (config-driven, replaces tautology)
The legacy stdDev < stdDev*2 was always true. New behaviour: stdDev <=
config.calibration.stabilityThreshold OR stdDev === 0. Default
threshold 0.01 in scaling-units. Schema field + editor UI added. 4
BUG-PRESERVED tests rewritten + 4 new edge tests. 101/101 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 17:29:15 +02:00

44 lines
1.5 KiB
JavaScript

'use strict';
const { BaseNodeAdapter } = require('generalFunctions');
const Measurement = require('./specificClass');
const commands = require('./commands');
class nodeClass extends BaseNodeAdapter {
static DomainClass = Measurement;
static commands = commands;
// Tick drives the simulator's random walk when enabled. Disabled mode is
// event-driven via the `output-changed` emit from the analog Channel.
static tickInterval = 1000;
static statusInterval = 1000;
buildDomainConfig(uiConfig, _nodeId) {
let channels = [];
if (typeof uiConfig.channels === 'string' && uiConfig.channels.trim()) {
try { channels = JSON.parse(uiConfig.channels); }
catch (e) { this.node.warn(`Invalid channels JSON: ${e.message}`); channels = []; }
} else if (Array.isArray(uiConfig.channels)) {
channels = uiConfig.channels;
}
const mode = (typeof uiConfig.mode === 'string' && uiConfig.mode.toLowerCase() === 'digital') ? 'digital' : 'analog';
return {
scaling: {
enabled: uiConfig.scaling,
inputMin: uiConfig.i_min,
inputMax: uiConfig.i_max,
absMin: uiConfig.o_min,
absMax: uiConfig.o_max,
offset: uiConfig.i_offset,
},
smoothing: { smoothWindow: uiConfig.count, smoothMethod: uiConfig.smooth_method },
simulation: { enabled: uiConfig.simulator },
calibration: { stabilityThreshold: uiConfig.stabilityThreshold },
mode: { current: mode },
channels,
};
}
}
module.exports = nodeClass;