|
|
@@ -9,6 +9,11 @@
|
|
|
#include <time.h>
|
|
|
|
|
|
#include "time_sntp.h"
|
|
|
+
|
|
|
+#include "esp_log.h"
|
|
|
+
|
|
|
+static const char* TAG = "class_flow_postproc";
|
|
|
+
|
|
|
//#define SERIAL_DEBUG // testing debug on serial enabled
|
|
|
|
|
|
|
|
|
@@ -72,10 +77,10 @@ string ClassFlowPostProcessing::GetPreValue(std::string _number)
|
|
|
|
|
|
void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _extern)
|
|
|
{
|
|
|
- printf("SetPrevalue: %f, %s\n", zw, _numbers.c_str());
|
|
|
+ ESP_LOGD(TAG, "SetPrevalue: %f, %s", zw, _numbers.c_str());
|
|
|
for (int j = 0; j < NUMBERS.size(); ++j)
|
|
|
{
|
|
|
-// printf("Number %d, %s\n", j, NUMBERS[j]->name.c_str());
|
|
|
+// ESP_LOGD(TAG, "Number %d, %s", j, NUMBERS[j]->name.c_str());
|
|
|
if (NUMBERS[j]->name == _numbers)
|
|
|
{
|
|
|
NUMBERS[j]->PreValue = zw;
|
|
|
@@ -86,7 +91,7 @@ void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _exte
|
|
|
time(&(NUMBERS[j]->lastvalue));
|
|
|
localtime(&(NUMBERS[j]->lastvalue));
|
|
|
}
|
|
|
-// printf("Found %d! - set to %f\n", j, NUMBERS[j]->PreValue);
|
|
|
+// ESP_LOGD(TAG, "Found %d! - set to %f", j, NUMBERS[j]->PreValue);
|
|
|
}
|
|
|
}
|
|
|
UpdatePreValueINI = true;
|
|
|
@@ -110,7 +115,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|
|
return false;
|
|
|
|
|
|
fgets(zw, 1024, pFile);
|
|
|
- printf("Read line Prevalue.ini: %s", zw);
|
|
|
+ ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
|
|
|
zwtime = trim(std::string(zw));
|
|
|
if (zwtime.length() == 0)
|
|
|
return false;
|
|
|
@@ -161,7 +166,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|
|
_done = true;
|
|
|
else
|
|
|
{
|
|
|
- printf("Read line Prevalue.ini: %s", zw);
|
|
|
+ ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
|
|
|
zerlegt = HelperZerlegeZeile(trim(std::string(zw)), "\t");
|
|
|
if (zerlegt.size() > 1)
|
|
|
{
|
|
|
@@ -177,7 +182,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|
|
{
|
|
|
fgets(zw, 1024, pFile);
|
|
|
fclose(pFile);
|
|
|
- printf("%s", zw);
|
|
|
+ ESP_LOGD(TAG, "%s", zw);
|
|
|
zwvalue = trim(std::string(zw));
|
|
|
NUMBERS[0]->PreValue = stod(zwvalue.c_str());
|
|
|
|
|
|
@@ -194,7 +199,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|
|
whenStart.tm_sec = ss;
|
|
|
whenStart.tm_isdst = -1;
|
|
|
|
|
|
- printf("TIME: %d, %d, %d, %d, %d, %d\n", whenStart.tm_year, whenStart.tm_mon, whenStart.tm_wday, whenStart.tm_hour, whenStart.tm_min, whenStart.tm_sec);
|
|
|
+ ESP_LOGD(TAG, "TIME: %d, %d, %d, %d, %d, %d", whenStart.tm_year, whenStart.tm_mon, whenStart.tm_wday, whenStart.tm_hour, whenStart.tm_min, whenStart.tm_sec);
|
|
|
|
|
|
NUMBERS[0]->lastvalue = mktime(&whenStart);
|
|
|
|
|
|
@@ -236,10 +241,10 @@ void ClassFlowPostProcessing::SavePreValue()
|
|
|
struct tm* timeinfo = localtime(&NUMBERS[j]->lastvalue);
|
|
|
strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
|
|
|
NUMBERS[j]->timeStamp = std::string(buffer);
|
|
|
-// printf("SaverPreValue %d, Value: %f, Nachkomma %d\n", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
|
|
+// ESP_LOGD(TAG, "SaverPreValue %d, Value: %f, Nachkomma %d", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
|
|
|
|
|
_zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n";
|
|
|
- printf("Write PreValue Zeile: %s\n", _zw.c_str());
|
|
|
+ ESP_LOGD(TAG, "Write PreValue Zeile: %s", _zw.c_str());
|
|
|
if (pFile) {
|
|
|
fputs(_zw.c_str(), pFile);
|
|
|
}
|
|
|
@@ -278,7 +283,7 @@ void ClassFlowPostProcessing::handleDecimalExtendedResolution(string _decsep, st
|
|
|
{
|
|
|
string _digit, _decpos;
|
|
|
int _pospunkt = _decsep.find_first_of(".");
|
|
|
-// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
|
|
+// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
|
|
if (_pospunkt > -1)
|
|
|
_digit = _decsep.substr(0, _pospunkt);
|
|
|
else
|
|
|
@@ -308,7 +313,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
|
|
|
{
|
|
|
string _digit, _decpos;
|
|
|
int _pospunkt = _decsep.find_first_of(".");
|
|
|
-// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
|
|
+// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
|
|
if (_pospunkt > -1)
|
|
|
_digit = _decsep.substr(0, _pospunkt);
|
|
|
else
|
|
|
@@ -324,7 +329,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
|
|
|
}
|
|
|
/* catch(const std::exception& e)
|
|
|
{
|
|
|
- printf("ERROR - Decimalshift is not a number: %s\n", _value.c_str());
|
|
|
+ ESP_LOGD(TAG, "ERROR - Decimalshift is not a number: %s", _value.c_str());
|
|
|
}
|
|
|
*/
|
|
|
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
|
|
@@ -343,13 +348,36 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep, string _value)
|
|
|
+{
|
|
|
+ string _digit, _decpos;
|
|
|
+ int _pospunkt = _decsep.find_first_of(".");
|
|
|
+// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
|
|
+ if (_pospunkt > -1)
|
|
|
+ _digit = _decsep.substr(0, _pospunkt);
|
|
|
+ else
|
|
|
+ _digit = "default";
|
|
|
+
|
|
|
+ for (int j = 0; j < NUMBERS.size(); ++j)
|
|
|
+ {
|
|
|
+ float _zwdc = 9.2;
|
|
|
+ {
|
|
|
+ _zwdc = stof(_value);
|
|
|
+ }
|
|
|
+ if (_digit == "default" || NUMBERS[j]->name == _digit) // erstmal auf default setzen (falls sonst nichts gesetzt)
|
|
|
+ {
|
|
|
+ NUMBERS[j]->AnalogDigitalTransitionStart = _zwdc;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
|
|
|
void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value)
|
|
|
{
|
|
|
string _digit, _decpos;
|
|
|
int _pospunkt = _decsep.find_first_of(".");
|
|
|
-// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
|
|
+// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
|
|
if (_pospunkt > -1)
|
|
|
_digit = _decsep.substr(0, _pospunkt);
|
|
|
else
|
|
|
@@ -376,36 +404,33 @@ void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value)
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
|
|
|
{
|
|
|
string _digit, _decpos;
|
|
|
int _pospunkt = _decsep.find_first_of(".");
|
|
|
-// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
|
|
+// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
|
|
if (_pospunkt > -1)
|
|
|
_digit = _decsep.substr(0, _pospunkt);
|
|
|
else
|
|
|
_digit = "default";
|
|
|
-
|
|
|
for (int j = 0; j < NUMBERS.size(); ++j)
|
|
|
{
|
|
|
float _zwdc = 1;
|
|
|
-
|
|
|
// try
|
|
|
{
|
|
|
_zwdc = stof(_value);
|
|
|
}
|
|
|
/* catch(const std::exception& e)
|
|
|
{
|
|
|
- printf("ERROR - MaxRateValue is not a number: %s\n", _value.c_str());
|
|
|
+ ESP_LOGD(TAG, "ERROR - MaxRateValue is not a number: %s", _value.c_str());
|
|
|
}
|
|
|
*/
|
|
|
-
|
|
|
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
|
|
{
|
|
|
NUMBERS[j]->useMaxRateValue = true;
|
|
|
NUMBERS[j]->MaxRateValue = _zwdc;
|
|
|
}
|
|
|
-
|
|
|
if (NUMBERS[j]->name == _digit)
|
|
|
{
|
|
|
NUMBERS[j]->useMaxRateValue = true;
|
|
|
@@ -447,6 +472,10 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|
|
{
|
|
|
handleDecimalSeparator(zerlegt[0], zerlegt[1]);
|
|
|
}
|
|
|
+ if ((toUpper(_param) == "ANALOGDIGITALTRANSITIONSTART") && (zerlegt.size() > 1))
|
|
|
+ {
|
|
|
+ handleAnalogDigitalTransitionStart(zerlegt[0], zerlegt[1]);
|
|
|
+ }
|
|
|
if ((toUpper(_param) == "MAXRATEVALUE") && (zerlegt.size() > 1))
|
|
|
{
|
|
|
handleMaxRateValue(zerlegt[0], zerlegt[1]);
|
|
|
@@ -517,7 +546,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
|
|
|
flowAnalog->UpdateNameNumbers(&name_numbers);
|
|
|
}
|
|
|
|
|
|
- printf("Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d\n", name_numbers.size(), anzDIGIT, anzANALOG);
|
|
|
+ ESP_LOGD(TAG, "Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d", name_numbers.size(), anzDIGIT, anzANALOG);
|
|
|
|
|
|
for (int _num = 0; _num < name_numbers.size(); ++_num)
|
|
|
{
|
|
|
@@ -557,6 +586,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
|
|
|
_number->DecimalShift = 0;
|
|
|
_number->DecimalShiftInitial = 0;
|
|
|
_number->isExtendedResolution = false;
|
|
|
+ _number->AnalogDigitalTransitionStart=9.2;
|
|
|
|
|
|
|
|
|
_number->FlowRateAct = 0; // m3 / min
|
|
|
@@ -572,7 +602,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < NUMBERS.size(); ++i) {
|
|
|
- printf("Number %s, Anz DIG: %d, Anz ANA %d\n", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
|
|
|
+ ESP_LOGD(TAG, "Number %s, Anz DIG: %d, Anz ANA %d", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -641,7 +671,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo);
|
|
|
zwtime = std::string(strftime_buf);
|
|
|
|
|
|
- printf("Anzahl NUMBERS: %d\n", NUMBERS.size());
|
|
|
+ ESP_LOGD(TAG, "Anzahl NUMBERS: %d", NUMBERS.size());
|
|
|
|
|
|
for (int j = 0; j < NUMBERS.size(); ++j)
|
|
|
{
|
|
|
@@ -666,7 +696,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
}
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After analog->getReadout: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After analog->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi)
|
|
|
NUMBERS[j]->ReturnRawValue = "." + NUMBERS[j]->ReturnRawValue;
|
|
|
@@ -674,17 +704,17 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
if (NUMBERS[j]->digit_roi)
|
|
|
{
|
|
|
if (NUMBERS[j]->analog_roi)
|
|
|
- NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float) + NUMBERS[j]->ReturnRawValue;
|
|
|
+ NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogDigitalTransitionStart) + NUMBERS[j]->ReturnRawValue;
|
|
|
else
|
|
|
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After digital->getReadout: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After digital->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift);
|
|
|
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After ShiftDecimal: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After ShiftDecimal: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
|
|
|
if (IgnoreLeadingNaN)
|
|
|
@@ -692,29 +722,34 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
NUMBERS[j]->ReturnRawValue.erase(0, 1);
|
|
|
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After IgnoreLeadingNaN: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After IgnoreLeadingNaN: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
NUMBERS[j]->ReturnValue = NUMBERS[j]->ReturnRawValue;
|
|
|
|
|
|
if (findDelimiterPos(NUMBERS[j]->ReturnValue, "N") != std::string::npos)
|
|
|
{
|
|
|
if (PreValueUse && NUMBERS[j]->PreValueOkay)
|
|
|
+ {
|
|
|
NUMBERS[j]->ReturnValue = ErsetzteN(NUMBERS[j]->ReturnValue, NUMBERS[j]->PreValue);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
+ WriteDataLog(j);
|
|
|
continue; // es gibt keinen Zahl, da noch ein N vorhanden ist.
|
|
|
+ }
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After findDelimiterPos: ReturnValue %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After findDelimiterPos: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
// Lösche führende Nullen (außer es ist nur noch einen 0)
|
|
|
while ((NUMBERS[j]->ReturnValue.length() > 1) && (NUMBERS[j]->ReturnValue[0] == '0'))
|
|
|
NUMBERS[j]->ReturnValue.erase(0, 1);
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After removeLeadingZeros: ReturnValue %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
+ ESP_LOGD(TAG, "After removeLeadingZeros: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
|
|
|
#endif
|
|
|
NUMBERS[j]->Value = std::stod(NUMBERS[j]->ReturnValue);
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After setting the Value: Value %f and as double is %f\n", NUMBERS[j]->Value, std::stod(NUMBERS[j]->ReturnValue));
|
|
|
+ ESP_LOGD(TAG, "After setting the Value: Value %f and as double is %f", NUMBERS[j]->Value, std::stod(NUMBERS[j]->ReturnValue));
|
|
|
#endif
|
|
|
|
|
|
if (NUMBERS[j]->checkDigitIncreaseConsistency)
|
|
|
@@ -722,20 +757,20 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
if (flowDigit)
|
|
|
{
|
|
|
if (flowDigit->getCNNType() != Digital)
|
|
|
- printf("checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)\n");
|
|
|
+ ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)");
|
|
|
else
|
|
|
NUMBERS[j]->Value = checkDigitConsistency(NUMBERS[j]->Value, NUMBERS[j]->DecimalShift, NUMBERS[j]->analog_roi != NULL, NUMBERS[j]->PreValue);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("checkDigitIncreaseConsistency = true - no digital numbers defined!\n");
|
|
|
+ ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - no digital numbers defined!");
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After checkDigitIncreaseConsistency: Value %f\n", NUMBERS[j]->Value);
|
|
|
+ ESP_LOGD(TAG, "After checkDigitIncreaseConsistency: Value %f", NUMBERS[j]->Value);
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@@ -744,7 +779,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue))
|
|
|
{
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("Neg: value=%f, preValue=%f, preToll%f\n", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
|
|
|
+ ESP_LOGD(TAG, "Neg: value=%f, preValue=%f, preToll%f", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
|
|
|
NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))
|
|
|
) ;
|
|
|
#endif
|
|
|
@@ -756,13 +791,14 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
|
|
|
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
|
|
NUMBERS[j]->ReturnValue = "";
|
|
|
+ WriteDataLog(j);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After AllowNegativeRates: Value %f\n", NUMBERS[j]->Value);
|
|
|
+ ESP_LOGD(TAG, "After AllowNegativeRates: Value %f", NUMBERS[j]->Value);
|
|
|
#endif
|
|
|
double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in Sekunden
|
|
|
difference /= 60;
|
|
|
@@ -783,11 +819,12 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
|
|
NUMBERS[j]->ReturnValue = "";
|
|
|
NUMBERS[j]->ReturnRateValue = "";
|
|
|
+ WriteDataLog(j);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("After MaxRateCheck: Value %f\n", NUMBERS[j]->Value);
|
|
|
+ ESP_LOGD(TAG, "After MaxRateCheck: Value %f", NUMBERS[j]->Value);
|
|
|
#endif
|
|
|
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
|
|
NUMBERS[j]->lastvalue = imagetime;
|
|
|
@@ -802,13 +839,37 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|
|
UpdatePreValueINI = true;
|
|
|
|
|
|
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
|
|
+ ESP_LOGD(TAG, "%s", zw.c_str());
|
|
|
LogFile.WriteToFile(_zw);
|
|
|
+ WriteDataLog(j);
|
|
|
}
|
|
|
|
|
|
SavePreValue();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+void ClassFlowPostProcessing::WriteDataLog(int _index)
|
|
|
+{
|
|
|
+ string analog = "";
|
|
|
+ string digital = "";
|
|
|
+ string timezw = "";
|
|
|
+ char buffer[80];
|
|
|
+ struct tm* timeinfo = localtime(&NUMBERS[_index]->lastvalue);
|
|
|
+ strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
|
|
|
+ timezw = std::string(buffer);
|
|
|
+
|
|
|
+ if (flowAnalog)
|
|
|
+ analog = flowAnalog->getReadoutRawString(_index);
|
|
|
+ if (flowDigit)
|
|
|
+ digital = flowDigit->getReadoutRawString(_index);
|
|
|
+ LogFile.WriteToData(timezw, NUMBERS[_index]->name,
|
|
|
+ NUMBERS[_index]->ReturnRawValue, NUMBERS[_index]->ReturnValue, NUMBERS[_index]->ReturnPreValue,
|
|
|
+ NUMBERS[_index]->ReturnRateValue, NUMBERS[_index]->ReturnChangeAbsolute,
|
|
|
+ NUMBERS[_index]->ErrorMessageText,
|
|
|
+ digital, analog);
|
|
|
+ ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_index]->ReturnRawValue.c_str(), NUMBERS[_index]->ReturnValue.c_str(), NUMBERS[_index]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|
|
{
|
|
|
@@ -816,7 +877,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|
|
{
|
|
|
if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) // es gibt nur digitale ziffern
|
|
|
{
|
|
|
-// printf("Nurdigital\n");
|
|
|
+// ESP_LOGD(TAG, "Nurdigital");
|
|
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
|
|
|
|
|
if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
|
|
@@ -827,7 +888,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|
|
|
|
|
if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // es gibt nur analoge ziffern
|
|
|
{
|
|
|
-// printf("Nur analog\n");
|
|
|
+// ESP_LOGD(TAG, "Nur analog");
|
|
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
|
|
if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
|
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1;
|
|
|
@@ -837,7 +898,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|
|
|
|
|
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // digital + analog
|
|
|
{
|
|
|
-// printf("Nur digital + analog\n");
|
|
|
+// ESP_LOGD(TAG, "Nur digital + analog");
|
|
|
|
|
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
|
|
NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift;
|
|
|
@@ -847,7 +908,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|
|
|
|
|
}
|
|
|
|
|
|
- printf("UpdateNachkommaDecShift NUMBER%i: Nachkomma %i, DecShift %i\n", j, NUMBERS[j]->Nachkomma,NUMBERS[j]->DecimalShift);
|
|
|
+ ESP_LOGD(TAG, "UpdateNachkommaDecShift NUMBER%i: Nachkomma %i, DecShift %i", j, NUMBERS[j]->Nachkomma,NUMBERS[j]->DecimalShift);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -866,10 +927,12 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror, i
|
|
|
return NUMBERS[_number]->ReturnValue;
|
|
|
}
|
|
|
|
|
|
+/* Jetzt als globale Funktion in Helper.h
|
|
|
+
|
|
|
string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){
|
|
|
std::stringstream stream;
|
|
|
int _zw = _in;
|
|
|
-// printf("AnzNachkomma: %d\n", _anzNachkomma);
|
|
|
+// ESP_LOGD(TAG, "AnzNachkomma: %d", _anzNachkomma);
|
|
|
|
|
|
if (_anzNachkomma < 0) {
|
|
|
_anzNachkomma = 0;
|
|
|
@@ -888,6 +951,7 @@ string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){
|
|
|
|
|
|
return stream.str();
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
|
|
|
string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue)
|
|
|
@@ -934,7 +998,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams
|
|
|
pot++;
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("checkDigitConsistency: pot=%d, decimalshift=%d\n", pot, _decilamshift);
|
|
|
+ ESP_LOGD(TAG, "checkDigitConsistency: pot=%d, decimalshift=%d", pot, _decilamshift);
|
|
|
#endif
|
|
|
pot_max = ((int) log10(input)) + 1;
|
|
|
while (pot <= pot_max)
|
|
|
@@ -966,7 +1030,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams
|
|
|
}
|
|
|
}
|
|
|
#ifdef SERIAL_DEBUG
|
|
|
- printf("checkDigitConsistency: input=%f", input);
|
|
|
+ ESP_LOGD(TAG, "checkDigitConsistency: input=%f", input);
|
|
|
#endif
|
|
|
pot++;
|
|
|
}
|
|
|
@@ -989,3 +1053,5 @@ string ClassFlowPostProcessing::getReadoutError(int _number)
|
|
|
{
|
|
|
return NUMBERS[_number]->ErrorMessageText;
|
|
|
}
|
|
|
+
|
|
|
+
|