fixing the drying calculator by making sure to update the initial time when the mode is changed
This commit is contained in:
parent
792eea73bf
commit
b2f3fac57e
1 changed files with 15 additions and 1 deletions
|
|
@ -250,6 +250,7 @@ export default function BinVisualizer(props: Props) {
|
||||||
const [cfmHighOpen, setCFMHighOpen] = useState(false);
|
const [cfmHighOpen, setCFMHighOpen] = useState(false);
|
||||||
const [{ user }] = useGlobalState();
|
const [{ user }] = useGlobalState();
|
||||||
const [newPreset, setNewPreset] = useState<pond.BinMode>(pond.BinMode.BIN_MODE_NONE);
|
const [newPreset, setNewPreset] = useState<pond.BinMode>(pond.BinMode.BIN_MODE_NONE);
|
||||||
|
const [newBinMode, setNewBinMode] = useState<pond.BinMode>(pond.BinMode.BIN_MODE_NONE);
|
||||||
const [selectedCable, setSelectedCable] = useState<GrainCable>();
|
const [selectedCable, setSelectedCable] = useState<GrainCable>();
|
||||||
const [openNodeDialog, setOpenNodeDialog] = useState(false);
|
const [openNodeDialog, setOpenNodeDialog] = useState(false);
|
||||||
const [cableDevice, setCableDevice] = useState<Device | undefined>();
|
const [cableDevice, setCableDevice] = useState<Device | undefined>();
|
||||||
|
|
@ -345,6 +346,7 @@ export default function BinVisualizer(props: Props) {
|
||||||
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
|
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
|
||||||
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
|
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
|
||||||
setGrainSubtype(bin.subtype());
|
setGrainSubtype(bin.subtype());
|
||||||
|
setNewBinMode(bin.settings.mode);
|
||||||
}
|
}
|
||||||
if (bin.settings) {
|
if (bin.settings) {
|
||||||
let t = bin.settings.outdoorTemp;
|
let t = bin.settings.outdoorTemp;
|
||||||
|
|
@ -1967,6 +1969,7 @@ export default function BinVisualizer(props: Props) {
|
||||||
|
|
||||||
const setModeStorage = () => {
|
const setModeStorage = () => {
|
||||||
setNewPreset(pond.BinMode.BIN_MODE_STORAGE);
|
setNewPreset(pond.BinMode.BIN_MODE_STORAGE);
|
||||||
|
setNewBinMode(pond.BinMode.BIN_MODE_STORAGE);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setModeCooldown = () => {
|
const setModeCooldown = () => {
|
||||||
|
|
@ -1974,6 +1977,7 @@ export default function BinVisualizer(props: Props) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setNewPreset(pond.BinMode.BIN_MODE_COOLDOWN);
|
setNewPreset(pond.BinMode.BIN_MODE_COOLDOWN);
|
||||||
|
setNewBinMode(pond.BinMode.BIN_MODE_COOLDOWN);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setModeDrying = () => {
|
const setModeDrying = () => {
|
||||||
|
|
@ -1982,13 +1986,16 @@ export default function BinVisualizer(props: Props) {
|
||||||
bin.settings.inventory?.initialMoisture < bin.settings.inventory?.targetMoisture
|
bin.settings.inventory?.initialMoisture < bin.settings.inventory?.targetMoisture
|
||||||
) {
|
) {
|
||||||
setNewPreset(pond.BinMode.BIN_MODE_HYDRATING);
|
setNewPreset(pond.BinMode.BIN_MODE_HYDRATING);
|
||||||
|
setNewBinMode(pond.BinMode.BIN_MODE_HYDRATING);
|
||||||
} else {
|
} else {
|
||||||
setNewPreset(pond.BinMode.BIN_MODE_DRYING);
|
setNewPreset(pond.BinMode.BIN_MODE_DRYING);
|
||||||
|
setNewBinMode(pond.BinMode.BIN_MODE_DRYING);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeMoistureDialog = () => {
|
const closeMoistureDialog = () => {
|
||||||
setNewPreset(0);
|
setNewPreset(0);
|
||||||
|
setNewBinMode(bin.settings.mode);
|
||||||
setShowInputMoisture(false);
|
setShowInputMoisture(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2049,6 +2056,7 @@ export default function BinVisualizer(props: Props) {
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setNewPreset(0);
|
setNewPreset(0);
|
||||||
|
setNewBinMode(bin.settings.mode);
|
||||||
setShowInputMoisture(false);
|
setShowInputMoisture(false);
|
||||||
}}
|
}}
|
||||||
color="primary">
|
color="primary">
|
||||||
|
|
@ -2090,7 +2098,13 @@ export default function BinVisualizer(props: Props) {
|
||||||
}
|
}
|
||||||
if (b.settings.outdoorHumidity !== undefined)
|
if (b.settings.outdoorHumidity !== undefined)
|
||||||
b.settings.outdoorHumidity = Number(outdoorHumidityInput);
|
b.settings.outdoorHumidity = Number(outdoorHumidityInput);
|
||||||
b.settings.mode = newPreset;
|
|
||||||
|
if (b.settings.mode != newBinMode){
|
||||||
|
if(b.settings.inventory){
|
||||||
|
b.settings.inventory.initialTimestamp = moment().format();
|
||||||
|
}
|
||||||
|
b.settings.mode = newBinMode;
|
||||||
|
}
|
||||||
|
|
||||||
binAPI.updateBin(bin.key(), b.settings, as).then(resp => {
|
binAPI.updateBin(bin.key(), b.settings, as).then(resp => {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue