diff --git a/Changelog.md b/Changelog.md index 691cbfbd..735ac1e7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,7 +10,7 @@ - SD card info into the "Info" Menue (thanks to [@Slider007]( https://github.com/Slider0007)) - Added a logging of the values in a text table in `/log/data` - each measurement is one line - Format: tabulator separated - - Content: time, raw-value, return-value, pre-value, error-text, cnn-digital, cnn-analog + - Content: time, name-of-number, raw-value, return-value, pre-value, change-rate, change-absolute, error-text, cnn-digital, cnn-analog - ATTENTION: format not fully fixed yet! diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 100f8895..319ca661 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -848,17 +848,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(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()); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 79075d01..f707f170 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -44,7 +44,7 @@ protected: void handleAnalogDigitalTransitionStart(string _decsep, string _value); std::string GetStringReadouts(general); - void WriteDataLog(int _analog); + void WriteDataLog(int _index); diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index 0d3e2b96..82723067 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -62,7 +62,7 @@ std::string ClassLogFile::getESPHeapInfo(){ return espInfoResultStr; } -void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog) +void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog) { ESP_LOGD(TAG, "Start WriteToData\n"); time_t rawtime; @@ -86,23 +86,20 @@ void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnV pFile = fopen(logpath.c_str(), "a+"); if (pFile!=NULL) { - time_t rawtime; - struct tm* timeinfo; - char buffer[80]; - - time(&rawtime); - timeinfo = localtime(&rawtime); - - strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo); - - zwtime = std::string(buffer) + "\t"; - fputs(zwtime.c_str(), pFile); + fputs(_timestamp.c_str(), pFile); + fputs("\t", pFile); + fputs(_name.c_str(), pFile); + fputs("\t", pFile); fputs(_ReturnRawValue.c_str(), pFile); fputs("\t", pFile); fputs(_ReturnValue.c_str(), pFile); fputs("\t", pFile); fputs(_ReturnPreValue.c_str(), pFile); fputs("\t", pFile); + fputs(_ReturnRateValue.c_str(), pFile); + fputs("\t", pFile); + fputs(_ReturnChangeAbsolute.c_str(), pFile); + fputs("\t", pFile); fputs(_ErrorMessageText.c_str(), pFile); fputs(_digital.c_str(), pFile); fputs(_analog.c_str(), pFile); diff --git a/code/components/jomjol_logfile/ClassLogFile.h b/code/components/jomjol_logfile/ClassLogFile.h index 76426db5..da33557f 100644 --- a/code/components/jomjol_logfile/ClassLogFile.h +++ b/code/components/jomjol_logfile/ClassLogFile.h @@ -30,7 +30,8 @@ public: void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true); void RemoveOld(); - void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog); +// void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog); + void WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog); std::string GetCurrentFileName();