From 7b2a80a13d94e9be1c5bc0247212c2366d29baef Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 25 Feb 2023 14:20:55 +0100 Subject: [PATCH] Enhance pages (#2075) * enhance pages * . * . * . * . * . * . --------- Co-authored-by: CaCO3 --- .../jomjol_flowcontroll/ClassFlowControll.cpp | 32 ++++-- .../jomjol_flowcontroll/ClassFlowControll.h | 2 + .../jomjol_tfliteclass/server_tflite.cpp | 108 +++++++++++------- sd-card/html/edit_alignment.html | 2 +- sd-card/html/edit_analog.html | 2 +- sd-card/html/edit_digits.html | 2 +- sd-card/html/edit_reference.html | 2 +- sd-card/html/index.html | 1 + sd-card/html/prevalue_set.html | 36 ++++-- 9 files changed, 121 insertions(+), 66 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 6eb6024a..145fe8b0 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -195,6 +195,7 @@ void ClassFlowControll::SetInitialParameter(void) disabled = false; aktRunNr = 0; aktstatus = "Flow task not yet created"; + aktstatusWithTime = aktstatus; } @@ -272,6 +273,8 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type) void ClassFlowControll::InitFlow(std::string config) { aktstatus = "Initialization"; + aktstatusWithTime = aktstatus; + //#ifdef ENABLE_MQTT //MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization", false); // Right now, not possible -> MQTT Service is going to be started later //#endif //ENABLE_MQTT @@ -318,6 +321,12 @@ void ClassFlowControll::InitFlow(std::string config) } +std::string* ClassFlowControll::getActStatusWithTime() +{ + return &aktstatusWithTime; +} + + std::string* ClassFlowControll::getActStatus() { return &aktstatus; @@ -327,6 +336,7 @@ std::string* ClassFlowControll::getActStatus() void ClassFlowControll::setActStatus(std::string _aktstatus) { aktstatus = _aktstatus; + aktstatusWithTime = aktstatus; } @@ -338,10 +348,10 @@ void ClassFlowControll::doFlowTakeImageOnly(string time) { if (FlowControll[i]->name() == "ClassFlowTakeImage") { zw_time = getCurrentTimeString("%H:%M:%S"); - std::string flowStatus = TranslateAktstatus(FlowControll[i]->name()); - aktstatus = flowStatus + " (" + zw_time + ")"; + aktstatus = TranslateAktstatus(FlowControll[i]->name()); + aktstatusWithTime = aktstatus + " (" + zw_time + ")"; #ifdef ENABLE_MQTT - MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false); + MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false); #endif //ENABLE_MQTT FlowControll[i]->doFlow(time); @@ -371,11 +381,11 @@ bool ClassFlowControll::doFlow(string time) for (int i = 0; i < FlowControll.size(); ++i) { zw_time = getCurrentTimeString("%H:%M:%S"); - std::string flowStatus = TranslateAktstatus(FlowControll[i]->name()); - aktstatus = flowStatus + " (" + zw_time + ")"; - //LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatus); + aktstatus = TranslateAktstatus(FlowControll[i]->name()); + aktstatusWithTime = aktstatus + " (" + zw_time + ")"; + //LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatusWithTime); #ifdef ENABLE_MQTT - MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false); + MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false); #endif //ENABLE_MQTT #ifdef DEBUG_DETAIL_ON @@ -405,11 +415,11 @@ bool ClassFlowControll::doFlow(string time) } zw_time = getCurrentTimeString("%H:%M:%S"); - std::string flowStatus = "Flow finished"; - aktstatus = flowStatus + " (" + zw_time + ")"; - //LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatus); + aktstatus = "Flow finished"; + aktstatusWithTime = aktstatus + " (" + zw_time + ")"; + //LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatusWithTime); #ifdef ENABLE_MQTT - MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false); + MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false); #endif //ENABLE_MQTT return result; diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index 1c42bc3e..6a2194de 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -37,6 +37,7 @@ protected: float AutoInterval; bool SetupModeActive; void SetInitialParameter(void); + std::string aktstatusWithTime; std::string aktstatus; int aktRunNr; @@ -71,6 +72,7 @@ public: bool isAutoStart(long &_interval); + std::string* getActStatusWithTime(); std::string* getActStatus(); void setActStatus(std::string _aktstatus); diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index e8e8a3ba..f4c00227 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -379,55 +379,85 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) if (query.find("full") != std::string::npos) { string txt, zw; - - txt = "

Aligned Image:

\n"; - txt = txt + "Digital Counter:

"; - httpd_resp_sendstr_chunk(req, txt.c_str()); - - std::vector htmlinfodig; - htmlinfodig = tfliteflow.GetAllDigital(); - for (int i = 0; i < htmlinfodig.size(); ++i) - { - if (tfliteflow.GetTypeDigital() == Digital) + std::string *status = tfliteflow.getActStatus(); + + if ((countRounds <= 1) && (*status != std::string("Flow finished"))) { // First round not completed yet + txt = ""; + txt += "

Please wait for the first round to complete!

Current state: " + *status + "

\n"; + httpd_resp_sendstr_chunk(req, txt.c_str()); + } + else { + /* Digital ROIs */ + txt = ""; + txt += "

Recognized Digit ROIs (previous round)

\n"; + txt += "\n"; + + std::vector htmlinfodig; + htmlinfodig = tfliteflow.GetAllDigital(); + + for (int i = 0; i < htmlinfodig.size(); ++i) { - if (htmlinfodig[i]->val == 10) - zw = "NaN"; - else - zw = to_string((int) htmlinfodig[i]->val); + if (tfliteflow.GetTypeDigital() == Digital) + { + if (htmlinfodig[i]->val == 10) + zw = "NaN"; + else + zw = to_string((int) htmlinfodig[i]->val); - txt = "filename + "\"> " + zw; + txt += "\n"; + } + else + { + std::stringstream stream; + stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val; + zw = stream.str(); + + txt += "\n"; + } + delete htmlinfodig[i]; } - else + + htmlinfodig.clear(); + + txt += "

