From 1e43c70adff9e85ba45b50cdb24f5b7fdcbc0a64 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Tue, 4 Oct 2022 21:24:45 +0200 Subject: [PATCH 01/20] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 67 +++++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 3261db7d..6899d63c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,31 +1,54 @@ ---- name: Bug report -about: Create a bug report to help us improve -title: '' -labels: '' -assignees: '' +description: Create a bug report to help us improve +body: ---- -Thank you for taking your time to report a bug. + - type: markdown + attributes: + value: | + Thank you for taking your time to report a bug. -Before you proceed, please check: -- Do you use the latest version? See https://github.com/jomjol/AI-on-the-edge-device/releases. -- Is there already another similar issue? Check for open and closed Issue in https://github.com/jomjol/AI-on-the-edge-device/issues. -- Are instructions in the readme solving your issue (https://github.com/jomjol/AI-on-the-edge-device/tree/master#readme)? -- Are instructions in the wiki solving your issue? (https://github.com/jomjol/AI-on-the-edge-device/wiki)? + Before you proceed, please check: + - [ ] Do you use the [latest version](https://github.com/jomjol/AI-on-the-edge-device/releases)? + - [ ] Is there already another similar issue? Check for open and closed [Issue](https://github.com/jomjol/AI-on-the-edge-device/issues) and [Discussions](https://github.com/jomjol/AI-on-the-edge-device/discussions). + - [ ] Are instructions in the [README](https://github.com/jomjol/AI-on-the-edge-device/tree/master#readme) solving your issue? + - [ ] Are instructions in the [Wiki](https://github.com/jomjol/AI-on-the-edge-device/wiki) solving your issue? -**Describe the bug** -A clear and concise description of what the bug is. -**Version** -Which version are you using? (See menu `System > Info`). -**Expected behavior** -A clear and concise description of what you expected to happen. + - type: textarea + validations: + required: true + attributes: + label: The Problem + description: A clear and concise description of what the bug is. -**Screenshots** -If applicable, add screenshots to help explain your problem. -**Additional context** -Add any other context about the problem here. + + - type: input + validations: + required: true + attributes: + label: Version + description: Which version are you using? (See menu `System > Info`). + + + + - type: textarea + attributes: + label: Expected Behavior + description: A clear and concise description of what you expected to happen. + + + + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain your problem. + + + + - type: textarea + attributes: + label: Additional Context + description: Add any other context about the problem here. From e82cbbf1173d7a6e74c96f4fbe855bfb4d67baa4 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Tue, 4 Oct 2022 23:24:32 +0200 Subject: [PATCH 02/20] Rename bug_report.md to bug_report.yml --- .github/ISSUE_TEMPLATE/{bug_report.md => bug_report.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/ISSUE_TEMPLATE/{bug_report.md => bug_report.yml} (100%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug_report.yml From 730006977c41c63beb1ac4c95a7b69de1a43c0f9 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Thu, 13 Oct 2022 21:58:18 +0200 Subject: [PATCH 03/20] improved issues guiding (#1168) --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ .github/ISSUE_TEMPLATE/general_question.md | 10 ---------- 3 files changed, 6 insertions(+), 11 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/general_question.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 6899d63c..799f0f58 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,5 +1,5 @@ name: Bug report -description: Create a bug report to help us improve +description: Use this form if you think you found a bug body: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..56ffed01 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Open a new discussion + url: https://github.com/jomjol/AI-on-the-edge-device/discussions/categories/q-a + about: Use this form if you have a question or need help setting your AI-on-the-edge-device it up diff --git a/.github/ISSUE_TEMPLATE/general_question.md b/.github/ISSUE_TEMPLATE/general_question.md deleted file mode 100644 index edb3863b..00000000 --- a/.github/ISSUE_TEMPLATE/general_question.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: General Question -about: General Question => Open a discussion instead -title: '' -labels: '' -assignees: '' - ---- - -If its not a bug, please open a discussion instead, see https://github.com/jomjol/AI-on-the-edge-device/discussions From 2ed3f4aa40660096cec3931fcd35f31c5653ca25 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:12:11 +0200 Subject: [PATCH 04/20] Revert "Merge pull request #1167 from haverland/fix_analogtodigital" This reverts commit ba59c8ee66a9fba9a6e9fb0447fee960996e4e49, reversing changes made to 730006977c41c63beb1ac4c95a7b69de1a43c0f9. --- .github/workflows/build.yaml | 5 - Changelog.md | 20 - FeatureRequest.md | 214 ++--- .../components/jomjol_controlGPIO/SmartLeds.h | 3 +- .../jomjol_fileserver_ota/server_file.cpp | 2 +- .../ClassFlowCNNGeneral.cpp | 30 +- .../jomjol_flowcontroll/ClassFlowCNNGeneral.h | 2 +- .../jomjol_flowcontroll/ClassFlowControll.cpp | 4 +- .../ClassFlowPostProcessing.cpp | 3 +- .../components/jomjol_mqtt/interface_mqtt.cpp | 45 +- code/dependencies.lock | 3 +- code/main/main.cpp | 2 - code/platformio.ini | 6 +- .../test_cnnflowcontroll.cpp | 107 +++ .../test_flowpostprocessing.cpp | 111 +-- code/test/test_suite_flowcontroll.cpp | 22 +- sd-card/html/edit_config_param.html | 800 +++++++++++------- 17 files changed, 753 insertions(+), 626 deletions(-) create mode 100644 code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a0fc41c4..880cc674 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -189,11 +189,6 @@ jobs: ./sd-card/html/version.txt key: ${{ github.run_number }} - - name: Set Variables - id: vars - run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Prepare artifacts for release run: | mkdir -p firmware diff --git a/Changelog.md b/Changelog.md index bfb91709..8d0fee71 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,25 +1,5 @@ # Changelog -## [Unreleased] - -### Added - -- Addes PreValue to `/json` ([#1154](https://github.com/jomjol/AI-on-the-edge-device/issues/1154)) - -### Changed - -- Updated built environment to `espressif32@v5.2.0` - -### Fixed - -- [#1116](https://github.com/jomjol/AI-on-the-edge-device/issues/1116) precision problem at setting prevalue -- [#1119](https://github.com/jomjol/AI-on-the-edge-device/issues/1119) renamed `firmware.bin` not working in OTA -### Removed - -- n.a. - - - ## [12.0.1](https://github.com/jomjol/AI-on-the-edge-device/releases/tag/v12.0.1), 2022-09-29 Improve **u**ser e**x**perience diff --git a/FeatureRequest.md b/FeatureRequest.md index 2020fb78..a9c84319 100644 --- a/FeatureRequest.md +++ b/FeatureRequest.md @@ -11,18 +11,9 @@ ____ -#### #30 Support meter clock over - -* In case of meter clocking over, that is, reaching its max. value and starting over from 0, - accept the new value and calculate correctly the difference. - (see line 739 onwards in ClassFlowPostProcessing.cpp) - -* In case of meter clocking over, that is, reaching its max. value and starting over from 0, - accept the new value and calculate correctly the difference. - (see line 739 onwards in ClassFlowPostProcessing.cpp) - - +#### ~~#29 Add favicon and use the hostname for the website~~- implemented v11.3.1 +~~* https://github.com/jomjol/AI-on-the-edge-device/issues/927~~ #### #28 Improved error handling for ROIs @@ -56,7 +47,13 @@ ____ * Show the CPU Temp directly in Webpage. Also add the value to MQTT sending - + + +#### ~~#22 Direct hint to the different neural network files in the other repositories~~- implemented >v11.3.1 + +~~* https://github.com/jomjol/AI-on-the-edge-device/issues/644~~ + + #### #21 Extended "CheckDigitalConsistency" Logik @@ -64,21 +61,40 @@ ____ +#### #20 Deep sleep and push mode + +* Let the device be normally in deep sleep state, and wake it up periodically to collect data and push it via MQTT or HTTP post. +* Support ESP-NOW to reduce the overhead of connecting to wifi and mqtt +* the above should enable battery powered applications + +* An other way to set deep sleep would be to enable it in a specific period (at night). + + +#### #19 Extended log informations + +* https://github.com/jomjol/AI-on-the-edge-device/issues/580 + + + +#### ~~#18 Document WLAN-strength in web page~~ + +* ~~https://github.com/jomjol/AI-on-the-edge-device/issues/563~~ + + + +#### ~~#17 Direct InfluxDB connection~~ + +* ~~Done in v10.6.0~~ + #### #16 Serial Communication * https://github.com/jomjol/AI-on-the-edge-device/issues/512 - * Send the readout value via RX/TX interface with a dedicated TAG - * Make dedicated communication FlowModule - * Modification of RX/TX communication - * Configuration interfache - - #### #15 Calibration for FishEye image @@ -92,6 +108,16 @@ ____ +#### ~~#14 Backup and restore option for configuration~~- implemented v11.3.1 + +* ~~https://github.com/jomjol/AI-on-the-edge-device/issues/459~~ + +* ~~Implement a zip file compression for store and restore~~ + +* ~~Update the html to handle it~~ + + + #### #13 Manage non linear gauge without CNN re-training * https://github.com/jomjol/AI-on-the-edge-device/issues/443 @@ -100,6 +126,12 @@ ____ +#### ~~#12 Less reboots due to memory leakage~~ + +* ~~Issue: #414 & #425 #430~~ + + + #### #11 MQTT - configurable payload * https://github.com/jomjol/AI-on-the-edge-device/issues/344 @@ -112,14 +144,18 @@ ____ +#### #9 Basic auth for the UI + +* https://github.com/jomjol/AI-on-the-edge-device/issues/283 + +* Implementation of an authentication mechanism. + #### #8 MQTT configurable readout intervall Make the readout intervall configurable via MQTT. * Change the mqtt part to receive and process input and not only sending - - #### #7 Extended Error Handling Check different types of error (e.g. tflite not availabe) and generate an error on the html page. @@ -130,7 +166,15 @@ To do: * Implement a checking algo * Extend the firmware and html page for the error handling +#### ~~#6 Check for double ROI names~~ - implemented v8.0.0 +~~Check during configuration, that ROI names are unique.~~ + +~~To do:~~ + +* ~~Implementation of ROI name checking in html code before saving analog or digital ROIs~~ + + #### #5 Configurable decimal separator (point or comma) @@ -144,112 +188,6 @@ To do: -#### #2 MQTT-controll with callback -* https://github.com/jomjol/AI-on-the-edge-device/issues/105 - -Extend the MQTT client to also enable callbacks for configuration setting - -To do: - -* implement callback for receiving information and override `config.ini` settings - -* change configuration management to handle online updates (currently changes need a restart) - -* think about the startup, as there the default config is loaded - - - -____ - - - -# Refused - -#### #9 Basic auth for the UI - -* https://github.com/jomjol/AI-on-the-edge-device/issues/283 - -* Implementation of an authentication mechanism. - -This will not be part of the free version - - - -#### #20 Deep sleep and push mode - -* Let the device be normally in deep sleep state, and wake it up periodically to collect data and push it via MQTT or HTTP post. -* Support ESP-NOW to reduce the overhead of connecting to wifi and mqtt -* the above should enable battery powered applications - -* An other way to set deep sleep would be to enable it in a specific period (at night). - -Technically not possible, as the limiting factor for the power consumption is not the esp32, but the electrical curcuit on the ESP32CAM board, which consumes a lot already in deep sleep mode. - - - -# Closed - - -#### ~~#29 Add favicon and use the hostname for the website~~- implemented v11.3.1 - - - -#### ~~#19 Extended log informations~~ - -~~* https://github.com/jomjol/AI-on-the-edge-device/issues/580~~ - - - -#### ~~#29 Add favicon and use the hostname for the website~~- implemented v11.3.1 - -~~* https://github.com/jomjol/AI-on-the-edge-device/issues/927~~ - - - -#### ~~#22 Direct hint to the different neural network files in the other repositories~~- implemented >v11.3.1 - -~~* https://github.com/jomjol/AI-on-the-edge-device/issues/644~~ - - - -#### ~~#18 Document WLAN-strength in web page~~ - -* ~~https://github.com/jomjol/AI-on-the-edge-device/issues/563~~ - - - -#### ~~#17 Direct InfluxDB connection~~ - -* ~~Done in v10.6.0~~ - - - -#### ~~#14 Backup and restore option for configuration~~- implemented v11.3.1 - -* ~~https://github.com/jomjol/AI-on-the-edge-device/issues/459~~ - -* ~~Implement a zip file compression for store and restore~~ - -* ~~Update the html to handle it~~ - - - -#### ~~#12 Less reboots due to memory leakage~~ - -* ~~Issue: #414 & #425 #430~~ - - - -#### ~~#6 Check for double ROI names~~ - implemented v8.0.0 - -~~Check during configuration, that ROI names are unique.~~ - -~~To do:~~ - -* ~~Implementation of ROI name checking in html code before saving analog or digital ROIs~~ - - - #### ~~#4 Initial Shifting and Rotation~~ - implemented v7.0.0 * ~~https://github.com/jomjol/AI-on-the-edge-device/issues/123~~ @@ -276,6 +214,27 @@ Technically not possible, as the limiting factor for the power consumption is no + + +____ + +#### #2 MQTT-controll with callback +* https://github.com/jomjol/AI-on-the-edge-device/issues/105 + +Extend the MQTT client to also enable callbacks for configuration setting + +To do: + +* implement callback for receiving information and override `config.ini` settings + +* change configuration management to handle online updates (currently changes need a restart) + +* think about the startup, as there the default config is loaded + + + +____ + #### ~~#1 Optional GPIO for external flash/lighting~~ - implemented (v8.0.0) * ~~https://github.com/jomjol/AI-on-the-edge-device/issues/133~~ @@ -289,6 +248,3 @@ Technically not possible, as the limiting factor for the power consumption is no * ~~Implementation of a software module for external light source (e.g. WS8132 LED controller, ...)~~ * ~~Update of the camera module to use the external light instead of the internal flash light~~ * ~~Adopt the configuration algorithm with a configurable light source~~ - - - diff --git a/code/components/jomjol_controlGPIO/SmartLeds.h b/code/components/jomjol_controlGPIO/SmartLeds.h index 4c46fec7..824eb337 100644 --- a/code/components/jomjol_controlGPIO/SmartLeds.h +++ b/code/components/jomjol_controlGPIO/SmartLeds.h @@ -269,8 +269,7 @@ private: std::unique_ptr< Rgb[] > _secondBuffer; Rgb *_buffer; - SemaphoreHandle_t _finishedFlag; -// xSemaphoreHandle _finishedFlag; + xSemaphoreHandle _finishedFlag; int _pixelPosition; int _componentPosition; diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 6b54f531..5bdd89c2 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -769,7 +769,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st zw = std::string(archive_filename); printf("Rohfilename: %s\n", zw.c_str()); - if (getFileType(zw) == "BIN") + if (toUpper(zw) == "FIRMWARE.BIN") { zw = _target_bin + zw; ret = zw; diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 7701546b..88a5fd41 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -35,7 +35,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution if (GENERAL[_analog]->ROI.size() == 0) return result; if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout _analog=" + std::to_string(_analog) + ", _extendedResolution=" + std::to_string(_extendedResolution) + ", prev=" + std::to_string(prev)); - + if (CNNType == Analogue || CNNType == Analogue100) { float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; @@ -147,6 +147,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger, if (AnalogerVorgaenger) { +// result = ZeigerEvalAnalogToDigitNeu(zahl, eval_vorgaenger); result = ZeigerEvalAnalogToDigitNeu(zahl, zahl_vorgaenger, eval_vorgaenger); if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybridNeu - Analoger Vorgänger, Bewertung über ZeigerEvalAnalogNeu = " + std::to_string(result) + " zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe)); @@ -215,22 +216,20 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor return result; } - /* if ((ziffer_vorgaenger >= DigitalUebergangsbereichVorgaengerAnalogToDigit ) && (ziffer_vorgaenger <= (10.0 - DigitalUebergangsbereichVorgaengerAnalogToDigit))) + if ((ziffer_vorgaenger >= DigitalUebergangsbereichVorgaengerAnalogToDigit ) && (ziffer_vorgaenger <= (10.0 - DigitalUebergangsbereichVorgaengerAnalogToDigit))) { - Bei DigitalUebergangsbereichVorgaengerAnalogToDigit verursacht runden weitere Fehler // kein Ziffernwechsel, da Vorgänger weit genug weg ist (0+/-DigitalUebergangsbereichVorgaenger) --> zahl wird gerundet if ((ergebnis_nachkomma <= 2) || (ergebnis_nachkomma >= 8)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht - result = ((int) trunc(zahl) + 10) % 10; - else result = ((int) round(zahl) + 10) % 10; - - result = ((int) trunc(zahl) + 10) % 10; + else + result = ((int) trunc(zahl) + 10) % 10; + if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - kein Ziffernwechsel, da Vorkomma weit genug weg = " + std::to_string(result) + " zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe)); return result; } -*/ - if (ziffer_vorgaenger <= 3 && eval_vorgaenger<9) // Nulldurchgang hat stattgefunden (!Bewertung über Prev_value und nicht Zahl!) --> hier aufrunden (2.8 --> 3, aber auch 3.1 --> 3) + + if (ziffer_vorgaenger <= 1 && eval_vorgaenger<9) // Nulldurchgang hat stattgefunden (!Bewertung über Prev_value und nicht Zahl!) --> hier aufrunden (2.8 --> 3, aber auch 3.1 --> 3) // aber Sonderfall ziffer_vorgaeger = 0.1 vor_vorgaenger 9.9 => eval_vorgaenger ist 9, damit hat Nulldurchgang nicht stattgefunden. { if (ergebnis_nachkomma > 5) @@ -242,15 +241,10 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor return result; } - // Vorlauf ziffer_vorgaenger <=9.9 und ergebnis_nachkomma >=0..1 (digits drehen nach umschalten nicht gleich weiter) - // Beispiel dig=4.0, ana=9.1 ==> dig=3 - - // Nachlauf ziffer_vorgaenger 0..2 und ergebnis_nachkomma 8..9 - // Beispiel dig=6.8, ana=2.2 ==> dig=7 - // dig=4.8, ana=5.5 => dig=4 - - // Aber zwischen ziffer_vorgaenger 3..8 keine Veränderung - if (ergebnis_nachkomma >= 1 || (ziffer_vorgaenger>3 && ziffer_vorgaenger<8) ) + // bleibt nur >= 9.5 --> noch kein Nulldurchgang --> 2.8 --> 2, und 3.1 --> 2 + // hier auf 4 reduziert, da erst ab Vorgänder 9 anfängt umzustellen. Bei 9.5 Vorgänger kann die aktuelle + // Zahl noch x.4 - x.5 sein. + if (ergebnis_nachkomma >= 4) result = ergebnis_vorkomma; else result = (ergebnis_vorkomma - 1 + 10) % 10; diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h index 055df5e3..e53ec9c0 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h @@ -28,7 +28,7 @@ protected: float DigitalUnschaerfe = 0.2; int DigitalBand = 3; float DigitalAnalogerVorgaengerUebergangsbereich = 2; - // nicht mehr benötigt float DigitalUebergangsbereichVorgaengerAnalogToDigit = 1; // war vorher 2 + float DigitalUebergangsbereichVorgaengerAnalogToDigit = 1; // war vorher 2 float DigitalUebergangsbereichVorgaenger = 0.7; // 9.3 - 0.7 float DigitalUebergangsbereichVorlauf = 9.7; // Vorlauf-Nulldurchgang passiert erst ab ca. 9.7 diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 615795c9..db72aedf 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -404,7 +404,7 @@ string ClassFlowControll::GetPrevalue(std::string _number) std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern) { - double zw; + float zw; char* p; _newvalue = trim(_newvalue); @@ -416,7 +416,7 @@ std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string } else { - zw = strtod(_newvalue.c_str(), &p); + zw = strtof(_newvalue.c_str(), &p); if (zw == 0) return "- Error in String to Value Conversion!!! Must be of format value=123.456"; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index a894ba09..178d209f 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -35,7 +35,6 @@ std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, else json += " \"value\": \"\"," + _lineend; json += " \"raw\": \"" + NUMBERS[i]->ReturnRawValue + "\"," + _lineend; - json += " \"pre\": \"" + NUMBERS[i]->ReturnPreValue + "\"," + _lineend; json += " \"error\": \"" + NUMBERS[i]->ErrorMessageText + "\"," + _lineend; if (NUMBERS[i]->ReturnRateValue.length() > 0) json += " \"rate\": " + NUMBERS[i]->ReturnRateValue + "," + _lineend; @@ -79,7 +78,7 @@ void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _exte if (NUMBERS[j]->name == _numbers) { NUMBERS[j]->PreValue = zw; - NUMBERS[j]->ReturnPreValue = RundeOutput(zw, NUMBERS[j]->Nachkomma); + NUMBERS[j]->ReturnPreValue = std::to_string(zw); NUMBERS[j]->PreValueOkay = true; if (_extern) { diff --git a/code/components/jomjol_mqtt/interface_mqtt.cpp b/code/components/jomjol_mqtt/interface_mqtt.cpp index 47c6a4bb..1789d252 100644 --- a/code/components/jomjol_mqtt/interface_mqtt.cpp +++ b/code/components/jomjol_mqtt/interface_mqtt.cpp @@ -52,7 +52,6 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) break; case MQTT_EVENT_DISCONNECTED: ESP_LOGI(TAG_INTERFACEMQTT, "MQTT_EVENT_DISCONNECTED"); - esp_mqtt_client_reconnect(client); break; case MQTT_EVENT_SUBSCRIBED: ESP_LOGI(TAG_INTERFACEMQTT, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id); @@ -100,6 +99,17 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st int _lzw = _zwmessage.length(); +/* LWTContext = _LWTContext; + + mqtt_cfg.uri = _mqttURI.c_str(); + mqtt_cfg.client_id = _clientid.c_str(); + mqtt_cfg.lwt_topic = _LWTContext.c_str(); + mqtt_cfg.lwt_msg = _zwmessage.c_str(); + mqtt_cfg.lwt_retain = 1; + mqtt_cfg.lwt_msg_len = _lzw; + mqtt_cfg.keepalive = _keepalive; +*/ + esp_mqtt_client_config_t mqtt_cfg = { .uri = _mqttURI.c_str(), .client_id = _clientid.c_str(), @@ -154,6 +164,39 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st return true; } +/* +void MQTTReConnect(){ + std::string _zwmessage = "connection lost"; + int _lzw = _zwmessage.length(); + +>>>>>>> Stashed changes + client = esp_mqtt_client_init(&mqtt_cfg); + if (client) + { + if (esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client) != ESP_OK) + LogFile.WriteToFile("MQTT - Could not register event!"); + if (esp_mqtt_client_start(client) != ESP_OK) + LogFile.WriteToFile("MQTT - Could not start client!"); + +<<<<<<< Updated upstream + if(MQTTPublish(_LWTContext, "", 1)) { + LogFile.WriteToFile("MQTT - Client init successful"); + } +======= + if (mqtt_connected) + MQTTPublish(LWTContext, "", 1); + else + LogFile.WriteToFile("Problem with (Re)Connection not successful!"); + +>>>>>>> Stashed changes + } + else + { + LogFile.WriteToFile("MQTT - Could not Init client!"); + } + +} +*/ void MQTTdestroy() { if (client != NULL) { diff --git a/code/dependencies.lock b/code/dependencies.lock index 6e6120b5..de82408d 100644 --- a/code/dependencies.lock +++ b/code/dependencies.lock @@ -1,3 +1,2 @@ -manifest_hash: 4e37bb0f9273c4de05f38688720fe32aa6e5b892452694a4f7a2ca1659f02cf6 -target: esp32 +manifest_hash: 45994dbfed009907994c31f6d279c5861a1eacbf219ce8b58e74e39b3393816a version: 1.0.0 diff --git a/code/main/main.cpp b/code/main/main.cpp index 40fbb43b..4a79fb05 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -118,8 +118,6 @@ bool Init_NVS_SDCard() void task_NoSDBlink(void *pvParameter) { -// esp_rom_gpio_pad_select_gpio(BLINK_GPIO); - gpio_pad_select_gpio(BLINK_GPIO); gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); diff --git a/code/platformio.ini b/code/platformio.ini index 9a39a856..39b6032c 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -13,12 +13,14 @@ src_dir = main [env:esp32cam] -;platform = espressif32@4.4.0 -platform = espressif32@5.2.0 +platform = espressif32@4.4.0 +;platform = espressif32@5.1.0 +;platform = espressif32 board = esp32cam ;board = m5stack-core-esp32 framework = espidf +;board_build.partitions = partitions_singleapp.csv board_build.partitions = partitions.csv lib_deps = diff --git a/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp new file mode 100644 index 00000000..9d7c9b09 --- /dev/null +++ b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp @@ -0,0 +1,107 @@ +#include +#include + +class UnderTestCNN : public ClassFlowCNNGeneral { + public: + using ClassFlowCNNGeneral::ZeigerEvalAnalogNeu; + using ClassFlowCNNGeneral::ZeigerEvalHybridNeu; + using ClassFlowCNNGeneral::ClassFlowCNNGeneral; + +}; + + +/** + * @brief test if all combinations of digit + * evaluation are running correctly + */ +void test_ZeigerEval() +{ + UnderTestCNN undertest = UnderTestCNN(nullptr, Digital100); + + // 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); + 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)); + + 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)); + + 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)); + +} + +/** + * @brief test if all combinations of digit + * evaluation are running correctly + */ +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)); + + // 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("ZeigerEvalHybridNeu(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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); + // 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)); + + // 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)); + + // pre = 9.9 (0.0 raw) + // zahl = 1.8 + TEST_ASSERT_EQUAL(2, undertest.ZeigerEvalHybridNeu(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)); + + + // issue #879 vorgaenger is -1, zahl = 6.7 + //TEST_ASSERT_EQUAL(7, undertest.ZeigerEvalHybrid(6.7, -1.0, -1)); + + +} + diff --git a/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp b/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp index 47c61775..758868d0 100644 --- a/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp +++ b/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp @@ -101,7 +101,7 @@ void test_doFlow() { digits = { 1.1, 9.0, 4.0}; analogs = { 8.1, 2.6, 6.25, 9.7}; - expected = "193.8259"; + expected = "194.8259"; result = process_doFlow(analogs, digits); TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); @@ -303,113 +303,6 @@ void test_doFlow() { result = process_doFlow(analogs, digits, Digital100, false, true, -3); TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - // Fehler bei V12.0.1 - // Lokal - digits = { 9.8, 9.8, 1.9, 0.9, 0.9, 9.9, 2.9, 4.8}; // 211.0355 als falsches Ergebnis - analogs = { 5.5}; - expected = "211.0345"; - expected_extended= "211.03455"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, -3); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, -3); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - // Fehler bei V12.0.1 - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333 - digits = { 2.2, 4.5, 5.9}; // 245.938 als falsches Ergebnis - analogs = { 9.4, 3.8, 8.6}; - expected = "245.938"; - expected_extended= "245.9386"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, 0); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, 0); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - // Fehler bei V12.0.1 - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333 - digits = { 2.2, 4.5, 5.9}; // 245.938 kein Fehler. Aber Grenzfall, deshalb mit als Test aufgenommen. - analogs = { 9.4, 3.8, 8.6}; - expected = "245.938"; - expected_extended= "245.9386"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, 0); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, 0); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - // Fehler bei V12.0.1 - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1265523710 - digits = { 2.0, 4.0, 6.8}; // 246.2045 als falsches Ergebnis - analogs = { 2.2, 0.1, 4.5}; - expected = "247.204"; - expected_extended= "247.2045"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, 0); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, 0); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - - // Fehler bei V12.0.1 - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issue-1391153343 - digits = { 1.0, 4.0, 2.0}; // 142.9269 als falsches Ergebnis - analogs = { 9.2, 2.5, 6.8, 9.0}; - expected = "141.9269"; - expected_extended= "141.92690"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, 0); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, 0); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - - // Fehler bei V12.0.1 - // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1262626388 - digits = { 1.2, 6.8, 0.0, 0.0, 5.0, 2.8}; //170.05387 als falsches Ergebnis - analogs = { 8.7}; - expected = "170.0528"; - expected_extended= "170.05287"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, -3); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, -3); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); - - - // Fehler bei rolling post V12.0.1 - // lokal watermeter1 - digits = { 0.0, 0.0, 9.0, 1.0}; //91.88174 als falsches Ergebnis - analogs = {9.0, 8.0, 1.8, 7.4}; - expected = "90.8817"; - expected_extended= "90.88174"; - - // extendResolution=false - result = process_doFlow(analogs, digits, Digital100, false, false, 0); - TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); - - // checkConsistency=false und extendResolution=true - result = process_doFlow(analogs, digits, Digital100, false, true, 0); - TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); } @@ -495,11 +388,9 @@ std::string process_doFlow(std::vector analog, std::vector digits, } string time; - // run test TEST_ASSERT_TRUE(undertestPost->doFlow(time)); - return undertestPost->getReadout(0); } diff --git a/code/test/test_suite_flowcontroll.cpp b/code/test/test_suite_flowcontroll.cpp index 10dc3a83..62c9fea1 100644 --- a/code/test/test_suite_flowcontroll.cpp +++ b/code/test/test_suite_flowcontroll.cpp @@ -1,4 +1,5 @@ #include +#include "components/jomjol-flowcontroll/test_cnnflowcontroll.cpp" #include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp" // SD-Card //////////////////// #include "nvs_flash.h" @@ -7,24 +8,6 @@ #include "driver/sdmmc_host.h" #include "driver/sdmmc_defs.h" static const char *TAGMAIN = "main"; -#define __SD_USE_ONE_LINE_MODE__ -#include "server_GPIO.h" - - - - -void initGPIO() -{ - gpio_config_t io_conf; - //set as output mode - io_conf.mode = gpio_mode_t::GPIO_MODE_INPUT; - //bit mask of the pins that you want to set,e.g.GPIO18/19 - io_conf.pull_down_en = gpio_pulldown_t::GPIO_PULLDOWN_ENABLE; - //set pull-up mode - io_conf.pull_up_en = gpio_pullup_t::GPIO_PULLUP_DISABLE; - //configure GPIO with the given settings - gpio_config(&io_conf); -} bool Init_NVS_SDCard() { @@ -97,10 +80,11 @@ bool Init_NVS_SDCard() */ extern "C" void app_main() { - initGPIO(); Init_NVS_SDCard(); UNITY_BEGIN(); +// RUN_TEST(test_ZeigerEval); +// RUN_TEST(test_ZeigerEvalHybrid); RUN_TEST(test_doFlow); UNITY_END(); diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index caf488b6..b84e4ae1 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -9,83 +9,65 @@ h1 {font-size: 2em;} h2 {font-size: 1.5em; margin-block-start: 0.0em; margin-block-end: 0.2em;} h3 {font-size: 1.2em;} -h4 { - margin-bottom: 0; -} - p {font-size: 1em;} -table { - border: 0pt; - border-collapse: collapse; -} - - -tr { - border-bottom: 1px solid lightgray; -} - -td { - padding: 10px; -} - .button { - padding: 5px 20px; + padding: 5px 20px; width: 211px; - font-size: 16px; + font-size: 16px; } textarea { - font-size: 14px; + font-size: 14px; } .description { - color: black; - font-size: 80%; + color: black; + font-size: 80%; } .disabled { - color:lightgrey; + color:lightgrey; } .smallSelect { - width: 30px; + width: 30px; } .invalid-input { - background-color: #FFAA00; + background-color: #FFAA00; } .hidden { - display: none; + display: none; } - -.expert { - background-color: #ffc5c5; -} - -.indent1 { - padding-left: 40px; -} - -.indent2 { - padding-left: 69px; -} - -

Configuration

- - -

+ + + + + +
+

Config.ini:

+
+ + +
+ +
+