updates to safety features

This commit is contained in:
znetsixe
2025-11-25 14:57:39 +01:00
parent 5a575a29fe
commit d91609b3a4
3 changed files with 104 additions and 9 deletions

View File

@@ -65,6 +65,13 @@ class nodeClass {
refHeight: uiConfig.refHeight,
minHeightBasedOn: uiConfig.minHeightBasedOn,
basinBottomRef: uiConfig.basinBottomRef,
},
safety:{
enableDryRunProtection: uiConfig.enableDryRunProtection,
dryRunThresholdPercent: uiConfig.dryRunThresholdPercent,
enableOverfillProtection: uiConfig.enableOverfillProtection,
overfillThresholdPercent: uiConfig.overfillThresholdPercent,
timeleftToFullOrEmptyThresholdSeconds: uiConfig.timeleftToFullOrEmptyThresholdSeconds
}
};

View File

@@ -103,10 +103,19 @@ class PumpingStation {
return;
}
//get threshholds from config
const timeThreshhold = this.config.safety.timeleftToFullOrEmptyThresholdSeconds; //seconds
const triggerHighVol = this.basin.maxVolOverflow * ( this.config.safety.overfillThresholdPercent/100 );
const triggerLowVol = this.basin.minVol * ( this.config.safety.dryRunThresholdPercent/100 );
const {
enableDryRunProtection,
dryRunThresholdPercent,
enableOverfillProtection,
overfillThresholdPercent,
timeleftToFullOrEmptyThresholdSeconds
} = this.config.safety || {};
const dryRunEnabled = Boolean(enableDryRunProtection);
const overfillEnabled = Boolean(enableOverfillProtection);
const timeProtectionEnabled = timeleftToFullOrEmptyThresholdSeconds > 0;
const triggerHighVol = this.basin.maxVolOverflow * ((Number(overfillThresholdPercent) || 0) / 100);
const triggerLowVol = this.basin.minVol * (1 + ((Number(dryRunThresholdPercent) || 0) / 100));
// trigger conditions for draining
if(direction == "draining"){
@@ -116,7 +125,10 @@ class PumpingStation {
`direction=${String(direction)}; triggerLowVol=${Number.isFinite(triggerLowVol) ? triggerLowVol.toFixed(2) + ' m3' : 'N/A'}`
);
if( (remainingTime < timeThreshhold && remainingTime !== null) || vol < triggerLowVol || vol == null){
const timeTriggered = timeProtectionEnabled && remainingTime != null && remainingTime < timeleftToFullOrEmptyThresholdSeconds;
const dryRunTriggered = dryRunEnabled && vol < triggerLowVol;
if (timeTriggered || dryRunTriggered) {
//shut down all downstream or atequipment machines,pumping stations and machine groups
Object.entries(this.machines).forEach(([machineId, machine]) => {
const position = machine?.config?.functionality?.positionVsParent;
@@ -142,7 +154,11 @@ class PumpingStation {
`remainingTime=${Number.isFinite(remainingTime) ? remainingTime.toFixed(1) + ' s' : 'N/A'}; ` +
`direction=${String(direction)}; triggerHighVol=${Number.isFinite(triggerHighVol) ? triggerHighVol.toFixed(2) + ' m3' : 'N/A'}`
);
if( (remainingTime < timeThreshhold && remainingTime !== null) || vol > triggerHighVol || vol == null){
const timeTriggered =timeProtectionEnabled &&remainingTime != null && remainingTime < timeleftToFullOrEmptyThresholdSeconds;
const overfillTriggered = overfillEnabled && vol > triggerHighVol;
if (timeTriggered || overfillTriggered) {
//shut down all upstream machines,pumping stations and machine groups
Object.entries(this.machines).forEach(([machineId, machine]) => {
const position = machine?.config?.functionality?.positionVsParent;
@@ -476,6 +492,7 @@ class PumpingStation {
_onLevelMeasurement(position, value, context = {}) {
this.measurements.type('level').variant('measured').position(position).value(value).unit(context.unit);
const levelSeries = this.measurements.type('level').variant('measured').position(position);
const levelMeters = levelSeries.getCurrentValue('m');
@@ -1014,7 +1031,7 @@ 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(levelSensor, levelSensor.config.functionality.softwareType);
//station.childRegistrationUtils.registerChild(inflowSensor, inflowSensor.config.functionality.softwareType);
//station.childRegistrationUtils.registerChild(outflowSensor, outflowSensor.config.functionality.softwareType);
@@ -1023,7 +1040,7 @@ if (require.main === module) {
// Seed initial measurements
//seedSample(levelSensor, 'level', 1.8, 'm');
seedSample(levelSensor, 'level', 1.8, 'm');
//seedSample(inflowSensor, 'flow', 0.35, 'm3/s');
//seedSample(outflowSensor, 'flow', 0.20, 'm3/s');