use host time to calculate the real event time

This commit is contained in:
lukas 2020-12-12 15:58:05 +01:00
parent 747e7bbbf8
commit 0817fcf492
3 changed files with 77 additions and 68 deletions

View File

@ -13,7 +13,10 @@ before_script:
build:
stage: build
script: "platformio run -e esp12e"
script:
- "platformio run -e esp12e"
- vers=$(grep -Po '[0-9]*\.[0-9]*\.[0-9]*(?=\")' ./src/Pins.h)
- mv .pio/'build/esp12e/*.bin Pumpensteuerung-${vers}.bin
artifacts:
paths:
- .pio/build/esp12e/*.bin
- ./*.bin

View File

@ -1,12 +1,6 @@
import React, {Component} from 'react';
import {Box, List, ListItem, ListItemText} from '@material-ui/core';
import {
FormButton,
restController,
RestControllerProps,
RestFormLoader,
SectionContent
} from '../components';
import {FormButton, restController, RestControllerProps, RestFormLoader, SectionContent} from '../components';
import {ENDPOINT_ROOT} from "../api";
import {GeneralInformaitonState} from "./types";
import RefreshIcon from "@material-ui/icons/Refresh";
@ -21,12 +15,6 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
componentDidMount() {
this.props.loadData();
// this.intervalhandler = window.setInterval(() => {
// this.props.loadData();
// console.log("refreshing data");
// console.log(this.props.data)
// }, 10000);
}
componentWillUnmount() {
@ -39,58 +27,62 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
<RestFormLoader
{...this.props}
render={props => (
<>
<List>
<ListItem>
<ListItemText
primary="Chip läuft seit:"
secondary={this.stringifyTime(props.data.runtime)}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Zuletzt zu wenig Wasser:"
secondary={props.data.lastWaterOutage !== 0 ? "vor " + this.stringifyTime(props.data.lastWaterOutage) : "noch nie!"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Letzer Pumpenzyklus"
secondary={props.data.lastpumptime !== 0 ? "vor " + this.stringifyTime(props.data.lastpumptime) : "noch nie!"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Letze Pumpdauer:"
secondary={props.data.lastPumpDuration !== 0 ? this.stringifyTime(props.data.lastPumpDuration) : "-"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Temperatur/Luftfeuchtigkeit:"
secondary={(props.data.temp !== -1 ? props.data.temp + "C" : "Auslesefehler!") + " / " + (props.data.hum !== -1 ? props.data.hum + "%" : "Auslesefehler!")}
/>
</ListItem>
<ListItem>
<ListItemText
primary="WasserSensor / DruckSensor"
secondary={(props.data.watersensor ? "EIN" : "AUS!") + " / " + (props.data.pressuresensor ? "EIN" : "AUS")}
/>
</ListItem>
</List>
<Box display="flex" flexWrap="wrap">
<Box flexGrow={1} padding={1}>
<FormButton startIcon={<RefreshIcon/>} variant="contained" color="secondary"
onClick={this.props.loadData}>
Refresh
</FormButton>
</Box>
<Box flexWrap="none" padding={1} whiteSpace="nowrap">
Version: {props.data.version}
</Box>
<>
<List>
<ListItem>
<ListItemText
primary="Chip läuft seit:"
secondary={this.stringifyTime(props.data.runtime) + ' / ' + this.getRealTimeString(props.data.runtime)}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Zuletzt zu wenig Wasser:"
secondary={props.data.lastWaterOutage !== 0 ? "vor " +
this.stringifyTime(props.data.lastWaterOutage) + ' / ' +
this.getRealTimeString(props.data.lastWaterOutage) : "noch nie!"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Letzer Pumpenzyklus"
secondary={props.data.lastpumptime !== 0 ? "vor " +
this.stringifyTime(props.data.lastpumptime) + ' / ' +
this.getRealTimeString(props.data.lastpumptime) : "noch nie!"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Letze Pumpdauer:"
secondary={props.data.lastPumpDuration !== 0 ? this.stringifyTime(props.data.lastPumpDuration) : "-"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Temperatur/Luftfeuchtigkeit:"
secondary={(props.data.temp !== -1 ? props.data.temp + "C" : "Auslesefehler!") + " / " + (props.data.hum !== -1 ? props.data.hum + "%" : "Auslesefehler!")}
/>
</ListItem>
<ListItem>
<ListItemText
primary="WasserSensor / DruckSensor"
secondary={(props.data.watersensor ? "EIN" : "AUS!") + " / " + (props.data.pressuresensor ? "EIN" : "AUS")}
/>
</ListItem>
</List>
<Box display="flex" flexWrap="wrap">
<Box flexGrow={1} padding={1}>
<FormButton startIcon={<RefreshIcon/>} variant="contained" color="secondary"
onClick={this.props.loadData}>
Refresh
</FormButton>
</Box>
</>
)}
<Box flexWrap="none" padding={1} whiteSpace="nowrap">
Version: {props.data.version}
</Box>
</Box>
</>
)}
/>
</SectionContent>
);
@ -100,7 +92,7 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
* stringify seconds to a pretty format
* @param sec number of seconds
*/
stringifyTime(sec: number): string {
private stringifyTime(sec: number): string {
if (sec >= 86400) {
// display days
return (Math.trunc(sec / 86400) + "d " + Math.trunc((sec % 86400) / 3600) + "h " + Math.trunc((sec % 3600) / 60) + "min " + sec % 60 + "sec");
@ -115,6 +107,20 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
return (sec + "sec");
}
}
private getRealTimeString(runtime: number): string {
const timestamp = Date.now();
const a = new Date(timestamp - (runtime * 1000));
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
const year = a.getFullYear();
const month = months[a.getMonth()];
const date = a.getDate();
const hour = a.getHours();
const min = "0" + a.getMinutes();
const sec = "0" + a.getSeconds();
return '[' + date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) + ']';
}
}
export default restController(GENERALINFORMATION_SETTINGS_ENDPOINT, GeneralInformation);

View File

@ -16,6 +16,6 @@
#define TempSensorPin D4
// version info
#define VERSION "v1.2.1"
#define VERSION "v1.2.2"
#endif //PUMPENSTEUERUNG_PINS_H