forked from RnD/pumpingStation
Fixes next idle machine for level control
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const EventEmitter = require('events');
|
||||
const {logger,configUtils,configManager,childRegistrationUtils,MeasurementContainer,coolprop,interpolation} = require('generalFunctions');
|
||||
|
||||
class PumpingStation {
|
||||
constructor(config = {}) {
|
||||
this.emitter = new EventEmitter();
|
||||
@@ -192,7 +193,10 @@ class PumpingStation {
|
||||
}
|
||||
|
||||
_nextIdleMachine() {
|
||||
return Object.values(this.machines).find(m => !m._isOperationalState());
|
||||
return Object.values(this.machines).find((machine) => {
|
||||
const position = machine?.config?.functionality?.positionVsParent;
|
||||
return ( position === 'downstream' || position === 'atEquipment') && !machine._isOperationalState();
|
||||
});
|
||||
}
|
||||
|
||||
//control logic
|
||||
@@ -370,6 +374,7 @@ class PumpingStation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_onLevelMeasurement(position, value, context = {}) {
|
||||
const levelSeries = this.measurements.type('level').variant('measured').position(position);
|
||||
const levelMeters = levelSeries.getCurrentValue('m');
|
||||
@@ -688,11 +693,13 @@ class PumpingStation {
|
||||
return 'steady';
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Basin Calculations */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
initBasinProperties() {
|
||||
|
||||
const volEmptyBasin = this.config.basin.volume;
|
||||
const heightBasin = this.config.basin.height;
|
||||
const heightInlet = this.config.basin.heightInlet;
|
||||
@@ -718,12 +725,7 @@ class PumpingStation {
|
||||
minVolOut
|
||||
};
|
||||
|
||||
this.measurements
|
||||
.type('volume')
|
||||
.variant('predicted')
|
||||
.position('atEquipment')
|
||||
.value(maxVolOverflow)
|
||||
.unit('m3');
|
||||
this.measurements.type('volume').variant('predicted').position('atEquipment').value(maxVolOverflow).unit('m3');
|
||||
|
||||
this.logger.debug(
|
||||
`Basin initialized | area=${surfaceArea.toFixed(2)} m2, max=${maxVol.toFixed(2)} m3, overflow=${maxVolOverflow.toFixed(2)} m3`
|
||||
@@ -771,7 +773,7 @@ module.exports = PumpingStation;
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Example usage */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
if (require.main === module) {
|
||||
const Measurement = require('../../measurement/src/specificClass');
|
||||
const RotatingMachine = require('../../rotatingMachine/src/specificClass');
|
||||
|
||||
Reference in New Issue
Block a user