Merge branch 'rolling' into add-log-level-to-logfile2

This commit is contained in:
CaCO3
2022-10-25 14:14:23 +02:00
committed by GitHub
22 changed files with 729 additions and 111 deletions

View File

@@ -21,6 +21,22 @@ static const char* TAG = "class_flow_postproc";
#define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d"
std::string ClassFlowPostProcessing::getNumbersName()
{
std::string ret="";
for (int i = 0; i < NUMBERS.size(); ++i)
{
ret += NUMBERS[i]->name;
if (i < NUMBERS.size()-1)
ret = ret + "\t";
}
// ESP_LOGI(TAG, "Result ClassFlowPostProcessing::getNumbersName: %s", ret.c_str());
return ret;
}
std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, std::string _lineend)
{
std::string json="{" + _lineend;
@@ -848,17 +864,26 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
return true;
}
void ClassFlowPostProcessing::WriteDataLog(int _analog)
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(_analog);
analog = flowAnalog->getReadoutRawString(_index);
if (flowDigit)
digital = flowDigit->getReadoutRawString(_analog);
// LogFile.WriteToFile(ESP_LOG_INFO, analog);
LogFile.WriteToData(NUMBERS[_analog]->ReturnRawValue, NUMBERS[_analog]->ReturnValue, NUMBERS[_analog]->ReturnPreValue, NUMBERS[_analog]->ErrorMessageText, digital, analog);
ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_analog]->ReturnRawValue.c_str(), NUMBERS[_analog]->ReturnValue.c_str(), NUMBERS[_analog]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
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());
}
@@ -918,6 +943,8 @@ 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;
@@ -940,6 +967,7 @@ string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){
return stream.str();
}
*/
string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue)