mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-06 11:36:51 +03:00
Enhance pages (#2075)
* enhance pages * . * . * . * . * . * . --------- Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -195,6 +195,7 @@ void ClassFlowControll::SetInitialParameter(void)
|
|||||||
disabled = false;
|
disabled = false;
|
||||||
aktRunNr = 0;
|
aktRunNr = 0;
|
||||||
aktstatus = "Flow task not yet created";
|
aktstatus = "Flow task not yet created";
|
||||||
|
aktstatusWithTime = aktstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -272,6 +273,8 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|||||||
void ClassFlowControll::InitFlow(std::string config)
|
void ClassFlowControll::InitFlow(std::string config)
|
||||||
{
|
{
|
||||||
aktstatus = "Initialization";
|
aktstatus = "Initialization";
|
||||||
|
aktstatusWithTime = aktstatus;
|
||||||
|
|
||||||
//#ifdef ENABLE_MQTT
|
//#ifdef ENABLE_MQTT
|
||||||
//MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization", false); // Right now, not possible -> MQTT Service is going to be started later
|
//MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization", false); // Right now, not possible -> MQTT Service is going to be started later
|
||||||
//#endif //ENABLE_MQTT
|
//#endif //ENABLE_MQTT
|
||||||
@@ -318,6 +321,12 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string* ClassFlowControll::getActStatusWithTime()
|
||||||
|
{
|
||||||
|
return &aktstatusWithTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string* ClassFlowControll::getActStatus()
|
std::string* ClassFlowControll::getActStatus()
|
||||||
{
|
{
|
||||||
return &aktstatus;
|
return &aktstatus;
|
||||||
@@ -327,6 +336,7 @@ std::string* ClassFlowControll::getActStatus()
|
|||||||
void ClassFlowControll::setActStatus(std::string _aktstatus)
|
void ClassFlowControll::setActStatus(std::string _aktstatus)
|
||||||
{
|
{
|
||||||
aktstatus = _aktstatus;
|
aktstatus = _aktstatus;
|
||||||
|
aktstatusWithTime = aktstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -338,10 +348,10 @@ void ClassFlowControll::doFlowTakeImageOnly(string time)
|
|||||||
{
|
{
|
||||||
if (FlowControll[i]->name() == "ClassFlowTakeImage") {
|
if (FlowControll[i]->name() == "ClassFlowTakeImage") {
|
||||||
zw_time = getCurrentTimeString("%H:%M:%S");
|
zw_time = getCurrentTimeString("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
aktstatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatusWithTime = aktstatus + " (" + zw_time + ")";
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false);
|
||||||
#endif //ENABLE_MQTT
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
FlowControll[i]->doFlow(time);
|
FlowControll[i]->doFlow(time);
|
||||||
@@ -371,11 +381,11 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
{
|
{
|
||||||
zw_time = getCurrentTimeString("%H:%M:%S");
|
zw_time = getCurrentTimeString("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
aktstatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatusWithTime = aktstatus + " (" + zw_time + ")";
|
||||||
//LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatus);
|
//LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatusWithTime);
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false);
|
||||||
#endif //ENABLE_MQTT
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
@@ -405,11 +415,11 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
}
|
}
|
||||||
|
|
||||||
zw_time = getCurrentTimeString("%H:%M:%S");
|
zw_time = getCurrentTimeString("%H:%M:%S");
|
||||||
std::string flowStatus = "Flow finished";
|
aktstatus = "Flow finished";
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatusWithTime = aktstatus + " (" + zw_time + ")";
|
||||||
//LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatus);
|
//LogFile.WriteToFile(ESP_LOG_INFO, TAG, aktstatusWithTime);
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", aktstatus, false);
|
||||||
#endif //ENABLE_MQTT
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ protected:
|
|||||||
float AutoInterval;
|
float AutoInterval;
|
||||||
bool SetupModeActive;
|
bool SetupModeActive;
|
||||||
void SetInitialParameter(void);
|
void SetInitialParameter(void);
|
||||||
|
std::string aktstatusWithTime;
|
||||||
std::string aktstatus;
|
std::string aktstatus;
|
||||||
int aktRunNr;
|
int aktRunNr;
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ public:
|
|||||||
|
|
||||||
bool isAutoStart(long &_interval);
|
bool isAutoStart(long &_interval);
|
||||||
|
|
||||||
|
std::string* getActStatusWithTime();
|
||||||
std::string* getActStatus();
|
std::string* getActStatus();
|
||||||
void setActStatus(std::string _aktstatus);
|
void setActStatus(std::string _aktstatus);
|
||||||
|
|
||||||
|
|||||||
@@ -379,55 +379,85 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
if (query.find("full") != std::string::npos)
|
if (query.find("full") != std::string::npos)
|
||||||
{
|
{
|
||||||
string txt, zw;
|
string txt, zw;
|
||||||
|
|
||||||
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
|
||||||
txt = txt + "Digital Counter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> htmlinfodig;
|
|
||||||
htmlinfodig = tfliteflow.GetAllDigital();
|
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfodig.size(); ++i)
|
std::string *status = tfliteflow.getActStatus();
|
||||||
{
|
|
||||||
if (tfliteflow.GetTypeDigital() == Digital)
|
if ((countRounds <= 1) && (*status != std::string("Flow finished"))) { // First round not completed yet
|
||||||
|
txt = "<body style=\"font-family: arial\">";
|
||||||
|
txt += "<h3>Please wait for the first round to complete!</h3><h3>Current state: " + *status + "</h3>\n";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Digital ROIs */
|
||||||
|
txt = "<body style=\"font-family: arial\">";
|
||||||
|
txt += "<h3>Recognized Digit ROIs (previous round)</h3>\n";
|
||||||
|
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfodig;
|
||||||
|
htmlinfodig = tfliteflow.GetAllDigital();
|
||||||
|
|
||||||
|
for (int i = 0; i < htmlinfodig.size(); ++i)
|
||||||
{
|
{
|
||||||
if (htmlinfodig[i]->val == 10)
|
if (tfliteflow.GetTypeDigital() == Digital)
|
||||||
zw = "NaN";
|
{
|
||||||
else
|
if (htmlinfodig[i]->val == 10)
|
||||||
zw = to_string((int) htmlinfodig[i]->val);
|
zw = "NaN";
|
||||||
|
else
|
||||||
|
zw = to_string((int) htmlinfodig[i]->val);
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt += "<td style=\"width: 100px\"><h4>" + zw + "</h4><p><img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"></p></td>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
||||||
|
zw = stream.str();
|
||||||
|
|
||||||
|
txt += "<td style=\"width: 100px\"><h4>" + zw + "</h4><p><img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"></p></td>\n";
|
||||||
|
}
|
||||||
|
delete htmlinfodig[i];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
htmlinfodig.clear();
|
||||||
|
|
||||||
|
txt += "</tr></table>\n";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
/* Analog ROIs */
|
||||||
|
txt = "<h3>Recognized Analog ROIs (previous round)</h3>\n";
|
||||||
|
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfoana;
|
||||||
|
htmlinfoana = tfliteflow.GetAllAnalog();
|
||||||
|
for (int i = 0; i < htmlinfoana.size(); ++i)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val;
|
||||||
zw = stream.str();
|
zw = stream.str();
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt += "<td style=\"width: 150px;\"><h4>" + zw + "</h4><p><img src=\"/img_tmp/" + htmlinfoana[i]->filename + "\"></p></td>\n";
|
||||||
|
delete htmlinfoana[i];
|
||||||
|
}
|
||||||
|
htmlinfoana.clear();
|
||||||
|
|
||||||
|
txt += "</tr>\n</table>\n";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
/* Full Image
|
||||||
|
* Only show it after the image got taken and aligned */
|
||||||
|
txt = "<h3>Aligned Image (current round)</h3>\n";
|
||||||
|
if ((*status == std::string("Initialization")) ||
|
||||||
|
(*status == std::string("Initialization (delayed)")) ||
|
||||||
|
(*status == std::string("Take Image"))) {
|
||||||
|
txt += "<p>Current state: " + *status + "</p>\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
txt += "<img src=\"/img_tmp/alg_roi.jpg\">\n";
|
||||||
}
|
}
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
delete htmlinfodig[i];
|
|
||||||
}
|
}
|
||||||
htmlinfodig.clear();
|
|
||||||
|
|
||||||
txt = " <p> Analog Meter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> 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 = "<img src=\"/img_tmp/" + htmlinfoana[i]->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 */
|
/* 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);
|
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string* zw = tfliteflow.getActStatus();
|
string* zw = tfliteflow.getActStatusWithTime();
|
||||||
resp_str = zw->c_str();
|
resp_str = zw->c_str();
|
||||||
|
|
||||||
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
|
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ select {
|
|||||||
param;
|
param;
|
||||||
|
|
||||||
function doReboot() {
|
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";
|
var stringota = getDomainname() + "/reboot";
|
||||||
window.location = stringota;
|
window.location = stringota;
|
||||||
window.location.href = stringota;
|
window.location.href = stringota;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ th, td {
|
|||||||
|
|
||||||
|
|
||||||
function doReboot() {
|
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";
|
var stringota = getDomainname() + "/reboot";
|
||||||
window.location = stringota;
|
window.location = stringota;
|
||||||
window.location.href = stringota;
|
window.location.href = stringota;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ th, td {
|
|||||||
domainname = getDomainname();
|
domainname = getDomainname();
|
||||||
|
|
||||||
function doReboot() {
|
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";
|
var stringota = getDomainname() + "/reboot";
|
||||||
window.location = stringota;
|
window.location = stringota;
|
||||||
window.location.href = stringota;
|
window.location.href = stringota;
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SaveReference(){
|
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;
|
param["Alignment"]["InitialRotate"].value1 = document.getElementById("prerotateangle").value;
|
||||||
|
|
||||||
if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked))
|
if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="style.css?v=$COMMIT_HASH" type="text/css" >
|
<link rel="stylesheet" href="style.css?v=$COMMIT_HASH" type="text/css" >
|
||||||
|
<link href="firework.css?v=$COMMIT_HASH" rel="stylesheet">
|
||||||
|
|
||||||
<script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
|
<script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
|
||||||
<script type="text/javascript" src="readconfigcommon.js?v=$COMMIT_HASH"></script>
|
<script type="text/javascript" src="readconfigcommon.js?v=$COMMIT_HASH"></script>
|
||||||
|
|||||||
@@ -48,20 +48,32 @@ input[type=number] {
|
|||||||
|
|
||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<h3>Current Value:</h3><p>
|
<td>
|
||||||
<div id="prevalue"></div>
|
<h3>Current "Previous Value":</h3>
|
||||||
<h3>Set Value:</h3><p>
|
</td>
|
||||||
Input (Format = 123.456):<p>
|
<td>
|
||||||
Previous Value:
|
<div id="prevalue"></div>
|
||||||
<input type="number" id="myInput" name="myInput"
|
</td>
|
||||||
pattern="[0-9]+([\.,][0-9]+)?" step="0.001"
|
</tr>
|
||||||
title="This should be a number with up to 4 decimal places.">
|
<tr>
|
||||||
<p></p>
|
<td>
|
||||||
<button class="button" type="button" onclick="setprevalue()">Set Previous Value</button>
|
<h3>New "Previous Value":<br>(Format = 123.456)</h3><p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" id="myInput" name="myInput"
|
||||||
|
pattern="[0-9]+([\.,][0-9]+)?" step="0.001"
|
||||||
|
title="This should be a number with up to 4 decimal places.">
|
||||||
|
<button class="button" type="button" onclick="setprevalue()">Set Previous Value</button>
|
||||||
|
<p>(The current "Raw Value" got entered as the suggested new "Previous Value")</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<h3>Result:</h3><p>
|
<td>
|
||||||
<div id="result" readonly></div>
|
<h3>Result:</h3>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id="result" readonly></div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user