" + zw + "

filename + "\">

" + zw + "

filename + "\">

\n"; + httpd_resp_sendstr_chunk(req, txt.c_str()); + + + /* Analog ROIs */ + txt = "

Recognized Analog ROIs (previous round)

\n"; + txt += "\n"; + + std::vector htmlinfoana; + htmlinfoana = tfliteflow.GetAllAnalog(); + for (int i = 0; i < htmlinfoana.size(); ++i) { std::stringstream stream; - stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val; + stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val; zw = stream.str(); - txt = "filename + "\"> " + zw; + txt += "\n"; + delete htmlinfoana[i]; + } + htmlinfoana.clear(); + + txt += "\n

" + zw + "

filename + "\">

\n"; + httpd_resp_sendstr_chunk(req, txt.c_str()); + + + /* Full Image + * Only show it after the image got taken and aligned */ + txt = "

Aligned Image (current round)

\n"; + if ((*status == std::string("Initialization")) || + (*status == std::string("Initialization (delayed)")) || + (*status == std::string("Take Image"))) { + txt += "

Current state: " + *status + "

\n"; + } + else { + txt += "\n"; } httpd_resp_sendstr_chunk(req, txt.c_str()); - delete htmlinfodig[i]; } - htmlinfodig.clear(); - - txt = "

Analog Meter:

"; - httpd_resp_sendstr_chunk(req, txt.c_str()); - - std::vector htmlinfoana; - htmlinfoana = tfliteflow.GetAllAnalog(); - for (int i = 0; i < htmlinfoana.size(); ++i) - { - std::stringstream stream; - stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val; - zw = stream.str(); - - txt = "filename + "\"> " + zw; - httpd_resp_sendstr_chunk(req, txt.c_str()); - delete htmlinfoana[i]; - } - htmlinfoana.clear(); - } /* Respond with an empty chunk to signal HTTP response completion */ @@ -664,7 +694,7 @@ esp_err_t handler_statusflow(httpd_req_t *req) ESP_LOGD(TAG, "handler_prevalue: %s", req->uri); #endif - string* zw = tfliteflow.getActStatus(); + string* zw = tfliteflow.getActStatusWithTime(); resp_str = zw->c_str(); httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN); diff --git a/sd-card/html/edit_alignment.html b/sd-card/html/edit_alignment.html index f827992f..41e5fbca 100644 --- a/sd-card/html/edit_alignment.html +++ b/sd-card/html/edit_alignment.html @@ -115,7 +115,7 @@ select { param; function doReboot() { - if (confirm("Are you sure you want to reboot? Did you save the config?")) { + if (confirm("Are you sure you want to reboot? Did you save your changes?")) { var stringota = getDomainname() + "/reboot"; window.location = stringota; window.location.href = stringota; diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index 162f0364..3c104131 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -165,7 +165,7 @@ th, td { function doReboot() { - if (confirm("Are you sure you want to reboot? Did you save the config?")) { + if (confirm("Are you sure you want to reboot? Did you save your changes?")) { var stringota = getDomainname() + "/reboot"; window.location = stringota; window.location.href = stringota; diff --git a/sd-card/html/edit_digits.html b/sd-card/html/edit_digits.html index 60736c4f..b8e8fce8 100644 --- a/sd-card/html/edit_digits.html +++ b/sd-card/html/edit_digits.html @@ -161,7 +161,7 @@ th, td { domainname = getDomainname(); function doReboot() { - if (confirm("Are you sure you want to reboot? Did you save the config?")) { + if (confirm("Are you sure you want to reboot? Did you save your changes?")) { var stringota = getDomainname() + "/reboot"; window.location = stringota; window.location.href = stringota; diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index 4254ba60..62a8235d 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -238,7 +238,7 @@ table { } function SaveReference(){ - if (confirm("Are you sure you want to update the reference image?")) { + if (confirm("Are you sure you want to update the Reference Image?")) { param["Alignment"]["InitialRotate"].value1 = document.getElementById("prerotateangle").value; if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked)) diff --git a/sd-card/html/index.html b/sd-card/html/index.html index 9d2f0f0c..56cdf5dd 100644 --- a/sd-card/html/index.html +++ b/sd-card/html/index.html @@ -6,6 +6,7 @@ + diff --git a/sd-card/html/prevalue_set.html b/sd-card/html/prevalue_set.html index 108da9f3..7a3d7d7c 100644 --- a/sd-card/html/prevalue_set.html +++ b/sd-card/html/prevalue_set.html @@ -48,20 +48,32 @@ input[type=number] { -

Current Value:

-

-

Set Value:

- Input (Format = 123.456):

- Previous Value: - -

- + + + + + + -

Result:

-

+ +
+

Current "Previous Value":

+
+
+
+

New "Previous Value":
(Format = 123.456)

 

+
+ + +

(The current "Raw Value" got entered as the suggested new "Previous Value")

+
+

Result:

+
+
+