From 5f44cf6f091a47a5d705c2e6fd5e0c97ee8c89f3 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Tue, 3 Feb 2026 15:14:49 -0600 Subject: [PATCH] chaging the gate list display slightly to show the delta temp of the last temp reading on the gate --- src/gate/GateList.tsx | 203 +++++++++++++++++++++++------------------- 1 file changed, 109 insertions(+), 94 deletions(-) diff --git a/src/gate/GateList.tsx b/src/gate/GateList.tsx index e864980..5c7fb0c 100644 --- a/src/gate/GateList.tsx +++ b/src/gate/GateList.tsx @@ -110,67 +110,83 @@ export default function GateList(props: Props) { } } - const lastOutletReading = (reading: pond.UnitMeasurementsForComponent[]) => { - let outletDisplay = "--" - let timeSince = "No Reading Yet" - let color = "" - reading.forEach(um => { - let clone = cloneDeep(um) - let measurement = UnitMeasurement.create(clone, user) - if(measurement.type === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE || measurement.type === quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE){ - let nodes = measurement.values[measurement.values.length-1].values - outletDisplay = nodes[nodes.length-1].toFixed(2) + " " + measurement.unit - timeSince = moment(measurement.timestamps[measurement.timestamps.length-1]).fromNow() - color = measurement.colour - } - }) + // const lastOutletReading = (reading: pond.UnitMeasurementsForComponent[]) => { + // let outletDisplay = "--" + // let timeSince = "No Reading Yet" + // let color = "" + // reading.forEach(um => { + // let clone = cloneDeep(um) + // let measurement = UnitMeasurement.create(clone, user) + // if(measurement.type === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE || measurement.type === quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE){ + // let nodes = measurement.values[measurement.values.length-1].values + // outletDisplay = nodes[nodes.length-1].toFixed(2) + " " + measurement.unit + // timeSince = moment(measurement.timestamps[measurement.timestamps.length-1]).fromNow() + // color = measurement.colour + // } + // }) - if(isMobile){ - return ( - - {outletDisplay} - {timeSince} - - ) - } - return ( - - - Value: - {outletDisplay} - - - Time: - {timeSince} - - - ) - } + // if(isMobile){ + // return ( + // + // {outletDisplay} + // {timeSince} + // + // ) + // } + // return ( + // + // + // Value: + // {outletDisplay} + // + // + // Time: + // {timeSince} + // + // + // ) + // } - const tempDisplay = (gate: Gate) => { - let display = "--" - if(gate.status.pcaState !== pond.PCAState.PCA_STATE_OFF){ - //only display it if the final temp is between -4 and 60 C, is a valid number, and is not exactly 0 - //0 is technically a valid number but the likely hood of the calculation being exactly 0 is negligible - if (gate.status.finalTemp < 60 && gate.status.finalTemp > -40 && !isNaN(gate.status.finalTemp) && gate.status.finalTemp !== 0){ - display = getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? CtoF(gate.status.finalTemp).toFixed(2) + "°F" : gate.status.finalTemp.toFixed(2) + "°C" - } - } - return ( - - {display} - - ) - } + // const tempDisplay = (gate: Gate) => { + // let display = "--" + // if(gate.status.pcaState !== pond.PCAState.PCA_STATE_OFF){ + // //only display it if the final temp is between -4 and 60 C, is a valid number, and is not exactly 0 + // //0 is technically a valid number but the likely hood of the calculation being exactly 0 is negligible + // if (gate.status.finalTemp < 60 && gate.status.finalTemp > -40 && !isNaN(gate.status.finalTemp) && gate.status.finalTemp !== 0){ + // display = getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? CtoF(gate.status.finalTemp).toFixed(2) + "°F" : gate.status.finalTemp.toFixed(2) + "°C" + // } + // } + // return ( + // + // {display} + // + // ) + // } const conditionDisplay = (gate: Gate) => { + console.log(gate) let display = "" + let deltaTemp = 0 if(gate.status.pcaState === pond.PCAState.PCA_STATE_OFF){ display = "Inactive" } else if (gate.status.pcaState === pond.PCAState.PCA_STATE_UNKNOWN){ display = "--" - } else { - display = gate.status.heating ? "Heating" : "Cooling" + } else { //the pca is currently active calulate the delta temp (T2 - T1) provided there are two temps + //loop to find the temp readings + let clone = cloneDeep(gate.status.lastTempReading) + clone.forEach(unitMeasurement => { + let um = UnitMeasurement.create(unitMeasurement, user) + if(um.type === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE){ + if(um.values.length > 0){ //as long as there is at least on thing in the measurements + let lastReading = um.values[um.values.length-1] //there should only be one measurement in here but just make sure to get the end of the array + if(lastReading.values.length > 1){ //make sure there are at least two values in the array + console.log(lastReading.values) + deltaTemp = lastReading.values[lastReading.values.length -1] - lastReading.values[0] //subtract the first value from the last value to get the delta + } + } + } + }) + display = deltaTemp.toFixed(2) + (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? "°F" : "°C") } return ( @@ -222,43 +238,44 @@ export default function GateList(props: Props) { )} }, - { - title: "Estimated Temp", - render: gate => { - return ( - - {tempDisplay(gate)} - - ) - } - }, - { - title: "Last FLow", - render: gate => ( - - - Flow: - {gate.status.lastMassAirflow.toFixed(2)} kg/s - - - Read: - {gate.status.lastUpdate !== "" ? moment(gate.status.lastUpdate).fromNow() : "No Reading Yet"} - - - ) - }, - { - title: "Outlet Temperature", - render: gate => ( - {lastOutletReading(gate.status.lastTempReading)} - ) - }, - { - title: "Outlet Pressure", - render: gate => ( - {lastOutletReading(gate.status.lastPressureReading)} - ) - } + //taking out these columns for now because were not sure if the customer actually wants them + // { + // title: "Estimated Temp", + // render: gate => { + // return ( + // + // {tempDisplay(gate)} + // + // ) + // } + // }, + // { + // title: "Last FLow", + // render: gate => ( + // + // + // Flow: + // {gate.status.lastMassAirflow.toFixed(2)} kg/s + // + // + // Read: + // {gate.status.lastUpdate !== "" ? moment(gate.status.lastUpdate).fromNow() : "No Reading Yet"} + // + // + // ) + // }, + // { + // title: "Outlet Temperature", + // render: gate => ( + // {lastOutletReading(gate.status.lastTempReading)} + // ) + // }, + // { + // title: "Outlet Pressure", + // render: gate => ( + // {lastOutletReading(gate.status.lastPressureReading)} + // ) + // } ] } const mobileCols = (): Column[] => { @@ -297,7 +314,8 @@ export default function GateList(props: Props) { Conditioning: {conditionDisplay(gate)} - + {/* taking these out for now because we are not sure if the customer wants them */} + {/* Estimated Temp: {tempDisplay(gate)} @@ -313,11 +331,8 @@ export default function GateList(props: Props) { Outlet Pressure: {lastOutletReading(gate.status.lastPressureReading)} - + */} - // - - // ) }