mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 12:06:58 +03:00
Merge branch 'rolling' into various-improvements
This commit is contained in:
@@ -400,7 +400,7 @@ bool GpioHandler::readConfig()
|
|||||||
|
|
||||||
if (gpioExtLED > 0)
|
if (gpioExtLED > 0)
|
||||||
{
|
{
|
||||||
// LogFile.WriteToFile("Startsequence 06"); // Nremove
|
// LogFile.WriteToFile(ESP_LOG_INFO, "Startsequence 06"); // Nremove
|
||||||
// vTaskDelay( xDelay );
|
// vTaskDelay( xDelay );
|
||||||
// xDelay = 5000 / portTICK_PERIOD_MS;
|
// xDelay = 5000 / portTICK_PERIOD_MS;
|
||||||
// ESP_LOGD(TAG_SERVERGPIO, "main: sleep for: %ldms", (long) xDelay);
|
// ESP_LOGD(TAG_SERVERGPIO, "main: sleep for: %ldms", (long) xDelay);
|
||||||
@@ -458,7 +458,7 @@ esp_err_t GpioHandler::handleHttpRequest(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("handler_switch_GPIO - Start");
|
LogFile.WriteHeapInfo("handler_switch_GPIO - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("handler_switch_GPIO");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "handler_switch_GPIO");
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _valueGPIO[30];
|
char _valueGPIO[30];
|
||||||
char _valueStatus[30];
|
char _valueStatus[30];
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ void CCamera::EnableAutoExposure(int flashdauer)
|
|||||||
LEDOnOff(false);
|
LEDOnOff(false);
|
||||||
LightOnOff(false);
|
LightOnOff(false);
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Camera Capture Failed (Procedure 'EnableAutoExposure') --> Reboot"
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Camera Capture Failed (Procedure 'EnableAutoExposure') --> Reboot! "
|
||||||
"Check that your camera module is working and connected properly.");
|
"Check that your camera module is working and connected properly.");
|
||||||
//doReboot();
|
//doReboot();
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
|||||||
LightOnOff(false);
|
LightOnOff(false);
|
||||||
|
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Camera is not working anymore (CCamera::CaptureToBasisImage) - most probably caused by a hardware problem (instablility, ...). "
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Camera is not working anymore (CCamera::CaptureToBasisImage) - most probably caused by a hardware problem (instablility, ...). "
|
||||||
"System will reboot.");
|
"System will reboot.");
|
||||||
doReboot();
|
doReboot();
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
|||||||
{
|
{
|
||||||
ESP_LOGE(TAGCAMERACLASS, "Insufficient memory space for image in function CaptureToBasisImage()");
|
ESP_LOGE(TAGCAMERACLASS, "Insufficient memory space for image in function CaptureToBasisImage()");
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Insufficient memory space for image in function CaptureToBasisImage()");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Insufficient memory space for image in function CaptureToBasisImage()");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < _size; ++i)
|
for (int i = 0; i < _size; ++i)
|
||||||
*(zwischenspeicher + i) = *(fb->buf + i);
|
*(zwischenspeicher + i) = *(fb->buf + i);
|
||||||
@@ -366,7 +366,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
|||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height);
|
std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height);
|
||||||
_zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height);
|
_zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height);
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, _zw);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int x = 0; x < width; ++x)
|
for (int x = 0; x < width; ++x)
|
||||||
@@ -414,7 +414,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
|||||||
LEDOnOff(false);
|
LEDOnOff(false);
|
||||||
LightOnOff(false);
|
LightOnOff(false);
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Camera Capture Failed (CCamera::CaptureToFile) --> Reboot"
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Camera Capture Failed (CCamera::CaptureToFile) --> Reboot! "
|
||||||
"Check that your camera module is working and connected properly.");
|
"Check that your camera module is working and connected properly.");
|
||||||
//doReboot();
|
//doReboot();
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
|
|
||||||
static esp_err_t logfileact_get_handler(httpd_req_t *req)
|
static esp_err_t logfileact_get_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("logfileact_get_handler");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "logfileact_get_handler");
|
||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
//struct stat file_stat;
|
//struct stat file_stat;
|
||||||
@@ -387,7 +387,7 @@ static esp_err_t logfileact_get_handler(httpd_req_t *req)
|
|||||||
/* Handler to download a file kept on the server */
|
/* Handler to download a file kept on the server */
|
||||||
static esp_err_t download_get_handler(httpd_req_t *req)
|
static esp_err_t download_get_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("download_get_handler");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "download_get_handler");
|
||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
@@ -488,7 +488,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
/* Handler to upload a file onto the server */
|
/* Handler to upload a file onto the server */
|
||||||
static esp_err_t upload_post_handler(httpd_req_t *req)
|
static esp_err_t upload_post_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("upload_post_handler");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "upload_post_handler");
|
||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
@@ -631,7 +631,7 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
|
|||||||
/* Handler to delete a file from the server */
|
/* Handler to delete a file from the server */
|
||||||
static esp_err_t delete_post_handler(httpd_req_t *req)
|
static esp_err_t delete_post_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("delete_post_handler");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "delete_post_handler");
|
||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("handler_ota_update - Start");
|
LogFile.WriteHeapInfo("handler_ota_update - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("handler_ota_update");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "handler_ota_update");
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _filename[100];
|
char _filename[100];
|
||||||
char _valuechar[30];
|
char _valuechar[30];
|
||||||
@@ -493,8 +493,8 @@ void task_reboot(void *pvParameter)
|
|||||||
|
|
||||||
void doReboot(){
|
void doReboot(){
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Reboot triggered by Software (5s).");
|
LogFile.WriteToFile(ESP_LOG_INFO, "Reboot triggered by Software (5s).");
|
||||||
LogFile.WriteToFile("Reboot in 5sec");
|
LogFile.WriteToFile(ESP_LOG_WARN, "Reboot in 5sec");
|
||||||
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
||||||
// KillTFliteTasks(); // kills itself
|
// KillTFliteTasks(); // kills itself
|
||||||
gpio_handler_destroy();
|
gpio_handler_destroy();
|
||||||
@@ -510,7 +510,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("handler_reboot - Start");
|
LogFile.WriteHeapInfo("handler_reboot - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("handler_reboot");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "handler_reboot");
|
||||||
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
||||||
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s.<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
|
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s.<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
std::string zw2 = "Alignmentmodus gewählt: " + zerlegt[1];
|
std::string zw2 = "Alignmentmodus gewählt: " + zerlegt[1];
|
||||||
LogFile.WriteToFile(zw2);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, zw2);
|
||||||
#endif
|
#endif
|
||||||
if (toUpper(zerlegt[1]) == "HIGHACCURACY")
|
if (toUpper(zerlegt[1]) == "HIGHACCURACY")
|
||||||
alg_algo = 1;
|
alg_algo = 1;
|
||||||
@@ -137,7 +137,7 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
References[i].alignment_algo = alg_algo;
|
References[i].alignment_algo = alg_algo;
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
std::string zw2 = "Alignmentmodus geschrieben: " + std::to_string(alg_algo);
|
std::string zw2 = "Alignmentmodus geschrieben: " + std::to_string(alg_algo);
|
||||||
LogFile.WriteToFile(zw2);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, zw2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
|
|
||||||
if (GENERAL[_analog]->ROI.size() == 0)
|
if (GENERAL[_analog]->ROI.size() == 0)
|
||||||
return result;
|
return result;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout _analog=" + std::to_string(_analog) + ", _extendedResolution=" + std::to_string(_extendedResolution) + ", prev=" + std::to_string(prev));
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout _analog=" + std::to_string(_analog) + ", _extendedResolution=" + std::to_string(_extendedResolution) + ", prev=" + std::to_string(prev));
|
||||||
|
|
||||||
if (CNNType == Analogue || CNNType == Analogue100)
|
if (CNNType == Analogue || CNNType == Analogue100)
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10;
|
int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10;
|
||||||
|
|
||||||
prev = ZeigerEvalAnalogNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev);
|
prev = ZeigerEvalAnalogNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev);
|
||||||
// if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout(analog) zahl=" + std::to_string(zahl) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev));
|
// LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout(analog) zahl=" + std::to_string(zahl) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev));
|
||||||
result = std::to_string(prev);
|
result = std::to_string(prev);
|
||||||
|
|
||||||
if (_extendedResolution && (CNNType != Digital))
|
if (_extendedResolution && (CNNType != Digital))
|
||||||
@@ -82,7 +82,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
|
|
||||||
result = std::to_string(ergebnis_vorkomma) + std::to_string(ergebnis_nachkomma);
|
result = std::to_string(ergebnis_vorkomma) + std::to_string(ergebnis_nachkomma);
|
||||||
prev = ergebnis_vorkomma;
|
prev = ergebnis_vorkomma;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout(dig100-ext) ergebnis_vorkomma=" + std::to_string(ergebnis_vorkomma) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev));
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout(dig100-ext) ergebnis_vorkomma=" + std::to_string(ergebnis_vorkomma) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
else
|
else
|
||||||
prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev);
|
prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev);
|
||||||
result = std::to_string(prev);
|
result = std::to_string(prev);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout(dig100) prev=" + std::to_string(prev));
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout(dig100) prev=" + std::to_string(prev));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,16 +108,16 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
if (GENERAL[_analog]->ROI[i]->result_float >= 0)
|
if (GENERAL[_analog]->ROI[i]->result_float >= 0)
|
||||||
{
|
{
|
||||||
prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
|
prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout#ZeigerEvalHybridNeu()= " + std::to_string(prev));
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout#ZeigerEvalHybridNeu()= " + std::to_string(prev));
|
||||||
result = std::to_string(prev) + result;
|
result = std::to_string(prev) + result;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout#result= " + result);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout#result= " + result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prev = -1;
|
prev = -1;
|
||||||
result = "N" + result;
|
result = "N" + result;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout(result_float<0 /'N') result_float=" + std::to_string(GENERAL[_analog]->ROI[i]->result_float));
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::getReadout(result_float<0 /'N') result_float=" + std::to_string(GENERAL[_analog]->ROI[i]->result_float));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
else
|
else
|
||||||
result = (int) ((int) trunc(zahl) + 10) % 10;
|
result = (int) ((int) trunc(zahl) + 10) % 10;
|
||||||
|
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - kein Vorgänger - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalHybridNeu - kein Vorgänger - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
if (AnalogerVorgaenger)
|
if (AnalogerVorgaenger)
|
||||||
{
|
{
|
||||||
result = ZeigerEvalAnalogToDigitNeu(zahl, zahl_vorgaenger, eval_vorgaenger, digitalAnalogTransitionStart);
|
result = ZeigerEvalAnalogToDigitNeu(zahl, zahl_vorgaenger, eval_vorgaenger, digitalAnalogTransitionStart);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - Analoger Vorgänger, Bewertung über ZeigerEvalAnalogNeu = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalHybridNeu - Analoger Vorgänger, Bewertung über ZeigerEvalAnalogNeu = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
else
|
else
|
||||||
result = ((int) trunc(zahl) + 10) % 10;
|
result = ((int) trunc(zahl) + 10) % 10;
|
||||||
|
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, kein Ziffernwechsel, da Vorkomma weit genug weg = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, kein Ziffernwechsel, da Vorkomma weit genug weg = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
else
|
else
|
||||||
// Akt. digit und Vorgänger haben Nulldurchgang
|
// Akt. digit und Vorgänger haben Nulldurchgang
|
||||||
result = ergebnis_vorkomma;
|
result = ergebnis_vorkomma;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, Nulldurchgang hat stattgefunden = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, Nulldurchgang hat stattgefunden = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
// keinen Nulldurchgang hat. Daher wird um 1 reduziert.
|
// keinen Nulldurchgang hat. Daher wird um 1 reduziert.
|
||||||
result = (ergebnis_vorkomma - 1 + 10) % 10;
|
result = (ergebnis_vorkomma - 1 + 10) % 10;
|
||||||
|
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, >= 9.5 --> noch kein Nulldurchgang = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, >= 9.5 --> noch kein Nulldurchgang = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe) + " ergebnis_nachkomma = " + std::to_string(ergebnis_nachkomma));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe) + " ergebnis_nachkomma = " + std::to_string(ergebnis_nachkomma));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -216,13 +216,13 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor
|
|||||||
// vor/nachkomma neu berechnen, da wir anhand der Unschaefe die Zahl anpassen.
|
// vor/nachkomma neu berechnen, da wir anhand der Unschaefe die Zahl anpassen.
|
||||||
ergebnis_nachkomma = ((int) floor(result * 10)) % 10;
|
ergebnis_nachkomma = ((int) floor(result * 10)) % 10;
|
||||||
ergebnis_vorkomma = ((int) floor(result) + 10) % 10;
|
ergebnis_vorkomma = ((int) floor(result) + 10) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - digitaleUnschaerfe - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - digitaleUnschaerfe - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger: " + std::to_string(ziffer_vorgaenger) +
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger: " + std::to_string(ziffer_vorgaenger) +
|
||||||
" erg_vorkomma: " + std::to_string(ergebnis_vorkomma) +
|
" erg_vorkomma: " + std::to_string(ergebnis_vorkomma) +
|
||||||
" erg_nachkomma: " + std::to_string(ergebnis_nachkomma));
|
" erg_nachkomma: " + std::to_string(ergebnis_nachkomma));
|
||||||
} else {
|
} else {
|
||||||
result = (int) ((int) trunc(zahl) + 10) % 10;
|
result = (int) ((int) trunc(zahl) + 10) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - KEINE digitaleUnschaerfe - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - KEINE digitaleUnschaerfe - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger));
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor
|
|||||||
|
|
||||||
{
|
{
|
||||||
result = ((ergebnis_vorkomma+10) - 1) % 10;
|
result = ((ergebnis_vorkomma+10) - 1) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) +
|
" zahl: " + std::to_string(zahl) +
|
||||||
" ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) +
|
" ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) +
|
||||||
" erg_nachkomma = " + std::to_string(ergebnis_nachkomma));
|
" erg_nachkomma = " + std::to_string(ergebnis_nachkomma));
|
||||||
@@ -255,7 +255,7 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger)
|
|||||||
if (ziffer_vorgaenger == -1)
|
if (ziffer_vorgaenger == -1)
|
||||||
{
|
{
|
||||||
result = (int) floor(zahl);
|
result = (int) floor(zahl);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - kein Vorgänger - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - kein Vorgänger - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -268,14 +268,14 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger)
|
|||||||
if (ziffer_vorgaenger <= AnalogFehler)
|
if (ziffer_vorgaenger <= AnalogFehler)
|
||||||
{
|
{
|
||||||
result = ((int) floor(zahl_max) + 10) % 10;
|
result = ((int) floor(zahl_max) + 10) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl uneindeutig, Korrektur nach oben - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl uneindeutig, Korrektur nach oben - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (ziffer_vorgaenger >= 10 - AnalogFehler)
|
if (ziffer_vorgaenger >= 10 - AnalogFehler)
|
||||||
{
|
{
|
||||||
result = ((int) floor(zahl_min) + 10) % 10;
|
result = ((int) floor(zahl_min) + 10) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl uneindeutig, Korrektur nach unten - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl uneindeutig, Korrektur nach unten - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger)
|
|||||||
|
|
||||||
|
|
||||||
result = ((int) floor(zahl) + 10) % 10;
|
result = ((int) floor(zahl) + 10) % 10;
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl eindeutig, keine Korrektur notwendig - Ergebnis = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::ZeigerEvalAnalogNeu - Zahl eindeutig, keine Korrektur notwendig - Ergebnis = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
" zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " AnalogFehler = " + std::to_string(AnalogFehler));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -471,7 +471,7 @@ bool ClassFlowCNNGeneral::doFlow(string time)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::doFlow nach Alignment");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "ClassFlowCNNGeneral::doFlow nach Alignment");
|
||||||
|
|
||||||
doNeuralNetwork(time);
|
doNeuralNetwork(time);
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ bool ClassFlowCNNGeneral::getNetworkParameter()
|
|||||||
zwcnn = FormatFileName(zwcnn);
|
zwcnn = FormatFileName(zwcnn);
|
||||||
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
||||||
if (!tflite->LoadModel(zwcnn)) {
|
if (!tflite->LoadModel(zwcnn)) {
|
||||||
LogFile.WriteToFile("Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
||||||
delete tflite;
|
delete tflite;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -595,8 +595,7 @@ bool ClassFlowCNNGeneral::getNetworkParameter()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogFile.WriteToFile("ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "tflite passt nicht zur Firmware (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")");
|
||||||
ESP_LOGD(TAG, "ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +615,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
zwcnn = FormatFileName(zwcnn);
|
zwcnn = FormatFileName(zwcnn);
|
||||||
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
||||||
if (!tflite->LoadModel(zwcnn)) {
|
if (!tflite->LoadModel(zwcnn)) {
|
||||||
LogFile.WriteToFile("Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
||||||
|
|
||||||
delete tflite;
|
delete tflite;
|
||||||
return false;
|
return false;
|
||||||
@@ -637,7 +636,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "Nach Invoke");
|
||||||
|
|
||||||
f1 = tflite->GetOutputValue(0);
|
f1 = tflite->GetOutputValue(0);
|
||||||
f2 = tflite->GetOutputValue(1);
|
f2 = tflite->GetOutputValue(1);
|
||||||
@@ -680,14 +679,14 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "Nach Invoke");
|
||||||
|
|
||||||
_num = tflite->GetOutClassification(0, 10);
|
_num = tflite->GetOutClassification(0, 10);
|
||||||
_nachkomma = tflite->GetOutClassification(11, 21);
|
_nachkomma = tflite->GetOutClassification(11, 21);
|
||||||
|
|
||||||
|
|
||||||
string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma);
|
string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres);
|
||||||
|
|
||||||
if ((_num == 10) || (_nachkomma == 10)) // NaN detektiert
|
if ((_num == 10) || (_nachkomma == 10)) // NaN detektiert
|
||||||
GENERAL[_ana]->ROI[i]->result_float = -1;
|
GENERAL[_ana]->ROI[i]->result_float = -1;
|
||||||
@@ -696,7 +695,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
@@ -720,20 +719,20 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "Nach Invoke");
|
||||||
|
|
||||||
_num = tflite->GetOutClassification(0, 9);
|
_num = tflite->GetOutClassification(0, 9);
|
||||||
_nachkomma = tflite->GetOutClassification(10, 19);
|
_nachkomma = tflite->GetOutClassification(10, 19);
|
||||||
|
|
||||||
|
|
||||||
string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma);
|
string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres);
|
||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
@@ -760,7 +759,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "Nach Invoke");
|
||||||
|
|
||||||
_num = tflite->GetOutClassification(0, 9);
|
_num = tflite->GetOutClassification(0, 9);
|
||||||
_numplus = (_num + 1) % 10;
|
_numplus = (_num + 1) % 10;
|
||||||
@@ -792,7 +791,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
zw = zw + " _val (p, m): " + to_string(_val) + " " + to_string(_valplus) + " " + to_string(_valminus);
|
zw = zw + " _val (p, m): " + to_string(_val) + " " + to_string(_valplus) + " " + to_string(_valminus);
|
||||||
zw = zw + " result: " + to_string(result) + " _fit: " + to_string(_fit);
|
zw = zw + " result: " + to_string(result) + " _fit: " + to_string(_fit);
|
||||||
ESP_LOGD(TAG, "details cnn: %s", zw.c_str());
|
ESP_LOGD(TAG, "details cnn: %s", zw.c_str());
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, zw);
|
||||||
|
|
||||||
|
|
||||||
_result_save_file = result;
|
_result_save_file = result;
|
||||||
@@ -803,7 +802,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
result = -1;
|
result = -1;
|
||||||
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
|
_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) + ")";
|
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold) + ")";
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(ESP_LOG_WARN, zw);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ class ClassFlowCNNGeneral :
|
|||||||
public ClassFlowImage
|
public ClassFlowImage
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool debugdetailgeneral = true;
|
|
||||||
t_CNNType CNNType;
|
t_CNNType CNNType;
|
||||||
std::vector<general*> GENERAL;
|
std::vector<general*> GENERAL;
|
||||||
float CNNGoodThreshold;
|
float CNNGoodThreshold;
|
||||||
|
|||||||
@@ -301,12 +301,12 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
|
|
||||||
if (!FlowControll[i]->doFlow(time)){
|
if (!FlowControll[i]->doFlow(time)){
|
||||||
repeat++;
|
repeat++;
|
||||||
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
LogFile.WriteToFile(ESP_LOG_WARN, "Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
||||||
if (i) i -= 1; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
|
if (i) i -= 1; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
|
||||||
result = false;
|
result = false;
|
||||||
if (repeat > 5) {
|
if (repeat > 5) {
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Wiederholung 5x nicht erfolgreich --> reboot");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Wiederholung 5x nicht erfolgreich --> reboot");
|
||||||
doReboot();
|
doReboot();
|
||||||
// Schritt wurde 5x wiederholt --> reboot
|
// Schritt wurde 5x wiederholt --> reboot
|
||||||
}
|
}
|
||||||
@@ -494,7 +494,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
// reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
|
// reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Rebooting to activate new HOSTNAME...");
|
LogFile.WriteToFile(ESP_LOG_WARN, "Rebooting to activate new HOSTNAME...");
|
||||||
esp_restart();
|
esp_restart();
|
||||||
hard_restart();
|
hard_restart();
|
||||||
doReboot();
|
doReboot();
|
||||||
@@ -509,9 +509,9 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((toUpper(zerlegt[0]) == "LOGLEVEL") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "LOGLEVEL") && (zerlegt.size() > 1)) // TODO there seems to be no such parameter in the config, but there is one called "Debug_Logfile_value1"!
|
||||||
{
|
{
|
||||||
LogFile.setLogLevel(stoi(zerlegt[1]));
|
LogFile.setLogLevel((esp_log_level_t)(stoi(zerlegt[1]))); // Gets mapped to esp_log_level_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ string ClassFlowImage::CreateLogFolder(string time) {
|
|||||||
string logPath = LogImageLocation + "/" + time.LOGFILE_TIME_FORMAT_DATE_EXTR + "/" + time.LOGFILE_TIME_FORMAT_HOUR_EXTR;
|
string logPath = LogImageLocation + "/" + time.LOGFILE_TIME_FORMAT_DATE_EXTR + "/" + time.LOGFILE_TIME_FORMAT_HOUR_EXTR;
|
||||||
isLogImage = mkdir_r(logPath.c_str(), S_IRWXU) == 0;
|
isLogImage = mkdir_r(logPath.c_str(), S_IRWXU) == 0;
|
||||||
if (!isLogImage) {
|
if (!isLogImage) {
|
||||||
LogFile.WriteToFile("Can't create log folder for analog images. Path " + logPath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Can't create log folder for analog images. Path " + logPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return logPath;
|
return logPath;
|
||||||
@@ -128,7 +128,7 @@ void ClassFlowImage::RemoveOldLogs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogFile.WriteToFile("Image folder deleted: " + std::to_string(deleted) + ". Image folder not deleted: " + std::to_string(notDeleted));
|
LogFile.WriteToFile(ESP_LOG_INFO, "Image folder deleted: " + std::to_string(deleted) + ". Image folder not deleted: " + std::to_string(notDeleted));
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
// Try sending mainerrortopic. If it fails, re-run init
|
// Try sending mainerrortopic. If it fails, re-run init
|
||||||
if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
LogFile.WriteToFile("MQTT - Re-running init...!");
|
LogFile.WriteToFile(ESP_LOG_WARN, "MQTT - Re-running init...!");
|
||||||
if (!MQTTInit(this->uri, this->clientname, this->user, this->password, this->mainerrortopic, keepAlive))
|
if (!MQTTInit(this->uri, this->clientname, this->user, this->password, this->mainerrortopic, keepAlive))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
MQTTenable = false;
|
MQTTenable = false;
|
||||||
@@ -166,14 +166,14 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
/* if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
/* if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
LogFile.WriteToFile("MQTT - Could not publish connection status!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not publish connection status!");
|
||||||
MQTTenable = false;
|
MQTTenable = false;
|
||||||
return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
|
return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* if(!MQTTPublish(_LWTContext, "", 1))
|
/* if(!MQTTPublish(_LWTContext, "", 1))
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("MQTT - Could not publish LWT!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not publish LWT!");
|
||||||
MQTTenable = false;
|
MQTTenable = false;
|
||||||
return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
|
return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
|
||||||
}*/
|
}*/
|
||||||
@@ -195,7 +195,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
// Try sending mainerrortopic. If it fails, re-run init
|
// Try sending mainerrortopic. If it fails, re-run init
|
||||||
if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
LogFile.WriteToFile("MQTT - Re-running init...!");
|
LogFile.WriteToFile(ESP_LOG_WARN, "MQTT - Re-running init...!");
|
||||||
if (!MQTTInit(this->uri, this->clientname, this->user, this->password, this->mainerrortopic, keepAlive))
|
if (!MQTTInit(this->uri, this->clientname, this->user, this->password, this->mainerrortopic, keepAlive))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
MQTTenable = false;
|
MQTTenable = false;
|
||||||
|
|||||||
@@ -856,7 +856,7 @@ 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;
|
||||||
ESP_LOGD(TAG, "%s", zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, _zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec)
|
|||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
xDelay = _waitsec * 1000 / portTICK_PERIOD_MS;
|
xDelay = _waitsec * 1000 / portTICK_PERIOD_MS;
|
||||||
std::string zw = "File is locked: " + std::string(nm) + " - wait for " + std::to_string(_waitsec) + " seconds";
|
std::string zw = "File is locked: " + std::string(nm) + " - wait for " + std::to_string(_waitsec) + " seconds";
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, zw);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
pfile = fopen(nm, _mode);
|
pfile = fopen(nm, _mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
if (isSimilar)
|
if (isSimilar)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteToFile("Use FastAlignment sucessfull");
|
LogFile.WriteToFile(ESP_LOG_INFO, "Use FastAlignment sucessfull");
|
||||||
#endif
|
#endif
|
||||||
_ref->found_x = _ref->fastalg_x;
|
_ref->found_x = _ref->fastalg_x;
|
||||||
_ref->found_y = _ref->fastalg_y;
|
_ref->found_y = _ref->fastalg_y;
|
||||||
|
|||||||
@@ -362,11 +362,8 @@ void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len)
|
|||||||
ESP_LOGD(TAG, "Image loaded from memory: %d, %d, %d", width, height, channels);
|
ESP_LOGD(TAG, "Image loaded from memory: %d, %d, %d", width, height, channels);
|
||||||
if ((width * height * channels) == 0)
|
if ((width * height * channels) == 0)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Image with size 0 loaded --> reboot to be done! "
|
|
||||||
"Check that your camera module is working and connected properly.");
|
|
||||||
|
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Image with size 0 loaded --> reboot to be done! "
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Image with size 0 loaded --> reboot to be done! "
|
||||||
"Check that your camera module is working and connected properly.");
|
"Check that your camera module is working and connected properly.");
|
||||||
|
|
||||||
doReboot();
|
doReboot();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
|
#include "esp_log.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -20,11 +21,11 @@ ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt", "/sdcard/log/dat
|
|||||||
|
|
||||||
void ClassLogFile::WriteHeapInfo(std::string _id)
|
void ClassLogFile::WriteHeapInfo(std::string _id)
|
||||||
{
|
{
|
||||||
std::string _zw = "\t" + _id;
|
std::string _zw = _id;
|
||||||
if (loglevel > 0)
|
if (loglevel > ESP_LOG_WARN)
|
||||||
_zw = _zw + "\t" + getESPHeapInfo();
|
_zw = _zw + "\t" + getESPHeapInfo();
|
||||||
|
|
||||||
WriteToFile(_zw);
|
WriteToFile(ESP_LOG_DEBUG, _zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ std::string ClassLogFile::getESPHeapInfo(){
|
|||||||
|
|
||||||
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)
|
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");
|
ESP_LOGD(TAG, "Start WriteToData");
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
@@ -107,16 +108,17 @@ void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::s
|
|||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "Can't open data file %s", logpath.c_str());
|
ESP_LOGE(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, esp_log_level_t level, std::string info, bool _time)
|
||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
std::string zwtime;
|
std::string zwtime;
|
||||||
|
std::string logline = "";
|
||||||
|
|
||||||
if (!doLogFile){
|
if (!doLogFile){
|
||||||
return;
|
return;
|
||||||
@@ -139,14 +141,39 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
|
|||||||
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
|
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
|
||||||
|
|
||||||
zwtime = std::string(buffer);
|
zwtime = std::string(buffer);
|
||||||
info = zwtime + ": " + info;
|
logline = zwtime;
|
||||||
}
|
}
|
||||||
fputs(info.c_str(), pFile);
|
|
||||||
fputs("\n", pFile);
|
|
||||||
|
|
||||||
|
std::string loglevelString;
|
||||||
|
switch(level) {
|
||||||
|
case ESP_LOG_NONE:
|
||||||
|
loglevelString = "NONE";
|
||||||
|
break;
|
||||||
|
case ESP_LOG_ERROR:
|
||||||
|
loglevelString = "ERR";
|
||||||
|
break;
|
||||||
|
case ESP_LOG_WARN:
|
||||||
|
loglevelString = "WRN";
|
||||||
|
break;
|
||||||
|
case ESP_LOG_INFO:
|
||||||
|
loglevelString = "INF";
|
||||||
|
break;
|
||||||
|
case ESP_LOG_DEBUG:
|
||||||
|
loglevelString = "DBG";
|
||||||
|
break;
|
||||||
|
case ESP_LOG_VERBOSE:
|
||||||
|
loglevelString = "VER";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
loglevelString = "NONE";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
logline = logline + "\t<" + loglevelString + ">\t" + info.c_str() + "\n";
|
||||||
|
fputs(logline.c_str(), pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "Can't open log file %s", _fn.c_str());
|
ESP_LOGE(TAG, "Can't open log file %s", _fn.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,14 +185,14 @@ void ClassLogFile::SetRetention(unsigned short _retentionInDays){
|
|||||||
retentionInDays = _retentionInDays;
|
retentionInDays = _retentionInDays;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ClassLogFile::WriteToFile(std::string info, bool _time)
|
void ClassLogFile::WriteToFile(esp_log_level_t level, std::string info, bool _time)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
struct stat path_stat;
|
struct stat path_stat;
|
||||||
if (stat(logroot.c_str(), &path_stat) != 0) {
|
if (stat(logroot.c_str(), &path_stat) != 0) {
|
||||||
ESP_LOGI(TAG, "Create log folder: %s", logroot.c_str());
|
ESP_LOGI(TAG, "Create log folder: %s", logroot.c_str());
|
||||||
if (mkdir_r(logroot.c_str(), S_IRWXU) == -1) {
|
if (mkdir_r(logroot.c_str(), S_IRWXU) == -1) {
|
||||||
ESP_LOGI(TAG, "Can't create log folder");
|
ESP_LOGE(TAG, "Can't create log folder");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -179,8 +206,8 @@ void ClassLogFile::WriteToFile(std::string info, bool _time)
|
|||||||
strftime(buffer, 30, logfile.c_str(), timeinfo);
|
strftime(buffer, 30, logfile.c_str(), timeinfo);
|
||||||
std::string logpath = logroot + "/" + buffer;
|
std::string logpath = logroot + "/" + buffer;
|
||||||
|
|
||||||
WriteToDedicatedFile(logpath, info, _time);
|
WriteToDedicatedFile(logpath, level, info, _time);
|
||||||
ESP_LOGD(TAG, "%s", info.c_str());
|
ESP_LOG_LEVEL(level, TAG, "%s", info.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ClassLogFile::GetCurrentFileName()
|
std::string ClassLogFile::GetCurrentFileName()
|
||||||
@@ -242,7 +269,7 @@ void ClassLogFile::RemoveOld()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogFile.WriteToFile("logfiles deleted: " + std::to_string(deleted) + " files not deleted (incl. leer.txt): " + std::to_string(notDeleted));
|
LogFile.WriteToFile(ESP_LOG_INFO, "logfiles deleted: " + std::to_string(deleted) + " files not deleted (incl. leer.txt): " + std::to_string(notDeleted));
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
|
||||||
@@ -297,6 +324,6 @@ ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile, std::stri
|
|||||||
dataroot = _logdatapath;
|
dataroot = _logdatapath;
|
||||||
doLogFile = true;
|
doLogFile = true;
|
||||||
retentionInDays = 10;
|
retentionInDays = 10;
|
||||||
loglevel = 0;
|
loglevel = ESP_LOG_INFO;
|
||||||
MakeDir("/sdcard/log/data");
|
MakeDir("/sdcard/log/data");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
|
||||||
class ClassLogFile
|
class ClassLogFile
|
||||||
@@ -11,23 +12,23 @@ private:
|
|||||||
std::string datafile;
|
std::string datafile;
|
||||||
bool doLogFile;
|
bool doLogFile;
|
||||||
unsigned short retentionInDays;
|
unsigned short retentionInDays;
|
||||||
int loglevel;
|
esp_log_level_t loglevel;
|
||||||
public:
|
public:
|
||||||
ClassLogFile(std::string _logpath, std::string _logfile, std::string _logdatapath, std::string _datafile);
|
ClassLogFile(std::string _logpath, std::string _logfile, std::string _logdatapath, std::string _datafile);
|
||||||
|
|
||||||
std::string getESPHeapInfo();
|
std::string getESPHeapInfo();
|
||||||
|
|
||||||
void setLogLevel(int i){loglevel = i;};
|
void setLogLevel(esp_log_level_t i){loglevel = i;};
|
||||||
|
|
||||||
void WriteHeapInfo(std::string _id);
|
void WriteHeapInfo(std::string _id);
|
||||||
|
|
||||||
void SwitchOnOff(bool _doLogFile);
|
void SwitchOnOff(bool _doLogFile);
|
||||||
void SetRetention(unsigned short _retentionInDays);
|
void SetRetention(unsigned short _retentionInDays);
|
||||||
|
|
||||||
void CreateLogDirectories();
|
void WriteToFile(esp_log_level_t level, std::string info, bool _time = true);
|
||||||
|
void WriteToDedicatedFile(std::string _fn, esp_log_level_t level, std::string info, bool _time = true);
|
||||||
|
|
||||||
void WriteToFile(std::string info, bool _time = true);
|
void CreateLogDirectories();
|
||||||
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 _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);
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ bool MQTTPublish(std::string _key, std::string _content, int retained_flag){
|
|||||||
std::string zw;
|
std::string zw;
|
||||||
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
||||||
if (msg_id < 0) {
|
if (msg_id < 0) {
|
||||||
LogFile.WriteToFile("MQTT - Failed to publish '" + _key + "'!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Failed to publish '" + _key + "'!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
zw = "MQTT - sent publish successful in MQTTPublish, msg_id=" + std::to_string(msg_id) + ", " + _key + ", " + _content;
|
zw = "MQTT - sent publish successful in MQTTPublish, msg_id=" + std::to_string(msg_id) + ", " + _key + ", " + _content;
|
||||||
if (debugdetail) LogFile.WriteToFile(zw);
|
if (debugdetail) LogFile.WriteToFile(ESP_LOG_INFO, zw);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
|
|||||||
.keepalive = _keepalive
|
.keepalive = _keepalive
|
||||||
};
|
};
|
||||||
|
|
||||||
LogFile.WriteToFile("MQTT - Init");
|
LogFile.WriteToFile(ESP_LOG_INFO, "MQTT - Init");
|
||||||
|
|
||||||
if (_user.length() && _password.length()){
|
if (_user.length() && _password.length()){
|
||||||
mqtt_cfg.username = _user.c_str();
|
mqtt_cfg.username = _user.c_str();
|
||||||
@@ -128,28 +128,28 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
|
|||||||
{
|
{
|
||||||
if (esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client) != ESP_OK)
|
if (esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client) != ESP_OK)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("MQTT - Could not register event!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not register event!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (esp_mqtt_client_start(client) != ESP_OK)
|
if (esp_mqtt_client_start(client) != ESP_OK)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("MQTT - Could not start client!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not start client!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if(!MQTTPublish(_LWTContext, "", 1))
|
/* if(!MQTTPublish(_LWTContext, "", 1))
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("MQTT - Could not publish LWT!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not publish LWT!");
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("MQTT - Could not Init client!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "MQTT - Could not Init client!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile.WriteToFile("MQTT - Init successful");
|
LogFile.WriteToFile(ESP_LOG_INFO, "MQTT - Init successful");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ void MQTTregisterSubscribeFunction(std::string topic, std::function<bool(std::st
|
|||||||
|
|
||||||
void MQTTconnected(){
|
void MQTTconnected(){
|
||||||
if (mqtt_connected) {
|
if (mqtt_connected) {
|
||||||
LogFile.WriteToFile("MQTT - Connected");
|
LogFile.WriteToFile(ESP_LOG_INFO, "MQTT - Connected");
|
||||||
if (connectFunktionMap != NULL) {
|
if (connectFunktionMap != NULL) {
|
||||||
for(std::map<std::string, std::function<void()>>::iterator it = connectFunktionMap->begin(); it != connectFunktionMap->end(); ++it) {
|
for(std::map<std::string, std::function<void()>>::iterator it = connectFunktionMap->begin(); it != connectFunktionMap->end(); ++it) {
|
||||||
it->second();
|
it->second();
|
||||||
@@ -222,7 +222,7 @@ void MQTTconnected(){
|
|||||||
if (subscribeFunktionMap != NULL) {
|
if (subscribeFunktionMap != NULL) {
|
||||||
for(std::map<std::string, std::function<bool(std::string, char*, int)>>::iterator it = subscribeFunktionMap->begin(); it != subscribeFunktionMap->end(); ++it) {
|
for(std::map<std::string, std::function<bool(std::string, char*, int)>>::iterator it = subscribeFunktionMap->begin(); it != subscribeFunktionMap->end(); ++it) {
|
||||||
int msg_id = esp_mqtt_client_subscribe(client, it->first.c_str(), 0);
|
int msg_id = esp_mqtt_client_subscribe(client, it->first.c_str(), 0);
|
||||||
LogFile.WriteToFile("MQTT - topic " + it->first + " subscribe successful, msg_id=" + std::to_string(msg_id));
|
LogFile.WriteToFile(ESP_LOG_INFO, "MQTT - topic " + it->first + " subscribe successful, msg_id=" + std::to_string(msg_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteToFile("Nach dem Laden in input");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, "Nach dem Laden in input");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -185,7 +185,7 @@ void CTfLiteClass::MakeAllocate()
|
|||||||
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
||||||
if (allocate_status != kTfLiteOk) {
|
if (allocate_status != kTfLiteOk) {
|
||||||
TF_LITE_REPORT_ERROR(error_reporter, "AllocateTensors() failed");
|
TF_LITE_REPORT_ERROR(error_reporter, "AllocateTensors() failed");
|
||||||
LogFile.WriteToFile("AllocateTensors() failed");
|
LogFile.WriteToFile(ESP_LOG_ERROR, "AllocateTensors() failed");
|
||||||
|
|
||||||
this->GetInputDimension();
|
this->GetInputDimension();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
while (auto_isrunning)
|
while (auto_isrunning)
|
||||||
{
|
{
|
||||||
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
|
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, _zw);
|
||||||
fr_start = esp_timer_get_time();
|
fr_start = esp_timer_get_time();
|
||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
@@ -751,13 +751,13 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
LogFile.RemoveOld();
|
LogFile.RemoveOld();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile.WriteToFile("task_autodoFlow - round done");
|
LogFile.WriteToFile(ESP_LOG_INFO, "task_autodoFlow - round done");
|
||||||
//CPU Temp
|
//CPU Temp
|
||||||
float cputmp = temperatureRead();
|
float cputmp = temperatureRead();
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << cputmp;
|
stream << std::fixed << std::setprecision(1) << cputmp;
|
||||||
string zwtemp = "CPU Temperature: " + stream.str();
|
string zwtemp = "CPU Temperature: " + stream.str();
|
||||||
LogFile.WriteToFile(zwtemp);
|
LogFile.WriteToFile(ESP_LOG_INFO, zwtemp);
|
||||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||||
if (auto_intervall > fr_delta_ms)
|
if (auto_intervall > fr_delta_ms)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void setTimeZone(std::string _tzstring)
|
|||||||
setenv("TZ", _tzstring.c_str(), 1);
|
setenv("TZ", _tzstring.c_str(), 1);
|
||||||
tzset();
|
tzset();
|
||||||
_tzstring = "Time zone set to " + _tzstring;
|
_tzstring = "Time zone set to " + _tzstring;
|
||||||
LogFile.WriteToFile(_tzstring);
|
LogFile.WriteToFile(ESP_LOG_INFO, _tzstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void obtain_time(void)
|
static void obtain_time(void)
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ extern "C" void app_main(void)
|
|||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
setup_time();
|
setup_time();
|
||||||
setBootTime();
|
setBootTime();
|
||||||
|
|
||||||
LogFile.WriteToFile("=============================================================================================");
|
LogFile.WriteToFile("=============================================================================================");
|
||||||
LogFile.WriteToFile("=================================== Main Started ============================================");
|
LogFile.WriteToFile("=================================== Main Started ============================================");
|
||||||
LogFile.WriteToFile("=============================================================================================");
|
LogFile.WriteToFile("=============================================================================================");
|
||||||
@@ -229,12 +230,12 @@ extern "C" void app_main(void)
|
|||||||
std::string _zws = "Not enough PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize);
|
std::string _zws = "Not enough PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize);
|
||||||
_zws = _zws + "\nEither not initialzed, too small (2MByte only) or not present at all. Firmware cannot start!!";
|
_zws = _zws + "\nEither not initialzed, too small (2MByte only) or not present at all. Firmware cannot start!!";
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile(_zws);
|
LogFile.WriteToFile(ESP_LOG_ERROR, _zws);
|
||||||
LogFile.SwitchOnOff(false);
|
LogFile.SwitchOnOff(false);
|
||||||
} else {
|
} else {
|
||||||
if (cam != ESP_OK) {
|
if (cam != ESP_OK) {
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Failed to initialize camera module. "
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Failed to initialize camera module. "
|
||||||
"Check that your camera module is working and connected properly.");
|
"Check that your camera module is working and connected properly.");
|
||||||
LogFile.SwitchOnOff(false);
|
LogFile.SwitchOnOff(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -242,7 +243,7 @@ extern "C" void app_main(void)
|
|||||||
camera_fb_t * fb = esp_camera_fb_get();
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Camera cannot be initialzed. "
|
LogFile.WriteToFile(ESP_LOG_ERROR, "Camera cannot be initialzed. "
|
||||||
"System will reboot.");
|
"System will reboot.");
|
||||||
doReboot();
|
doReboot();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("info_get_handler - Start");
|
LogFile.WriteHeapInfo("info_get_handler - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("info_get_handler");
|
LogFile.WriteToFile(ESP_LOG_INFO, "info_get_handler");
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _valuechar[30];
|
char _valuechar[30];
|
||||||
std::string _task;
|
std::string _task;
|
||||||
|
|||||||
Reference in New Issue
Block a user