Compare commits

...

8 Commits

Author SHA1 Message Date
znetsixe
9e4b149b64 fixed multiple children being able to pull and push to pumpingstation 2025-11-06 16:46:54 +01:00
znetsixe
1848486f1c bug fixes output formatting 2025-11-06 11:19:20 +01:00
znetsixe
d44cbc978b updates visual 2025-11-03 09:17:22 +01:00
znetsixe
f243761f00 Updated node status 2025-11-03 07:42:51 +01:00
znetsixe
2a31c7ec69 working pumpingstation with machines 2025-10-28 17:04:26 +01:00
znetsixe
69f68adffe testing codex 2025-10-27 19:55:48 +01:00
znetsixe
5a1eff37d7 Need to remove wobble on level only 2025-10-27 17:45:48 +01:00
znetsixe
e8f9207a92 some major design choises updated 2025-10-27 16:39:06 +01:00
2 changed files with 745 additions and 682 deletions

View File

@@ -101,65 +101,60 @@ class nodeClass {
_updateNodeStatus() { _updateNodeStatus() {
const ps = this.source; const ps = this.source;
try {
// --- Basin & measurements -------------------------------------------------
const maxVolBeforeOverflow = ps.basin?.maxVolOverflow ?? ps.basin?.maxVol ?? 0;
const volumeMeasurement = ps.measurements.type("volume").variant("measured").position("atEquipment");
const currentVolume = volumeMeasurement.getCurrentValue("m3") ?? 0;
const netFlowMeasurement = ps.measurements.type("netFlowRate").variant("predicted").position("atEquipment");
const netFlowM3s = netFlowMeasurement?.getCurrentValue("m3/s") ?? 0;
const netFlowM3h = netFlowM3s * 3600;
const percentFull = ps.measurements.type("volume").variant("procent").position("atEquipment").getCurrentValue() ?? 0;
// --- State information ---------------------------------------------------- const pickVariant = (type, prefer = ['measured', 'predicted'], position = 'atEquipment', unit) => {
const direction = ps.state?.direction || "unknown"; for (const variant of prefer) {
const secondsRemaining = ps.state?.seconds ?? null; const chain = ps.measurements.type(type).variant(variant).position(position);
const value = unit ? chain.getCurrentValue(unit) : chain.getCurrentValue();
const timeRemaining = secondsRemaining ? `${Math.round(secondsRemaining / 60)}` : 0 + " min"; if (value != null) return { value, variant };
// --- Icon / colour selection ---------------------------------------------
let symbol = "❔";
let fill = "grey";
switch (direction) {
case "filling":
symbol = "⬆️";
fill = "blue";
break;
case "draining":
symbol = "⬇️";
fill = "orange";
break;
case "stable":
symbol = "⏸️";
fill = "green";
break;
default:
symbol = "❔";
fill = "grey";
break;
} }
return { value: null, variant: null };
};
// --- Status text ---------------------------------------------------------- const vol = pickVariant('volume', ['measured', 'predicted'], 'atEquipment', 'm3');
const textParts = [ const volPercent = pickVariant('volumePercent', ['measured','predicted'], 'atEquipment'); // already unitless
`${symbol} ${percentFull.toFixed(1)}%`, const level = pickVariant('level', ['measured', 'predicted'], 'atEquipment', 'm');
`V=${currentVolume.toFixed(2)} / ${maxVolBeforeOverflow.toFixed(2)}`, const netFlow = pickVariant('netFlowRate', ['measured', 'predicted'], 'atEquipment', 'm3/h');
`net=${netFlowM3h.toFixed(1)} m³/h`,
`t≈${timeRemaining}`
];
return { const maxVolBeforeOverflow = ps.basin?.maxVolOverflow ?? ps.basin?.maxVol ?? 0;
fill, const currentVolume = vol.value ?? 0;
shape: "dot", const currentvolPercent = volPercent.value ?? 0;
text: textParts.join(" | ") const netFlowM3h = netFlow.value ?? 0;
};
} catch (error) { const direction = ps.state?.direction ?? 'unknown';
this.node.error("Error in updateNodeStatus: " + error.message); const secondsRemaining = ps.state?.seconds ?? null;
return { fill: "red", shape: "ring", text: "Status Error" }; const timeRemainingMinutes = secondsRemaining != null ? Math.round(secondsRemaining / 60) : null;
const badgePieces = [];
badgePieces.push(`${currentvolPercent.toFixed(1)}% `);
badgePieces.push(
`V=${currentVolume.toFixed(2)} / ${maxVolBeforeOverflow.toFixed(2)}`
);
badgePieces.push(`net: ${netFlowM3h.toFixed(0)} m³/h`);
if (timeRemainingMinutes != null) {
badgePieces.push(`t≈${timeRemainingMinutes} min)`);
} }
const { symbol, fill } = (() => {
switch (direction) {
case 'filling': return { symbol: '⬆️', fill: 'blue' };
case 'draining': return { symbol: '⬇️', fill: 'orange' };
case 'steady': return { symbol: '⏸️', fill: 'green' };
default: return { symbol: '❔', fill: 'grey' };
}
})();
badgePieces[0] = `${symbol} ${badgePieces[0]}`;
return {
fill,
shape: 'dot',
text: badgePieces.join(' | ')
};
} }
// any time based functions here // any time based functions here
_startTickLoop() { _startTickLoop() {
setTimeout(() => { setTimeout(() => {
@@ -182,8 +177,8 @@ class nodeClass {
//pumping station needs time based ticks to recalc level when predicted //pumping station needs time based ticks to recalc level when predicted
this.source.tick(); this.source.tick();
const raw = this.source.getOutput(); const raw = this.source.getOutput();
const processMsg = this._output.formatMsg(raw, this.config, 'process'); const processMsg = this._output.formatMsg(raw, this.source.config, 'process');
const influxMsg = this._output.formatMsg(raw, this.config, 'influxdb'); const influxMsg = this._output.formatMsg(raw, this.source.config, 'influxdb');
// Send only updated outputs on ports 0 & 1 // Send only updated outputs on ports 0 & 1
this.node.send([processMsg, influxMsg]); this.node.send([processMsg, influxMsg]);

File diff suppressed because it is too large Load Diff