Rolling 20210506v2

This commit is contained in:
jomjol
2021-05-06 21:50:14 +02:00
parent 016f4088d4
commit d36cbde7aa
16 changed files with 104 additions and 14 deletions

View File

@@ -74,10 +74,9 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
tStart = mktime(&whenStart);
time_t now;
time(&now);
localtime(&now);
double difference = difftime(now, tStart);
time(&lastvalue);
localtime(&lastvalue);
double difference = difftime(lastvalue, tStart);
difference /= 60;
if (difference > PreValueAgeStartup)
return false;
@@ -123,12 +122,16 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
zwtime = std::string(buffer);
timeStamp = std::string(buffer);
}
else
{
timeStamp = zwtime;
}
PreValue = value;
fputs(zwtime.c_str(), pFile);
fputs(timeStamp.c_str(), pFile);
fputs("\n", pFile);
fputs(to_string(value).c_str(), pFile);
fputs("\n", pFile);
@@ -139,6 +142,7 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
{
FlowRateAct = 0;
PreValueUse = false;
PreValueAgeStartup = 30;
AllowNegativeRates = false;
@@ -150,6 +154,7 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
checkDigitIncreaseConsistency = false;
DecimalShift = 0;
ErrorMessageText = "";
timeStamp = "";
FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
ListFlowControll = lfc;
}
@@ -343,12 +348,15 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
PreValueOkay = true;
PreValue = Value;
time(&lastvalue);
localtime(&lastvalue);
SavePreValue(Value, zwtime);
}
return true;
}
zw = ErsetzteN(ReturnRawValue);
Value = std::stof(zw);
@@ -359,6 +367,14 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
time_t currenttime;
time(&currenttime);
localtime(&currenttime);
double difference = difftime(currenttime, lastvalue); // in Sekunden
difference /= 60; // in Minuten
FlowRateAct = (Value - PreValue) / difference;
if ((!AllowNegativeRates) && (Value < PreValue))
{
ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue + " - checked value: " + std::to_string(Value) + " ";
@@ -506,6 +522,16 @@ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamsh
return input;
}
string ClassFlowPostProcessing::getReadoutRate()
{
return std::to_string(FlowRateAct);
}
string ClassFlowPostProcessing::getReadoutTimeStamp()
{
return timeStamp;
}
string ClassFlowPostProcessing::getReadoutError()
{