diff --git a/README.md b/README.md index 9e097f59..299c939b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ If you would like to support the developer with a cup of coffee you can do that ### Known Issues * slow response of web server during picture analysis +* spontaneous reboots (mostly due to html access during image processing) - self recovery implemented ------ @@ -40,7 +41,15 @@ If you would like to support the developer with a cup of coffee you can do that -##### Rolling - (2021-01-05) +##### Rolling - (2021-01-17) + +* Disabling of digital counters implemented +* Attention: do not disable digital and analog! +* Bug fixing: + + * Configuration of analog counters on html-page failed (enable/disable, undefined ROIs) + +2021-01-05 * Configuration: simple enabling / disabling of analog counters diff --git a/code/components/connect_wlan/connect_wlan.cpp b/code/components/connect_wlan/connect_wlan.cpp index dd66e62a..04e6d96a 100644 --- a/code/components/connect_wlan/connect_wlan.cpp +++ b/code/components/connect_wlan/connect_wlan.cpp @@ -217,7 +217,7 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net netmask = std::string(ip4addr_ntoa(&ip_info2.netmask)); gw = std::string(ip4addr_ntoa(&ip_info2.gw)); - vEventGroupDelete(wifi_event_group); +// vEventGroupDelete(wifi_event_group); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp b/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp index ca03486f..82cc4b94 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp @@ -3,7 +3,7 @@ #include #include #include - + // #define OHNETFLITE #ifndef OHNETFLITE @@ -97,7 +97,7 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph) if (aktparamgraph[0] == ';') { disabled = true; - while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)); + while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph)); printf("[Analog] is disabled !!!\n"); return true; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowAnalog.h b/code/components/jomjol_flowcontroll/ClassFlowAnalog.h index 64de44e0..6ef2336d 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAnalog.h +++ b/code/components/jomjol_flowcontroll/ClassFlowAnalog.h @@ -40,6 +40,6 @@ public: std::vector GetHTMLInfo(); int AnzahlROIs(){return ROI.size();}; - string name(){return "ClassFlowAnalog";}; + string name(){return "ClassFlowAnalog";}; }; diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 117d980f..444f8619 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -76,6 +76,8 @@ void ClassFlowControll::SetInitialParameter(void) flowanalog = NULL; flowpostprocessing = NULL; disabled = false; + aktRunNr = 0; + aktstatus = "Startup"; } @@ -241,6 +243,21 @@ bool ClassFlowControll::doFlow(string time) return result; } +void ClassFlowControll::UpdateAktStatus(std::string _flow) +{ + aktstatus = gettimestring("%Y%m%d-%H%M%S"); + aktstatus = aktstatus + "\t" + std::to_string(aktRunNr) + "\t"; + + if (_flow == "ClassFlowMakeImage") + aktstatus = aktstatus + "Taking Raw Image"; + else + if (_flow == "ClassFlowAlignment") + aktstatus = aktstatus + "Aligning Image"; + + +} + + string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false) { if (flowpostprocessing) diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index d46d1829..6ef26a2c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -28,6 +28,9 @@ protected: bool SetupModeActive; void SetInitialParameter(void); std::string aktstatus; + int aktRunNr; + + void UpdateAktStatus(std::string _flow); public: void InitFlow(std::string config); diff --git a/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp b/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp index a259cee2..9225ce6e 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp @@ -85,13 +85,21 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph) aktparamgraph = trim(aktparamgraph); if (aktparamgraph.size() == 0) - if (!this->GetNextParagraph(pfile, aktparamgraph)) + if (!this->GetNextParagraph(pfile, aktparamgraph)) return false; - - if (aktparamgraph.compare("[Digits]") != 0) // Paragraph passt nicht + if ((aktparamgraph.compare("[Digits]") != 0) && (aktparamgraph.compare(";[Digits]") != 0)) // Paragraph passt nich zu MakeImage return false; + if (aktparamgraph[0] == ';') + { + disabled = true; + while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph)); + printf("[Digits] is disabled !!!\n"); + return true; + } + + while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph)) { zerlegt = this->ZerlegeZeile(aktparamgraph); @@ -169,6 +177,9 @@ string ClassFlowDigit::getHTMLSingleStep(string host) bool ClassFlowDigit::doFlow(string time) { + if (disabled) + return true; + if (!doAlignAndCut(time)){ return false; }; @@ -182,6 +193,9 @@ bool ClassFlowDigit::doFlow(string time) bool ClassFlowDigit::doAlignAndCut(string time) { + if (disabled) + return true; + CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage(); for (int i = 0; i < ROI.size(); ++i) @@ -200,6 +214,9 @@ bool ClassFlowDigit::doAlignAndCut(string time) bool ClassFlowDigit::doNeuralNetwork(string time) { + if (disabled) + return true; + string logPath = CreateLogFolder(time); #ifndef OHNETFLITE diff --git a/code/components/jomjol_flowcontroll/ClassFlowDigit.h b/code/components/jomjol_flowcontroll/ClassFlowDigit.h index d3043642..941c0f27 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDigit.h +++ b/code/components/jomjol_flowcontroll/ClassFlowDigit.h @@ -23,7 +23,7 @@ protected: bool SaveAllFiles; ClassFlowAlignment* flowpostalignment; - + bool doNeuralNetwork(string time); bool doAlignAndCut(string time); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index f48f4fe6..ced38fef 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -14,17 +14,28 @@ string ClassFlowPostProcessing::GetPreValue() { std::string result; + bool isAnalog = false; + bool isDigit = false; + + int AnzahlAnalog = 0; result = RundeOutput(PreValue, -DecimalShift); for (int i = 0; i < ListFlowControll->size(); ++i) { if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0) { - int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs(); - result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift); + isAnalog = true; + AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs(); + } + if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0) + { + isDigit = true; } } + if (isDigit && isAnalog) + result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift); + return result; } @@ -75,17 +86,24 @@ bool ClassFlowPostProcessing::LoadPreValue(void) ReturnValue = to_string(Value); ReturnValueNoError = ReturnValue; - // falls es Analog gibt, dann die Anzahl der Nachkommastellen feststellen und entsprechend runden: + bool isAnalog = false; + bool isDigit = false; + int AnzahlAnalog = 0; + for (int i = 0; i < ListFlowControll->size(); ++i) { if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0) - { - int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs(); - ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift); - ReturnValueNoError = ReturnValue; - } + isAnalog = true; + if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0) + isDigit = true; } - + + if (isDigit || isAnalog) + { + ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift); + ReturnValueNoError = ReturnValue; + } + return true; } @@ -119,28 +137,6 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime) } -/* -ClassFlowPostProcessing::ClassFlowPostProcessing() -{ - PreValueUse = false; - PreValueAgeStartup = 30; - AllowNegativeRates = false; - MaxRateValue = 0.1; - ErrorMessage = false; - ListFlowControll = NULL; - PreValueOkay = false; - useMaxRateValue = false; - checkDigitIncreaseConsistency = false; - DecimalShift = 0; - ErrorMessageText = ""; - disabled = false; - disabled = false; - - - FilePreValue = FormatFileName("/sdcard/config/prevalue.ini"); -} -*/ - ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector* lfc) { PreValueUse = false; @@ -273,6 +269,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) int AnzahlAnalog = 0; string zw; time_t imagetime = 0; + string rohwert; ErrorMessageText = ""; @@ -311,6 +308,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) // isdigit = true; digit = "12N"; // isanalog = true; analog = "456"; + ReturnRawValue = ""; + if (isdigit) ReturnRawValue = digit; if (isdigit && isanalog) @@ -318,8 +317,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if (isanalog) ReturnRawValue = ReturnRawValue + analog; + + if (!isdigit) + { + AnzahlAnalog = 0; + } + ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift); + rohwert = ReturnRawValue; + if (!PreValueUse || !PreValueOkay) { ReturnValue = ReturnRawValue; @@ -354,7 +361,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if ((!AllowNegativeRates) && (Value < PreValue)) { - ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " "; + ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue; Value = PreValue; zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift); } @@ -397,10 +404,24 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror) string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){ std::stringstream stream; + int _zw = _in; +// printf("AnzNachkomma: %d\n", _anzNachkomma); + if (_anzNachkomma < 0) { _anzNachkomma = 0; } - stream << std::fixed << std::setprecision(_anzNachkomma) << _in; + + if (_anzNachkomma > 0) + { + stream << std::fixed << std::setprecision(_anzNachkomma) << _in; + return stream.str(); + } + else + { + stream << _zw; + } + + return stream.str(); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 2c1371e3..435c6d48 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -34,7 +34,6 @@ protected: string RundeOutput(float _in, int _anzNachkomma); public: -// ClassFlowPostProcessing(); ClassFlowPostProcessing(std::vector* lfc); bool ReadParameter(FILE* pfile, string& aktparamgraph); bool doFlow(string time); diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 963fa9b5..b4ff5a25 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -470,21 +470,26 @@ esp_err_t handler_prevalue(httpd_req_t *req) const char* resp_str; string zw; -// printf("handler_prevalue:\n"); printf(req->uri); printf("\n"); +#ifdef DEBUG_DETAIL_ON + printf("handler_prevalue:\n"); printf(req->uri); printf("\n"); +#endif char _query[100]; char _size[10] = ""; if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK) { -// printf("Query: "); printf(_query); printf("\n"); +#ifdef DEBUG_DETAIL_ON + printf("Query: "); printf(_query); printf("\n"); +#endif + if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK) { #ifdef DEBUG_DETAIL_ON printf("Value: "); printf(_size); printf("\n"); #endif } - } + } if (strlen(_size) == 0) zw = tfliteflow.GetPrevalue(); diff --git a/code/main/version.cpp b/code/main/version.cpp index 475c48cb..2524b7ba 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="e520609"; +const char* GIT_REV="9bb715f"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2021-01-05 20:40"; \ No newline at end of file +const char* BUILD_TIME="2021-01-17 12:21"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 475c48cb..2524b7ba 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="e520609"; +const char* GIT_REV="9bb715f"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2021-01-05 20:40"; \ No newline at end of file +const char* BUILD_TIME="2021-01-17 12:21"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index f65bc1da..243da78b 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index b6fd554b..5a3da29e 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index a3df0519..757146bc 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index f21ad335..080d89d6 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -147,16 +147,20 @@ function EnDisableAnalog() { $("#div2").addClass("disabledDiv"); } - sah1(document.getElementById("div1")); + sah1(document.getElementById("div1"), !isEnabled); + if (isEnabled) + { + UpdateROIs(); + } } - function sah1(el) { +function sah1(el, _target) { try { - el.disabled = el.disabled ? false : true; + el.disabled = _target; } catch (E) {} if (el.childNodes && el.childNodes.length > 0) { for (var x = 0; x < el.childNodes.length; x++) { - sah1(el.childNodes[x]); + sah1(el.childNodes[x], _target); } } } @@ -219,7 +223,7 @@ function ChangeSelection(){ } function SaveToConfig(){ - _enabled = document.getElementById("index").checked; + _enabled = document.getElementById("Category_Analog_enabled").checked; SaveROIToConfig(ROIInfo, "[Analog]", basepath, _enabled); UpdatePage(); } @@ -346,22 +350,25 @@ function ParseIni(_basepath) { } - function draw() { + function draw() { var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); context.drawImage(imageObj, 0, 0); - lw = 4 - context.lineWidth = lw; - context.strokeStyle = "#FF0000"; - var x0 = parseInt(rect.startX) - parseInt(lw/2); - var y0 = parseInt(rect.startY) - parseInt(lw/2); - var dx = parseInt(rect.w) + parseInt(lw); - var dy = parseInt(rect.h) + parseInt(lw); - context.strokeRect(x0, y0, dx, dy); - ROIInfo[aktindex]["x"] = rect.startX; - ROIInfo[aktindex]["y"] = rect.startY; - ROIInfo[aktindex]["dx"] = rect.w; - ROIInfo[aktindex]["dy"] = rect.h; + if (document.getElementById("Category_Analog_enabled").checked) + { + lw = 4 + context.lineWidth = lw; + context.strokeStyle = "#FF0000"; + var x0 = parseInt(rect.startX) - parseInt(lw/2); + var y0 = parseInt(rect.startY) - parseInt(lw/2); + var dx = parseInt(rect.w) + parseInt(lw); + var dy = parseInt(rect.h) + parseInt(lw); + context.strokeRect(x0, y0, dx, dy); + ROIInfo[aktindex]["x"] = rect.startX; + ROIInfo[aktindex]["y"] = rect.startY; + ROIInfo[aktindex]["dx"] = rect.w; + ROIInfo[aktindex]["dy"] = rect.h; + } } function getCoords(elem) { // crossbrowser version diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index f569185f..639e787d 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -179,8 +179,10 @@ textarea { - -

Digits

+ + + +

Digits

@@ -736,6 +738,7 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){ function UpdateInput() { document.getElementById("Category_Analog_enabled").checked = category["Analog"]["enabled"]; + document.getElementById("Category_Digits_enabled").checked = category["Digits"]["enabled"]; document.getElementById("Category_MQTT_enabled").checked = category["MQTT"]["enabled"]; WriteParameter(param, category, "MakeImage", "LogImageLocation", true); @@ -787,6 +790,7 @@ function UpdateInput() { function ReadParameterAll() { category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked; + category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked; category["MQTT"]["enabled"] = document.getElementById("Category_MQTT_enabled").checked; ReadParameter(param, "MakeImage", "LogImageLocation", true); @@ -853,6 +857,7 @@ function FormatDecimalValue(_param, _cat, _name) { function UpdateAfterCategoryCheck() { ReadParameterAll(); category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked; + category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked; UpdateInput(); } diff --git a/sd-card/html/edit_digits.html b/sd-card/html/edit_digits.html index 909ecdab..1ea6c861 100644 --- a/sd-card/html/edit_digits.html +++ b/sd-card/html/edit_digits.html @@ -55,7 +55,10 @@ th, td { -

Edit Digits

+

+ Edit Digits

+ +
@@ -91,7 +94,9 @@ th, td { -
y: dy:
+ + +
@@ -102,6 +107,7 @@ th, td { +