From e093b003f04171fa2f05e5df25544d34bd04fb5b Mon Sep 17 00:00:00 2001 From: Parag More Date: Thu, 2 Jul 2026 19:39:12 +0530 Subject: [PATCH] fix(cooling): include per-group PTs in miners C1 supply/return tables The FE builds the SUPPLY/RETURN tables from line.supply.sensors / line.return.sensors and the delta-P table from differential_pressure. Append each group's supply/return PT (type 'Pressure - Group N') to the sensor lists so the per-group pressures render, and number groups absolutely (line1 1-8, line2 9-16) since the FE prints entry.group. --- .../handlers/cooling.system.handlers.js | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/workers/lib/server/handlers/cooling.system.handlers.js b/workers/lib/server/handlers/cooling.system.handlers.js index abb0b8a..e9001aa 100644 --- a/workers/lib/server/handlers/cooling.system.handlers.js +++ b/workers/lib/server/handlers/cooling.system.handlers.js @@ -77,6 +77,9 @@ function buildVibrationSwitch (vibrationSwitches, switchTag) { function buildGroupDifferentialPressure (lineConfig, pressures) { const groupSensors = lineConfig.group_pressure_sensors || {} + // Absolute group number (line1 -> 1-8, line2 -> 9-16), parsed from the + // line's "Groups N-M" label so the UI labels each row correctly. + const groupStart = parseInt((String(lineConfig.groups || '').match(/\d+/) || ['1'])[0], 10) || 1 if (Array.isArray(groupSensors)) { return groupSensors.map((sensorId, i) => { @@ -84,7 +87,7 @@ function buildGroupDifferentialPressure (lineConfig, pressures) { const mkSlot = (val) => ({ tag: sensorId, type: pt?.type || null, - reading: val != null ? { value: val, unit: pt?.unit || 'bar' } : null + reading: { value: val ?? null, unit: pt?.unit || 'bar' } }) const supply = mkSlot(pt?.supply_pressure) const ret = mkSlot(pt?.return_pressure) @@ -97,10 +100,10 @@ function buildGroupDifferentialPressure (lineConfig, pressures) { : null) const unit = supply.reading?.unit || ret.reading?.unit || pt?.unit || 'bar' return { - group: i + 1, + group: groupStart + i, supply, return: ret, - delta_p: deltaPVal != null ? { value: deltaPVal, unit } : null + delta_p: { value: deltaPVal ?? null, unit } } }) } @@ -167,6 +170,17 @@ function buildMinersCircuit1View (equipment, config) { const controlValveId = lineConfig.control_valve const controlValve = valves?.find(v => v.equipment === controlValveId) + // Per-group PTs feed three UI tables: their supply/return readings belong in + // the SUPPLY/RETURN sensor lists (below temp/flow), and the ΔP table reads + // differential_pressure. The FE renders each `type` verbatim as the row label. + const groupDp = buildGroupDifferentialPressure(lineConfig, pressures) + const supplyGroupSensors = groupDp + .filter(g => g.supply?.tag) + .map(g => ({ tag: g.supply.tag, type: `Pressure · Group ${g.group}`, reading: g.supply.reading })) + const returnGroupSensors = groupDp + .filter(g => g.return?.tag) + .map(g => ({ tag: g.return.tag, type: `Pressure · Group ${g.group}`, reading: g.return.reading })) + lines.push({ name: lineConfig.name, groups: lineConfig.groups, @@ -174,14 +188,14 @@ function buildMinersCircuit1View (equipment, config) { temperature: supplyTempSensor?.reading || getSensorReading(temperatures, lineConfig.supply_temp_sensor, coolingConfig.defaults?.supply_temp), pressure: getSensorReading(pressures, lineConfig.supply_pressure_sensor), flow: getSensorReading(flows, lineConfig.supply_flow_sensor), - sensors: [supplyTempSensor, supplyPressureSensor, supplyFlowSensor].filter(Boolean) + sensors: [supplyTempSensor, supplyPressureSensor, supplyFlowSensor, ...supplyGroupSensors].filter(Boolean) }, return: { temperature: getSensorReading(temperatures, lineConfig.return_temp_sensor, coolingConfig.defaults?.return_temp), pressure: getSensorReading(pressures, lineConfig.return_pressure_sensor), - sensors: [returnTempSensor, returnPressureSensor].filter(Boolean) + sensors: [returnTempSensor, returnPressureSensor, ...returnGroupSensors].filter(Boolean) }, - differential_pressure: buildGroupDifferentialPressure(lineConfig, pressures), + differential_pressure: groupDp, heat_exchanger: hx ? { id: hx.equipment,