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 EventEmitter = require('events');
|
||||||
const {logger,configUtils,configManager,childRegistrationUtils,MeasurementContainer,coolprop,interpolation} = require('generalFunctions');
|
const {logger,configUtils,configManager,childRegistrationUtils,MeasurementContainer,coolprop,interpolation} = require('generalFunctions');
|
||||||
|
|
||||||
class PumpingStation {
|
class PumpingStation {
|
||||||
constructor(config = {}) {
|
constructor(config = {}) {
|
||||||
this.emitter = new EventEmitter();
|
this.emitter = new EventEmitter();
|
||||||
@@ -192,7 +193,10 @@ class PumpingStation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_nextIdleMachine() {
|
_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
|
//control logic
|
||||||
@@ -370,6 +374,7 @@ class PumpingStation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_onLevelMeasurement(position, value, context = {}) {
|
_onLevelMeasurement(position, value, context = {}) {
|
||||||
const levelSeries = this.measurements.type('level').variant('measured').position(position);
|
const levelSeries = this.measurements.type('level').variant('measured').position(position);
|
||||||
const levelMeters = levelSeries.getCurrentValue('m');
|
const levelMeters = levelSeries.getCurrentValue('m');
|
||||||
@@ -688,11 +693,13 @@ class PumpingStation {
|
|||||||
return 'steady';
|
return 'steady';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
/* Basin Calculations */
|
/* Basin Calculations */
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
initBasinProperties() {
|
initBasinProperties() {
|
||||||
|
|
||||||
const volEmptyBasin = this.config.basin.volume;
|
const volEmptyBasin = this.config.basin.volume;
|
||||||
const heightBasin = this.config.basin.height;
|
const heightBasin = this.config.basin.height;
|
||||||
const heightInlet = this.config.basin.heightInlet;
|
const heightInlet = this.config.basin.heightInlet;
|
||||||
@@ -718,12 +725,7 @@ class PumpingStation {
|
|||||||
minVolOut
|
minVolOut
|
||||||
};
|
};
|
||||||
|
|
||||||
this.measurements
|
this.measurements.type('volume').variant('predicted').position('atEquipment').value(maxVolOverflow).unit('m3');
|
||||||
.type('volume')
|
|
||||||
.variant('predicted')
|
|
||||||
.position('atEquipment')
|
|
||||||
.value(maxVolOverflow)
|
|
||||||
.unit('m3');
|
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Basin initialized | area=${surfaceArea.toFixed(2)} m2, max=${maxVol.toFixed(2)} m3, overflow=${maxVolOverflow.toFixed(2)} m3`
|
`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 */
|
/* Example usage */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
const Measurement = require('../../measurement/src/specificClass');
|
const Measurement = require('../../measurement/src/specificClass');
|
||||||
const RotatingMachine = require('../../rotatingMachine/src/specificClass');
|
const RotatingMachine = require('../../rotatingMachine/src/specificClass');
|
||||||
|
|||||||
Reference in New Issue
Block a user