mark invalid and replaced values in database

This commit is contained in:
Wolfgang Hottgenroth 2019-11-05 15:07:19 +01:00
parent 61b1498d7b
commit 8c0c864905
3 changed files with 8 additions and 6 deletions

View File

@ -86,15 +86,17 @@ int main (void) {
uint32_t diff = ringbufferGet();
double f = 1.0 / (((double) diff) / 1000000.0);
int valid = settled ? 1 : 0;
if (settled && (abs(f - lastF) > epsilon)) {
logmsg(LOG_INFO, "Current f=%f, last f=%f, gradient too large, skipped\n", f, lastF);
skipped++;
f = lastF;
valid = 0;
}
lastF = f;
// printf("%f\n", f);
influxAddFrequency(f);
// printf("%f, %d\n", f, valid);
influxAddFrequency(f, valid);
ledTick++;
if (ledTick == 50) {

View File

@ -79,7 +79,7 @@ static void influxSendRequest() {
led(E_BLUE, false);
}
void influxAddFrequency(double f) {
void influxAddFrequency(double f, int valid) {
static uint32_t entries = 0;
static uint32_t totalEntries = 0;
char tmpBuf[256];
@ -87,7 +87,7 @@ void influxAddFrequency(double f) {
clock_gettime(CLOCK_REALTIME, &t);
uint64_t tt = (((uint64_t)t.tv_sec) * 1000) + (((uint64_t)t.tv_nsec) / 1000000);
int c = sprintf(tmpBuf, "mainsfrequency,host=%s freq=%f %llu\n", influxTag, f, tt);
int c = sprintf(tmpBuf, "mainsfrequency,host=%s,valid=%d freq=%f %llu\n", influxTag, valid, f, tt);
if ((bufferNextEntry + c + 10) > (influxBuffer + BUFSIZE)) {
influxSendRequest();

View File

@ -3,7 +3,7 @@
#include <libconfig.h>
void influxAddFrequency(double f);
void influxAddFrequency(double f, int valid);
void influxInit(config_t *pCfg);
#endif // _INFLUX_H_
#endif // _INFLUX_H_