From f6369ff2378cde4f0a36411f1047eed223127fdd Mon Sep 17 00:00:00 2001 From: Nicolas Liaudat Date: Mon, 19 Dec 2022 22:05:45 +0100 Subject: [PATCH] Code translation (#1626) * comment translation * translation part #2 * code translation from DE to ENG #part3 * translation #4 * dismantled =>splitted * bereich => range * Update defines.h Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> --- .../jomjol_configfile/configFile.cpp | 2 +- .../jomjol_controlGPIO/server_GPIO.cpp | 54 +-- .../ClassControllCamera.cpp | 41 +- .../ClassControllCamera.h | 5 +- .../jomjol_fileserver_ota/server_ota.cpp | 2 +- .../jomjol_flowcontroll/ClassFlow.cpp | 2 +- .../ClassFlowAlignment.cpp | 90 ++--- .../ClassFlowCNNGeneral.cpp | 359 +++++++----------- .../jomjol_flowcontroll/ClassFlowCNNGeneral.h | 12 +- .../jomjol_flowcontroll/ClassFlowControll.cpp | 69 ++-- .../ClassFlowDefineTypes.h | 20 +- .../jomjol_flowcontroll/ClassFlowInfluxDB.cpp | 24 +- .../jomjol_flowcontroll/ClassFlowMQTT.cpp | 54 +-- .../ClassFlowMakeImage.cpp | 78 ++-- .../jomjol_flowcontroll/ClassFlowMakeImage.h | 2 +- .../ClassFlowPostProcessing.cpp | 156 ++++---- .../ClassFlowPostProcessing.h | 2 +- .../ClassFlowWriteList.cpp | 12 +- .../jomjol_image_proc/CAlignAndCutImage.cpp | 4 +- .../jomjol_image_proc/CImageBasis.cpp | 8 +- .../jomjol_tfliteclass/CTfLiteClass.cpp | 10 +- .../jomjol_tfliteclass/server_tflite.cpp | 15 +- code/components/jomjol_wlan/read_wlanini.cpp | 44 +-- code/main/main.cpp | 6 +- code/main/server_main.cpp | 24 +- code/platformio.ini | 23 +- code/sdkconfig.defaults | 58 ++- .../test_PointerEvalAnalogToDigitNew.cpp | 104 +++++ .../test_ZeigerEvalAnalogToDigitNeu.cpp | 104 ----- .../test_cnnflowcontroll.cpp | 50 +-- code/test/test_suite_flowcontroll.cpp | 2 +- 31 files changed, 686 insertions(+), 750 deletions(-) create mode 100644 code/test/components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp delete mode 100644 code/test/components/jomjol-flowcontroll/test_ZeigerEvalAnalogToDigitNeu.cpp diff --git a/code/components/jomjol_configfile/configFile.cpp b/code/components/jomjol_configfile/configFile.cpp index 775661b6..22ca9298 100644 --- a/code/components/jomjol_configfile/configFile.cpp +++ b/code/components/jomjol_configfile/configFile.cpp @@ -67,7 +67,7 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof) } *rt = zw; *rt = trim(*rt); - while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph + while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) { fgets(zw, 1024, pFile); ESP_LOGD(TAG, "%s", zw); diff --git a/code/components/jomjol_controlGPIO/server_GPIO.cpp b/code/components/jomjol_controlGPIO/server_GPIO.cpp index b3cc67a9..ba5dd92e 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.cpp +++ b/code/components/jomjol_controlGPIO/server_GPIO.cpp @@ -306,7 +306,7 @@ bool GpioHandler::readConfig() ConfigFile configFile = ConfigFile(_configFile); - std::vector zerlegt; + std::vector splitted; std::string line = ""; bool disabledLine = false; bool eof = false; @@ -340,31 +340,31 @@ bool GpioHandler::readConfig() bool registerISR = false; while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line)) { - zerlegt = ZerlegeZeile(line); + splitted = ZerlegeZeile(line); // const std::regex pieces_regex("IO([0-9]{1,2})"); // std::smatch pieces_match; - // if (std::regex_match(zerlegt[0], pieces_match, pieces_regex) && (pieces_match.size() == 2)) + // if (std::regex_match(splitted[0], pieces_match, pieces_regex) && (pieces_match.size() == 2)) // { // std::string gpioStr = pieces_match[1]; - ESP_LOGD(TAG, "conf param %s", toUpper(zerlegt[0]).c_str()); - if (toUpper(zerlegt[0]) == "MAINTOPICMQTT") { + ESP_LOGD(TAG, "conf param %s", toUpper(splitted[0]).c_str()); + if (toUpper(splitted[0]) == "MAINTOPICMQTT") { // ESP_LOGD(TAG, "MAINTOPICMQTT found"); -// mainTopicMQTT = zerlegt[1]; - } else if ((zerlegt[0].rfind("IO", 0) == 0) && (zerlegt.size() >= 6)) +// mainTopicMQTT = splitted[1]; + } else if ((splitted[0].rfind("IO", 0) == 0) && (splitted.size() >= 6)) { - ESP_LOGI(TAG,"Enable GP%s in %s mode", zerlegt[0].c_str(), zerlegt[1].c_str()); - std::string gpioStr = zerlegt[0].substr(2, 2); + ESP_LOGI(TAG,"Enable GP%s in %s mode", splitted[0].c_str(), splitted[1].c_str()); + std::string gpioStr = splitted[0].substr(2, 2); gpio_num_t gpioNr = (gpio_num_t)atoi(gpioStr.c_str()); - gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1])); - gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2])); - uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str()); + gpio_pin_mode_t pinMode = resolvePinMode(toLower(splitted[1])); + gpio_int_type_t intType = resolveIntType(toLower(splitted[2])); + uint16_t dutyResolution = (uint8_t)atoi(splitted[3].c_str()); #ifdef ENABLE_MQTT - bool mqttEnabled = toLower(zerlegt[4]) == "true"; + bool mqttEnabled = toLower(splitted[4]) == "true"; #endif // ENABLE_MQTT - bool httpEnabled = toLower(zerlegt[5]) == "true"; + bool httpEnabled = toLower(splitted[5]) == "true"; char gpioName[100]; - if (zerlegt.size() >= 7) { - strcpy(gpioName, trim(zerlegt[6]).c_str()); + if (splitted.size() >= 7) { + strcpy(gpioName, trim(splitted[6]).c_str()); } else { sprintf(gpioName, "GPIO%d", gpioNr); } @@ -386,28 +386,28 @@ bool GpioHandler::readConfig() registerISR = true; } } - if (toUpper(zerlegt[0]) == "LEDNUMBERS") + if (toUpper(splitted[0]) == "LEDNUMBERS") { - LEDNumbers = stoi(zerlegt[1]); + LEDNumbers = stoi(splitted[1]); } - if (toUpper(zerlegt[0]) == "LEDCOLOR") + if (toUpper(splitted[0]) == "LEDCOLOR") { uint8_t _r, _g, _b; - _r = stoi(zerlegt[1]); - _g = stoi(zerlegt[2]); - _b = stoi(zerlegt[3]); + _r = stoi(splitted[1]); + _g = stoi(splitted[2]); + _b = stoi(splitted[3]); LEDColor = Rgb{_r, _g, _b}; } - if (toUpper(zerlegt[0]) == "LEDTYPE") + if (toUpper(splitted[0]) == "LEDTYPE") { - if (zerlegt[1] == "WS2812") + if (splitted[1] == "WS2812") LEDType = LED_WS2812; - if (zerlegt[1] == "WS2812B") + if (splitted[1] == "WS2812B") LEDType = LED_WS2812B; - if (zerlegt[1] == "SK6812") + if (splitted[1] == "SK6812") LEDType = LED_SK6812; - if (zerlegt[1] == "WS2813") + if (splitted[1] == "WS2813") LEDType = LED_WS2813; } } diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index f70e459c..2545b1df 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -50,8 +50,8 @@ static camera_config_t camera_config = { .pin_pclk = CAM_PIN_PCLK, //XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental) - .xclk_freq_hz = 20000000, // Orginalwert -// .xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!! Hängt in Version 9.2 !!!! + .xclk_freq_hz = 20000000, // Orginal value +// .xclk_freq_hz = 5000000, // Test to get rid of the image errors !!!! Hangs in version 9.2 !!!! .ledc_timer = LEDC_TIMER_0, .ledc_channel = LEDC_CHANNEL_0, @@ -61,8 +61,7 @@ static camera_config_t camera_config = { .jpeg_quality = 12, //0-63 lower number means higher quality .fb_count = 1, //if more than one, i2s runs in continuous mode. Use only with JPEG .fb_location = CAMERA_FB_IN_PSRAM, /*!< The location where the frame buffer will be allocated */ -// .grab_mode = CAMERA_GRAB_WHEN_EMPTY, - .grab_mode = CAMERA_GRAB_LATEST, // erst ab neuer esp32cam-version + .grab_mode = CAMERA_GRAB_LATEST, // only from new esp32cam version }; @@ -179,39 +178,17 @@ void CCamera::SetQualitySize(int qual, framesize_t resol) image_height = 480; image_width = 640; } - // No higher Mode than VGA, damit der Kameraspeicher ausreicht. -/* - if (resol == FRAMESIZE_SVGA) - { - image_height = 600; - image_width = 800; - } - if (resol == FRAMESIZE_XGA) - { - image_height = 768; - image_width = 1024; - } - if (resol == FRAMESIZE_SXGA) - { - image_height = 1024; - image_width = 1280; - } - if (resol == FRAMESIZE_UXGA) - { - image_height = 1200; - image_width = 1600; - } -*/ + } -void CCamera::EnableAutoExposure(int flashdauer) +void CCamera::EnableAutoExposure(int flash_duration) { ESP_LOGD(TAG, "EnableAutoExposure"); LEDOnOff(true); - if (flashdauer > 0) + if (flash_duration > 0) LightOnOff(true); - const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS; + const TickType_t xDelay = flash_duration / portTICK_PERIOD_MS; vTaskDelay( xDelay ); camera_fb_t * fb = esp_camera_fb_get(); @@ -235,7 +212,7 @@ void CCamera::EnableAutoExposure(int flashdauer) LEDOnOff(false); LightOnOff(false); isFixedExposure = true; - waitbeforepicture_org = flashdauer; + waitbeforepicture_org = flash_duration; } @@ -351,7 +328,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) { string ftype; - LEDOnOff(true); // Abgeschaltet, um Strom zu sparen !!!!!! + LEDOnOff(true); // Switched off to save power ! if (delay > 0) { diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index 68be8724..3763e9d5 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -38,10 +38,9 @@ class CCamera { bool SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation); void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol); void SetLEDIntensity(float _intrel); - - void EnableAutoExposure(int flashdauer); + void EnableAutoExposure(int flash_duration); bool getCameraInitSuccessful(); - + framesize_t TextToFramesize(const char * text); diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp index 60bec35e..67c10ef8 100644 --- a/code/components/jomjol_fileserver_ota/server_ota.cpp +++ b/code/components/jomjol_fileserver_ota/server_ota.cpp @@ -154,7 +154,7 @@ static bool ota_update_task(std::string fn) int data_read; - FILE* f = OpenFileAndWait(fn.c_str(), "rb"); // vorher nur "r" + FILE* f = OpenFileAndWait(fn.c_str(), "rb"); // previously only "r if (f == NULL) { // File does not exist return false; diff --git a/code/components/jomjol_flowcontroll/ClassFlow.cpp b/code/components/jomjol_flowcontroll/ClassFlow.cpp index 491f2879..0de7428d 100644 --- a/code/components/jomjol_flowcontroll/ClassFlow.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlow.cpp @@ -106,7 +106,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt) ESP_LOGD(TAG, "%s", zw); *rt = zw; *rt = trim(*rt); - while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph + while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) { *rt = ""; if (!fgets(zw, 1024, pfile)) diff --git a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp index 3442a5e2..5460fef7 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp @@ -49,7 +49,7 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector* lfc) } } - if (!ImageBasis) // die Funktion Bilder aufnehmen existiert nicht --> muss erst erzeugt werden NUR ZU TESTZWECKEN + if (!ImageBasis) // the function take pictures does not exist --> must be created first ONLY FOR TEST PURPOSES { if (AlignmentExtendedDebugging) ESP_LOGD(TAG, "CImageBasis had to be created"); ImageBasis = new CImageBasis(namerawimage); @@ -59,7 +59,7 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector* lfc) bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; int suchex = 40; int suchey = 40; int alg_algo = 0; @@ -71,61 +71,61 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph) if (!this->GetNextParagraph(pfile, aktparamgraph)) return false; - if (aktparamgraph.compare("[Alignment]") != 0) // Paragraph passt nich zu MakeImage + if (aktparamgraph.compare("[Alignment]") != 0) //Paragraph does not fit MakeImage return false; while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); - if ((toUpper(zerlegt[0]) == "FLIPIMAGESIZE") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph); + if ((toUpper(splitted[0]) == "FLIPIMAGESIZE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") initialflip = true; } - if ((toUpper(zerlegt[0]) == "INITIALMIRROR") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "INITIALMIRROR") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") initialmirror = true; } - if (((toUpper(zerlegt[0]) == "INITALROTATE") || (toUpper(zerlegt[0]) == "INITIALROTATE")) && (zerlegt.size() > 1)) + if (((toUpper(splitted[0]) == "INITALROTATE") || (toUpper(splitted[0]) == "INITIALROTATE")) && (splitted.size() > 1)) { - this->initalrotate = std::stod(zerlegt[1]); + this->initalrotate = std::stod(splitted[1]); } - if ((toUpper(zerlegt[0]) == "SEARCHFIELDX") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SEARCHFIELDX") && (splitted.size() > 1)) { - suchex = std::stod(zerlegt[1]); + suchex = std::stod(splitted[1]); } - if ((toUpper(zerlegt[0]) == "SEARCHFIELDY") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SEARCHFIELDY") && (splitted.size() > 1)) { - suchey = std::stod(zerlegt[1]); + suchey = std::stod(splitted[1]); } - if ((toUpper(zerlegt[0]) == "ANTIALIASING") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "ANTIALIASING") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") use_antialiasing = true; } - if ((zerlegt.size() == 3) && (anz_ref < 2)) + if ((splitted.size() == 3) && (anz_ref < 2)) { - References[anz_ref].image_file = FormatFileName("/sdcard" + zerlegt[0]); - References[anz_ref].target_x = std::stod(zerlegt[1]); - References[anz_ref].target_y = std::stod(zerlegt[2]); + References[anz_ref].image_file = FormatFileName("/sdcard" + splitted[0]); + References[anz_ref].target_x = std::stod(splitted[1]); + References[anz_ref].target_y = std::stod(splitted[2]); anz_ref++; } - if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") SaveAllFiles = true; } - if ((toUpper(zerlegt[0]) == "ALIGNMENTALGO") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "ALIGNMENTALGO") && (splitted.size() > 1)) { #ifdef DEBUG_DETAIL_ON - std::string zw2 = "Alignmentmodus gewählt: " + zerlegt[1]; + std::string zw2 = "Alignment mode selected: " + splitted[1]; LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2); #endif - if (toUpper(zerlegt[1]) == "HIGHACCURACY") + if (toUpper(splitted[1]) == "HIGHACCURACY") alg_algo = 1; - if (toUpper(zerlegt[1]) == "FAST") + if (toUpper(splitted[1]) == "FAST") alg_algo = 2; } } @@ -137,7 +137,7 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph) References[i].fastalg_SAD_criteria = SAD_criteria; References[i].alignment_algo = alg_algo; #ifdef DEBUG_DETAIL_ON - std::string zw2 = "Alignmentmodus geschrieben: " + std::to_string(alg_algo); + std::string zw2 = "Alignment mode written: " + std::to_string(alg_algo); LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2); #endif } @@ -210,7 +210,7 @@ bool ClassFlowAlignment::doFlow(string time) ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg")); } - if (ImageTMP) // nuss gelöscht werden, um Speicherplatz für das Laden von tflite zu haben + if (ImageTMP) // must be deleted to have memory space for loading tflite { delete ImageTMP; ImageTMP = NULL; @@ -270,7 +270,7 @@ bool ClassFlowAlignment::LoadReferenceAlignmentValues(void) FILE* pFile; char zw[1024]; string zwvalue; - std::vector zerlegt; + std::vector splitted; // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01"); @@ -291,8 +291,8 @@ bool ClassFlowAlignment::LoadReferenceAlignmentValues(void) // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues02"); fgets(zw, 1024, pFile); - zerlegt = ZerlegeZeile(std::string(zw), " \t"); - if (zerlegt.size() < 6) + splitted = ZerlegeZeile(std::string(zw), " \t"); + if (splitted.size() < 6) { // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 01"); fclose(pFile); @@ -301,16 +301,16 @@ bool ClassFlowAlignment::LoadReferenceAlignmentValues(void) // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03"); - References[0].fastalg_x = stoi(zerlegt[0]); - References[0].fastalg_y = stoi(zerlegt[1]); - References[0].fastalg_SAD = stof(zerlegt[2]); - References[0].fastalg_min = stoi(zerlegt[3]); - References[0].fastalg_max = stoi(zerlegt[4]); - References[0].fastalg_avg = stof(zerlegt[5]); + References[0].fastalg_x = stoi(splitted[0]); + References[0].fastalg_y = stoi(splitted[1]); + References[0].fastalg_SAD = stof(splitted[2]); + References[0].fastalg_min = stoi(splitted[3]); + References[0].fastalg_max = stoi(splitted[4]); + References[0].fastalg_avg = stof(splitted[5]); fgets(zw, 1024, pFile); - zerlegt = ZerlegeZeile(std::string(zw)); - if (zerlegt.size() < 6) + splitted = ZerlegeZeile(std::string(zw)); + if (splitted.size() < 6) { // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 02"); fclose(pFile); @@ -319,12 +319,12 @@ bool ClassFlowAlignment::LoadReferenceAlignmentValues(void) // LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03"); - References[1].fastalg_x = stoi(zerlegt[0]); - References[1].fastalg_y = stoi(zerlegt[1]); - References[1].fastalg_SAD = stof(zerlegt[2]); - References[1].fastalg_min = stoi(zerlegt[3]); - References[1].fastalg_max = stoi(zerlegt[4]); - References[1].fastalg_avg = stof(zerlegt[5]); + References[1].fastalg_x = stoi(splitted[0]); + References[1].fastalg_y = stoi(splitted[1]); + References[1].fastalg_SAD = stof(splitted[2]); + References[1].fastalg_min = stoi(splitted[3]); + References[1].fastalg_max = stoi(splitted[4]); + References[1].fastalg_avg = stof(splitted[5]); fclose(pFile); diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index a07da032..dbf15f8a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -31,7 +31,7 @@ ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNTy logfileRetentionInDays = 5; } -string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _vorgaengerAnalog, float analogDigitalTransitionStart) +string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float analogDigitalTransitionStart) { string result = ""; @@ -41,19 +41,19 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution if (CNNType == Analogue || CNNType == Analogue100) { - float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; - int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10; + float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; + int result_after_decimal_point = ((int) floor(number * 10) + 10) % 10; - prev = ZeigerEvalAnalogNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev); -// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(analog) zahl=" + std::to_string(zahl) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev)); + prev = PointerEvalAnalogNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev); +// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(analog) number=" + std::to_string(number) + ", result_after_decimal_point=" + std::to_string(result_after_decimal_point) + ", prev=" + std::to_string(prev)); result = std::to_string(prev); if (_extendedResolution && (CNNType != Digital)) - result = result + std::to_string(ergebnis_nachkomma); + result = result + std::to_string(result_after_decimal_point); for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i) { - prev = ZeigerEvalAnalogNeu(GENERAL[_analog]->ROI[i]->result_float, prev); + prev = PointerEvalAnalogNew(GENERAL[_analog]->ROI[i]->result_float, prev); result = std::to_string(prev) + result; } return result; @@ -74,25 +74,24 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) { - float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; - if (zahl >= 0) // NaN? + float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; + if (number >= 0) // NaN? { - if (_extendedResolution) // ist nur gesetzt, falls es die erste Ziffer ist (kein Analog vorher!) + if (_extendedResolution) // is only set if it is the first digit (no analogue before!) { - int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10; - int ergebnis_vorkomma = ((int) floor(zahl)) % 10; + int result_after_decimal_point = ((int) floor(number * 10)) % 10; + int result_before_decimal_point = ((int) floor(number)) % 10; - result = std::to_string(ergebnis_vorkomma) + std::to_string(ergebnis_nachkomma); - prev = ergebnis_vorkomma; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(dig100-ext) ergebnis_vorkomma=" + std::to_string(ergebnis_vorkomma) + ", ergebnis_nachkomma=" + std::to_string(ergebnis_nachkomma) + ", prev=" + std::to_string(prev)); + result = std::to_string(result_before_decimal_point) + std::to_string(result_after_decimal_point); + prev = result_before_decimal_point; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(dig100-ext) result_before_decimal_point=" + std::to_string(result_before_decimal_point) + ", result_after_decimal_point=" + std::to_string(result_after_decimal_point) + ", prev=" + std::to_string(prev)); } else { -// prev = ZeigerEval(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev); - if (_vorgaengerAnalog >= 0) - prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _vorgaengerAnalog, prev, true, analogDigitalTransitionStart); + if (_before_narrow_Analog >= 0) + prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, analogDigitalTransitionStart); else - prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev); + prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev); result = std::to_string(prev); LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(dig100) prev=" + std::to_string(prev)); @@ -109,8 +108,8 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution { if (GENERAL[_analog]->ROI[i]->result_float >= 0) { - prev = ZeigerEvalHybridNeu(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#ZeigerEvalHybridNeu()= " + std::to_string(prev)); + prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#PointerEvalHybridNew()= " + std::to_string(prev)); result = std::to_string(prev) + result; LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#result= " + result); @@ -130,115 +129,115 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution return result; } -int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger, int eval_vorgaenger, bool AnalogerVorgaenger, float digitalAnalogTransitionStart) +int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitalAnalogTransitionStart) { int result; - int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10; - int ergebnis_vorkomma = ((int) floor(zahl) + 10) % 10; + int result_after_decimal_point = ((int) floor(number * 10)) % 10; + int result_before_decimal_point = ((int) floor(number) + 10) % 10; - if (eval_vorgaenger < 0) + if (eval_predecessors < 0) { - if ((ergebnis_nachkomma <= DigitalUnschaerfe * 10) || (ergebnis_nachkomma >= DigitalUnschaerfe * 10)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht - result = (int) (round(zahl) + 10) % 10; + if ((result_after_decimal_point <= Digital_Uncertainty * 10) || (result_after_decimal_point >= Digital_Uncertainty * 10)) // Band around the digit --> Rounding, as digit reaches inaccuracy in the frame + result = (int) (round(number) + 10) % 10; else - result = (int) ((int) trunc(zahl) + 10) % 10; + result = (int) ((int) trunc(number) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - No predecessor - Result = " + std::to_string(result) + + " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty)); return result; } - if (AnalogerVorgaenger) + if (Analog_Predecessors) { - result = ZeigerEvalAnalogToDigitNeu(zahl, zahl_vorgaenger, eval_vorgaenger, digitalAnalogTransitionStart); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitalAnalogTransitionStart); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - Analog predecessor, evaluation over PointerEvalAnalogNew = " + std::to_string(result) + + " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty)); return result; } - if ((zahl_vorgaenger >= DigitalUebergangsbereichVorgaenger ) && (zahl_vorgaenger <= (10.0 - DigitalUebergangsbereichVorgaenger))) + if ((number_of_predecessors >= Digital_Transition_Area_Predecessor ) && (number_of_predecessors <= (10.0 - Digital_Transition_Area_Predecessor))) { - // kein Ziffernwechsel, da Vorgänger weit genug weg ist (0+/-DigitalUebergangsbereichVorgaenger) --> zahl wird gerundet - if ((ergebnis_nachkomma <= DigitalBand) || (ergebnis_nachkomma >= (10-DigitalBand))) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht - result = ((int) round(zahl) + 10) % 10; + // no digit change, because predecessor is far enough away (0+/-DigitalTransitionRangePredecessor) --> number is rounded + if ((result_after_decimal_point <= DigitalBand) || (result_after_decimal_point >= (10-DigitalBand))) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame + result = ((int) round(number) + 10) % 10; else - result = ((int) trunc(zahl) + 10) % 10; + result = ((int) trunc(number) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, no change of digits, as pre-decimal point far enough away = " + std::to_string(result) + + " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty)); return result; } - if (eval_vorgaenger <= 1) // Nulldurchgang beim Vorgänger hat stattgefunden (!Bewertung über Prev_value und nicht Zahl!) --> hier aufrunden (2.8 --> 3, aber auch 3.1 --> 3) + if (eval_predecessors <= 1) // Zero crossing at the predecessor has taken place (! evaluation via Prev_value and not number!) --> round up here (2.8 --> 3, but also 3.1 --> 3) { - // Wir nehmen einfach an, dass das aktuelle Digit nach dem Nulldurchgang des Vorgängers - // mindestens zur Hälfte (x.5) durchlaufen hat - if (ergebnis_nachkomma > 5) - // Das akt. digit hat noch keinen Nulldurchgang, aber der Vorgänger schon. - result = (ergebnis_vorkomma + 1) % 10; + // We simply assume that the current digit after the zero crossing of the predecessor + // has passed through at least half (x.5) + if (result_after_decimal_point > 5) + // The current digit does not yet have a zero crossing, but the predecessor does.. + result = (result_before_decimal_point + 1) % 10; else - // Akt. digit und Vorgänger haben Nulldurchgang - result = ergebnis_vorkomma % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + // Act. digit and predecessor have zero crossing + result = result_before_decimal_point % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, zero crossing has taken placen = " + std::to_string(result) + + " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty)); return result; } - // bleibt nur >= 9.x --> noch kein Nulldurchgang --> 2.8 --> 2, - // und ab 9.7(DigitalUebergangsbereichVorlauf) 3.1 --> 2 - // alles >=x.4 kann als aktuelle Zahl gelten im Übergang. Bei 9.x Vorgänger kann die aktuelle - // Zahl noch x.6 - x.7 sein. - // Vorlauf (else - Zweig) passiert nicht bereits ab 9. - if (DigitalUebergangsbereichVorlauf>=zahl_vorgaenger || ergebnis_nachkomma >= 4) - // aktuelles digit hat genauso wie das Vorgängerdigit noch keinen Nulldurchgang. - result = ergebnis_vorkomma % 10; + // remains only >= 9.x --> no zero crossing yet --> 2.8 --> 2, + // and from 9.7(DigitalTransitionRangeLead) 3.1 --> 2 + // everything >=x.4 can be considered as current number in transition. With 9.x predecessor the current + // number can still be x.6 - x.7. + // Preceding (else - branch) does not already happen from 9. + if (Digital_Transition_Area_Forward>=number_of_predecessors || result_after_decimal_point >= 4) + // The current digit, like the previous digit, does not yet have a zero crossing. + result = result_before_decimal_point % 10; else - // aktuelles digit läuft dem kleineren digit (9.x) vor. Also schon >=x.0 während das vorherige Digit noch - // keinen Nulldurchgang hat. Daher wird um 1 reduziert. - result = (ergebnis_vorkomma - 1 + 10) % 10; + // current digit precedes the smaller digit (9.x). So already >=x.0 while the previous digit has not yet + // has no zero crossing. Therefore, it is reduced by 1. + result = (result_before_decimal_point - 1 + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - O analogue predecessor, >= 9.5 --> no zero crossing yet = " + std::to_string(result) + + " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty) + " result_after_decimal_point = " + std::to_string(result_after_decimal_point)); return result; } -int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vorgaenger, int eval_vorgaenger, float analogDigitalTransitionStart) +int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder, int eval_predecessors, float analogDigitalTransitionStart) { int result; - int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10; - int ergebnis_vorkomma = ((int) floor(zahl) + 10) % 10; + int result_after_decimal_point = ((int) floor(number * 10)) % 10; + int result_before_decimal_point = ((int) floor(number) + 10) % 10; bool roundedUp = false; - // Innerhalb der digitalen Unschaefe - if ((ergebnis_nachkomma >= (10-DigitalUnschaerfe * 10)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht - || (eval_vorgaenger <= 4 && ergebnis_nachkomma>=6)) { // oder digit läuft nach (analog =0..4, digit >=6) - result = (int) (round(zahl) + 10) % 10; + // Within the digital inequalities + if ((result_after_decimal_point >= (10-Digital_Uncertainty * 10)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame + || (eval_predecessors <= 4 && result_after_decimal_point>=6)) { // or digit runs after (analogue =0..4, digit >=6) + result = (int) (round(number) + 10) % 10; roundedUp = true; - // vor/nachkomma neu berechnen, da wir anhand der Unschaefe die Zahl anpassen. - ergebnis_nachkomma = ((int) floor(result * 10)) % 10; - ergebnis_vorkomma = ((int) floor(result) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalAnalogToDigitNeu - digitaleUnschaerfe - Ergebnis = " + std::to_string(result) + - " zahl: " + std::to_string(zahl) + " ziffer_vorgaenger: " + std::to_string(ziffer_vorgaenger) + - " erg_vorkomma: " + std::to_string(ergebnis_vorkomma) + - " erg_nachkomma: " + std::to_string(ergebnis_nachkomma)); + // before/ after decimal point, because we adjust the number based on the uncertainty. + result_after_decimal_point = ((int) floor(result * 10)) % 10; + result_before_decimal_point = ((int) floor(result) + 10) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digital Uncertainty - Result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) + + " erg before comma: " + std::to_string(result_before_decimal_point) + + " erg after comma: " + std::to_string(result_after_decimal_point)); } else { - result = (int) ((int) trunc(zahl) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalAnalogToDigitNeu - KEINE digitaleUnschaerfe - Ergebnis = " + std::to_string(result) + - " zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger)); + result = (int) ((int) trunc(number) + 10) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder)); } - // Kein Nulldurchgang hat stattgefunden. - // Nur eval_vorgaenger verwendet, da ziffer_vorgaenger hier falsch sein könnte. - // ziffer_vorgaenger<=0.1 & eval_vorgaenger=9 entspricht analog wurde zurückgesetzt wegen vorhergehender analog, die noch nicht auf 0 sind. - if ((eval_vorgaenger>=6 && (ziffer_vorgaenger>analogDigitalTransitionStart || ziffer_vorgaenger<=0.2) && roundedUp)) + // No zero crossing has taken place. + // Only eval_predecessors used because numeral_preceder could be wrong here. + // numeral_preceder<=0.1 & eval_predecessors=9 corresponds to analogue was reset because of previous analogue that are not yet at 0. + if ((eval_predecessors>=6 && (numeral_preceder>analogDigitalTransitionStart || numeral_preceder<=0.2) && roundedUp)) { - result = ((ergebnis_vorkomma+10) - 1) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalAnalogToDigitNeu - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) + - " zahl: " + std::to_string(zahl) + - " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + - " erg_nachkomma = " + std::to_string(ergebnis_nachkomma)); + result = ((result_before_decimal_point+10) - 1) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) + + " number: " + std::to_string(number) + + " numeral_preceder = " + std::to_string(numeral_preceder) + + " eerg after comma = " + std::to_string(result_after_decimal_point)); } @@ -246,44 +245,44 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor } -int ClassFlowCNNGeneral::ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger) +int ClassFlowCNNGeneral::PointerEvalAnalogNew(float number, int numeral_preceder) { - float zahl_min, zahl_max; + float number_min, number_max; int result; - if (ziffer_vorgaenger == -1) + if (numeral_preceder == -1) { - result = (int) floor(zahl); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + result = (int) floor(number); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - No predecessor - Result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error)); return result; } - zahl_min = zahl - AnalogFehler / 10.0; - zahl_max = zahl + AnalogFehler / 10.0; + number_min = number - Analog_error / 10.0; + number_max = number + Analog_error / 10.0; - if ((int) floor(zahl_max) - (int) floor(zahl_min) != 0) + if ((int) floor(number_max) - (int) floor(number_min) != 0) { - if (ziffer_vorgaenger <= AnalogFehler) + if (numeral_preceder <= Analog_error) { - result = ((int) floor(zahl_max) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + result = ((int) floor(number_max) + 10) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number ambiguous, correction upwards - result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error)); return result; } - if (ziffer_vorgaenger >= 10 - AnalogFehler) + if (numeral_preceder >= 10 - Analog_error) { - result = ((int) floor(zahl_min) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + result = ((int) floor(number_min) + 10) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number ambiguous, downward correction - result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error)); return result; } } - result = ((int) floor(zahl) + 10) % 10; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "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)); + result = ((int) floor(number) + 10) % 10; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number unambiguous, no correction necessary - result = " + std::to_string(result) + + " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error)); return result; @@ -292,7 +291,7 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger) bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); @@ -318,53 +317,53 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); - if ((toUpper(zerlegt[0]) == "LOGIMAGELOCATION") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph); + if ((toUpper(splitted[0]) == "LOGIMAGELOCATION") && (splitted.size() > 1)) { - this->LogImageLocation = "/sdcard" + zerlegt[1]; + this->LogImageLocation = "/sdcard" + splitted[1]; this->isLogImage = true; } - if ((toUpper(zerlegt[0]) == "LOGIMAGESELECT") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LOGIMAGESELECT") && (splitted.size() > 1)) { - LogImageSelect = zerlegt[1]; + LogImageSelect = splitted[1]; isLogImageSelect = true; } - if ((toUpper(zerlegt[0]) == "LOGFILERETENTIONINDAYS") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LOGFILERETENTIONINDAYS") && (splitted.size() > 1)) { - this->logfileRetentionInDays = std::stoi(zerlegt[1]); + this->logfileRetentionInDays = std::stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "MODEL") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "MODEL") && (splitted.size() > 1)) { - this->cnnmodelfile = zerlegt[1]; + this->cnnmodelfile = splitted[1]; } - if ((toUpper(zerlegt[0]) == "CNNGOODTHRESHOLD") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "CNNGOODTHRESHOLD") && (splitted.size() > 1)) { - CNNGoodThreshold = std::stof(zerlegt[1]); + CNNGoodThreshold = std::stof(splitted[1]); } - if (zerlegt.size() >= 5) + if (splitted.size() >= 5) { - general* _analog = GetGENERAL(zerlegt[0], true); + general* _analog = GetGENERAL(splitted[0], true); roi* neuroi = _analog->ROI[_analog->ROI.size()-1]; - neuroi->posx = std::stoi(zerlegt[1]); - neuroi->posy = std::stoi(zerlegt[2]); - neuroi->deltax = std::stoi(zerlegt[3]); - neuroi->deltay = std::stoi(zerlegt[4]); + neuroi->posx = std::stoi(splitted[1]); + neuroi->posy = std::stoi(splitted[2]); + neuroi->deltax = std::stoi(splitted[3]); + neuroi->deltay = std::stoi(splitted[4]); neuroi->CCW = false; - if (zerlegt.size() >= 6) + if (splitted.size() >= 6) { - neuroi->CCW = toUpper(zerlegt[5]) == "TRUE"; + neuroi->CCW = toUpper(splitted[5]) == "TRUE"; } neuroi->result_float = -1; neuroi->image = NULL; neuroi->image_org = NULL; } - if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") SaveAllFiles = true; } } @@ -414,7 +413,7 @@ general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true) if (GENERAL[i]->name == _analog) _ret = GENERAL[i]; - if (!_create) // nicht gefunden und soll auch nicht erzeugt werden + if (!_create) // not found and should not be created return _ret; if (_ret == NULL) @@ -470,7 +469,7 @@ bool ClassFlowCNNGeneral::doFlow(string time) return false; }; - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "doFlow nach Alignment"); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "doFlow after alignment"); doNeuralNetwork(time); @@ -594,7 +593,7 @@ bool ClassFlowCNNGeneral::getNetworkParameter() } break; default: - LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "tflite passt nicht zur Firmware (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")"); + LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "tflite does not fit the firmware (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")"); } } @@ -638,7 +637,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image); tflite->Invoke(); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke"); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "After Invoke"); f1 = tflite->GetOutputValue(0); f2 = tflite->GetOutputValue(1); @@ -649,7 +648,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) else GENERAL[n]->ROI[roi]->result_float = result * 10; - ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float); + ESP_LOGD(TAG, "General result (Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float); if (isLogImage) LogImage(logPath, GENERAL[n]->ROI[roi]->name, &GENERAL[n]->ROI[roi]->result_float, NULL, time, GENERAL[n]->ROI[roi]->image_org); } break; @@ -659,7 +658,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) { 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); + ESP_LOGD(TAG, "General result (Digit)%i: %d", roi, GENERAL[n]->ROI[roi]->result_klasse); if (isLogImage) { @@ -675,85 +674,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) } } } break; -/* - case DigitalHyprid: - { - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid"); - int _num, _nachkomma; - tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image); - tflite->Invoke(); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke"); - - _num = tflite->GetOutClassification(0, 10); - _nachkomma = tflite->GetOutClassification(11, 21); - - - string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma); - LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres); - - if ((_num == 10) || (_nachkomma == 10)) // NaN detektiert - GENERAL[_ana]->ROI[i]->result_float = -1; - else - 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); - _zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float); - LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres); - - if (isLogImage) - { - string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->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); - } - else - { - LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org); - } - } - } break; -*/ -/* - case DigitalHyprid10: - { - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid10"); - int _num, _nachkomma; - - tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image); - tflite->Invoke(); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke"); - - _num = tflite->GetOutClassification(0, 9); - _nachkomma = tflite->GetOutClassification(10, 19); - - - string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma); - LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres); - - 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); - _zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float); - LogFile.WriteToFile(ESP_LOG_DEBUG, _zwres); - - if (isLogImage) - { - string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->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); - } - else - { - LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org); - } - } - } break; -*/ case DoubleHyprid10: { @@ -765,7 +686,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image); tflite->Invoke(); - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke"); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "After Invoke"); _num = tflite->GetOutClassification(0, 9); _numplus = (_num + 1) % 10; @@ -805,7 +726,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) { 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. + _result_save_file+= 100; // In case fit is not sufficient, the result should still be saved with "-10x.y". string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold) + ")"; LogFile.WriteToFile(ESP_LOG_WARN, TAG, zw); } @@ -935,7 +856,7 @@ std::vector ClassFlowCNNGeneral::GetHTMLInfo() return result; } -int ClassFlowCNNGeneral::getAnzahlGENERAL() +int ClassFlowCNNGeneral::getNumberGENERAL() { return GENERAL.size(); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h index e090a449..ba129b09 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h @@ -23,6 +23,7 @@ protected: t_CNNType CNNType; std::vector GENERAL; float CNNGoodThreshold; + //moved to define.h //float Analog_error = 3.0; //float AnalogToDigtalFehler = 0.8; @@ -32,7 +33,6 @@ protected: //float Digital_Transition_Area_Predecessor = 0.7; // 9.3 - 0.7 //float Digital_Transition_Area_Forward = 9.7; // Pre-run zero crossing only happens from approx. 9.7 onwards - string cnnmodelfile; int modelxsize, modelysize, modelchannel; bool isLogImageSelect; @@ -41,9 +41,9 @@ protected: bool SaveAllFiles; - int ZeigerEvalAnalogNeu(float zahl, int ziffer_vorgaenger); - int ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vorgaenger, int eval_vorgaenger, float analogDigitalTransitionStart); - int ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger, int eval_vorgaenger, bool AnalogerVorgaenger = false, float analogDigitalTransitionStart=9.2); + int PointerEvalAnalogNew(float zahl, int numeral_preceder); + int PointerEvalAnalogToDigitNew(float zahl, float numeral_preceder, int eval_predecessors, float analogDigitalTransitionStart); + int PointerEvalHybridNew(float zahl, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors = false, float analogDigitalTransitionStart=9.2); @@ -59,7 +59,7 @@ public: bool doFlow(string time); string getHTMLSingleStep(string host); - string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _vorgaengerAnalog = -1, float analogDigitalTransitionStart=9.2); + string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _before_narrow_Analog = -1, float analogDigitalTransitionStart=9.2); string getReadoutRawString(int _analog); @@ -67,7 +67,7 @@ public: std::vector GetHTMLInfo(); - int getAnzahlGENERAL(); + int getNumberGENERAL(); general* GetGENERAL(int _analog); general* GetGENERAL(string _name, bool _create); general* FindGENERAL(string _name_number); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index afffd9bb..6d635759 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -62,7 +62,7 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _ for (int i = 0; i < FlowControll.size(); ++i) if (FlowControll[i]->name().compare(_classname) == 0){ - if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // falls es ein MakeImage ist, braucht das Bild nicht extra aufgenommen zu werden, dass passiert bei html-Abfrage automatisch + if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // if it is a MakeImage, the image does not need to be included, this happens automatically with the html query. FlowControll[i]->doFlow(""); result = FlowControll[i]->getHTMLSingleStep(_host); } @@ -173,7 +173,7 @@ void ClassFlowControll::SetInitialParameter(void) bool ClassFlowControll::isAutoStart(long &_intervall) { - _intervall = AutoIntervall * 60 * 1000; // AutoIntervall: Minuten -> ms + _intervall = AutoIntervall * 60 * 1000; // AutoInterval: minutes -> ms return AutoStart; } @@ -220,7 +220,7 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type) flowpostprocessing = (ClassFlowPostProcessing*) cfc; } - if (cfc) // Wird nur angehangen, falls es nicht [AutoTimer] ist, denn dieses ist für FlowControll + if (cfc) // Attached only if it is not [AutoTimer], because this is for FlowControll FlowControll.push_back(cfc); if (toUpper(_type).compare("[AUTOTIMER]") == 0) @@ -292,7 +292,6 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){ for (int i = 0; i < FlowControll.size(); ++i) { if (FlowControll[i]->name() == "ClassFlowMakeImage") { -// zw_time = gettimestring("%Y%m%d-%H%M%S"); zw_time = gettimestring("%H:%M:%S"); std::string flowStatus = TranslateAktstatus(FlowControll[i]->name()); aktstatus = flowStatus + " (" + zw_time + ")"; @@ -307,8 +306,6 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){ bool ClassFlowControll::doFlow(string time) { -// CleanTempFolder(); // dazu muss man noch eine Rolling einführen - bool result = true; std::string zw_time; int repeat = 0; @@ -340,12 +337,12 @@ bool ClassFlowControll::doFlow(string time) if (!FlowControll[i]->doFlow(time)){ repeat++; LogFile.WriteToFile(ESP_LOG_WARN, TAG, "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; // vPrevious step must be repeated (probably take pictures) result = false; if (repeat > 5) { LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Wiederholung 5x nicht erfolgreich --> reboot"); doReboot(); - // Schritt wurde 5x wiederholt --> reboot + //Step was repeated 5x --> reboot } } else @@ -474,7 +471,7 @@ std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); @@ -489,23 +486,23 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph, " ="); - if ((toUpper(zerlegt[0]) == "AUTOSTART") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph, " ="); + if ((toUpper(splitted[0]) == "AUTOSTART") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") { AutoStart = true; } } - if ((toUpper(zerlegt[0]) == "INTERVALL") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "INTERVALL") && (splitted.size() > 1)) { - AutoIntervall = std::stof(zerlegt[1]); + AutoIntervall = std::stof(splitted[1]); } - if ((toUpper(zerlegt[0]) == "DATALOGACTIVE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "DATALOGACTIVE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") { LogFile.SetDataLogToSD(true); } @@ -514,53 +511,53 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) } } - if ((toUpper(zerlegt[0]) == "DATALOGRETENTIONINDAYS") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "DATALOGRETENTIONINDAYS") && (splitted.size() > 1)) { - LogFile.SetDataLogRetention(std::stoi(zerlegt[1])); + LogFile.SetDataLogRetention(std::stoi(splitted[1])); } - if ((toUpper(zerlegt[0]) == "LOGFILE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LOGFILE") && (splitted.size() > 1)) { /* matches esp_log_level_t */ - if ((toUpper(zerlegt[1]) == "TRUE") || (toUpper(zerlegt[1]) == "2")) + if ((toUpper(splitted[1]) == "TRUE") || (toUpper(splitted[1]) == "2")) { LogFile.setLogLevel(ESP_LOG_WARN); } - else if ((toUpper(zerlegt[1]) == "FALSE") || (toUpper(zerlegt[1]) == "0") || (toUpper(zerlegt[1]) == "1")) + else if ((toUpper(splitted[1]) == "FALSE") || (toUpper(splitted[1]) == "0") || (toUpper(splitted[1]) == "1")) { LogFile.setLogLevel(ESP_LOG_ERROR); } - else if (toUpper(zerlegt[1]) == "3") + else if (toUpper(splitted[1]) == "3") { LogFile.setLogLevel(ESP_LOG_INFO); } - else if (toUpper(zerlegt[1]) == "4") + else if (toUpper(splitted[1]) == "4") { LogFile.setLogLevel(ESP_LOG_DEBUG); } } - if ((toUpper(zerlegt[0]) == "LOGFILERETENTIONINDAYS") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LOGFILERETENTIONINDAYS") && (splitted.size() > 1)) { - LogFile.SetLogFileRetention(std::stoi(zerlegt[1])); + LogFile.SetLogFileRetention(std::stoi(splitted[1])); } - if ((toUpper(zerlegt[0]) == "TIMEZONE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "TIMEZONE") && (splitted.size() > 1)) { - string zw = "Set TimeZone: " + zerlegt[1]; - setTimeZone(zerlegt[1]); + string zw = "Set TimeZone: " + splitted[1]; + setTimeZone(splitted[1]); } - if ((toUpper(zerlegt[0]) == "TIMESERVER") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "TIMESERVER") && (splitted.size() > 1)) { - string zw = "Set TimeZone: " + zerlegt[1]; - reset_servername(zerlegt[1]); + string zw = "Set TimeZone: " + splitted[1]; + reset_servername(splitted[1]); } - if ((toUpper(zerlegt[0]) == "HOSTNAME") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "HOSTNAME") && (splitted.size() > 1)) { - if (ChangeHostName("/sdcard/wlan.ini", zerlegt[1])) + if (ChangeHostName("/sdcard/wlan.ini", splitted[1])) { - // reboot notwendig damit die neue wlan.ini auch benutzt wird !!! + // reboot necessary so that the new wlan.ini is also used !!! fclose(pfile); LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Rebooting to activate new HOSTNAME..."); esp_restart(); @@ -569,9 +566,9 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) } } - if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SETUPMODE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") { SetupModeActive = true; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h index c7ebc693..8ddca869 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h +++ b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h @@ -33,20 +33,20 @@ struct NumberPost { bool checkDigitIncreaseConsistency; time_t lastvalue; string timeStamp; - double FlowRateAct; // m3 / min - double PreValue; // letzter Wert, der gut ausgelesen wurde - double Value; // letzer ausgelesener Wert, inkl. Korrekturen - string ReturnRateValue; // RückgabewertRate - string ReturnChangeAbsolute; // RückgabewertRate - string ReturnRawValue; // Rohwert (mit N & führenden 0) - string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung - string ReturnPreValue; // korrigierter Rückgabewert ohne Fehlermeldung - string ErrorMessageText; // Fehlermeldung bei Consistency Check + double FlowRateAct; // m3 / min + double PreValue; // last value that was read out well + double Value; // last value read out, incl. corrections + string ReturnRateValue; // return value rate + string ReturnChangeAbsolute; // return value rate + string ReturnRawValue; // Raw value (with N & leading 0) + string ReturnValue; // corrected return value, if necessary with error message + string ReturnPreValue; // corrected return value without error message + string ErrorMessageText; // Error message for consistency check int AnzahlAnalog; int AnzahlDigital; int DecimalShift; int DecimalShiftInitial; - float AnalogDigitalTransitionStart; // Wann ist das digit > x.1, also wann fängt es an zu kippen + float AnalogDigitalTransitionStart; // When is the digit > x.1, i.e. when does it start to tilt? int Nachkomma; bool isExtendedResolution; diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp index 9d91ec22..5e0eb8fd 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp @@ -69,7 +69,7 @@ ClassFlowInfluxDB::ClassFlowInfluxDB(std::vector* lfc, ClassFlow *_p bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); @@ -83,26 +83,26 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { ESP_LOGD(TAG, "while loop reading line: %s", aktparamgraph.c_str()); - zerlegt = ZerlegeZeile(aktparamgraph); - if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph); + if ((toUpper(splitted[0]) == "USER") && (splitted.size() > 1)) { - this->user = zerlegt[1]; + this->user = splitted[1]; } - if ((toUpper(zerlegt[0]) == "PASSWORD") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "PASSWORD") && (splitted.size() > 1)) { - this->password = zerlegt[1]; + this->password = splitted[1]; } - if ((toUpper(zerlegt[0]) == "URI") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "URI") && (splitted.size() > 1)) { - this->uri = zerlegt[1]; + this->uri = splitted[1]; } - if (((toUpper(zerlegt[0]) == "MEASUREMENT")) && (zerlegt.size() > 1)) + if (((toUpper(splitted[0]) == "MEASUREMENT")) && (splitted.size() > 1)) { - this->measurement = zerlegt[1]; + this->measurement = splitted[1]; } - if (((toUpper(zerlegt[0]) == "DATABASE")) && (zerlegt.size() > 1)) + if (((toUpper(splitted[0]) == "DATABASE")) && (splitted.size() > 1)) { - this->database = zerlegt[1]; + this->database = splitted[1]; } } diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp index 10a53ea6..a62d8b96 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -87,7 +87,7 @@ ClassFlowMQTT::ClassFlowMQTT(std::vector* lfc, ClassFlow *_prev) bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); @@ -95,76 +95,76 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) if (!this->GetNextParagraph(pfile, aktparamgraph)) return false; - if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph passt nich zu MakeImage + if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph does not fit MakeImage return false; while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); - if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph); + if ((toUpper(splitted[0]) == "USER") && (splitted.size() > 1)) { - this->user = zerlegt[1]; + this->user = splitted[1]; } - if ((toUpper(zerlegt[0]) == "PASSWORD") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "PASSWORD") && (splitted.size() > 1)) { - this->password = zerlegt[1]; + this->password = splitted[1]; } - if ((toUpper(zerlegt[0]) == "URI") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "URI") && (splitted.size() > 1)) { - this->uri = zerlegt[1]; + this->uri = splitted[1]; } - if ((toUpper(zerlegt[0]) == "SETRETAINFLAG") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SETRETAINFLAG") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") { + if (toUpper(splitted[1]) == "TRUE") { SetRetainFlag = 1; setMqtt_Server_Retain(SetRetainFlag); } } - if ((toUpper(zerlegt[0]) == "HOMEASSISTANTDISCOVERY") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "HOMEASSISTANTDISCOVERY") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") SetHomeassistantDiscoveryEnabled(true); } - if ((toUpper(zerlegt[0]) == "METERTYPE") && (zerlegt.size() > 1)) { + if ((toUpper(splitted[0]) == "METERTYPE") && (splitted.size() > 1)) { /* Use meter type for the device class Make sure it is a listed one on https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes */ - if (toUpper(zerlegt[1]) == "WATER_M3") { + if (toUpper(splitted[1]) == "WATER_M3") { mqttServer_setMeterType("water", "m³", "h", "m³/h"); } - else if (toUpper(zerlegt[1]) == "WATER_L") { + else if (toUpper(splitted[1]) == "WATER_L") { mqttServer_setMeterType("water", "L", "h", "L/h"); } - else if (toUpper(zerlegt[1]) == "WATER_FT3") { + else if (toUpper(splitted[1]) == "WATER_FT3") { mqttServer_setMeterType("water", "ft³", "m", "ft³/m"); // Minutes } - else if (toUpper(zerlegt[1]) == "WATER_GAL") { + else if (toUpper(splitted[1]) == "WATER_GAL") { mqttServer_setMeterType("water", "gal", "h", "gal/h"); } - else if (toUpper(zerlegt[1]) == "GAS_M3") { + else if (toUpper(splitted[1]) == "GAS_M3") { mqttServer_setMeterType("gas", "m³", "h", "m³/h"); } - else if (toUpper(zerlegt[1]) == "GAS_FT3") { + else if (toUpper(splitted[1]) == "GAS_FT3") { mqttServer_setMeterType("gas", "ft³", "m", "ft³/m"); // Minutes } - else if (toUpper(zerlegt[1]) == "ENERGY_WH") { + else if (toUpper(splitted[1]) == "ENERGY_WH") { mqttServer_setMeterType("energy", "Wh", "h", "W"); } - else if (toUpper(zerlegt[1]) == "ENERGY_KWH") { + else if (toUpper(splitted[1]) == "ENERGY_KWH") { mqttServer_setMeterType("energy", "kWh", "h", "kW"); } - else if (toUpper(zerlegt[1]) == "ENERGY_MWH") { + else if (toUpper(splitted[1]) == "ENERGY_MWH") { mqttServer_setMeterType("energy", "MWh", "h", "MW"); } } - if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "CLIENTID") && (splitted.size() > 1)) { - this->clientname = zerlegt[1]; + this->clientname = splitted[1]; } - if (((toUpper(zerlegt[0]) == "TOPIC") || (toUpper(zerlegt[0]) == "MAINTOPIC")) && (zerlegt.size() > 1)) + if (((toUpper(splitted[0]) == "TOPIC") || (toUpper(splitted[0]) == "MAINTOPIC")) && (splitted.size() > 1)) { - maintopic = zerlegt[1]; + maintopic = splitted[1]; mqttServer_setMainTopic(maintopic); } } diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp index ef28d5f8..235681ae 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp @@ -26,14 +26,14 @@ esp_err_t ClassFlowMakeImage::camera_capture(){ return ESP_OK; } -void ClassFlowMakeImage::takePictureWithFlash(int flashdauer) +void ClassFlowMakeImage::takePictureWithFlash(int flash_duration) { - // für den Fall, dass das Bild geflippt wird, muss es hier zurück gesetzt werden //// + // in case the image is flipped, it must be reset here // rawImage->width = image_width; rawImage->height = image_height; ///////////////////////////////////////////////////////////////////////////////////// - ESP_LOGD(TAG, "Flashdauer: %d", flashdauer); - Camera.CaptureToBasisImage(rawImage, flashdauer); + ESP_LOGD(TAG, "flash_duration: %d", flash_duration); + Camera.CaptureToBasisImage(rawImage, flash_duration); time(&TimeImageTaken); localtime(&TimeImageTaken); @@ -65,7 +65,7 @@ ClassFlowMakeImage::ClassFlowMakeImage(std::vector* lfc) : ClassFlow bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); int _brightness = -100; @@ -76,66 +76,66 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) if (!this->GetNextParagraph(pfile, aktparamgraph)) return false; - if (aktparamgraph.compare("[MakeImage]") != 0) // Paragraph passt nich zu MakeImage + if (aktparamgraph.compare("[MakeImage]") != 0) // Paragraph does not fit MakeImage return false; while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); - if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1)) + splitted = ZerlegeZeile(aktparamgraph); + if ((splitted[0] == "LogImageLocation") && (splitted.size() > 1)) { - LogImageLocation = "/sdcard" + zerlegt[1]; + LogImageLocation = "/sdcard" + splitted[1]; isLogImage = true; } - if ((zerlegt[0] == "ImageQuality") && (zerlegt.size() > 1)) - ImageQuality = std::stod(zerlegt[1]); + if ((splitted[0] == "ImageQuality") && (splitted.size() > 1)) + ImageQuality = std::stod(splitted[1]); - if ((zerlegt[0] == "ImageSize") && (zerlegt.size() > 1)) + if ((splitted[0] == "ImageSize") && (splitted.size() > 1)) { - ImageSize = Camera.TextToFramesize(zerlegt[1].c_str()); + ImageSize = Camera.TextToFramesize(splitted[1].c_str()); isImageSize = true; } - if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") SaveAllFiles = true; } - if ((toUpper(zerlegt[0]) == "WAITBEFORETAKINGPICTURE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "WAITBEFORETAKINGPICTURE") && (splitted.size() > 1)) { - waitbeforepicture = stoi(zerlegt[1]); + waitbeforepicture = stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "LOGFILERETENTIONINDAYS") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LOGFILERETENTIONINDAYS") && (splitted.size() > 1)) { - this->logfileRetentionInDays = std::stoi(zerlegt[1]); + this->logfileRetentionInDays = std::stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "BRIGHTNESS") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "BRIGHTNESS") && (splitted.size() > 1)) { - _brightness = stoi(zerlegt[1]); + _brightness = stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "CONTRAST") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "CONTRAST") && (splitted.size() > 1)) { - _contrast = stoi(zerlegt[1]); + _contrast = stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "SATURATION") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "SATURATION") && (splitted.size() > 1)) { - _saturation = stoi(zerlegt[1]); + _saturation = stoi(splitted[1]); } - if ((toUpper(zerlegt[0]) == "FIXEDEXPOSURE") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "FIXEDEXPOSURE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") FixedExposure = true; } - if ((toUpper(zerlegt[0]) == "LEDINTENSITY") && (zerlegt.size() > 1)) + if ((toUpper(splitted[0]) == "LEDINTENSITY") && (splitted.size() > 1)) { - float ledintensity = stof(zerlegt[1]); + float ledintensity = stof(splitted[1]); ledintensity = min((float) 100, ledintensity); ledintensity = max((float) 0, ledintensity); Camera.SetLEDIntensity(ledintensity); @@ -154,11 +154,11 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) if (FixedExposure && (waitbeforepicture > 0)) { // ESP_LOGD(TAG, "Fixed Exposure enabled!"); - int flashdauer = (int) (waitbeforepicture * 1000); - Camera.EnableAutoExposure(flashdauer); + int flash_duration = (int) (waitbeforepicture * 1000); + Camera.EnableAutoExposure(flash_duration); waitbeforepicture = 0.2; -// flashdauer = (int) (waitbeforepicture * 1000); -// takePictureWithFlash(flashdauer); +// flash_duration = (int) (waitbeforepicture * 1000); +// takePictureWithFlash(flash_duration); // rawImage->SaveToFile("/sdcard/init2.jpg"); } @@ -176,7 +176,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime) { string logPath = CreateLogFolder(zwtime); - int flashdauer = (int) (waitbeforepicture * 1000); + int flash_duration = (int) (waitbeforepicture * 1000); #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash"); @@ -187,7 +187,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime) esp_wifi_stop(); // to save power usage and #endif - takePictureWithFlash(flashdauer); + takePictureWithFlash(flash_duration); #ifdef WIFITURNOFF esp_wifi_start(); @@ -211,11 +211,11 @@ bool ClassFlowMakeImage::doFlow(string zwtime) esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req) { - int flashdauer = (int) (waitbeforepicture * 1000); + int flash_duration = (int) (waitbeforepicture * 1000); time(&TimeImageTaken); localtime(&TimeImageTaken); - return Camera.CaptureToHTTP(req, flashdauer); + return Camera.CaptureToHTTP(req, flash_duration); } @@ -223,8 +223,8 @@ ImageData* ClassFlowMakeImage::SendRawImage() { CImageBasis *zw = new CImageBasis(rawImage); ImageData *id; - int flashdauer = (int) (waitbeforepicture * 1000); - Camera.CaptureToBasisImage(zw, flashdauer); + int flash_duration = (int) (waitbeforepicture * 1000); + Camera.CaptureToBasisImage(zw, flash_duration); time(&TimeImageTaken); localtime(&TimeImageTaken); diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h index 048c19a3..ad375625 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h @@ -25,7 +25,7 @@ protected: void CopyFile(string input, string output); esp_err_t camera_capture(); - void takePictureWithFlash(int flashdauer); + void takePictureWithFlash(int flash_duration); void SetInitialParameter(void); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index f125189f..11db8e01 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -122,13 +122,13 @@ void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _exte bool ClassFlowPostProcessing::LoadPreValue(void) { - std::vector zerlegt; + std::vector splitted; FILE* pFile; char zw[1024]; string zwtime, zwvalue, name; bool _done = false; - UpdatePreValueINI = false; // Konvertierung ins neue Format + UpdatePreValueINI = false; // Conversion to the new format pFile = fopen(FilePreValue.c_str(), "r"); @@ -141,21 +141,21 @@ bool ClassFlowPostProcessing::LoadPreValue(void) if (zwtime.length() == 0) return false; - zerlegt = HelperZerlegeZeile(zwtime, "\t"); - if (zerlegt.size() > 1) // neues Format + splitted = HelperZerlegeZeile(zwtime, "\t"); + if (splitted.size() > 1) // Conversion to the new format { - while ((zerlegt.size() > 1) && !_done) + while ((splitted.size() > 1) && !_done) { - name = trim(zerlegt[0]); - zwtime = trim(zerlegt[1]); - zwvalue = trim(zerlegt[2]); + name = trim(splitted[0]); + zwtime = trim(splitted[1]); + zwvalue = trim(splitted[2]); for (int j = 0; j < NUMBERS.size(); ++j) { if (NUMBERS[j]->name == name) { NUMBERS[j]->PreValue = stod(zwvalue.c_str()); - NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma + 1); // SIcherheitshalber 1 Stelle mehr, da ggf. Exgtended Resolution an ist (wird erst beim ersten Durchlauf gesetzt) + NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma + 1); // To be on the safe side, 1 digit more, as Exgtended Resolution may be on (will only be set during the first run). time_t tStart; int yy, month, dd, hh, mm, ss; @@ -188,18 +188,18 @@ bool ClassFlowPostProcessing::LoadPreValue(void) else { ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw); - zerlegt = HelperZerlegeZeile(trim(std::string(zw)), "\t"); - if (zerlegt.size() > 1) + splitted = HelperZerlegeZeile(trim(std::string(zw)), "\t"); + if (splitted.size() > 1) { - name = trim(zerlegt[0]); - zwtime = trim(zerlegt[1]); - zwvalue = trim(zerlegt[2]); + name = trim(splitted[0]); + zwtime = trim(splitted[1]); + zwvalue = trim(splitted[2]); } } } fclose(pFile); } - else // altes Format + else // Old Format { fgets(zw, 1024, pFile); fclose(pFile); @@ -239,7 +239,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void) NUMBERS[0]->ReturnValue = RundeOutput(NUMBERS[0]->Value, NUMBERS[0]->Nachkomma); } - UpdatePreValueINI = true; // Konvertierung ins neue Format + UpdatePreValueINI = true; // Conversion to the new format SavePreValue(); } @@ -251,7 +251,7 @@ void ClassFlowPostProcessing::SavePreValue() FILE* pFile; string _zw; - if (!UpdatePreValueINI) // PreValues unverändert --> File muss nicht neu geschrieben werden + if (!UpdatePreValueINI) // PreValues unchanged --> File does not have to be rewritten return; pFile = fopen(FilePreValue.c_str(), "w"); @@ -265,7 +265,7 @@ void ClassFlowPostProcessing::SavePreValue() // ESP_LOGD(TAG, "SaverPreValue %d, Value: %f, Nachkomma %d", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma); _zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n"; - ESP_LOGD(TAG, "Write PreValue Zeile: %s", _zw.c_str()); + ESP_LOGD(TAG, "Write PreValue line: %s", _zw.c_str()); if (pFile) { fputs(_zw.c_str(), pFile); } @@ -317,7 +317,7 @@ void ClassFlowPostProcessing::handleDecimalExtendedResolution(string _decsep, st if (toUpper(_value) == "TRUE") _zwdc = true; - if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt) + if (_digit == "default") // Set to default first (if nothing else is set) { NUMBERS[j]->isExtendedResolution = _zwdc; } @@ -353,7 +353,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val ESP_LOGD(TAG, "ERROR - Decimalshift is not a number: %s", _value.c_str()); } */ - if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt) + if (_digit == "default") // Set to default first (if nothing else is set) { NUMBERS[j]->DecimalShift = _zwdc; NUMBERS[j]->DecimalShiftInitial = _zwdc; @@ -385,7 +385,7 @@ void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep, { _zwdc = stof(_value); } - if (_digit == "default" || NUMBERS[j]->name == _digit) // erstmal auf default setzen (falls sonst nichts gesetzt) + if (_digit == "default" || NUMBERS[j]->name == _digit) // Set to default first (if nothing else is set) { NUMBERS[j]->AnalogDigitalTransitionStart = _zwdc; @@ -411,7 +411,7 @@ void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value) if (toUpper(_value) == "RATECHANGE") _rt = RateChange; - if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt) + if (_digit == "default") // Set to default first (if nothing else is set) { NUMBERS[j]->RateType = _rt; } @@ -447,7 +447,7 @@ void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value) ESP_LOGD(TAG, "ERROR - MaxRateValue is not a number: %s", _value.c_str()); } */ - if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt) + if (_digit == "default") // Set to default first (if nothing else is set) { NUMBERS[j]->useMaxRateValue = true; NUMBERS[j]->MaxRateValue = _zwdc; @@ -463,7 +463,7 @@ void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value) bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; int _n; aktparamgraph = trim(aktparamgraph); @@ -473,7 +473,7 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph) return false; - if (aktparamgraph.compare("[PostProcessing]") != 0) // Paragraph passt nich zu MakeImage + if (aktparamgraph.compare("[PostProcessing]") != 0) // Paragraph does not fit MakeImage return false; InitNUMBERS(); @@ -481,65 +481,65 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); - std::string _param = GetParameterName(zerlegt[0]); + splitted = ZerlegeZeile(aktparamgraph); + std::string _param = GetParameterName(splitted[0]); - if ((toUpper(_param) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "EXTENDEDRESOLUTION") && (splitted.size() > 1)) { - handleDecimalExtendedResolution(zerlegt[0], zerlegt[1]); + handleDecimalExtendedResolution(splitted[0], splitted[1]); } - if ((toUpper(_param) == "DECIMALSHIFT") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "DECIMALSHIFT") && (splitted.size() > 1)) { - handleDecimalSeparator(zerlegt[0], zerlegt[1]); + handleDecimalSeparator(splitted[0], splitted[1]); } - if ((toUpper(_param) == "ANALOGDIGITALTRANSITIONSTART") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "ANALOGDIGITALTRANSITIONSTART") && (splitted.size() > 1)) { - handleAnalogDigitalTransitionStart(zerlegt[0], zerlegt[1]); + handleAnalogDigitalTransitionStart(splitted[0], splitted[1]); } - if ((toUpper(_param) == "MAXRATEVALUE") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "MAXRATEVALUE") && (splitted.size() > 1)) { - handleMaxRateValue(zerlegt[0], zerlegt[1]); + handleMaxRateValue(splitted[0], splitted[1]); } - if ((toUpper(_param) == "MAXRATETYPE") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "MAXRATETYPE") && (splitted.size() > 1)) { - handleMaxRateType(zerlegt[0], zerlegt[1]); + handleMaxRateType(splitted[0], splitted[1]); } - if ((toUpper(_param) == "PREVALUEUSE") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "PREVALUEUSE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") { PreValueUse = true; } } - if ((toUpper(_param) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "CHECKDIGITINCREASECONSISTENCY") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") for (_n = 0; _n < NUMBERS.size(); ++_n) NUMBERS[_n]->checkDigitIncreaseConsistency = true; } - if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") for (_n = 0; _n < NUMBERS.size(); ++_n) NUMBERS[_n]->AllowNegativeRates = true; } - if ((toUpper(_param) == "ERRORMESSAGE") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "ERRORMESSAGE") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") ErrorMessage = true; } - if ((toUpper(_param) == "IGNORELEADINGNAN") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "IGNORELEADINGNAN") && (splitted.size() > 1)) { - if (toUpper(zerlegt[1]) == "TRUE") + if (toUpper(splitted[1]) == "TRUE") IgnoreLeadingNaN = true; } - if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (zerlegt.size() > 1)) + if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (splitted.size() > 1)) { - PreValueAgeStartup = std::stoi(zerlegt[1]); + PreValueAgeStartup = std::stoi(splitted[1]); } } @@ -558,12 +558,12 @@ void ClassFlowPostProcessing::InitNUMBERS() if (flowDigit) { - anzDIGIT = flowDigit->getAnzahlGENERAL(); + anzDIGIT = flowDigit->getNumberGENERAL(); flowDigit->UpdateNameNumbers(&name_numbers); } if (flowAnalog) { - anzANALOG = flowAnalog->getAnzahlGENERAL(); + anzANALOG = flowAnalog->getNumberGENERAL(); flowAnalog->UpdateNameNumbers(&name_numbers); } @@ -594,9 +594,9 @@ void ClassFlowPostProcessing::InitNUMBERS() else _number->AnzahlAnalog = 0; - _number->ReturnRawValue = ""; // Rohwert (mit N & führenden 0) - _number->ReturnValue = ""; // korrigierter Rückgabewert, ggf. mit Fehlermeldung - _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check + _number->ReturnRawValue = ""; // Raw value (with N & leading 0). + _number->ReturnValue = ""; // corrected return value, possibly with error message + _number->ErrorMessageText = ""; // Error message for consistency check _number->ReturnPreValue = ""; _number->PreValueOkay = false; _number->AllowNegativeRates = false; @@ -610,12 +610,12 @@ void ClassFlowPostProcessing::InitNUMBERS() _number->AnalogDigitalTransitionStart=9.2; - _number->FlowRateAct = 0; // m3 / min - _number->PreValue = 0; // letzter Wert, der gut ausgelesen wurde - _number->Value = 0; // letzer ausgelesener Wert, inkl. Korrekturen - _number->ReturnRawValue = ""; // Rohwert (mit N & führenden 0) - _number->ReturnValue = ""; // korrigierter Rückgabewert, ggf. mit Fehlermeldung - _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check + _number->FlowRateAct = 0; // m3 / min + _number->PreValue = 0; // last value read out well + _number->Value = 0; // last value read out, incl. corrections + _number->ReturnRawValue = ""; // raw value (with N & leading 0) + _number->ReturnValue = ""; // corrected return value, possibly with error message + _number->ErrorMessageText = ""; // Error message for consistency check _number->Nachkomma = _number->AnzahlAnalog; @@ -647,7 +647,7 @@ string ClassFlowPostProcessing::ShiftDecimal(string in, int _decShift){ _pos_dec_neu = _pos_dec_org + _decShift; - if (_pos_dec_neu <= 0) { // Komma ist vor der ersten Ziffer + if (_pos_dec_neu <= 0) { // comma is before the first digit for (int i = 0; i > _pos_dec_neu; --i){ in = in.insert(0, "0"); } @@ -655,7 +655,7 @@ string ClassFlowPostProcessing::ShiftDecimal(string in, int _decShift){ return in; } - if (_pos_dec_neu > in.length()){ // Komma soll hinter String (123 --> 1230) + if (_pos_dec_neu > in.length()){ // Comma should be after string (123 --> 1230) for (int i = in.length(); i < _pos_dec_neu; ++i){ in = in.insert(in.length(), "0"); } @@ -680,7 +680,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) time_t imagetime = 0; string rohwert; - // Update Nachkomma, da sich beim Wechsel von CNNType Auto --> xyz auch die Nachkommastellen ändern können: + // Update decimal point, as the decimal places can also change when changing from CNNType Auto --> xyz: imagetime = flowMakeImage->getTimeImageTaken(); if (imagetime == 0) @@ -692,7 +692,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo); zwtime = std::string(strftime_buf); - ESP_LOGD(TAG, "Anzahl NUMBERS: %d", NUMBERS.size()); + ESP_LOGD(TAG, "Quantity NUMBERS: %d", NUMBERS.size()); for (int j = 0; j < NUMBERS.size(); ++j) { @@ -729,7 +729,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if (NUMBERS[j]->analog_roi) NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogDigitalTransitionStart) + NUMBERS[j]->ReturnRawValue; else - NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt + NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution only if there are no analogue digits } #ifdef SERIAL_DEBUG ESP_LOGD(TAG, "After digital->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str()); @@ -763,13 +763,13 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) NUMBERS[j]->lastvalue = imagetime; WriteDataLog(j); - continue; // es gibt keinen Zahl, da noch ein N vorhanden ist. + continue; // there is no number because there is still an N. } } #ifdef SERIAL_DEBUG ESP_LOGD(TAG, "After findDelimiterPos: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str()); #endif - // Lösche führende Nullen (außer es ist nur noch einen 0) + // Delete leading zeros (unless there is only one 0 left) while ((NUMBERS[j]->ReturnValue.length() > 1) && (NUMBERS[j]->ReturnValue[0] == '0')) NUMBERS[j]->ReturnValue.erase(0, 1); #ifdef SERIAL_DEBUG @@ -811,7 +811,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma)) ) ; #endif - // Bei isExtendedResolution Ungenauigkeit von 0.2 mit einrechnen. + // Include inaccuracy of 0.2 for isExtendedResolution. if (NUMBERS[j]->Value >= (NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))) && NUMBERS[j]->isExtendedResolution) { NUMBERS[j]->Value = NUMBERS[j]->PreValue; NUMBERS[j]->ReturnValue = to_string(NUMBERS[j]->PreValue); @@ -831,7 +831,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) #ifdef SERIAL_DEBUG ESP_LOGD(TAG, "After AllowNegativeRates: Value %f", NUMBERS[j]->Value); #endif - double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in Sekunden + double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in seconds difference /= 60; NUMBERS[j]->FlowRateAct = (NUMBERS[j]->Value - NUMBERS[j]->PreValue) / difference; NUMBERS[j]->ReturnRateValue = to_string(NUMBERS[j]->FlowRateAct); @@ -916,22 +916,22 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift() { for (int j = 0; j < NUMBERS.size(); ++j) { - if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) // es gibt nur digitale ziffern + if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) // There are only digital digits { // ESP_LOGD(TAG, "Nurdigital"); NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial; - if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden + if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) // Extended resolution is on and should also be used for this digit. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1; NUMBERS[j]->Nachkomma = -NUMBERS[j]->DecimalShift; } - if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // es gibt nur analoge ziffern + if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) { // ESP_LOGD(TAG, "Nur analog"); NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial; - if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden + if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1; NUMBERS[j]->Nachkomma = -NUMBERS[j]->DecimalShift; @@ -944,7 +944,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift() NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial; NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift; - if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden + if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // Extended resolution is on and should also be used for this digit. NUMBERS[j]->Nachkomma = NUMBERS[j]->Nachkomma+1; } @@ -1008,7 +1008,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams bool no_nulldurchgang = false; pot = _decilamshift; - if (!_isanalog) // falls es keine analogwerte gibt, kann die letzte nicht bewertet werden + if (!_isanalog) // if there are no analogue values, the last one cannot be evaluated { pot++; } @@ -1034,14 +1034,14 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams { if (aktdigit != olddigit) { - input = input + ((float) (olddigit - aktdigit)) * pow(10, pot); // Neue Digit wird durch alte Digit ersetzt; + input = input + ((float) (olddigit - aktdigit)) * pow(10, pot); // New Digit is replaced by old Digit; } } else { - if (aktdigit == olddigit) // trotz Nulldurchgang wurde Stelle nicht hochgezählt --> addiere 1 + if (aktdigit == olddigit) // despite zero crossing, digit was not incremented --> add 1 { - input = input + ((float) (1)) * pow(10, pot); // addiere 1 an der Stelle + input = input + ((float) (1)) * pow(10, pot); // add 1 at the point } } #ifdef SERIAL_DEBUG diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 5ae5e08c..a1d351ec 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -18,7 +18,7 @@ protected: int PreValueAgeStartup; bool ErrorMessage; - bool IgnoreLeadingNaN; // SPEZIALFALL für User Gustl + bool IgnoreLeadingNaN; // SPECIAL CASE for User Gustl ??? ClassFlowCNNGeneral* flowAnalog; diff --git a/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp b/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp index 9e987f12..368a5e26 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp @@ -37,7 +37,7 @@ ClassFlowWriteList::ClassFlowWriteList(std::vector* lfc) bool ClassFlowWriteList::ReadParameter(FILE* pfile, string& aktparamgraph) { - std::vector zerlegt; + std::vector splitted; aktparamgraph = trim(aktparamgraph); @@ -45,18 +45,12 @@ bool ClassFlowWriteList::ReadParameter(FILE* pfile, string& aktparamgraph) if (!this->GetNextParagraph(pfile, aktparamgraph)) return false; - if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph passt nich zu MakeImage + if (toUpper(aktparamgraph).compare("[MQTT]") != 0) return false; while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { - zerlegt = ZerlegeZeile(aktparamgraph); -/* - if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1)) - { - this->user = zerlegt[1]; - } -*/ + splitted = ZerlegeZeile(aktparamgraph); } return true; diff --git a/code/components/jomjol_image_proc/CAlignAndCutImage.cpp b/code/components/jomjol_image_proc/CAlignAndCutImage.cpp index 0a08b3f6..fcbaed45 100644 --- a/code/components/jomjol_image_proc/CAlignAndCutImage.cpp +++ b/code/components/jomjol_image_proc/CAlignAndCutImage.cpp @@ -41,14 +41,14 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2) r0_x = _temp1->target_x; r0_y = _temp1->target_y; - ESP_LOGD(TAG, "Vor ft->FindTemplate(_temp1); %s", _temp1->image_file.c_str()); + ESP_LOGD(TAG, "Before ft->FindTemplate(_temp1); %s", _temp1->image_file.c_str()); isSimilar1 = ft->FindTemplate(_temp1); _temp1->width = ft->tpl_width; _temp1->height = ft->tpl_height; r1_x = _temp2->target_x; r1_y = _temp2->target_y; - ESP_LOGD(TAG, "Vor ft->FindTemplate(_temp2); %s", _temp2->image_file.c_str()); + ESP_LOGD(TAG, "Before ft->FindTemplate(_temp2); %s", _temp2->image_file.c_str()); isSimilar2 = ft->FindTemplate(_temp2); _temp2->width = ft->tpl_width; _temp2->height = ft->tpl_height; diff --git a/code/components/jomjol_image_proc/CImageBasis.cpp b/code/components/jomjol_image_proc/CImageBasis.cpp index 48829d94..3400a780 100644 --- a/code/components/jomjol_image_proc/CImageBasis.cpp +++ b/code/components/jomjol_image_proc/CImageBasis.cpp @@ -93,7 +93,7 @@ struct SendJPGHTTP inline void writejpgtohttphelp(void *context, void *data, int size) { SendJPGHTTP* _send = (SendJPGHTTP*) context; - if ((_send->size + size) >= HTTP_BUFFER_SENT) // data passt nich mehr in buffer + if ((_send->size + size) >= HTTP_BUFFER_SENT) // data no longer fits in buffer { httpd_req_t *_req = _send->req; if (httpd_resp_send_chunk(_req, _send->buf, _send->size) != ESP_OK) @@ -122,7 +122,7 @@ esp_err_t CImageBasis::SendJPGtoHTTP(httpd_req_t *_req, const int quality) if (ii.size > 0) { - if (httpd_resp_send_chunk(_req, (char*) ii.buf, ii.size) != ESP_OK) // verschicke noch den Rest + if (httpd_resp_send_chunk(_req, (char*) ii.buf, ii.size) != ESP_OK) //still send the rest { ESP_LOGE(TAG, "File sending failed!"); ii.res = ESP_FAIL; @@ -137,7 +137,7 @@ esp_err_t CImageBasis::SendJPGtoHTTP(httpd_req_t *_req, const int quality) bool CImageBasis::CopyFromMemory(uint8_t* _source, int _size) { int gr = height * width * channels; - if (gr != _size) // Größe passt nicht + if (gr != _size) // Size does not fit { ESP_LOGD(TAG, "Cannot copy image from memory - sizes do not match: should be %d, but is %d", _size, gr); return false; @@ -506,7 +506,7 @@ void CImageBasis::SaveToFile(std::string _imageout) RGBImageLock(); - if ((typ == "jpg") || (typ == "JPG")) // ACHTUNG PROBLEMATISCH IM ESP32 + if ((typ == "jpg") || (typ == "JPG")) // CAUTION PROBLEMATIC IN ESP32 { stbi_write_jpg(_imageout.c_str(), width, height, channels, rgb_image, 0); } diff --git a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp index a996dce9..05b15d7a 100644 --- a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp +++ b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp @@ -56,7 +56,7 @@ int CTfLiteClass::GetOutClassification(int _von, int _bis) if (_bis >= numeroutput) { - ESP_LOGD(TAG, "ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!"); + ESP_LOGD(TAG, "NUMBER OF OUTPUT NEURONS does not match required classification!"); return -1; } @@ -168,7 +168,7 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs) } #ifdef DEBUG_DETAIL_ON - LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach dem Laden in input"); + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "After loading in input"); #endif return true; @@ -226,7 +226,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn) unsigned char *result = (unsigned char*) malloc(size); int anz = 1; - while (!result && (anz < 6)) // maximal 5x versuchen (= 5s) + while (!result && (anz < 6)) // Try a maximum of 5x (= 5s) { #ifdef DEBUG_DETAIL_ON ESP_LOGD(TAG, "Speicher ist voll - Versuche es erneut: %d", anz); @@ -237,7 +237,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn) if(result != NULL) { - FILE* f = OpenFileAndWait(_fn.c_str(), "rb"); // vorher nur "r" + FILE* f = OpenFileAndWait(_fn.c_str(), "rb"); // previously only "r fread(result, 1, size, f); fclose(f); }else { @@ -276,7 +276,7 @@ CTfLiteClass::CTfLiteClass() this->interpreter = nullptr; this->input = nullptr; this->output = nullptr; - this->kTensorArenaSize = 800 * 1024; /// laut testfile: 108000 - bisher 600;; 2021-09-11: 200 * 1024 + this->kTensorArenaSize = 800 * 1024; /// according to testfile: 108000 - so far 600;; 2021-09-11: 200 * 1024 this->tensor_arena = new uint8_t[kTensorArenaSize]; } diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index b214be24..f369d82c 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -237,9 +237,13 @@ esp_err_t handler_json(httpd_req_t *req) esp_err_t handler_wasserzaehler(httpd_req_t *req) { #ifdef DEBUG_DETAIL_ON - LogFile.WriteHeapInfo("handler_wasserzaehler - Start"); + LogFile.WriteHeapInfo("handler water counter - Start"); #endif + + + + if (FlowInitDone) { bool _rawValue = false; @@ -248,7 +252,9 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) std::string _type = "value"; string zw; - ESP_LOGD(TAG, "handler_wasserzaehler uri: %s", req->uri); + ESP_LOGD(TAG, "handler water counter uri: %s", req->uri); + + char _query[100]; char _size[10]; @@ -380,9 +386,14 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) return ESP_ERR_NOT_FOUND; } + + + + #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("handler_wasserzaehler - Done"); #endif + return ESP_OK; } diff --git a/code/components/jomjol_wlan/read_wlanini.cpp b/code/components/jomjol_wlan/read_wlanini.cpp index edc91628..5da76f0a 100644 --- a/code/components/jomjol_wlan/read_wlanini.cpp +++ b/code/components/jomjol_wlan/read_wlanini.cpp @@ -26,7 +26,7 @@ std::vector ZerlegeZeileWLAN(std::string input, std::string _delimiter = input = trim(input, delimiter); size_t pos = findDelimiterPos(input, delimiter); std::string token; - if (pos != std::string::npos) // Zerlegt nur bis ersten Gleichheitszeichen !!! Sonderfall für WLAN.ini + if (pos != std::string::npos) // splitted only up to first equal sign !!! Special case for WLAN.ini { token = input.substr(0, pos); token = trim(token, delimiter); @@ -51,7 +51,7 @@ void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_ho std::string dns = ""; std::string line = ""; - std::vector zerlegt; + std::vector splitted; hostname = std_hostname; FILE* pFile; @@ -70,53 +70,53 @@ void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_ho while ((line.size() > 0) || !(feof(pFile))) { // ESP_LOGD(TAG, "%s", line.c_str()); - zerlegt = ZerlegeZeileWLAN(line, "="); - zerlegt[0] = trim(zerlegt[0], " "); + splitted = ZerlegeZeileWLAN(line, "="); + splitted[0] = trim(splitted[0], " "); - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){ - hostname = trim(zerlegt[1]); + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "HOSTNAME")){ + hostname = trim(splitted[1]); if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){ hostname = hostname.substr(1, hostname.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){ - ssid = trim(zerlegt[1]); + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "SSID")){ + ssid = trim(splitted[1]); if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){ ssid = ssid.substr(1, ssid.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){ - passphrase = zerlegt[1]; + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "PASSWORD")){ + passphrase = splitted[1]; if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){ passphrase = passphrase.substr(1, passphrase.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ - ipaddress = zerlegt[1]; + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "IP")){ + ipaddress = splitted[1]; if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){ ipaddress = ipaddress.substr(1, ipaddress.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){ - gw = zerlegt[1]; + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "GATEWAY")){ + gw = splitted[1]; if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){ gw = gw.substr(1, gw.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){ - netmask = zerlegt[1]; + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "NETMASK")){ + netmask = splitted[1]; if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){ netmask = netmask.substr(1, netmask.length()-2); } } - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){ - dns = zerlegt[1]; + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "DNS")){ + dns = splitted[1]; if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){ dns = dns.substr(1, dns.length()-2); } @@ -191,7 +191,7 @@ bool ChangeHostName(std::string fn, std::string _newhostname) return false; string line = ""; - std::vector zerlegt; + std::vector splitted; bool found = false; @@ -213,10 +213,10 @@ bool ChangeHostName(std::string fn, std::string _newhostname) while ((line.size() > 0) || !(feof(pFile))) { ESP_LOGD(TAG, "%s", line.c_str()); - zerlegt = ZerlegeZeileWLAN(line, "="); - zerlegt[0] = trim(zerlegt[0], " "); + splitted = ZerlegeZeileWLAN(line, "="); + splitted[0] = trim(splitted[0], " "); - if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){ + if ((splitted.size() > 1) && (toUpper(splitted[0]) == "HOSTNAME")){ line = "hostname = \"" + _newhostname + "\"\n"; found = true; } diff --git a/code/main/main.cpp b/code/main/main.cpp index a61b9374..91b2bf3c 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -295,7 +295,7 @@ extern "C" void app_main(void) gpio_handler_create(server); - ESP_LOGD(TAG, "vor reg server main"); + ESP_LOGD(TAG, "Before reg server main"); register_server_main_uri(server, "/sdcard"); @@ -306,13 +306,13 @@ extern "C" void app_main(void) /* Main Init has successed or only an error which allows to continue operation */ if (getSystemStatus() == 0) { // No error flag is set LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Initialization completed successfully!"); - ESP_LOGD(TAG, "vor do autostart"); + ESP_LOGD(TAG, "Before do autostart"); TFliteDoAutoStart(); } else if (isSetSystemStatusFlag(SYSTEM_STATUS_CAM_FB_BAD) || // Non critical errors occured, we try to continue... isSetSystemStatusFlag(SYSTEM_STATUS_NTP_BAD)) { LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Initialization completed with errors, but trying to continue..."); - ESP_LOGD(TAG, "vor do autostart"); + ESP_LOGD(TAG, "Before do autostart"); TFliteDoAutoStart(); } else { // Any other error is critical and makes running the flow impossible. diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 6ab0912f..517ad0b7 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -455,18 +455,18 @@ httpd_handle_t start_webserver(void) httpd_handle_t server = NULL; httpd_config_t config = { }; - config.task_priority = tskIDLE_PRIORITY+3; //20221211: before: tskIDLE_PRIORITY+1; // 20210924 --> vorher +5 - config.stack_size = 32768; //20210921 --> vorher 32768 // bei 32k stürzt das Programm beim Bilderaufnehmen ab - config.core_id = 0; //20221211 --> force all not flow related tasks to CPU0, before: tskNO_AFFINITY; - config.server_port = 80; - config.ctrl_port = 32768; - config.max_open_sockets = 5; //20210921 --> vorher 7 - config.max_uri_handlers = 37; // vorher 24, 20220511: 35 - config.max_resp_headers = 8; - config.backlog_conn = 5; - config.lru_purge_enable = true; // dadurch werden alte Verbindungen gekappt, falls neue benögt werden. - config.recv_wait_timeout = 5; // default: 5 20210924 --> vorher 30 - config.send_wait_timeout = 5; // default: 5 20210924 --> vorher 30 + config.task_priority = tskIDLE_PRIORITY+3; //20221211: before: tskIDLE_PRIORITY+1; // 20210924 --> before +5 + config.stack_size = 32768; //20210921 --> before 32768 // at 32k the programme crashes when taking pictures + config.core_id = 0; //20221211 --> force all not flow related tasks to CPU0, before: tskNO_AFFINITY; + config.server_port = 80; + config.ctrl_port = 32768; + config.max_open_sockets = 5; //20210921 --> previously 7 + config.max_uri_handlers = 37; // previously 24, 20220511: 35 + config.max_resp_headers = 8; + config.backlog_conn = 5; + config.lru_purge_enable = true; // this cuts old connections if new ones are needed. + config.recv_wait_timeout = 5; // default: 5 20210924 --> previously 30 + config.send_wait_timeout = 5; // default: 5 20210924 --> previously 30 config.global_user_ctx = NULL; config.global_user_ctx_free_fn = NULL; config.global_transport_ctx = NULL; diff --git a/code/platformio.ini b/code/platformio.ini index e91212cf..b833d0f4 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -18,30 +18,12 @@ board = esp32cam ;board = m5stack-core-esp32 framework = espidf -;Add macro definition ENABLE_MQTT, ENABLE_INFLUXDB +;Add macro definition ENABLE_MQTT, ENABLE_INFLUXDB, DEBUG_DETAIL_ON build_flags = -D ENABLE_MQTT -D ENABLE_INFLUXDB ;board_build.partitions = partitions_singleapp.csv board_build.partitions = partitions.csv -;lib_deps not needed -;lib_deps = -; jomjol_configfile -; jomjol_helper -; jomjol_wlan -; jomjol_image_proc -; jomjol_controlcamera -; jomjol_flowcontroll -; jomjol_tfliteclass -; tflite-lib -; jomjol_fileserver_ota -; jomjol_time_sntp -; jomjol_logfile -; jomjol_mqtt -; jomjol_influxdb -; jomjol_controlGPIO - - monitor_speed = 115200 monitor_rts = 0 monitor_dtr = 0 @@ -49,4 +31,5 @@ monitor_dtr = 0 debug_tool = esp-prog ; Enable and adapt for logging over USB -;upload_port = /dev/ttyUSB0 \ No newline at end of file +;upload_port = /dev/ttyUSB0 +upload_port =com3 \ No newline at end of file diff --git a/code/sdkconfig.defaults b/code/sdkconfig.defaults index 11587c15..6d1038fb 100644 --- a/code/sdkconfig.defaults +++ b/code/sdkconfig.defaults @@ -11,7 +11,61 @@ CONFIG_TASK_WDT_CHECK_IDLE_TASK=n CONFIG_COMPILER_OPTIMIZATION_DEFAULT=n CONFIG_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_ESP32_REV_MIN_0=y +################################ changes #1577 +#better flash mode +ESPTOOLPY_FLASHMODE_QIO=y + +#may trouble very old esp-cam version (work with Chip is ESP32-D0WDQ6 (revision 1)) +ESP32_REV_MIN_3=y +CONFIG_ESP32_REV_MIN_3=y + +#set frequency +CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +SPIRAM_SPEED_80M=y + +#disable every logging +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=0 +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_FREERTOS_ASSERT_DISABLE=y +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=0 +CONFIG_LOG_DEFAULT_LEVEL_NONE=y +CONFIG_LOG_DEFAULT_LEVEL=0 +CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y +CONFIG_LWIP_ESP_LWIP_ASSERT=n +CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED=y +CONFIG_OPTIMIZATION_ASSERTION_LEVEL=0 +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set +CONFIG_BOOTLOADER_LOG_LEVEL=0 +# CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set +# CONFIG_LOG_COLORS is not set + +#disable lookup function +CONFIG_ESP_ERR_TO_NAME_LOOKUP=n +# CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set + +#no panic message +ESP_SYSTEM_PANIC_SILENT_REBOOT=y + +#disable Access point mode +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# CONFIG_ESP_WIFI_SOFTAP_SUPPORT is not set + +#disable ADC calibration (needed for external sensors) +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=n +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=n +CONFIG_ADC_CAL_LUT_ENABLE=needed + +#disable IPV6 () +CONFIG_LWIP_IPV6=n + +#Newlib format +CONFIG_NEWLIB_NANO_FORMAT=y + +################################ END - changes #1577 CONFIG_ESP32_DPORT_WORKAROUND=y @@ -28,7 +82,7 @@ CONFIG_PARTITION_TABLE_MD5=y CONFIG_ESP32_SPIRAM_SUPPORT=y CONFIG_SPIRAM_SIZE=-1 -CONFIG_SPIRAM_SPEED_40M=y +#CONFIG_SPIRAM_SPEED_40M=y ##changes #1577 CONFIG_SPIRAM=y CONFIG_SPIRAM_BOOT_INIT=y CONFIG_SPIRAM_USE_MALLOC=y diff --git a/code/test/components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp b/code/test/components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp new file mode 100644 index 00000000..825298ff --- /dev/null +++ b/code/test/components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp @@ -0,0 +1,104 @@ +#include +#include + +class UnderTestCNNGeneral : public ClassFlowCNNGeneral { + public: + UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) : + ClassFlowCNNGeneral(_flowalign, _cnntype) {}; + + using ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew; + + +}; + + +/** + * @brief + * + * Transition = x.8 - x.2 here no transition in the test cases. + * Offset = dig=x.n, ana= n.y: no offset, because both "n" are the same + */ +void test_analogToDigit_Standard() { + + UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100); + + // 4.8 is a "hanging" 5, i.e. it has not jumped over to 5.0. + // A "hanging digit" should still be rounded from Transition. + // Transition = yes + // Offset = no + TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew(4.8, 8.0, 8, 9.2)); + + // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217 + // Default: dig=9.6, ana=6.8 => erg=9 + // Transition = no + // Offset = no + TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.6, 6.8, 6, 9.2)); + + + // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920 + // Default: dig=4.6, ana=6.2 => erg=4 + // Transition = no + // Offset = no + TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.6, 6.2, 6, 9.2)); + + // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805 + // Hanging digit () + // Default: dig=6.8, ana=8.6 => erg=7 + // Transition = no + // Offset = no + TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 8.6, 6, 9.2)); + + // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805 + // Also hanging digit () with small pointer after 0 pass. + // Default: dig=6.8, ana=1.0 => erg=7 + // Transition = no + // Offset = no + TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 1.0, 1, 9.2)); + + +} + +void test_analogToDigit_Transition() { + UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100); + + // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175 + // Default: dig=3.9, ana=9.7 => erg=3 + // Transition = yes + // Zero crossing = no + // Offset = no + TEST_ASSERT_EQUAL_INT(3, undertest->PointerEvalAnalogToDigitNew( 3.9, 9.7, 9, 9.2)); + + // without reference + // Default: dig=4.0, ana=9.1 => erg=4 + // Transition = yes + // Zero crossing = no + // Offset = no + // Special feature: Digit has not yet started at analogue 9.1 + TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.0, 9.1, 9, 9.2)); + + // without reference + // Default: dig=9.8, ana=0.1, ana_2=9.9 => erg=9 + // transition = yes + // Zero crossing = no + // Offset = no + // Special feature: analogue is set back to 9 by previous analogue + TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.8, 0.1, 9, 9.2)); + + + // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333 + // Default: dig=5.9, ana=9.4 => erg=9 + // Transition = yes + // Zero crossing = no + // Offset = no + // Special feature: + TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew( 5.9, 9.4, 9, 9.2)); + + // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030 + // Default: dig=1.8, ana=7.8 => erg=9 + // Transition = yes + // Zero crossing = no + // Offset = no + // Special feature: Digit runs with analogue. Therefore 1.8 (vs. 7.8) + TEST_ASSERT_EQUAL_INT(1, undertest->PointerEvalAnalogToDigitNew( 1.8, 7.8, 7, 7.7)); + +} diff --git a/code/test/components/jomjol-flowcontroll/test_ZeigerEvalAnalogToDigitNeu.cpp b/code/test/components/jomjol-flowcontroll/test_ZeigerEvalAnalogToDigitNeu.cpp deleted file mode 100644 index a118a74c..00000000 --- a/code/test/components/jomjol-flowcontroll/test_ZeigerEvalAnalogToDigitNeu.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include - -class UnderTestCNNGeneral : public ClassFlowCNNGeneral { - public: - UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) : - ClassFlowCNNGeneral(_flowalign, _cnntype) {}; - - using ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu; - - -}; - - -/** - * @brief - * - * Transition = x.8 - x.2 hier keine Transition in den Testfaellen - * Versatz = dig=x.n, ana= n.y: kein Versatz, da beide "n" gleich - */ -void test_analogToDigit_Standard() { - - UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100); - - // 4.8 ist eine "hängende" 5. Heißt sie ist nicht bis auf 5.0 umgesprungen. - // ab Transition sollte trotzdem ein "hängendes Digit" gerundet werden. - // Transition = ja - // Versatz = nein - TEST_ASSERT_EQUAL_INT(5, undertest->ZeigerEvalAnalogToDigitNeu(4.8, 8.0, 8, 9.2)); - - // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217 - // Standard: dig=9.6, ana=6.8 => erg=9 - // Transition = nein - // Versatz = nein - TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.6, 6.8, 6, 9.2)); - - - // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920 - // Standard: dig=4.6, ana=6.2 => erg=4 - // Transition = nein - // Versatz = nein - TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.6, 6.2, 6, 9.2)); - - // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805 - // Hängendes digit () - // Standard: dig=6.8, ana=8.6 => erg=7 - // Transition = nein - // Versatz = nein - TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 8.6, 6, 9.2)); - - // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805 - // Ebenfalls Hängendes digit () bei kleinem Zeiger nach 0-Durchlauf - // Standard: dig=6.8, ana=1.0 => erg=7 - // Transition = nein - // Versatz = nein - TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 1.0, 1, 9.2)); - - -} - -void test_analogToDigit_Transition() { - UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100); - - // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175 - // Standard: dig=3.9, ana=9.7 => erg=3 - // Transition = ja - // Nulldurchgang = nein - // Versatz = nein - TEST_ASSERT_EQUAL_INT(3, undertest->ZeigerEvalAnalogToDigitNeu( 3.9, 9.7, 9, 9.2)); - - // ohne Referenz - // Standard: dig=4.0, ana=9.1 => erg=4 - // Transition = ja - // Nulldurchgang = nein - // Versatz = nein - // Besonderheit: Digit ist bei analog 9.1 noch nicht losgelaufen - TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.0, 9.1, 9, 9.2)); - - // ohne Referenz - // Standard: dig=9.8, ana=0.1, ana_2=9.9 => erg=9 - // Transition = ja - // Nulldurchgang = nein - // Versatz = nein - // Besonderheit: analog wird durch vorherigen analog wieder auf 9 gesetzt - TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.8, 0.1, 9, 9.2)); - - - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333 - // Standard: dig=5.9, ana=9.4 => erg=9 - // Transition = ja - // Nulldurchgang = nein - // Versatz = nein - // Besonderheit: - TEST_ASSERT_EQUAL_INT(5, undertest->ZeigerEvalAnalogToDigitNeu( 5.9, 9.4, 9, 9.2)); - - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030 - // Standard: dig=1.8, ana=7.8 => erg=9 - // Transition = ja - // Nulldurchgang = nein - // Versatz = nein - // Besonderheit: Digit läuft mit Analog mit. Deshalb 1.8 (vs. 7.8) - TEST_ASSERT_EQUAL_INT(1, undertest->ZeigerEvalAnalogToDigitNeu( 1.8, 7.8, 7, 7.7)); - -} diff --git a/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp index 9d7c9b09..5f6e6496 100644 --- a/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp +++ b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp @@ -3,8 +3,8 @@ class UnderTestCNN : public ClassFlowCNNGeneral { public: - using ClassFlowCNNGeneral::ZeigerEvalAnalogNeu; - using ClassFlowCNNGeneral::ZeigerEvalHybridNeu; + using ClassFlowCNNGeneral::PointerEvalAnalogNew; + using ClassFlowCNNGeneral::PointerEvalHybridNew; using ClassFlowCNNGeneral::ClassFlowCNNGeneral; }; @@ -20,21 +20,21 @@ void test_ZeigerEval() // the 5.2 is already above 5.0 and the previous digit too (3) printf("Test 5.2, 3\n"); - int result = undertest.ZeigerEvalAnalogNeu(5.2, 3); + int result = undertest.PointerEvalAnalogNew(5.2, 3); TEST_ASSERT_EQUAL(5, result); // the 5.2 is already above 5.0 and the previous digit not (9) // so the current digit shoult be reduced (4.9) printf("Test 5.2, 9\n"); - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(5.2, 9)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(5.2, 9)); printf("Test 4.4, 9\n"); // the 4.4 (digital100) is not above 5 and the previous digit (analog) too (9.3) - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(4.4, 9)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(4.4, 9)); printf("Test 4.5, 0\n"); // the 4.5 (digital100) is not above 5 and the previous digit (analog) too (9.6) - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(4.5, 0)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(4.5, 0)); } @@ -46,57 +46,57 @@ void test_ZeigerEvalHybrid() { UnderTestCNN undertest = UnderTestCNN(nullptr, Digital100); // the 5.2 and no previous should round down - printf("ZeigerEvalHybridNeu(5.2, 0, -1)\n"); - TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.2, 0, -1)); + printf("PointerEvalHybridNew(5.2, 0, -1)\n"); + TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.2, 0, -1)); // the 5.3 and no previous should trunc to 5 - printf("ZeigerEvalHybridNeu(5.3, 0, -1)\n"); - TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0, -1)); + printf("PointerEvalHybridNew(5.3, 0, -1)\n"); + TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0, -1)); - printf("ZeigerEvalHybridNeu(5.7, 0, -1)\n"); + printf("PointerEvalHybridNew(5.7, 0, -1)\n"); // the 5.7 and no previous should trunc to 5 - TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.7, 0, -1)); + TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1)); // the 5.8 and no previous should round up to 6 - printf("ZeigerEvalHybridNeu(5.8, 0, -1)\n"); - TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.8, 0, -1)); + printf("PointerEvalHybridNew(5.8, 0, -1)\n"); + TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.8, 0, -1)); // the 5.7 with previous and the previous between 0.3-0.5 should round up to 6 - TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.7, 0.4, 1)); + TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0.4, 1)); // the 5.3 with previous and the previous between 0.3-0.7 should round down to 5 - TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0.7, 1)); + TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0.7, 1)); // the 5.3 with previous and the previous <=0.5 should trunc to 5 - TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0.1, 1)); + TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0.1, 1)); // the 5.3 with previous and the previous >=9.5 should reduce to 4 - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(5.3, 9.6, 9)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(5.3, 9.6, 9)); // the 5.7 with previous and the previous >=9.5 should trunc to 5 - TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.7, 9.6, 9)); + TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.7, 9.6, 9)); // the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6) - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.6, 0)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.6, 0)); // the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6) - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.6, 9)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.6, 9)); // the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5) - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.5, 9)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.5, 9)); // 59.96889 - Pre: 58.94888 // 8.6 : 9.8 : 6.7 // the 4.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5) - TEST_ASSERT_EQUAL(8, undertest.ZeigerEvalHybridNeu(8.6, 9.8, 9)); + TEST_ASSERT_EQUAL(8, undertest.PointerEvalHybridNew(8.6, 9.8, 9)); // pre = 9.9 (0.0 raw) // zahl = 1.8 - TEST_ASSERT_EQUAL(2, undertest.ZeigerEvalHybridNeu(1.8, 9.0, 9)); + TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 9.0, 9)); // if a digit have an early transition and the pointer is < 9.0 // prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter) // zahl = 4.6 - TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.6, 6.0, 6)); + TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.6, 6.0, 6)); // issue #879 vorgaenger is -1, zahl = 6.7 diff --git a/code/test/test_suite_flowcontroll.cpp b/code/test/test_suite_flowcontroll.cpp index fed2218c..93a459a0 100644 --- a/code/test/test_suite_flowcontroll.cpp +++ b/code/test/test_suite_flowcontroll.cpp @@ -3,7 +3,7 @@ #include "components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp" #include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp" #include "components/jomjol-flowcontroll/test_flow_pp_negative.cpp" -#include "components/jomjol-flowcontroll/test_ZeigerEvalAnalogToDigitNeu.cpp" +#include "components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp" #include "components/jomjol-flowcontroll/test_getReadoutRawString.cpp" // SD-Card //////////////////// #include "nvs_flash.h"