Rolling 20210522

This commit is contained in:
jomjol
2021-05-22 07:39:10 +02:00
parent 528a4435a9
commit 8a26b817f7
7 changed files with 64 additions and 19 deletions

View File

@@ -43,7 +43,11 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
**General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
##### Rolling - (2021-05-20)
##### Rolling - (2021-05-22)
* Bug fix: calculation of flow rate
Rolling - (2021-05-20)
* Bug fix: mqtt retain message flag
Rolling - (2021-05-20)

View File

@@ -11,6 +11,13 @@
#include <time.h>
#include "time_sntp.h"
#define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S"
#define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d"
string ClassFlowPostProcessing::GetPreValue()
{
std::string result;
@@ -63,7 +70,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
int yy, month, dd, hh, mm, ss;
struct tm whenStart;
sscanf(zwtime.c_str(), "%d-%d-%dT%d:%d:%d", &yy, &month, &dd, &hh, &mm, &ss);
sscanf(zwtime.c_str(), PREVALUE_TIME_FORMAT_INPUT, &yy, &month, &dd, &hh, &mm, &ss);
whenStart.tm_year = yy - 1900;
whenStart.tm_mon = month - 1;
whenStart.tm_mday = dd;
@@ -72,11 +79,11 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
whenStart.tm_sec = ss;
whenStart.tm_isdst = -1;
tStart = mktime(&whenStart);
lastvalue = mktime(&whenStart);
time(&lastvalue);
localtime(&lastvalue);
double difference = difftime(lastvalue, tStart);
time(&tStart);
localtime(&tStart);
double difference = difftime(tStart, lastvalue);
difference /= 60;
if (difference > PreValueAgeStartup)
return false;
@@ -121,7 +128,7 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
timeStamp = std::string(buffer);
}
else
@@ -157,6 +164,15 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
timeStamp = "";
FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
ListFlowControll = lfc;
flowMakeImage = NULL;
for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowMakeImage") == 0)
{
flowMakeImage = (ClassFlowMakeImage*) (*ListFlowControll)[i];
}
}
}
@@ -348,8 +364,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
PreValueOkay = true;
PreValue = Value;
if (flowMakeImage)
{
lastvalue = flowMakeImage->getTimeImageTaken();
zwtime = ConvertTimeToString(lastvalue, PREVALUE_TIME_FORMAT_OUTPUT);
}
else
{
time(&lastvalue);
localtime(&lastvalue);
}
SavePreValue(Value, zwtime);
}
@@ -387,16 +411,28 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if (ErrorMessage && (ErrorMessageText.length() > 0))
ReturnValue = ReturnValue + "\t" + ErrorMessageText;
if (ErrorMessageText.length() == 0)
{
time_t currenttime;
if (flowMakeImage)
{
currenttime = flowMakeImage->getTimeImageTaken();
zwtime = ConvertTimeToString(currenttime, PREVALUE_TIME_FORMAT_OUTPUT);
}
else
{
time(&currenttime);
localtime(&currenttime);
// currenttime =
}
double difference = difftime(currenttime, lastvalue); // in Sekunden
difference /= 60; // in Minuten
FlowRateAct = (Value - PreValue) / difference;
lastvalue = currenttime;
// std::string _zw = "CalcRate: " + std::to_string(FlowRateAct) + " TimeDifference[min]: " + std::to_string(difference);
// _zw = _zw + " Value: " + std::to_string(Value) + " PreValue: " + std::to_string(PreValue);
// LogFile.WriteToFile(_zw);
if (ErrorMessageText.length() == 0)
{
PreValue = Value;
SavePreValue(Value, zwtime);
}

View File

@@ -1,9 +1,12 @@
#pragma once
#include "ClassFlow.h"
#include "ClassFlowMakeImage.h"
#include <string>
class ClassFlowPostProcessing :
public ClassFlow
{
@@ -30,6 +33,8 @@ protected:
string ErrorMessageText; // Fehlermeldung bei Consistency Check
string timeStamp;
ClassFlowMakeImage *flowMakeImage;
bool LoadPreValue(void);
string ShiftDecimal(string in, int _decShift);

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="9b791bb";
const char* GIT_REV="528a443";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-05-20 21:43";
const char* BUILD_TIME="2021-05-22 07:33";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="9b791bb";
const char* GIT_REV="528a443";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-05-20 21:43";
const char* BUILD_TIME="2021-05-22 07:33";

Binary file not shown.

Binary file not shown.