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

This commit is contained in:
csawatzky 2025-09-02 11:00:00 -06:00
parent 1b916a34de
commit 661a35b5a8
3 changed files with 17 additions and 12 deletions

View file

@ -476,11 +476,11 @@ export default function BinSVGV2(props: Props) {
return cableGrainPath; return cableGrainPath;
}; };
const nodeClass = (nodeTemp: number) => { const nodeClass = (nodeTemp: number, underTop: boolean) => {
if (hottestNodeTemp && hottestNodeTemp.toFixed(2) === nodeTemp.toFixed(2)) { if (hottestNodeTemp && hottestNodeTemp.toFixed(2) === nodeTemp.toFixed(2) && underTop) {
return classes.hotNode; 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.coldNode;
} }
return classes.cableNode; return classes.cableNode;
@ -507,12 +507,12 @@ export default function BinSVGV2(props: Props) {
//if the cables have the same number of nodes //if the cables have the same number of nodes
if (b.temperatures.length === a.temperatures.length) { if (b.temperatures.length === a.temperatures.length) {
//sort by temp only last and any type that has humidity first //sort by temp only last and any type that has humidity first
if ( if ((avg(a.humidities) === 0 || a.humidities.length === 0) && (avg(b.humidities) !== 0 || b.humidities.length > 0)) {
a.settings.subtype === quack.GrainCableSubtype.GRAIN_CABLE_SUBTYPE_OPI_TEMP &&
b.settings.subtype !== quack.GrainCableSubtype.GRAIN_CABLE_SUBTYPE_OPI_TEMP
) {
return 1; 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; return a.key() > b.key() ? 1 : -1;
} }
} }
@ -759,7 +759,7 @@ export default function BinSVGV2(props: Props) {
return ( return (
<g key={e.key}> <g key={e.key}>
{e.nodeNumber === topNode && !e.excluded && topNodeHat(cablePos, e.y)} {e.nodeNumber === topNode && !e.excluded && topNodeHat(cablePos, e.y)}
<circle cx={cablePos} cy={e.y} className={e.excluded ? classes.excludedNode : nodeClass(e.nodeTemp)} r="16"></circle> <circle cx={cablePos} cy={e.y} className={e.excluded ? classes.excludedNode : nodeClass(e.nodeTemp, e.nodeNumber <= topNode)} r="16"></circle>
</g> </g>
) )
} }

View file

@ -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 //also reverse it so that the node 1 (end of the cable) is in the first position
let filteredNodes = cable.filteredNodes(true) let filteredNodes = cable.filteredNodes(true)
temps.push(...filteredNodes.temps) temps.push(...filteredNodes.temps)
//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) humids.push(...filteredNodes.humids)
emcs.push(...filteredNodes.moistures) emcs.push(...filteredNodes.moistures)
}
// let tempClone = cloneDeep(cable.temperatures).reverse(); // let tempClone = cloneDeep(cable.temperatures).reverse();
// let humClone = cloneDeep(cable.humidities).reverse(); // let humClone = cloneDeep(cable.humidities).reverse();
// let emcClone = cloneDeep(cable.grainMoistures).reverse(); // let emcClone = cloneDeep(cable.grainMoistures).reverse();

View file

@ -255,6 +255,8 @@ export class GrainCable {
let humids: number [] = cloneDeep(this.humidities).reverse() let humids: number [] = cloneDeep(this.humidities).reverse()
let moistures: number[] = cloneDeep(this.grainMoistures).reverse() let moistures: number[] = cloneDeep(this.grainMoistures).reverse()
console.log(temps)
//filter out the excluded nodes //filter out the excluded nodes
temps = this.filter(temps) temps = this.filter(temps)
humids = this.filter(humids) humids = this.filter(humids)
@ -273,7 +275,7 @@ export class GrainCable {
let filtered: number[] = [] let filtered: number[] = []
values.forEach((val, index) => { values.forEach((val, index) => {
//if the node is not excluded AND is either under the top node OR top node is not set //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) filtered.push(val)
} }
}) })