Merge branch 'staging_environment'
This commit is contained in:
commit
2d00070130
4 changed files with 44 additions and 35 deletions
|
|
@ -20,6 +20,7 @@ interface Props {
|
||||||
ambient?: Component
|
ambient?: Component
|
||||||
start: Moment;
|
start: Moment;
|
||||||
end: Moment;
|
end: Moment;
|
||||||
|
multiGraphZoom?: (domain: number[] | string[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GateDeltaTempGraph(props: Props){
|
export default function GateDeltaTempGraph(props: Props){
|
||||||
|
|
@ -28,7 +29,8 @@ export default function GateDeltaTempGraph(props: Props){
|
||||||
ambient,
|
ambient,
|
||||||
deviceID,
|
deviceID,
|
||||||
start,
|
start,
|
||||||
end
|
end,
|
||||||
|
multiGraphZoom
|
||||||
} = props
|
} = props
|
||||||
const [data, setData] = useState<SSAreaDataPoint[]>([])
|
const [data, setData] = useState<SSAreaDataPoint[]>([])
|
||||||
const [{user}] = useGlobalState()
|
const [{user}] = useGlobalState()
|
||||||
|
|
@ -110,7 +112,6 @@ export default function GateDeltaTempGraph(props: Props){
|
||||||
end.toISOString(),
|
end.toISOString(),
|
||||||
500
|
500
|
||||||
).then(resp => {
|
).then(resp => {
|
||||||
console.log(resp)
|
|
||||||
if(resp.data.measurements){
|
if(resp.data.measurements){
|
||||||
let tempCompMeasurements = resp.data.measurements.map(um => UnitMeasurement.any(um, user));
|
let tempCompMeasurements = resp.data.measurements.map(um => UnitMeasurement.any(um, user));
|
||||||
//if there is an ambient component, then treat the temp component like a single sensor and not a chain, and use the ambient measurements as the inlet
|
//if there is an ambient component, then treat the temp component like a single sensor and not a chain, and use the ambient measurements as the inlet
|
||||||
|
|
@ -217,7 +218,8 @@ export default function GateDeltaTempGraph(props: Props){
|
||||||
tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"}
|
tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"}
|
||||||
yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")}
|
yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")}
|
||||||
colourAboveZero={{colour: warmingColour, label: "Heating"}}
|
colourAboveZero={{colour: warmingColour, label: "Heating"}}
|
||||||
colourBelowZero={{colour: coolingColour, label: "Cooling"}}/>
|
colourBelowZero={{colour: coolingColour, label: "Cooling"}}
|
||||||
|
multiGraphZoom={multiGraphZoom}/>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { Gate } from "models/Gate";
|
||||||
import moment, { Moment } from "moment";
|
import moment, { Moment } from "moment";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import { useGateAPI, useGlobalState } from "providers";
|
import { useGateAPI, useGlobalState } from "providers";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
gate: Gate;
|
gate: Gate;
|
||||||
|
|
@ -25,7 +25,6 @@ interface Props {
|
||||||
ambient?: string;
|
ambient?: string;
|
||||||
newXDomain?: number[] | string[];
|
newXDomain?: number[] | string[];
|
||||||
pressureComponent?: string;
|
pressureComponent?: string;
|
||||||
// setPCAState: (state: boolean) => void;
|
|
||||||
multiGraphZoom?: (domain: number[] | string[]) => void;
|
multiGraphZoom?: (domain: number[] | string[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +54,6 @@ export default function GateFlowGraph(props: Props) {
|
||||||
device,
|
device,
|
||||||
ambient,
|
ambient,
|
||||||
pressureComponent,
|
pressureComponent,
|
||||||
// setPCAState,
|
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
newXDomain,
|
newXDomain,
|
||||||
|
|
@ -74,12 +72,13 @@ export default function GateFlowGraph(props: Props) {
|
||||||
const eventThreshold = 5; //the threshold that if crossed from one measurement to the next during a flow event will end the current flow event and start a new one
|
const eventThreshold = 5; //the threshold that if crossed from one measurement to the next during a flow event will end the current flow event and start a new one
|
||||||
//const idleFlow = 3.5; //the mass air flow that must be crossed in order to start a flow event, anything below this will not start an event but must go below this to end an event
|
//const idleFlow = 3.5; //the mass air flow that must be crossed in order to start a flow event, anything below this will not start an event but must go below this to end an event
|
||||||
const [idleFlow, setIdleFlow] = useState(3.5)
|
const [idleFlow, setIdleFlow] = useState(3.5)
|
||||||
|
|
||||||
useEffect(() => {
|
const loadData = useCallback(()=>{
|
||||||
if (loadingChartData) return;
|
if (loadingChartData) return;
|
||||||
if (ambient && pressureComponent) {
|
if (ambient && pressureComponent) {
|
||||||
let gateIdle = idleFlow
|
let gateIdle = idleFlow
|
||||||
if(gate.settings.idleFlow){
|
if(gate.settings.idleFlow){
|
||||||
|
setIdleFlow(gate.settings.idleFlow)
|
||||||
gateIdle = gate.settings.idleFlow
|
gateIdle = gate.settings.idleFlow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,22 +130,17 @@ export default function GateFlowGraph(props: Props) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setRuntime(moment.duration(runtime));
|
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);
|
|
||||||
}
|
}
|
||||||
setFlowData(data);
|
setFlowData(data);
|
||||||
setLoadingChartData(false);
|
setLoadingChartData(false);
|
||||||
setRecent(recent);
|
setRecent(recent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [gateAPI, gate, ambient, pressureComponent, start, end, device, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
},[gateAPI, gate, ambient, pressureComponent, start, end, device, as])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadData()
|
||||||
|
}, [loadData]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
const loadFlowEvents = () => {
|
const loadFlowEvents = () => {
|
||||||
if (ambient && pressureComponent) {
|
if (ambient && pressureComponent) {
|
||||||
|
|
|
||||||
|
|
@ -101,16 +101,22 @@ export default function GateGraphs(props: Props) {
|
||||||
});
|
});
|
||||||
}, [gate, endDate, gateAPI, startDate, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [gate, endDate, gateAPI, startDate, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
const updateDateRange = (newStartDate: any, newEndDate: any) => {
|
const updateDateRange = (newStartDate: moment.Moment, newEndDate: moment.Moment) => {
|
||||||
let range = GetDefaultDateRange();
|
|
||||||
range.start = newStartDate;
|
|
||||||
range.end = newEndDate;
|
|
||||||
setStartDate(newStartDate);
|
setStartDate(newStartDate);
|
||||||
setEndDate(newEndDate);
|
setEndDate(newEndDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const zoomGraphs = (domain: string[] | number[]) => {
|
||||||
|
setZoomed(true)
|
||||||
|
if((domain[0] && !isNaN(parseInt(domain[0] as string))) && (domain[1] && !isNaN(parseInt(domain[1] as string)))){
|
||||||
|
updateDateRange(moment(domain[0]),moment(domain[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const zoomOut = () => {
|
const zoomOut = () => {
|
||||||
setXDomain(["dataMin", "dataMax"]);
|
let d = GetDefaultDateRange()
|
||||||
|
setStartDate(d.start)
|
||||||
|
setEndDate(d.end)
|
||||||
setZoomed(false);
|
setZoomed(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -175,8 +181,7 @@ export default function GateGraphs(props: Props) {
|
||||||
tooltip
|
tooltip
|
||||||
newXDomain={xDomain}
|
newXDomain={xDomain}
|
||||||
multiGraphZoom={domain => {
|
multiGraphZoom={domain => {
|
||||||
setXDomain(domain);
|
zoomGraphs(domain)
|
||||||
setZoomed(true);
|
|
||||||
}}
|
}}
|
||||||
multiGraphZoomOut
|
multiGraphZoomOut
|
||||||
/>
|
/>
|
||||||
|
|
@ -239,8 +244,7 @@ export default function GateGraphs(props: Props) {
|
||||||
tooltip
|
tooltip
|
||||||
newXDomain={xDomain}
|
newXDomain={xDomain}
|
||||||
multiGraphZoom={domain => {
|
multiGraphZoom={domain => {
|
||||||
setXDomain(domain);
|
zoomGraphs(domain)
|
||||||
setZoomed(true);
|
|
||||||
}}
|
}}
|
||||||
multiGraphZoomOut
|
multiGraphZoomOut
|
||||||
/>
|
/>
|
||||||
|
|
@ -250,7 +254,6 @@ export default function GateGraphs(props: Props) {
|
||||||
|
|
||||||
const graphHeader = (comp: Component) => {
|
const graphHeader = (comp: Component) => {
|
||||||
const componentIcon = GetComponentIcon(comp.settings.type, comp.settings.subtype, themeType);
|
const componentIcon = GetComponentIcon(comp.settings.type, comp.settings.subtype, themeType);
|
||||||
console.log(comp)
|
|
||||||
let measurement = cloneDeep(comp.status.measurement)
|
let measurement = cloneDeep(comp.status.measurement)
|
||||||
let umArray = measurement.map(um => UnitMeasurement.create(um, user))
|
let umArray = measurement.map(um => UnitMeasurement.create(um, user))
|
||||||
return (
|
return (
|
||||||
|
|
@ -356,17 +359,22 @@ export default function GateGraphs(props: Props) {
|
||||||
gate={gate}
|
gate={gate}
|
||||||
ambient={ambient}
|
ambient={ambient}
|
||||||
pressureComponent={pressure}
|
pressureComponent={pressure}
|
||||||
// setPCAState={(state: boolean) => {
|
|
||||||
// setPCAState(state);
|
|
||||||
// }}
|
|
||||||
multiGraphZoom={domain => {
|
multiGraphZoom={domain => {
|
||||||
setXDomain(domain);
|
zoomGraphs(domain)
|
||||||
setZoomed(true);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/* add a new chart here for the delta temp over time */}
|
{/* add a new chart here for the delta temp over time */}
|
||||||
{tempComp &&
|
{tempComp &&
|
||||||
<GateDeltaTempGraph deviceID={device} start={startDate} end={endDate} tempComponent={tempComp} ambient={ambientComp}/>
|
<GateDeltaTempGraph
|
||||||
|
deviceID={device}
|
||||||
|
start={startDate}
|
||||||
|
end={endDate}
|
||||||
|
tempComponent={tempComp}
|
||||||
|
ambient={ambientComp}
|
||||||
|
multiGraphZoom={domain => {
|
||||||
|
zoomGraphs(domain)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,12 @@ export default function GateList(props: Props) {
|
||||||
// cellStyle: {width: 100000},
|
// cellStyle: {width: 100000},
|
||||||
// sortKey: "state",
|
// sortKey: "state",
|
||||||
render: gate => {
|
render: gate => {
|
||||||
const deviceStateHelper = getDeviceStateHelper(gate.status.pcaDeviceState);
|
let deviceStateHelper = getDeviceStateHelper(pond.DeviceState.DEVICE_STATE_UNKNOWN);
|
||||||
|
if(moment().isAfter(moment(gate.status.deviceStateExpires).add(1, 'hour'))){
|
||||||
|
deviceStateHelper = getDeviceStateHelper(pond.DeviceState.DEVICE_STATE_MISSING)
|
||||||
|
}else{
|
||||||
|
deviceStateHelper = getDeviceStateHelper(gate.status.pcaDeviceState)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Box className={classes.cellContainer}>
|
<Box className={classes.cellContainer}>
|
||||||
<Tooltip title={deviceStateHelper.description}>{deviceStateHelper.icon}</Tooltip>
|
<Tooltip title={deviceStateHelper.description}>{deviceStateHelper.icon}</Tooltip>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue