From 661a35b5a8e95570a513d2d2aae53e46ef1cd25b Mon Sep 17 00:00:00 2001 From: csawatzky Date: Tue, 2 Sep 2025 11:00:00 -0600 Subject: [PATCH] fixed issue where the cables on the bin svg swapped due to the sorting algorithm, fixed filter issue that included the node one position above the top node, fixed issue that included temp only nodes in the average humidity and moisture calcs --- src/bin/BinSVGV2.tsx | 18 +++++++++--------- src/bin/BinVisualizerV2.tsx | 7 +++++-- src/models/GrainCable.ts | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bin/BinSVGV2.tsx b/src/bin/BinSVGV2.tsx index 2c7a888..c3c1a40 100644 --- a/src/bin/BinSVGV2.tsx +++ b/src/bin/BinSVGV2.tsx @@ -476,11 +476,11 @@ export default function BinSVGV2(props: Props) { return cableGrainPath; }; - const nodeClass = (nodeTemp: number) => { - if (hottestNodeTemp && hottestNodeTemp.toFixed(2) === nodeTemp.toFixed(2)) { + const nodeClass = (nodeTemp: number, underTop: boolean) => { + if (hottestNodeTemp && hottestNodeTemp.toFixed(2) === nodeTemp.toFixed(2) && underTop) { return classes.hotNode; } - if (coldestNodeTemp && coldestNodeTemp.toFixed(2) === nodeTemp.toFixed(2)) { + if (coldestNodeTemp && coldestNodeTemp.toFixed(2) === nodeTemp.toFixed(2) && underTop) { return classes.coldNode; } return classes.cableNode; @@ -507,12 +507,12 @@ export default function BinSVGV2(props: Props) { //if the cables have the same number of nodes if (b.temperatures.length === a.temperatures.length) { //sort by temp only last and any type that has humidity first - if ( - a.settings.subtype === quack.GrainCableSubtype.GRAIN_CABLE_SUBTYPE_OPI_TEMP && - b.settings.subtype !== quack.GrainCableSubtype.GRAIN_CABLE_SUBTYPE_OPI_TEMP - ) { + if ((avg(a.humidities) === 0 || a.humidities.length === 0) && (avg(b.humidities) !== 0 || b.humidities.length > 0)) { return 1; - } else { + } else if ((avg(b.humidities) === 0 || b.humidities.length === 0) && (avg(a.humidities) !== 0 || a.humidities.length > 0)) { + return -1; + } + else { return a.key() > b.key() ? 1 : -1; } } @@ -759,7 +759,7 @@ export default function BinSVGV2(props: Props) { return ( {e.nodeNumber === topNode && !e.excluded && topNodeHat(cablePos, e.y)} - + ) } diff --git a/src/bin/BinVisualizerV2.tsx b/src/bin/BinVisualizerV2.tsx index 3e5e131..6a10ff4 100644 --- a/src/bin/BinVisualizerV2.tsx +++ b/src/bin/BinVisualizerV2.tsx @@ -386,8 +386,11 @@ export default function BinVisualizer(props: Props) { //also reverse it so that the node 1 (end of the cable) is in the first position let filteredNodes = cable.filteredNodes(true) temps.push(...filteredNodes.temps) - humids.push(...filteredNodes.humids) - emcs.push(...filteredNodes.moistures) + //only push to the humidity values if the cable reads humidities + if(cable.subType() !== quack.GrainCableSubtype.GRAIN_CABLE_SUBTYPE_OPI_TEMP){ + humids.push(...filteredNodes.humids) + emcs.push(...filteredNodes.moistures) + } // let tempClone = cloneDeep(cable.temperatures).reverse(); // let humClone = cloneDeep(cable.humidities).reverse(); // let emcClone = cloneDeep(cable.grainMoistures).reverse(); diff --git a/src/models/GrainCable.ts b/src/models/GrainCable.ts index 52d6b6b..b382e2b 100644 --- a/src/models/GrainCable.ts +++ b/src/models/GrainCable.ts @@ -255,6 +255,8 @@ export class GrainCable { let humids: number [] = cloneDeep(this.humidities).reverse() let moistures: number[] = cloneDeep(this.grainMoistures).reverse() + console.log(temps) + //filter out the excluded nodes temps = this.filter(temps) humids = this.filter(humids) @@ -273,7 +275,7 @@ export class GrainCable { let filtered: number[] = [] values.forEach((val, index) => { //if the node is not excluded AND is either under the top node OR top node is not set - if(!this.excludedNodes.includes(index) && (index <= this.topNode || this.topNode === 0)){ + if(!this.excludedNodes.includes(index) && (index < this.topNode || this.topNode === 0)){ filtered.push(val) } })