diff --git a/package-lock.json b/package-lock.json index 6049cfe..9ffbcf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9780,7 +9780,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#cf0774d8aab2663916bbb0b2c44f4bb3352487b5", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#6cbc16a8de336d72e2e65619327e4462d26ce05d", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/src/bin/BinCardV2.tsx b/src/bin/BinCardV2.tsx index 7269784..33b42e4 100644 --- a/src/bin/BinCardV2.tsx +++ b/src/bin/BinCardV2.tsx @@ -401,6 +401,7 @@ export default function BinCard(props: Props) { fillPercentage={bin.fillPercent()} lidarEstimate={lidarPercentage} cables={cables} + co2Sensors={bin.status.co2} highTemp={bin.settings.highTemp} lowTemp={bin.settings.lowTemp} hottestNodeTemp={valDisplay === "high" ? hotNode?.temp : undefined} diff --git a/src/bin/BinSVGV2.tsx b/src/bin/BinSVGV2.tsx index 6e47511..a6093b9 100644 --- a/src/bin/BinSVGV2.tsx +++ b/src/bin/BinSVGV2.tsx @@ -30,6 +30,22 @@ const useStyles = makeStyles((theme: Theme) => { fill: "#0575E6" } }, + "@keyframes headspaceWarning": { + from: { + fill: "#d18221" + }, + to: { + fill: "#9a9d9f" + } + }, + "@keyframes headspaceCritical": { + from: { + fill: "#ff0000" + }, + to: { + fill: "#9a9d9f" + } + }, outerShell: { fill: "url(#outerShellGradient)" }, @@ -39,9 +55,17 @@ const useStyles = makeStyles((theme: Theme) => { container: { fill: "#a1a9b1" }, - headspace: { + headspaceNormal: { fill: "#9a9d9f" }, + headspaceWarning: { + fill: "#9a9d9f", + animation: "$headspaceWarning 0.5s alternate infinite" + }, + headspaceCritical: { + fill: "#9a9d9f", + animation: "$headspaceCritical 0.5s alternate infinite" + }, bottom: { fill: "#9c9fa2" }, @@ -107,6 +131,7 @@ interface Props { fillPercentage: number; lidarEstimate?: number; cables?: GrainCable[]; + co2Sensors: pond.BinCO2[]; hasMinHeight?: boolean; highTemp: number; lowTemp: number; @@ -180,7 +205,8 @@ export default function BinSVGV2(props: Props) { cableEstimate, hottestNodeTemp, coldestNodeTemp, - inventoryControl + inventoryControl, + co2Sensors } = props; const [{ user }] = useGlobalState(); const [extraDetails, setExtraDetails] = useState<"temps" | "hums">("temps"); @@ -310,6 +336,25 @@ export default function BinSVGV2(props: Props) { } }; + const headspaceClass = () => { + if (!co2Sensors || co2Sensors.length === 0) return classes.headspaceNormal; + // let testSensor = [pond.BinCO2.create({ + // device: 4, + // key: "testSensor", + // name: "test Sensor", + // ppm: 1600 + // })] + let highestReading = 0; + //testSensor.forEach(sensor => { + co2Sensors.forEach(sensor => { + //if the current sensor is greater the the currently highest reading change it to the current sensor + highestReading = sensor.ppm > highestReading ? sensor.ppm : highestReading; + }); + if (highestReading > 1500) return classes.headspaceCritical; + if (highestReading > 1000) return classes.headspaceWarning; + return classes.headspaceNormal; + }; + const borderColor = () => { //determine color of border based on node status: > high or < low = red, within both = green return !cables || cables.length === 0 ? "#000000" : nodeWarning ? "#ff0000" : "#00ff00"; @@ -946,7 +991,7 @@ export default function BinSVGV2(props: Props) { /> )} @@ -991,7 +1036,7 @@ export default function BinSVGV2(props: Props) { id="bottom" /> diff --git a/src/bin/BinStorageConditions.tsx b/src/bin/BinStorageConditions.tsx index 2e0d2cf..4f71818 100644 --- a/src/bin/BinStorageConditions.tsx +++ b/src/bin/BinStorageConditions.tsx @@ -636,7 +636,7 @@ export default function BinStorageConditions(props: Props) { {headspaceCO2.map(co2 => { - let measurement = UnitMeasurement.any(co2.status.lastGoodMeasurement[0]); + let measurement = UnitMeasurement.any(co2.status.lastGoodMeasurement[0] ?? UnitMeasurement.create()); let reading: number = 0; if (measurement.values[0] && measurement.values[0].values[0]) { reading = measurement.values[0].values[0]; diff --git a/src/bin/BinVisualizerV2.tsx b/src/bin/BinVisualizerV2.tsx index 935f9c1..88b8107 100644 --- a/src/bin/BinVisualizerV2.tsx +++ b/src/bin/BinVisualizerV2.tsx @@ -1400,6 +1400,7 @@ export default function BinVisualizer(props: Props) { fillPercentage={fillPercentage ?? 0} lidarEstimate={lidarPercentage} cables={grainCables} + co2Sensors={bin.status.co2} highTemp={bin.settings.highTemp} lowTemp={bin.settings.lowTemp} showTempHum={iOS ? nodeDetails : fullScreenHandler.active}