diff --git a/src/bin/BinVisualizerV2.tsx b/src/bin/BinVisualizerV2.tsx index 8cd41e0..c00072c 100644 --- a/src/bin/BinVisualizerV2.tsx +++ b/src/bin/BinVisualizerV2.tsx @@ -48,6 +48,8 @@ import { useBinAPI } from "providers/pond/binAPI"; import BindaptIcon from "products/Bindapt/BindaptIcon"; import { AccessTime, + ArrowForward, + ArrowForwardIos, CheckCircleOutline, Error, InfoOutlined, @@ -172,16 +174,21 @@ interface GrainConditions { emcTrend: number; } +interface CombinedPlenum { + tempHumidity?: Plenum, + pressure?: Pressure +} + interface Props { bin: Bin; loading: boolean; components: Map; componentDevices?: Map; devices: Device[]; - plenum?: Plenum; + plenums?: Plenum[]; ambient?: Ambient; cables?: GrainCable[]; - pressure?: Pressure; + pressures?: Pressure[]; interactions?: Interaction[]; //changeBinMode: (binMode: pond.BinMode) => boolean; refresh: (showSnack?: boolean) => void; @@ -197,9 +204,9 @@ export default function BinVisualizer(props: Props) { bin, //changeBinMode, //changeGrainAmount, - plenum, + plenums, ambient, - pressure, + pressures, loading, cables, components, @@ -282,6 +289,10 @@ export default function BinVisualizer(props: Props) { const [storageDate, setStorageDate] = useState(moment().format("YYYY-MM-DD")); const [storageTime, setStorageTime] = useState(moment().format("HH:mm")); + const [activePlenum, setActivePlenum] = useState() + const [activePlenumIndex, setActivePlenumIndex] = useState(0) + const [combinedPlenums, setCombinedPlenums] = useState([]) + // const StyledToggle = styled(ToggleButton)(({ theme }: { theme: Theme }) => ({ // root: { // backgroundColor: "transparent", @@ -335,6 +346,31 @@ export default function BinVisualizer(props: Props) { setModeTime(moment(bin.status.lastModeChange)); }, [bin.status.lastModeChange]); + useEffect(()=>{ + //match the plenums and pressures based on their location (address) + let combinedPlenums: CombinedPlenum[] = [] + if (plenums) { + plenums.forEach(plenum => { + let newCombinedPlenum: CombinedPlenum = { + tempHumidity: plenum + } + if (pressures) { + pressures.forEach(pressure => { + if(plenum.location().address === pressure.location().address){ + console.log("found match") + newCombinedPlenum.pressure = pressure + } + }) + } + combinedPlenums.push(newCombinedPlenum) + }) + } + if (combinedPlenums.length > 0){ + setActivePlenum(combinedPlenums[0]) + } + setCombinedPlenums(combinedPlenums) + },[plenums, pressures]) + useEffect(() => { setIsCustomInventory(bin.storage() !== pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN); setStorageType(bin.storage()); @@ -418,7 +454,6 @@ export default function BinVisualizer(props: Props) { //determine which node is the coldest so that the data displayed is for the same node let lowTempIndex = filteredNodes.temps.indexOf(Math.min(...filteredNodes.temps)) === -1 ? 0 : filteredNodes.temps.indexOf(Math.min(...filteredNodes.temps)); - console.log(lowTempIndex) lowNodeConditions = { tempC: filteredNodes.temps[lowTempIndex], humidity: filteredNodes.humids[lowTempIndex], @@ -1094,14 +1129,28 @@ export default function BinVisualizer(props: Props) { const plenumOverview = () => { return ( + - Plenum + Plenum {plenums && plenums?.length > 1 ? activePlenumIndex+1 : ""} + {plenums && plenums.length > 1 && + { + let newIndex = activePlenumIndex + 1 + if(newIndex > combinedPlenums.length - 1){ + newIndex = 0 + } + setActivePlenum(combinedPlenums[newIndex]) + setActivePlenumIndex(newIndex) + }}> + + + } + - {plenum ? ( + {activePlenum?.tempHumidity ? ( - {plenum.getTempString(user.settings.temperatureUnit)} + {activePlenum.tempHumidity.getTempString(user.settings.temperatureUnit)} @@ -1141,7 +1190,7 @@ export default function BinVisualizer(props: Props) { fontWeight: 650, color: humidColour }}> - {plenum.getHumidityString()} + {activePlenum.tempHumidity.getHumidityString()} @@ -1262,7 +1311,7 @@ export default function BinVisualizer(props: Props) { style={{ height: isMobile ? 20 : 25, width: isMobile ? 20 : 25 }} /> - {pressure ? ( + {activePlenum?.pressure ? ( - {pressure.getPressureString(user.settings.pressureUnit)} + {activePlenum.pressure.getPressureString(user.settings.pressureUnit)} {/* @@ -1600,7 +1649,7 @@ export default function BinVisualizer(props: Props) { Fan Performance - {pressure && pressure.fanId === 0 && !bin.settings.fan?.type && bin.fanID() === 0 && ( + {activePlenum?.pressure && activePlenum.pressure.fanId === 0 && !bin.settings.fan?.type && bin.fanID() === 0 && ( No fans found to calculate CFM @@ -1642,8 +1691,8 @@ export default function BinVisualizer(props: Props) { {ExtractMoisture( bin.grain(), - plenum?.temperature ?? 0, - plenum?.humidity ?? 0 + activePlenum?.tempHumidity?.temperature ?? 0, + activePlenum?.tempHumidity?.humidity ?? 0 ).toFixed(2)} % @@ -2148,7 +2197,7 @@ export default function BinVisualizer(props: Props) { {controls()} - {plenum && pressure && fanPerformance()} + {plenums && pressures && fanPerformance()} {ambient && ambientDisplay()} {(bin.status.fans.length > 0 || bin.status.heaters.length > 0) && controllerDisplay()} {dryingEstimate()} diff --git a/src/pages/Bin.tsx b/src/pages/Bin.tsx index 082a2c9..c352634 100644 --- a/src/pages/Bin.tsx +++ b/src/pages/Bin.tsx @@ -689,8 +689,8 @@ export default function Bin(props: Props) { const overview = () => { return (