58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
|
|
/**
|
||
|
|
* Standalone PumpingStation demo — run with `node examples/standalone-demo.js`.
|
||
|
|
* Builds a station + one pump, calibrates predicted volume, ticks once.
|
||
|
|
* Useful for sanity-checking the orchestrator without Node-RED.
|
||
|
|
*/
|
||
|
|
const PumpingStation = require('../src/specificClass');
|
||
|
|
const RotatingMachine = require('../../rotatingMachine/src/specificClass');
|
||
|
|
|
||
|
|
function createPumpingStationConfig(name) {
|
||
|
|
return {
|
||
|
|
general: {
|
||
|
|
logging: { enabled: true, logLevel: 'debug' },
|
||
|
|
name,
|
||
|
|
id: `${name}-${Date.now()}`,
|
||
|
|
flowThreshold: 1e-4,
|
||
|
|
},
|
||
|
|
functionality: { softwareType: 'pumpingStation', role: 'stationcontroller' },
|
||
|
|
basin: { volume: 43.75, height: 10, inflowLevel: 3, outflowLevel: 0.2, overflowLevel: 3.2 },
|
||
|
|
hydraulics: { refHeight: 'NAP', basinBottomRef: 0 },
|
||
|
|
safety: { enableDryRunProtection: false, enableOverfillProtection: false },
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
function createMachineConfig(name, position) {
|
||
|
|
return {
|
||
|
|
general: { name, logging: { enabled: false, logLevel: 'debug' } },
|
||
|
|
functionality: { softwareType: 'machine', positionVsParent: position },
|
||
|
|
asset: { supplier: 'Hydrostal', type: 'pump', category: 'centrifugal', model: 'hidrostal-H05K-S03R' },
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
function createMachineStateConfig() {
|
||
|
|
return {
|
||
|
|
general: { logging: { enabled: true, logLevel: 'debug' } },
|
||
|
|
movement: { speed: 1 },
|
||
|
|
time: { starting: 2, warmingup: 3, stopping: 2, coolingdown: 3 },
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
(async function demo() {
|
||
|
|
const station = new PumpingStation(createPumpingStationConfig('PumpingStationDemo'));
|
||
|
|
const pump1 = new RotatingMachine(createMachineConfig('Pump1', 'downstream'), createMachineStateConfig());
|
||
|
|
|
||
|
|
station.childRegistrationUtils.registerChild(pump1, 'machine');
|
||
|
|
|
||
|
|
setInterval(() => station.tick(), 1000);
|
||
|
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
||
|
|
|
||
|
|
console.log('Initial state:', station.state);
|
||
|
|
station.setManualInflow(300, Date.now(), 'l/s');
|
||
|
|
station.calibratePredictedVolume(3.4);
|
||
|
|
|
||
|
|
console.log('Station state:', station.state);
|
||
|
|
console.log('Station output:', station.getOutput());
|
||
|
|
})().catch((err) => {
|
||
|
|
console.error('Demo failed:', err);
|
||
|
|
});
|