Renamed variables and added debug log (#1537)

* add debug logs

* renamed variables

* renamed TAGs, added flow status logging

* .

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-12-10 20:39:43 +01:00
committed by GitHub
parent ba08b85225
commit 9d5846d0ce
11 changed files with 63 additions and 50 deletions

View File

@@ -5,7 +5,7 @@
#include <string.h>
#include "esp_log.h"
static const char *TAG = "FLOW CLASS";
static const char *TAG = "CLASS";
void ClassFlow::SetInitialParameter(void)

View File

@@ -9,7 +9,7 @@
#include "ClassLogFile.h"
static const char *TAG = "FLOW ALIGN";
static const char *TAG = "ALIGN";
bool AlignmentExtendedDebugging = true;

View File

@@ -620,19 +620,22 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
}
tflite->MakeAllocate();
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
for (int n = 0; n < GENERAL.size(); ++n) // For each NUMBER
{
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Processing Number '" + GENERAL[n]->name + "'");
for (int roi = 0; roi < GENERAL[n]->ROI.size(); ++roi) // For each ROI
{
ESP_LOGD(TAG, "General %d - TfLite", i);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ROI #" + std::to_string(roi) + " - TfLite");
//ESP_LOGD(TAG, "General %d - TfLite", i);
switch (CNNType) {
case Analogue:
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Analogue");
{
float f1, f2;
f1 = 0; f2 = 0;
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
tflite->Invoke();
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
@@ -640,39 +643,41 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
f2 = tflite->GetOutputValue(1);
float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - (result * 10);
if(GENERAL[n]->ROI[roi]->CCW)
GENERAL[n]->ROI[roi]->result_float = 10 - (result * 10);
else
GENERAL[_ana]->ROI[i]->result_float = result * 10;
GENERAL[n]->ROI[roi]->result_float = result * 10;
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
if (isLogImage)
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
LogImage(logPath, GENERAL[n]->ROI[roi]->name, &GENERAL[n]->ROI[roi]->result_float, NULL, time, GENERAL[n]->ROI[roi]->image_org);
} break;
case Digital:
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital");
{
GENERAL[_ana]->ROI[i]->result_klasse = 0;
GENERAL[_ana]->ROI[i]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[_ana]->ROI[i]->image);
ESP_LOGD(TAG, "Result General(Digit)%i: %d", i, GENERAL[_ana]->ROI[i]->result_klasse);
GENERAL[n]->ROI[roi]->result_klasse = 0;
GENERAL[n]->ROI[roi]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[n]->ROI[roi]->image);
ESP_LOGD(TAG, "Result General(Digit)%i: %d", roi, GENERAL[n]->ROI[roi]->result_klasse);
if (isLogImage)
{
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
if (isLogImageSelect)
{
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org);
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
}
else
{
LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org);
LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
}
}
} break;
/*
case DigitalHyprid:
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid");
int _num, _nachkomma;
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
@@ -713,6 +718,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
/*
case DigitalHyprid10:
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid10");
int _num, _nachkomma;
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
@@ -750,12 +756,13 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
case DoubleHyprid10:
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DoubleHyprid10");
int _num, _numplus, _numminus;
float _val, _valplus, _valminus;
float _fit;
float _result_save_file;
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
tflite->Invoke();
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
@@ -795,7 +802,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
if (_fit < CNNGoodThreshold)
{
GENERAL[_ana]->ROI[i]->isReject = true;
GENERAL[n]->ROI[roi]->isReject = true;
result = -1;
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold) + ")";
@@ -803,24 +810,24 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
}
else
{
GENERAL[_ana]->ROI[i]->isReject = false;
GENERAL[n]->ROI[roi]->isReject = false;
}
GENERAL[_ana]->ROI[i]->result_float = result;
ESP_LOGD(TAG, "Result General(Analog)%i: %f", i, GENERAL[_ana]->ROI[i]->result_float);
GENERAL[n]->ROI[roi]->result_float = result;
ESP_LOGD(TAG, "Result General(Analog)%i: %f", roi, GENERAL[n]->ROI[roi]->result_float);
if (isLogImage)
{
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
if (isLogImageSelect)
{
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
}
else
{
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
}
}
}
@@ -828,37 +835,38 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
case Digital100:
case Analogue100:
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital100 or Analogue100");
int _num;
float _result_save_file;
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
tflite->Invoke();
_num = tflite->GetOutClassification();
if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - ((float)_num / 10.0);
if(GENERAL[n]->ROI[roi]->CCW)
GENERAL[n]->ROI[roi]->result_float = 10 - ((float)_num / 10.0);
else
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0;
GENERAL[n]->ROI[roi]->result_float = (float)_num / 10.0;
_result_save_file = GENERAL[_ana]->ROI[i]->result_float;
_result_save_file = GENERAL[n]->ROI[roi]->result_float;
GENERAL[_ana]->ROI[i]->isReject = false;
GENERAL[n]->ROI[roi]->isReject = false;
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
if (isLogImage)
{
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
if (isLogImageSelect)
{
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
}
else
{
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
}
}

View File

@@ -29,7 +29,7 @@ extern "C" {
//#define DEBUG_DETAIL_ON
static const char* TAG = "FLOW CTRL";
static const char* TAG = "CTRL";
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
@@ -83,9 +83,9 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
if (_input.compare("ClassFlowInfluxDB") == 0)
return ("Sending InfluxDB");
if (_input.compare("ClassFlowPostProcessing") == 0)
return ("Processing");
return ("Post-Processing");
if (_input.compare("ClassFlowWriteList") == 0)
return ("Processing");
return ("Writing List");
return "Unkown Status";
}
@@ -287,6 +287,7 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
FlowControll[i]->doFlow(time);
@@ -317,6 +318,7 @@ bool ClassFlowControll::doFlow(string time)
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
@@ -348,6 +350,7 @@ bool ClassFlowControll::doFlow(string time)
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = "Flow finished";
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
return result;
}

View File

@@ -16,7 +16,7 @@ extern "C" {
#include "CImageBasis.h"
#include "esp_log.h"
static const char* TAG = "FLOW IMG";
static const char* TAG = "IMG";
ClassFlowImage::ClassFlowImage(const char* logTag)
{

View File

@@ -17,7 +17,7 @@
#define __HIDE_PASSWORD
static const char *TAG = "FLOW MQTT";
static const char *TAG = "MQTT";
#define LWT_TOPIC "connection"
#define LWT_CONNECTED "connected"
#define LWT_DISCONNECTED "connection lost"

View File

@@ -12,7 +12,7 @@
#include "esp_log.h"
static const char* TAG = "FLOW POSTPROC";
static const char* TAG = "POSTPROC";
//#define SERIAL_DEBUG // testing debug on serial enabled

View File

@@ -8,7 +8,7 @@
// #define DEBUG_DETAIL_ON
static const char *TAG = "C TFLITE";
static const char *TAG = "TFLITE";
float CTfLiteClass::GetOutputValue(int nr)
{
@@ -179,6 +179,8 @@ void CTfLiteClass::MakeAllocate()
static tflite::AllOpsResolver resolver;
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Make Allocate");
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());

View File

@@ -39,7 +39,7 @@ bool auto_isrunning = false;
int countRounds = 0;
static const char *TAG = "TFLITE";
static const char *TAG = "TFLITE SERVER";
int getCountFlowRounds() {

View File

@@ -133,13 +133,13 @@ static bool obtain_time(void)
void logNtpStatus(sntp_sync_status_t status) {
if (status == SNTP_SYNC_STATUS_COMPLETED) {
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status OK");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status OK");
}
else if (status == SNTP_SYNC_STATUS_IN_PROGRESS) {
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status: In Progress");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status: In Progress");
}
else { // SNTP_SYNC_STATUS_RESET
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status: Reset");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status: Reset");
}
}

View File

@@ -1,7 +1,7 @@
#include "test_flow_postrocess_helper.h"
#include "esp_log.h"
static const char *TAG = "FLOW CTRL POSTPROC TEST";
static const char *TAG = "POSTPROC TEST";
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
{