updating the gate and terminal stuff for the device changes since we no longer have MiPCA device use chains for pressure and duct temp and are now only measuring the outlet and substituting the temp inlet with the ambient temp and the pressure inlet with 0

This commit is contained in:
csawatzky 2026-02-25 16:10:12 -06:00
parent 2413cc36d1
commit b5adba8f93
6 changed files with 164 additions and 65 deletions

View file

@ -164,29 +164,49 @@ export default function GateList(props: Props) {
// }
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 { //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
} else { //the pca is currently active calulate the delta temp (outlet - ambient)
let ambient = cloneDeep(gate.status.lastAmbientReading)
let temp = cloneDeep(gate.status.lastTempReading)
if(ambient.length > 0 && temp.length > 0){
let ambientTemp: number | undefined
let outletTemp: number | undefined
ambient.forEach(um => {
if(um.type === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE){
let clone = cloneDeep(um)
let measurement = UnitMeasurement.any(clone, user)
if(measurement.values.length > 0){
let readings = measurement.values[measurement.values.length -1]
if(readings.values.length > 0){
ambientTemp = readings.values[readings.values.length -1]
}
}
}
})
temp.forEach(um => {
if(um.type === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE){
let clone = cloneDeep(um)
let measurement = UnitMeasurement.any(clone, user)
if(measurement.values.length > 0){
let readings = measurement.values[measurement.values.length -1]
if(readings.values.length > 0){
outletTemp = readings.values[readings.values.length -1]
}
}
}
})
if(ambientTemp && outletTemp){
let deltaTemp = outletTemp - ambientTemp
display = deltaTemp.toFixed(2) + (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? "°F" : "°C")
}else{
display = "Sensor Missing"
}
})
display = deltaTemp.toFixed(2) + (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? "°F" : "°C")
}
}
return (
<Typography>