updated the gate page to use the pca state in the gates status for the lights on the visualizer and the pca fan on/off, this also allows me to get rid of setting those base on the data loaded for the graph which will fix the bug where the light could change based on what date range you loaded
This commit is contained in:
parent
f02aa3a6e0
commit
e42f1a3fb0
5 changed files with 52 additions and 42 deletions
|
|
@ -51,8 +51,8 @@ export default function GateDevice(props: Props) {
|
|||
const [interactionDialog, setInteractionDialog] = useState(false);
|
||||
const [densityTemp, setDensityTemp] = useState(0);
|
||||
const isMobile = useMobile();
|
||||
const [pcaState, setPCAState] = useState(false);
|
||||
const [pcaFanOn, setPCAFanOn] = useState(false);
|
||||
// const [pcaState, setPCAState] = useState(false);
|
||||
// const [pcaFanOn, setPCAFanOn] = useState(false);
|
||||
const [detail, setDetail] = useState<"sensors" | "analytics">("analytics");
|
||||
const [lastAmbient, setLastAmbient] = useState(0);
|
||||
const [lastTemps, setLastTemps] = useState({ t1: 0, t2: 0 });
|
||||
|
|
@ -99,13 +99,13 @@ export default function GateDevice(props: Props) {
|
|||
break;
|
||||
case pond.GateComponentType.GATE_COMPONENT_TYPE_PRESSURE:
|
||||
setPressureKey(c.key());
|
||||
if (
|
||||
c.status.measurement[0] &&
|
||||
c.status.measurement[0].values[0] &&
|
||||
c.status.measurement[0].values[0].values[1]
|
||||
) {
|
||||
setPCAFanOn(c.status.measurement[0].values[0].values[1] > 996); //apx 4 iwg
|
||||
}
|
||||
// if (
|
||||
// c.status.measurement[0] &&
|
||||
// c.status.measurement[0].values[0] &&
|
||||
// c.status.measurement[0].values[0].values[1]
|
||||
// ) {
|
||||
// setPCAFanOn(c.status.measurement[0].values[0].values[1] > 996); //apx 4 iwg
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
// type is unknown, do nothing
|
||||
|
|
@ -345,8 +345,8 @@ export default function GateDevice(props: Props) {
|
|||
ambientSelector={ambientSelector}
|
||||
tempChainSelector={tempSelector}
|
||||
pressureChainSelector={pressureSelector}
|
||||
pcaState={pcaState}
|
||||
pcaFanState={pcaFanOn}
|
||||
pcaState={gate.status.pcaState}
|
||||
// pcaFanState={pcaFanOn}
|
||||
checkInTime={device.status.lastActive}
|
||||
/>
|
||||
<Button
|
||||
|
|
@ -374,9 +374,9 @@ export default function GateDevice(props: Props) {
|
|||
gate={gate}
|
||||
display={detail}
|
||||
compMap={componentOptions}
|
||||
setPCAState={(state: boolean) => {
|
||||
setPCAState(state);
|
||||
}}
|
||||
// setPCAState={(state: boolean) => {
|
||||
// setPCAState(state);
|
||||
// }}
|
||||
ambient={ambientKey}
|
||||
pressure={pressureKey}
|
||||
tempChain={tempKey}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ interface Props {
|
|||
ambient?: string;
|
||||
newXDomain?: number[] | string[];
|
||||
pressureComponent?: string;
|
||||
setPCAState: (state: boolean) => void;
|
||||
// setPCAState: (state: boolean) => void;
|
||||
multiGraphZoom?: (domain: number[] | string[]) => void;
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ export default function GateFlowGraph(props: Props) {
|
|||
device,
|
||||
ambient,
|
||||
pressureComponent,
|
||||
setPCAState,
|
||||
// setPCAState,
|
||||
start,
|
||||
end,
|
||||
newXDomain,
|
||||
|
|
@ -131,22 +131,22 @@ export default function GateFlowGraph(props: Props) {
|
|||
}
|
||||
});
|
||||
setRuntime(moment.duration(runtime));
|
||||
let state = false;
|
||||
if (
|
||||
data.length > 1 &&
|
||||
data[data.length - 1].value > gate.lowerFlow() &&
|
||||
data[data.length - 1].value < gate.upperFlow()
|
||||
) {
|
||||
state = true;
|
||||
}
|
||||
setPCAState(state);
|
||||
// let state = false;
|
||||
// if (
|
||||
// data.length > 1 &&
|
||||
// data[data.length - 1].value > gate.lowerFlow() &&
|
||||
// data[data.length - 1].value < gate.upperFlow()
|
||||
// ) {
|
||||
// state = true;
|
||||
// }
|
||||
// setPCAState(state);
|
||||
}
|
||||
setFlowData(data);
|
||||
setLoadingChartData(false);
|
||||
setRecent(recent);
|
||||
});
|
||||
}
|
||||
}, [gateAPI, gate, ambient, pressureComponent, start, end, device, setPCAState, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [gateAPI, gate, ambient, pressureComponent, start, end, device, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const loadFlowEvents = () => {
|
||||
if (ambient && pressureComponent) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ interface Props {
|
|||
tempChain: string;
|
||||
redKey: string;
|
||||
greenKey: string;
|
||||
setPCAState: (state: boolean) => void;
|
||||
// setPCAState: (state: boolean) => void;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
|
|
@ -63,7 +63,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||
);
|
||||
|
||||
export default function GateGraphs(props: Props) {
|
||||
const { gate, display, compMap, device, pressure, ambient, tempChain, greenKey, redKey, setPCAState } = props;
|
||||
const { gate, display, compMap, device, pressure, ambient, tempChain, greenKey, redKey } = props;
|
||||
const [{ as }] = useGlobalState();
|
||||
const [xDomain, setXDomain] = useState<string[] | number[]>(["dataMin", "dataMax"]);
|
||||
const [zoomed, setZoomed] = useState(false);
|
||||
|
|
@ -347,9 +347,9 @@ export default function GateGraphs(props: Props) {
|
|||
gate={gate}
|
||||
ambient={ambient}
|
||||
pressureComponent={pressure}
|
||||
setPCAState={(state: boolean) => {
|
||||
setPCAState(state);
|
||||
}}
|
||||
// setPCAState={(state: boolean) => {
|
||||
// setPCAState(state);
|
||||
// }}
|
||||
multiGraphZoom={domain => {
|
||||
setXDomain(domain);
|
||||
setZoomed(true);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ interface Props {
|
|||
ambientSelector: () => JSX.Element;
|
||||
tempChainSelector: () => JSX.Element;
|
||||
pressureChainSelector: () => JSX.Element;
|
||||
pcaState: boolean;
|
||||
pcaFanState: boolean;
|
||||
pcaState: pond.PCAState;
|
||||
// pcaFanState: boolean;
|
||||
checkInTime: string;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ export default function GateSVG(props: Props) {
|
|||
tempChainSelector,
|
||||
pressureChainSelector,
|
||||
pcaState,
|
||||
pcaFanState,
|
||||
// pcaFanState,
|
||||
checkInTime
|
||||
} = props;
|
||||
const classes = useStyles();
|
||||
|
|
@ -242,16 +242,23 @@ export default function GateSVG(props: Props) {
|
|||
return temp;
|
||||
};
|
||||
|
||||
const finalTempDisplay = (temp: number) => {
|
||||
let display = "--"
|
||||
if(pcaState === pond.PCAState.PCA_STATE_IN_BOUNDS || pcaState === pond.PCAState.PCA_STATE_OUT_BOUNDS){
|
||||
if(temp < 60 && temp > -40 && !isNaN(temp) && temp !== 0){
|
||||
display = convertFinalTemp(finalTemp).toFixed(2) + (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? "°F" : "°C")
|
||||
}
|
||||
}
|
||||
return display
|
||||
}
|
||||
|
||||
const renderValues = () => {
|
||||
let values: JSX.Element[] = [];
|
||||
//add the final temp display to the array
|
||||
values.push(
|
||||
<g key={"finalTemp"} id={"finalTemp"} data-name={"finalTemp"}>
|
||||
<text fontSize={7} className={classes.fontBase} x={100} y={85}>
|
||||
{convertFinalTemp(finalTemp).toFixed(2)}
|
||||
{user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
? "°F"
|
||||
: "°C"}
|
||||
{finalTempDisplay(finalTemp)}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
|
|
@ -302,7 +309,8 @@ export default function GateSVG(props: Props) {
|
|||
const pcaRed = () => {
|
||||
return (
|
||||
<g key={"pcaRed"} id={"pcaRed"} data-name={"pcaRed"}>
|
||||
<circle cx={175} cy={152} r={8} fill={pcaFanState ? (pcaState ? "grey" : "red") : "grey"} />
|
||||
{/* <circle cx={175} cy={152} r={8} fill={(pcaFanState && pcaState === pond.PCAState.PCA_STATE_OUT_BOUNDS) ? "red" : "grey"} /> */}
|
||||
<circle cx={175} cy={152} r={8} fill={pcaState === pond.PCAState.PCA_STATE_OUT_BOUNDS ? "red" : "grey"} />
|
||||
</g>
|
||||
);
|
||||
};
|
||||
|
|
@ -314,7 +322,8 @@ export default function GateSVG(props: Props) {
|
|||
cx={175}
|
||||
cy={174}
|
||||
r={8}
|
||||
fill={pcaFanState ? (pcaState ? "green" : "grey") : "grey"}
|
||||
//fill={(pcaFanState && pcaState === pond.PCAState.PCA_STATE_IN_BOUNDS) ? "green" : "grey"}
|
||||
fill={pcaState === pond.PCAState.PCA_STATE_IN_BOUNDS ? "green" : "grey"}
|
||||
/>
|
||||
</g>
|
||||
);
|
||||
|
|
@ -324,7 +333,8 @@ export default function GateSVG(props: Props) {
|
|||
return (
|
||||
<g key={"fanStatus"}>
|
||||
<text x={125} y={180} fontSize={5} className={classes.fontBase}>
|
||||
PCA Fan: {pcaFanState ? "ON" : "OFF"}
|
||||
{/* PCA Fan: {pcaFanState ? "ON" : "OFF"} */}
|
||||
PCA Fan: {pcaState === pond.PCAState.PCA_STATE_OFF ? "OFF" : "ON"}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ export default function Gate(props: Props) {
|
|||
gateAPI
|
||||
.getGatePageData(id, as)
|
||||
.then(resp => {
|
||||
//console.log(resp.data);
|
||||
console.log(resp.data);
|
||||
let p = new Map<number, pond.GateDeviceType>();
|
||||
Object.keys(resp.data.preferences).forEach(k => {
|
||||
let prefKey = parseInt(k);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue