diff --git a/FeatureRequest.md b/FeatureRequest.md index 5521641e..03953fbf 100644 --- a/FeatureRequest.md +++ b/FeatureRequest.md @@ -11,6 +11,16 @@ ____ +#### #7 Extended Error Handling + +Check different types of error (e.g. tflite not availabe) and generate an error on the html page. + +To do: + +* Make a list of "important" errors +* Implement a checking algo +* Extend the firmware and html page for the error handling + #### #6 Check for double ROI names Check during configuration, that ROI names are unique. diff --git a/README.md b/README.md index a9b484de..4321fe52 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ respectively ESP32-Cam housing only: https://www.thingiverse.com/thing:4571627 + + @@ -45,7 +47,25 @@ In other cases you can contact the developer via email: + +* MQTT: standardization of the naming - only the main topic needs to be specified. The subtopics will be named automatically. This is necessary to handle the multi number option. + **ATTENTION**: the parameter `maintopic` needs to be set + +* Remark: + + * This is an early stage - do only use it on a test system and make a backup of your configuration. + * The documentation is not updated yet. + +* **ATTENTION: the configuration and prevalue files are modified automatically and will not be backward compatible!** + + + +Rolling - (2021-06-17) * bug fix setting hostname, Flash-LED not off during reboot diff --git a/code/components/connect_wlan.zip b/code/components/connect_wlan.zip deleted file mode 100644 index 31ab9b29..00000000 Binary files a/code/components/connect_wlan.zip and /dev/null differ diff --git a/code/components/jomjol_flowcontroll/ClassFlow.cpp b/code/components/jomjol_flowcontroll/ClassFlow.cpp index 3ee76cfb..97d77dfb 100644 --- a/code/components/jomjol_flowcontroll/ClassFlow.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlow.cpp @@ -94,6 +94,23 @@ string ClassFlow::getReadout() return string(); } +std::string ClassFlow::GetParameterName(std::string _input) +{ + string _param; + int _pospunkt = _input.find_first_of("."); + if (_pospunkt > -1) + { + _param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1); + } + else + { + _param = _input; + } +// printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt); + return _param; +} + + bool ClassFlow::getNextLine(FILE* pfile, string *rt) { char zw[1024]; @@ -102,13 +119,13 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt) *rt = ""; return false; } - fgets(zw, 1024, pfile); - printf("%s", zw); - if ((strlen(zw) == 0) && feof(pfile)) + if (!fgets(zw, 1024, pfile)) { *rt = ""; + printf("END OF FILE\n"); return false; } + printf("%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 diff --git a/code/components/jomjol_flowcontroll/ClassFlow.h b/code/components/jomjol_flowcontroll/ClassFlow.h index bcad7b4f..4df4777c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlow.h +++ b/code/components/jomjol_flowcontroll/ClassFlow.h @@ -37,6 +37,8 @@ protected: virtual void SetInitialParameter(void); + std::string GetParameterName(std::string _input); + bool disabled; public: diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 921e40b0..48ff7fc5 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -275,7 +275,7 @@ string ClassFlowControll::getReadoutAll(int _type) out = out + numbers[i]->ReturnValue; break; case READOUT_TYPE_PREVALUE: - out = out + std::to_string(numbers[i]->PreValue); + out = out + numbers[i]->ReturnPreValue; break; case READOUT_TYPE_RAWVALUE: out = out + numbers[i]->ReturnRawValue; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp index 1d0e4c1b..fe73a89f 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -13,6 +13,9 @@ void ClassFlowMQTT::SetInitialParameter(void) topicError = ""; topicRate = ""; topicTimeStamp = ""; + maintopic = ""; + mainerrortopic = ""; + clientname = "watermeter"; OldValue = ""; flowpostprocessing = NULL; @@ -88,33 +91,23 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) { this->uri = zerlegt[1]; } - if ((toUpper(zerlegt[0]) == "TOPIC") && (zerlegt.size() > 1)) - { - this->topic = zerlegt[1]; - } - if ((toUpper(zerlegt[0]) == "TOPICERROR") && (zerlegt.size() > 1)) - { - this->topicError = zerlegt[1]; - } - if ((toUpper(zerlegt[0]) == "TOPICRATE") && (zerlegt.size() > 1)) - { - this->topicRate = zerlegt[1]; - } - if ((toUpper(zerlegt[0]) == "TOPICTIMESTAMP") && (zerlegt.size() > 1)) - { - this->topicTimeStamp = zerlegt[1]; - } if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1)) { this->clientname = zerlegt[1]; } + if (((toUpper(zerlegt[0]) == "TOPIC") || (toUpper(zerlegt[0]) == "MAINTOPIC")) && (zerlegt.size() > 1)) + { + maintopic = zerlegt[1]; + } } - if ((uri.length() > 0) && (topic.length() > 0)) + if ((uri.length() > 0) && (maintopic.length() > 0)) { - MQTTInit(uri, clientname, user, password, topicError, 60); + mainerrortopic = maintopic + "/connection"; + MQTTInit(uri, clientname, user, password, mainerrortopic, 60); + MQTTPublish(mainerrortopic, "connected"); } return true; @@ -128,13 +121,39 @@ bool ClassFlowMQTT::doFlow(string zwtime) std::string resultrate = ""; std::string resulttimestamp = ""; string zw = ""; + string namenumber = ""; + + MQTTPublish(mainerrortopic, "connected"); if (flowpostprocessing) { - result = flowpostprocessing->getReadoutParam(false, true); - resulterror = flowpostprocessing->getReadoutError(); - resultrate = flowpostprocessing->getReadoutRate(); - resulttimestamp = flowpostprocessing->getReadoutTimeStamp(); + std::vector NUMBERS = flowpostprocessing->GetNumbers(); + + for (int i = 0; i < NUMBERS.size(); ++i) + { + result = NUMBERS[i]->ReturnValueNoError; + resulterror = NUMBERS[i]->ErrorMessageText; + resultrate = std::to_string(NUMBERS[i]->FlowRateAct); + resulttimestamp = NUMBERS[i]->timeStamp; + + namenumber = NUMBERS[i]->name; + if (namenumber == "default") + namenumber = maintopic + "/"; + else + namenumber = maintopic + "/" + namenumber + "/"; + + zw = namenumber + "value"; + MQTTPublish(zw, result); + + zw = namenumber + "error"; + MQTTPublish(zw, resulterror, 1); + + zw = namenumber + "rate"; + MQTTPublish(zw, resultrate); + + zw = namenumber + "timestamp"; + MQTTPublish(zw, resulttimestamp); + } } else { @@ -149,25 +168,9 @@ bool ClassFlowMQTT::doFlow(string zwtime) result = result + "\t" + zw; } } + MQTTPublish(topic, result); } - MQTTPublish(topic, result); - - if (topicError.length() > 0) { - if (resulterror.length() == 0) - { - resulterror = " "; - } - MQTTPublish(topicError, resulterror, 1); - } - - if (topicRate.length() > 0) { - MQTTPublish(topicRate, resultrate); - } - - if (topicTimeStamp.length() > 0) { - MQTTPublish(topicTimeStamp, resulttimestamp); - } OldValue = result; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h b/code/components/jomjol_flowcontroll/ClassFlowMQTT.h index 99035659..52e58d55 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.h @@ -12,7 +12,9 @@ protected: std::string uri, topic, topicError, clientname, topicRate, topicTimeStamp; std::string OldValue; ClassFlowPostProcessing* flowpostprocessing; - std::string user, password; + std::string user, password; + + std::string maintopic, mainerrortopic; void SetInitialParameter(void); public: diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 25c8c684..2d578efa 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -28,10 +28,11 @@ string ClassFlowPostProcessing::GetPreValue(std::string _number) if (NUMBERS[i]->name == _number) index = i; - result = RundeOutput(NUMBERS[index]->PreValue, -NUMBERS[index]->DecimalShift); +// result = RundeOutput(NUMBERS[index]->PreValue, -NUMBERS[index]->DecimalShift); + result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->Nachkomma); - if (NUMBERS[index]->digit_roi && NUMBERS[index]->analog_roi) - result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->AnzahlAnalog - NUMBERS[index]->DecimalShift); +// if (NUMBERS[index]->digit_roi && NUMBERS[index]->analog_roi) +// result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->AnzahlAnalog - NUMBERS[index]->DecimalShift); return result; } @@ -83,6 +84,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void) if (NUMBERS[j]->name == name) { NUMBERS[j]->PreValue = stof(zwvalue.c_str()); + NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma); time_t tStart; int yy, month, dd, hh, mm, ss; @@ -247,10 +249,10 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val { string _digit, _decpos; int _pospunkt = _decsep.find_first_of("."); -// printf("Name: %s, Pospunkt: %d\n", _name.c_str(), _pospunkt); + printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt); if (_pospunkt > -1) { - _digit = _decsep.substr(_pospunkt+1, _decsep.length() - _pospunkt - 1); + _digit = _decsep.substr(0, _pospunkt); } else { @@ -264,6 +266,8 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val if (NUMBERS[j]->name == _digit) NUMBERS[j]->DecimalShift = stoi(_value); + + NUMBERS[j]->Nachkomma = NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift; } } @@ -289,7 +293,9 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { zerlegt = this->ZerlegeZeile(aktparamgraph); - if ((toUpper(zerlegt[0].substr(0, 12)) == "DECIMALSHIFT") && (zerlegt.size() > 1)) + std::string _param = GetParameterName(zerlegt[0]); + + if ((toUpper(_param) == "DECIMALSHIFT") && (zerlegt.size() > 1)) { handleDecimalSeparator(zerlegt[0], zerlegt[1]); } @@ -364,8 +370,10 @@ void ClassFlowPostProcessing::InitNUMBERS() } } - flowDigit->UpdateNameNumbers(&name_numbers); - flowAnalog->UpdateNameNumbers(&name_numbers); + if (flowDigit) + flowDigit->UpdateNameNumbers(&name_numbers); + if (flowAnalog) + flowAnalog->UpdateNameNumbers(&name_numbers); printf("Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d\n", name_numbers.size(), anzDIGIT, anzANALOG); @@ -398,6 +406,7 @@ void ClassFlowPostProcessing::InitNUMBERS() _number->ReturnValue = ""; // korrigierter Rückgabewert, ggf. mit Fehlermeldung _number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check + _number->ReturnPreValue = ""; _number->PreValueOkay = false; _number->AllowNegativeRates = false; _number->MaxRateValue = 0.1; @@ -414,6 +423,8 @@ void ClassFlowPostProcessing::InitNUMBERS() _number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check + _number->Nachkomma = _number->AnzahlAnalog; + NUMBERS.push_back(_number); } @@ -519,6 +530,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) NUMBERS[j]->PreValueOkay = true; NUMBERS[j]->PreValue = NUMBERS[j]->Value; + NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma); NUMBERS[j]->lastvalue = flowMakeImage->getTimeImageTaken(); zwtime = ConvertTimeToString(NUMBERS[j]->lastvalue, PREVALUE_TIME_FORMAT_OUTPUT); @@ -547,9 +559,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if (NUMBERS[j]->useMaxRateValue && (abs(NUMBERS[j]->Value - NUMBERS[j]->PreValue) > NUMBERS[j]->MaxRateValue)) { - NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + zwvalue + " - Pre: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift) + " "; + NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " "; NUMBERS[j]->Value = NUMBERS[j]->PreValue; - zwvalue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift); + zwvalue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma); } NUMBERS[j]->ReturnValueNoError = zwvalue; @@ -566,6 +578,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if (NUMBERS[j]->ErrorMessageText.length() == 0) { NUMBERS[j]->PreValue = NUMBERS[j]->Value; + NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma); NUMBERS[j]->ErrorMessageText = "no error"; UpdatePreValueINI = true; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 4e8858ec..30cd4da9 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -23,11 +23,13 @@ struct NumberPost { float Value; // letzer ausgelesener Wert, inkl. Korrekturen string ReturnRawValue; // Rohwert (mit N & führenden 0) string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung - string ReturnValueNoError; // korrigierter Rückgabewert ohne Fehlermeldung + string ReturnPreValue; // korrigierter Rückgabewert ohne Fehlermeldung + string ReturnValueNoError; string ErrorMessageText; // Fehlermeldung bei Consistency Check int AnzahlAnalog; int AnzahlDigital; int DecimalShift; + int Nachkomma; // ClassFlowAnalog* ANALOG; // ClassFlowDigit* DIGIT; diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index ac119e22..e93573df 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -387,7 +387,7 @@ httpd_handle_t start_webserver(void) httpd_config_t config = { }; config.task_priority = tskIDLE_PRIORITY+5; - config.stack_size = 32384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab + config.stack_size = 32768; // bei 32k stürzt das Programm beim Bilderaufnehmen ab config.core_id = tskNO_AFFINITY; config.server_port = 80; config.ctrl_port = 32768; diff --git a/code/main/version.cpp b/code/main/version.cpp index a4f66cad..9f656470 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="f4edd36"; +const char* GIT_REV="45154cb"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2021-06-17 20:14"; \ No newline at end of file +const char* BUILD_TIME="2021-07-01 19:03"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index a4f66cad..9f656470 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="f4edd36"; +const char* GIT_REV="45154cb"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2021-06-17 20:14"; \ No newline at end of file +const char* BUILD_TIME="2021-07-01 19:03"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index dbf21255..1bbf3c6c 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 0eb809e4..cd6e5789 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 3fc4deee..a907ca0b 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/images/numbers.jpg b/images/numbers.jpg new file mode 100644 index 00000000..bf3e71c4 Binary files /dev/null and b/images/numbers.jpg differ diff --git a/images/powermeter.jpg b/images/powermeter.jpg new file mode 100644 index 00000000..4bc5a313 Binary files /dev/null and b/images/powermeter.jpg differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 6709a972..544b5e49 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -18,7 +18,7 @@ InitialMirror= false AlignmentAlgo = Default [Digits] -Model = /config/dig0901s1q.tflite +Model = /config/dig1030s1q.tflite ;LogImageLocation = /log/digit ;LogfileRetentionInDays = 3 ModelInputSize = 20 32 diff --git a/sd-card/config/dig0870s3q.tflite b/sd-card/config/dig0870s3q.tflite deleted file mode 100644 index c2dd4fdc..00000000 Binary files a/sd-card/config/dig0870s3q.tflite and /dev/null differ diff --git a/sd-card/config/dig0900s1q.tflite b/sd-card/config/dig0900s1q.tflite deleted file mode 100644 index 83f7d055..00000000 Binary files a/sd-card/config/dig0900s1q.tflite and /dev/null differ diff --git a/sd-card/config/dig0901s1q.tflite b/sd-card/config/dig0901s1q.tflite deleted file mode 100644 index d4780032..00000000 Binary files a/sd-card/config/dig0901s1q.tflite and /dev/null differ diff --git a/sd-card/config/dig1030s1q.tflite b/sd-card/config/dig1030s1q.tflite new file mode 100644 index 00000000..9de4e5f5 Binary files /dev/null and b/sd-card/config/dig1030s1q.tflite differ diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index 975bf3ae..b5d421bc 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -69,10 +69,16 @@ th, td {
+ + + + +
+

- Number: + Number:

- - - - -
- @@ -268,7 +268,6 @@ function UpdateROIs(){ document.getElementById("newROI").disabled = false; document.getElementById("deleteROI").disabled = true; document.getElementById("index").disabled = true; - document.getElementById("saveroi").disabled = true; document.getElementById("renameROI").disabled = true; document.getElementById("moveNext").disabled = true; document.getElementById("movePrevious").disabled = true; @@ -280,7 +279,6 @@ function UpdateROIs(){ document.getElementById("deleteROI").disabled = false; document.getElementById("renameROI").disabled = false; document.getElementById("index").disabled = false; - document.getElementById("saveroi").disabled = false; } var _index = document.getElementById("index"); diff --git a/sd-card/html/edit_config.html b/sd-card/html/edit_config.html index 23825d5e..a8c2067e 100644 --- a/sd-card/html/edit_config.html +++ b/sd-card/html/edit_config.html @@ -41,7 +41,6 @@ textarea {
-