Merge branch 'node_exclusion_update' into staging_environment

This commit is contained in:
csawatzky 2025-08-01 11:47:30 -06:00
commit 384d8ad2ed
2 changed files with 44 additions and 26 deletions

View file

@ -431,8 +431,6 @@ export default function BinSVGV2(props: Props) {
); );
}; };
//console.log(cables)
const cableGrainEstimate = ( const cableGrainEstimate = (
points: GrainNodePoint[], points: GrainNodePoint[],
cableSpacing: number, cableSpacing: number,
@ -619,16 +617,6 @@ export default function BinSVGV2(props: Props) {
if (!cable.excludedNodes.includes(nodeNumber - 1)){ if (!cable.excludedNodes.includes(nodeNumber - 1)){
if (cable.topNode > 0) { if (cable.topNode > 0) {
if (nodeNumber <= cable.topNode) { if (nodeNumber <= cable.topNode) {
// nodeHeatMap.push(
// <ellipse
// key={index}
// cx={cablePos}
// cy={nodeY}
// rx="120"
// ry="60"
// fill={getGrainGradient(temp)}
// />
// );
nodeHeatMapData.push({ nodeHeatMapData.push({
key: index, key: index,
xCenter: cablePos, xCenter: cablePos,
@ -639,17 +627,6 @@ export default function BinSVGV2(props: Props) {
}) })
} }
} else if (nodeY > filledToY) { } else if (nodeY > filledToY) {
//otherwise use the fill level of the bin
// nodeHeatMap.push(
// <ellipse
// key={index}
// cx={cablePos}
// cy={nodeY}
// rx="120"
// ry="60"
// fill={getGrainGradient(temp)}
// />
// );
nodeHeatMapData.push({ nodeHeatMapData.push({
key: index, key: index,
xCenter: cablePos, xCenter: cablePos,

View file

@ -91,6 +91,7 @@ export default function GrainNodeInteractions(props: Props) {
const humDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_PERCENT); const humDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_PERCENT);
const moistureDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC); const moistureDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC);
const [topNode, setTopNode] = useState(false); const [topNode, setTopNode] = useState(false);
const [excluded, setExcluded] = useState(false);
const componentAPI = useComponentAPI(); const componentAPI = useComponentAPI();
const interactionAPI = useInteractionsAPI(); const interactionAPI = useInteractionsAPI();
const binAPI = useBinAPI(); const binAPI = useBinAPI();
@ -131,6 +132,13 @@ export default function GrainNodeInteractions(props: Props) {
} else { } else {
setTopNode(false); setTopNode(false);
} }
//determine if the node is excluded
if (cable.excludedNodes.includes(displayNode - 1)){
setExcluded(true)
}else{
setExcluded(false)
}
}, [cable, displayNode]); }, [cable, displayNode]);
const goToComponent = () => { const goToComponent = () => {
@ -167,6 +175,7 @@ export default function GrainNodeInteractions(props: Props) {
.then(resp => {}) .then(resp => {})
.catch(err => {}); .catch(err => {});
}); });
updateComponentCallback(cable.key())
}) })
.catch(err => { .catch(err => {
openSnack("Failed to update component"); openSnack("Failed to update component");
@ -204,6 +213,15 @@ export default function GrainNodeInteractions(props: Props) {
setTopNode(checked); setTopNode(checked);
}; };
const updateNodeExclusion = (checked: boolean) => {
if (checked) {
cable.settings.excludedNodes.push(selectedNode-1)
} else {
cable.settings.excludedNodes.splice(cable.settings.excludedNodes.indexOf(selectedNode - 1), 1)
}
setExcluded(checked)
}
const displayTemp = () => { const displayTemp = () => {
let tempFinal = nodeTemp ?? 0; let tempFinal = nodeTemp ?? 0;
if (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) { if (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
@ -312,15 +330,38 @@ export default function GrainNodeInteractions(props: Props) {
); );
}; };
const fillNodeSet = () => { const nodeControl = () => {
return ( return (
<Box style={{ marginTop: 10 }}> <Box style={{ marginTop: 10 }}>
<Typography style={{ fontSize: 20, fontWeight: 650 }}>Top Node Control</Typography> <Typography style={{ fontSize: 20, fontWeight: 650 }}>Node Control</Typography>
<FormControlLabel
style={{ marginTop: 10 }}
control={
<Checkbox
checked={excluded}
onChange={e => {
updateNodeExclusion(e.target.checked);
}}
name="excludedNode"
/>
}
label={
<React.Fragment>
<Typography style={{ fontSize: 15, fontWeight: 650 }}>
Exclude Node
</Typography>
<Typography style={{ fontSize: 15 }}>
If checked this will set the node to be disabled and will not be used for any calculations done for the bin
</Typography>
</React.Fragment>
}
/>
<FormControlLabel <FormControlLabel
style={{ marginTop: 10 }} style={{ marginTop: 10 }}
control={ control={
<Checkbox <Checkbox
checked={topNode} checked={topNode}
disabled={excluded}
onChange={e => { onChange={e => {
updateTopNode(e.target.checked); updateTopNode(e.target.checked);
}} }}
@ -418,7 +459,7 @@ export default function GrainNodeInteractions(props: Props) {
</DialogTitle> </DialogTitle>
<DialogContent> <DialogContent>
{latestReading()} {latestReading()}
{fillNodeSet()} {nodeControl()}
{interactionDisplay()} {interactionDisplay()}
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>