diff --git a/src/nodeClass.js b/src/nodeClass.js index 17aa9a0..85d50b5 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -218,11 +218,11 @@ class nodeClass { this.source.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent); break; case 'calibratePredictedVolume': - const injectedVol = isFinite(toFloat(msg.payload)); + const injectedVol = parseFloat(msg.payload); this.source.calibratePredictedVolume(injectedVol); break; case 'calibratePredictedLevel': - const injectedLevel = isFinite(toFloat(msg.payload)); + const injectedLevel = parseFloat(msg.payload); this.source.calibratePredictedLevel(injectedLevel); break; case 'q_in': { diff --git a/src/specificClass.js b/src/specificClass.js index d59a12f..66e50b1 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -137,23 +137,21 @@ class PumpingStation { /* --------------------------- Calibration --------------------------- */ calibratePredictedVolume(calibratedVol, timestamp = Date.now()) { - const volumeChain = this.measurements.type('volume').variant('predicted').position('atequipment'); - const levelChain = this.measurements.type('level').variant('predicted').position('atequipment'); + const volume = this.measurements.type('volume').variant('predicted').position('atequipment').get(); + const level = this.measurements.type('level').variant('predicted').position('atequipment').get(); - const volumeMeasurement = volumeChain.exists() ? volumeChain.get() : null; - if (volumeMeasurement) { - volumeMeasurement.values = []; - volumeMeasurement.timestamps = []; + if (volume) { + volume.values = []; + volume.timestamps = []; + } + + if (level) { + level.values = []; + level.timestamps = []; } - const levelMeasurement = levelChain.exists() ? levelChain.get() : null; - if (levelMeasurement) { - levelMeasurement.values = []; - levelMeasurement.timestamps = []; - } - - volumeChain.value(calibratedVol, timestamp, 'm3').unit('m3'); - levelChain.value(this._calcLevelFromVolume(calibratedVol), timestamp, 'm'); + this.measurements.type('volume').variant('predicted').position('atequipment').value(calibratedVol, timestamp, 'm3').unit('m3'); + this.measurements.type('level').variant('predicted').position('atequipment').value(this._calcLevelFromVolume(calibratedVol), timestamp, 'm'); this._predictedFlowState = { inflow: 0, outflow: 0, lastTimestamp: timestamp }; } @@ -373,6 +371,7 @@ class PumpingStation { return null; } + //scaled for robin min 2039 - 2960 max 53.04 _scaleLevelToFlowPercent(level) { const { minFlowLevel, maxFlowLevel } = this.config.control.levelbased; this.logger.debug(`Scaling minflow level : ${minFlowLevel} and maxflowLevel : ${maxFlowLevel}`); @@ -628,7 +627,7 @@ module.exports = PumpingStation; /* ------------------------------------------------------------------------- */ /* Example usage */ /* ------------------------------------------------------------------------- */ -/* + if (require.main === module) { const Measurement = require('../../measurement/src/specificClass'); const RotatingMachine = require('../../rotatingMachine/src/specificClass'); @@ -786,7 +785,7 @@ if (require.main === module) { console.log('Initial state:', station.state); station.setManualInflow(300,Date.now(),'l/s'); - + station.calibratePredictedVolume(3.4); //await pump1.handleInput('parent', 'execSequence', 'startup'); //await pump1.handleInput('parent', 'execMovement', 10); //