forked from RnD/pumpingStation
testing codex
This commit is contained in:
@@ -85,7 +85,6 @@ class pumpingStation {
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
case("upstream"):
|
||||
//check for predicted outgoing flow at the connected child pumpingsation
|
||||
child.measurements.emitter.on("flow.predicted.downstream", (eventData) => {
|
||||
@@ -152,8 +151,8 @@ class pumpingStation {
|
||||
const prevFlow = series.getLaggedValue(1, "m3/s"); // { value, timestamp, unit }
|
||||
|
||||
if (!currFLow || !prevFlow) return;
|
||||
|
||||
this.logger.debug(`currDownflow = ${currFLow.value} , prevDownFlow = ${prevFlow.value}`);
|
||||
|
||||
this.logger.debug(`Flowdir ${flowDir} => currFlow ${currFLow.value} , prevflow = ${prevFlow.value}`);
|
||||
|
||||
// calc difference in time
|
||||
const deltaT = currFLow.timestamp - prevFlow.timestamp;
|
||||
@@ -222,7 +221,7 @@ class pumpingStation {
|
||||
//this._calcNetFlow();
|
||||
const {time:timeleft, source:variant} = this._calcTimeRemaining();
|
||||
|
||||
this.logger.debug(`Remaining time ${Math.round(timeleft/60/60*100)/100} h, based on variant ${variant} `);
|
||||
this.logger.debug(`Remaining time ~${Math.round(timeleft/60/60*10)/10} h, based on variant ${variant} `);
|
||||
}
|
||||
|
||||
_calcTimeRemaining(){
|
||||
@@ -624,7 +623,7 @@ const PumpingStation = require("./specificClass");
|
||||
const RotatingMachine = require("../../rotatingMachine/src/specificClass");
|
||||
const Measurement = require("../../measurement/src/specificClass");
|
||||
|
||||
/** Helpers ******************************************************************/
|
||||
//Helpers
|
||||
function createPumpingStationConfig(name) {
|
||||
return {
|
||||
general: {
|
||||
@@ -754,10 +753,11 @@ function pushSample(measurement, type, value, unit) {
|
||||
.value(value, Date.now(), unit);
|
||||
}
|
||||
|
||||
/** Demo *********************************************************************/
|
||||
// Demo
|
||||
(async function demoStationWithPump() {
|
||||
const station = new PumpingStation(createPumpingStationConfig("PumpingStationDemo"));
|
||||
const pump = new RotatingMachine(createMachineConfig("Pump1"), createMachineStateConfig());
|
||||
const pump1 = new RotatingMachine(createMachineConfig("Pump1"), createMachineStateConfig());
|
||||
const pump2 = new RotatingMachine(createMachineConfig("Pump2"), createMachineStateConfig());
|
||||
|
||||
const levelSensor = new Measurement(createLevelMeasurementConfig("WetWellLevel"));
|
||||
const upstreamFlow = new Measurement(createFlowMeasurementConfig("InfluentFlow", "upstream"));
|
||||
@@ -765,15 +765,16 @@ function pushSample(measurement, type, value, unit) {
|
||||
|
||||
|
||||
// station uses the sensors
|
||||
/*
|
||||
|
||||
station.childRegistrationUtils.registerChild(levelSensor, levelSensor.config.functionality.softwareType);
|
||||
station.childRegistrationUtils.registerChild(upstreamFlow, upstreamFlow.config.functionality.softwareType);
|
||||
station.childRegistrationUtils.registerChild(downstreamFlow, downstreamFlow.config.functionality.softwareType);
|
||||
*/
|
||||
|
||||
|
||||
// pump owns the downstream flow sensor
|
||||
pump.childRegistrationUtils.registerChild(downstreamFlow, downstreamFlow.config.functionality.positionVsParent);
|
||||
station.childRegistrationUtils.registerChild(pump,"downstream");
|
||||
//pump.childRegistrationUtils.registerChild(downstreamFlow, downstreamFlow.config.functionality.positionVsParent);
|
||||
station.childRegistrationUtils.registerChild(pump1,"downstream");
|
||||
station.childRegistrationUtils.registerChild(pump2,"upstream");
|
||||
|
||||
setInterval(() => station.tick(), 1000);
|
||||
|
||||
@@ -782,7 +783,7 @@ function pushSample(measurement, type, value, unit) {
|
||||
pushSample(levelSensor, "level", 1.8, "m");
|
||||
pushSample(upstreamFlow, "flow", 0.35, "m3/s");
|
||||
pushSample(downstreamFlow, "flow", 0.20, "m3/s");
|
||||
*/
|
||||
//*/
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 20));
|
||||
|
||||
@@ -791,13 +792,17 @@ function pushSample(measurement, type, value, unit) {
|
||||
pushSample(downstreamFlow, "flow", 0.28, "m3/s");
|
||||
pushSample(upstreamFlow, "flow", 0.40, "m3/s");
|
||||
pushSample(levelSensor, "level", 1.85, "m");
|
||||
*/
|
||||
//*/
|
||||
|
||||
console.log("Station output:", station.getOutput());
|
||||
await pump.handleInput("parent", "execSequence", "startup");
|
||||
await pump.handleInput("parent", "execMovement", 50);
|
||||
await pump1.handleInput("parent", "execSequence", "startup");
|
||||
await pump2.handleInput("parent", "execSequence", "startup");
|
||||
await pump1.handleInput("parent", "execMovement", 5);
|
||||
await pump2.handleInput("parent", "execMovement", 5);
|
||||
console.log("Station state:", station.state);
|
||||
console.log("Station output:", station.getOutput());
|
||||
console.log("Pump state:", pump.state.getCurrentState());
|
||||
console.log("Pump state:", pump1.state.getCurrentState());
|
||||
console.log("Pump state:", pump2.state.getCurrentState());
|
||||
})();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user