mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 21:17:06 +03:00
start implementing direct data log
This commit is contained in:
@@ -127,6 +127,35 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string ClassFlowCNNGeneral::getReadoutRawString(int _analog)
|
||||||
|
{
|
||||||
|
string rt = "";
|
||||||
|
|
||||||
|
if (GENERAL[_analog]->ROI.size() == 0)
|
||||||
|
return rt;
|
||||||
|
|
||||||
|
for (int i = GENERAL[_analog]->ROI.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if (CNNType == Analogue || CNNType == Analogue100)
|
||||||
|
{
|
||||||
|
rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CNNType == Digital)
|
||||||
|
{
|
||||||
|
rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_klasse);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((CNNType == DoubleHyprid10) || (CNNType == Digital100))
|
||||||
|
{
|
||||||
|
rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger, int eval_vorgaenger, bool AnalogerVorgaenger)
|
int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger, int eval_vorgaenger, bool AnalogerVorgaenger)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public:
|
|||||||
string getHTMLSingleStep(string host);
|
string getHTMLSingleStep(string host);
|
||||||
string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _vorgaengerAnalog = -1);
|
string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _vorgaengerAnalog = -1);
|
||||||
|
|
||||||
|
string getReadoutRawString(int _analog);
|
||||||
|
|
||||||
void DrawROI(CImageBasis *_zw);
|
void DrawROI(CImageBasis *_zw);
|
||||||
|
|
||||||
std::vector<HTMLInfo*> GetHTMLInfo();
|
std::vector<HTMLInfo*> GetHTMLInfo();
|
||||||
|
|||||||
@@ -803,12 +803,26 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
|
|
||||||
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(_zw);
|
||||||
|
WriteDataLog(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePreValue();
|
SavePreValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassFlowPostProcessing::WriteDataLog(int _analog)
|
||||||
|
{
|
||||||
|
string analog = "";
|
||||||
|
string digital = "";
|
||||||
|
if (flowAnalog)
|
||||||
|
analog = flowAnalog->getReadout(_analog);
|
||||||
|
if (flowDigit)
|
||||||
|
digital = flowDigit->getReadout(_analog);
|
||||||
|
// LogFile.WriteToFile(analog);
|
||||||
|
LogFile.WriteToData(NUMBERS[_analog]->ReturnRawValue, NUMBERS[_analog]->ReturnValue, NUMBERS[_analog]->ErrorMessageText, digital, analog);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
||||||
{
|
{
|
||||||
@@ -989,3 +1003,5 @@ string ClassFlowPostProcessing::getReadoutError(int _number)
|
|||||||
{
|
{
|
||||||
return NUMBERS[_number]->ErrorMessageText;
|
return NUMBERS[_number]->ErrorMessageText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ protected:
|
|||||||
void handleDecimalExtendedResolution(string _decsep, string _value);
|
void handleDecimalExtendedResolution(string _decsep, string _value);
|
||||||
void handleMaxRateType(string _decsep, string _value);
|
void handleMaxRateType(string _decsep, string _value);
|
||||||
|
|
||||||
|
std::string GetStringReadouts(general);
|
||||||
|
|
||||||
|
void WriteDataLog(int _analog);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ extern "C" {
|
|||||||
|
|
||||||
static const char *TAG = "log";
|
static const char *TAG = "log";
|
||||||
|
|
||||||
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
|
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt", "/sdcard/log/data", "data_%Y-%m-%d.txt");
|
||||||
|
|
||||||
void ClassLogFile::WriteHeapInfo(std::string _id)
|
void ClassLogFile::WriteHeapInfo(std::string _id)
|
||||||
{
|
{
|
||||||
@@ -62,6 +62,59 @@ std::string ClassLogFile::getESPHeapInfo(){
|
|||||||
return espInfoResultStr;
|
return espInfoResultStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ErrorMessageText, std::string _digital, std::string _analog)
|
||||||
|
{
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm* timeinfo;
|
||||||
|
char buffer[30];
|
||||||
|
|
||||||
|
time(&rawtime);
|
||||||
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
|
strftime(buffer, 30, datafile.c_str(), timeinfo);
|
||||||
|
std::string logpath = dataroot + "/" + buffer;
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
std::string zwtime;
|
||||||
|
|
||||||
|
if (!doLogFile){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) + ":";
|
||||||
|
fputs(zwtime.c_str(), pFile);
|
||||||
|
fputs(_ReturnRawValue.c_str(), pFile);
|
||||||
|
fputs("\t", pFile);
|
||||||
|
fputs(_ReturnValue.c_str(), pFile);
|
||||||
|
fputs("\t", pFile);
|
||||||
|
fputs(_ErrorMessageText.c_str(), pFile);
|
||||||
|
fputs("\t", pFile);
|
||||||
|
fputs(_digital.c_str(), pFile);
|
||||||
|
fputs("\t", pFile);
|
||||||
|
fputs(_analog.c_str(), pFile);
|
||||||
|
fputs("\t", pFile);
|
||||||
|
fputs("\n", pFile);
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
} else {
|
||||||
|
ESP_LOGI(TAG, "Can't open data file %s", logpath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool _time)
|
void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool _time)
|
||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
@@ -161,6 +214,8 @@ void ClassLogFile::RemoveOld()
|
|||||||
rawtime = addDays(rawtime, -retentionInDays);
|
rawtime = addDays(rawtime, -retentionInDays);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////// message /////////////////////////////////////////
|
||||||
strftime(cmpfilename, 30, logfile.c_str(), timeinfo);
|
strftime(cmpfilename, 30, logfile.c_str(), timeinfo);
|
||||||
//ESP_LOGE(TAG, "log file name to compare: %s", cmpfilename);
|
//ESP_LOGE(TAG, "log file name to compare: %s", cmpfilename);
|
||||||
|
|
||||||
@@ -191,12 +246,46 @@ void ClassLogFile::RemoveOld()
|
|||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "%d older log files deleted. %d current log files not deleted.", deleted, notDeleted);
|
ESP_LOGI(TAG, "%d older log files deleted. %d current log files not deleted.", deleted, notDeleted);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////// data /////////////////////////////////////////
|
||||||
|
strftime(cmpfilename, 30, datafile.c_str(), timeinfo);
|
||||||
|
//ESP_LOGE(TAG, "log file name to compare: %s", cmpfilename);
|
||||||
|
|
||||||
|
dir = opendir(dataroot.c_str());
|
||||||
|
if (!dir) {
|
||||||
|
ESP_LOGI(TAG, "Failed to stat dir : %s", dataroot.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleted = 0;
|
||||||
|
notDeleted = 0;
|
||||||
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
|
if (entry->d_type == DT_REG) {
|
||||||
|
//ESP_LOGI(TAG, "list log file : %s %s", entry->d_name, cmpfilename);
|
||||||
|
if ((strlen(entry->d_name) == strlen(cmpfilename)) && (strcmp(entry->d_name, cmpfilename) < 0)) {
|
||||||
|
ESP_LOGI(TAG, "delete data file : %s", entry->d_name);
|
||||||
|
std::string filepath = logroot + "/" + entry->d_name;
|
||||||
|
if (unlink(filepath.c_str()) == 0) {
|
||||||
|
deleted ++;
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "can't delete file : %s", entry->d_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
notDeleted ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "%d older log files deleted. %d current log files not deleted.", deleted, notDeleted);
|
||||||
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile)
|
ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile, std::string _logdatapath, std::string _datafile)
|
||||||
{
|
{
|
||||||
logroot = _logroot;
|
logroot = _logroot;
|
||||||
logfile = _logfile;
|
logfile = _logfile;
|
||||||
|
datafile = _datafile;
|
||||||
|
dataroot = _logdatapath;
|
||||||
doLogFile = true;
|
doLogFile = true;
|
||||||
retentionInDays = 10;
|
retentionInDays = 10;
|
||||||
loglevel = 0;
|
loglevel = 0;
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ class ClassLogFile
|
|||||||
private:
|
private:
|
||||||
std::string logroot;
|
std::string logroot;
|
||||||
std::string logfile;
|
std::string logfile;
|
||||||
|
std::string dataroot;
|
||||||
|
std::string datafile;
|
||||||
bool doLogFile;
|
bool doLogFile;
|
||||||
unsigned short retentionInDays;
|
unsigned short retentionInDays;
|
||||||
int loglevel;
|
int loglevel;
|
||||||
public:
|
public:
|
||||||
ClassLogFile(std::string _logpath, std::string _logfile);
|
ClassLogFile(std::string _logpath, std::string _logfile, std::string _logdatapath, std::string _datafile);
|
||||||
|
|
||||||
std::string getESPHeapInfo();
|
std::string getESPHeapInfo();
|
||||||
|
|
||||||
@@ -26,6 +28,9 @@ public:
|
|||||||
void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true);
|
void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true);
|
||||||
void RemoveOld();
|
void RemoveOld();
|
||||||
|
|
||||||
|
void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ErrorMessageText, std::string _digital, std::string _analog);
|
||||||
|
|
||||||
|
|
||||||
std::string GetCurrentFileName();
|
std::string GetCurrentFileName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user