Updated node status

This commit is contained in:
znetsixe
2025-11-03 07:42:51 +01:00
parent 2a31c7ec69
commit f243761f00
2 changed files with 86 additions and 71 deletions

View File

@@ -1,6 +1,6 @@
const EventEmitter = require('events');
const {logger,configUtils,configManager,childRegistrationUtils,MeasurementContainer,coolprop,interpolation} = require('generalFunctions');
class PumpingStationV2 {
class PumpingStation {
constructor(config = {}) {
this.emitter = new EventEmitter();
this.configManager = new configManager();
@@ -18,6 +18,8 @@ class PumpingStationV2 {
this.machines = {};
this.stations = {};
//variants in determining what gets priority
this.flowVariants = ['measured', 'predicted'];
this.levelVariants = ['measured', 'predicted'];
@@ -61,6 +63,8 @@ class PumpingStationV2 {
this._updatePredictedVolume(snapshot);
const netFlow = this._selectBestNetFlow(snapshot);
//write netflow in measurment container
//this.measurements()
const remaining = this._computeRemainingTime(snapshot, netFlow);
this.state = {
@@ -160,8 +164,8 @@ class PumpingStationV2 {
.value(volume, context.timestamp, 'm3');
this.measurements
.type('volume')
.variant('percent')
.type('volumePercent')
.variant('measured')
.position('atequipment')
.value(percent, context.timestamp, '%');
}
@@ -416,6 +420,22 @@ class PumpingStationV2 {
.value(nextLevel, writeTimestamp, 'm')
.unit('m');
//calc how full this is in procen using minVol vs maxVolOverflow
const percent = this.interpolate.interpolate_lin_single_point(
currentVolume,
this.basin.minVol,
this.basin.maxVolOverflow,
0,
100
);
//store this percent value
this.measurements
.type('volumePercent')
.variant('predicted')
.position('atequipment')
.value(percent);
this._predictedFlowState.lastTimestamp = writeTimestamp;
}
@@ -465,7 +485,7 @@ class PumpingStationV2 {
.type('volume')
.variant('predicted')
.position('atEquipment')
.value(maxVol)
.value(maxVolOverflow)
.unit('m3');
this.logger.debug(
@@ -501,12 +521,12 @@ class PumpingStationV2 {
}
}
module.exports = PumpingStationV2;
module.exports = PumpingStation;
/* ------------------------------------------------------------------------- */
/* Example usage */
/* ------------------------------------------------------------------------- */
/*
if (require.main === module) {
const Measurement = require('../../measurement/src/specificClass');
const RotatingMachine = require('../../rotatingMachine/src/specificClass');
@@ -525,10 +545,10 @@ if (require.main === module) {
},
basin: {
volume: 43.75,
height: 3.5,
heightInlet: 0.3,
height: 10,
heightInlet: 3,
heightOutlet: 0.2,
heightOverflow: 3.0
heightOverflow: 3.2
},
hydraulics: {
refHeight: 'NAP',
@@ -630,7 +650,7 @@ if (require.main === module) {
}
(async function demo() {
const station = new PumpingStationV2(createPumpingStationConfig('PumpingStationDemo'));
const station = new PumpingStation(createPumpingStationConfig('PumpingStationDemo'));
const pump1 = new RotatingMachine(createMachineConfig('Pump1','downstream'), createMachineStateConfig());
const pump2 = new RotatingMachine(createMachineConfig('Pump2','upstream'), createMachineStateConfig());
@@ -638,20 +658,19 @@ if (require.main === module) {
const inflowSensor = new Measurement(createFlowMeasurementConfig('InfluentFlow', 'in'));
const outflowSensor = new Measurement(createFlowMeasurementConfig('PumpDischargeFlow', 'out'));
/*
station.childRegistrationUtils.registerChild(levelSensor, levelSensor.config.functionality.softwareType);
station.childRegistrationUtils.registerChild(inflowSensor, inflowSensor.config.functionality.softwareType);
station.childRegistrationUtils.registerChild(outflowSensor, outflowSensor.config.functionality.softwareType);
*/
//station.childRegistrationUtils.registerChild(levelSensor, levelSensor.config.functionality.softwareType);
//station.childRegistrationUtils.registerChild(inflowSensor, inflowSensor.config.functionality.softwareType);
//station.childRegistrationUtils.registerChild(outflowSensor, outflowSensor.config.functionality.softwareType);
station.childRegistrationUtils.registerChild(pump1, 'machine');
station.childRegistrationUtils.registerChild(pump2, 'machine');
// Seed initial measurements
/*
seedSample(levelSensor, 'level', 1.8, 'm');
seedSample(inflowSensor, 'flow', 0.35, 'm3/s');
seedSample(outflowSensor, 'flow', 0.20, 'm3/s');
*/
//seedSample(levelSensor, 'level', 1.8, 'm');
//seedSample(inflowSensor, 'flow', 0.35, 'm3/s');
//seedSample(outflowSensor, 'flow', 0.20, 'm3/s');
setInterval(
() => station.tick(), 1000);
@@ -672,3 +691,4 @@ if (require.main === module) {
console.error('Demo failed:', err);
});
}
//*/