From e0ae9b8e4f8f8a610246e09ea47d01320438b6a4 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:20:46 +0200 Subject: [PATCH] Extend Graph.html --- .../jomjol_fileserver_ota/server_file.cpp | 66 ++++++++++- .../jomjol_fileserver_ota/server_file.h | 3 + .../jomjol_flowcontroll/ClassFlowControll.cpp | 6 + .../jomjol_flowcontroll/ClassFlowControll.h | 1 + .../ClassFlowPostProcessing.cpp | 16 +++ .../ClassFlowPostProcessing.h | 1 + .../jomjol_tfliteclass/server_tflite.cpp | 12 ++ .../jomjol_tfliteclass/server_tflite.h | 3 + sd-card/html/edit_config_param.html | 32 ------ sd-card/html/graph.html | 103 ++++++++++++++---- sd-card/html/graph_data.html | 82 -------------- sd-card/html/readconfigparam.js | 62 +++++++++++ 12 files changed, 245 insertions(+), 142 deletions(-) delete mode 100644 sd-card/html/graph_data.html diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 22e1b064..f6a992b3 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -36,6 +36,8 @@ extern "C" { #include "defines.h" #include "ClassLogFile.h" +#include "server_tflite.h"" + #include "server_help.h" #include "interface_mqtt.h" #include "server_GPIO.h" @@ -78,13 +80,69 @@ using namespace std; string SUFFIX_ZW = "_0xge"; +esp_err_t get_numbers_file_handler(httpd_req_t *req) +{ + std::string ret = tfliteflow.getNumbersName(); + +// ESP_LOGI(TAG, "Result get_numbers_file_handler: %s", ret.c_str()); + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_set_type(req, "text/plain"); + + httpd_resp_sendstr_chunk(req, ret.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + + return ESP_OK; +} + + +esp_err_t get_data_file_handler(httpd_req_t *req) +{ + struct dirent *entry; + + std::string _filename, _fileext; + size_t pos = 0; + + const char verz_name[] = "/sdcard/log/data"; + ESP_LOGD(TAG, "Suche TFLITE in /sdcard/log/data"); + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_set_type(req, "text/plain"); + + DIR *dir = opendir(verz_name); + while ((entry = readdir(dir)) != NULL) + { + _filename = std::string(entry->d_name); + ESP_LOGD(TAG, "File: %s", _filename.c_str()); + + // ignore all files with starting dot (hidden files) + if (_filename.rfind(".", 0) == 0) { + continue; + } + + _fileext = _filename; + pos = _fileext.find_last_of("."); + if (pos != std::string::npos) + _fileext = _fileext.erase(0, pos + 1); + + ESP_LOGD(TAG, " Extension: %s", _fileext.c_str()); + + if (_fileext == "txt") + { + _filename = _filename + "\t"; + httpd_resp_sendstr_chunk(req, _filename.c_str()); + } + } + closedir(dir); + + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; +} + + esp_err_t get_tflite_file_handler(httpd_req_t *req) { -// DIR *verzeichnis; -// struct dirent *files; struct dirent *entry; -// struct stat entry_stat; - std::string _filename, _fileext; size_t pos = 0; diff --git a/code/components/jomjol_fileserver_ota/server_file.h b/code/components/jomjol_fileserver_ota/server_file.h index 9dbcc88f..1e2764c9 100644 --- a/code/components/jomjol_fileserver_ota/server_file.h +++ b/code/components/jomjol_fileserver_ota/server_file.h @@ -10,3 +10,6 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st void delete_all_in_directory(std::string _directory); esp_err_t get_tflite_file_handler(httpd_req_t *req); +esp_err_t get_data_file_handler(httpd_req_t *req); +esp_err_t get_numbers_file_handler(httpd_req_t *req); + diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 9c900844..545d591c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -647,6 +647,12 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req) return result; } + +string ClassFlowControll::getNumbersName() +{ + return flowpostprocessing->getNumbersName(); +} + string ClassFlowControll::getJSON(std::string _id, std::string _mac) { return flowpostprocessing->GetJSON(_id, _mac); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index a8f92dc3..5fd3b08a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -51,6 +51,7 @@ public: string GetPrevalue(std::string _number = ""); bool ReadParameter(FILE* pfile, string& aktparamgraph); string getJSON(std::string _id = "", std::string _mac = ""); + string getNumbersName(); string TranslateAktstatus(std::string _input); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index afe21a16..74bcb913 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -21,6 +21,22 @@ static const char* TAG = "class_flow_postproc"; #define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d" +std::string ClassFlowPostProcessing::getNumbersName() +{ + std::string ret=""; + + for (int i = 0; i < NUMBERS.size(); ++i) + { + ret += NUMBERS[i]->name; + if (i < NUMBERS.size()-1) + ret = ret + "\t"; + } + +// ESP_LOGI(TAG, "Result ClassFlowPostProcessing::getNumbersName: %s", ret.c_str()); + + return ret; +} + std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, std::string _lineend) { std::string json="{" + _lineend; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 3c53bb82..27a26d53 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -65,6 +65,7 @@ public: void SetPreValue(double zw, string _numbers, bool _extern = false); std::string GetJSON(std::string _id = "", std::string _mac = "", std::string _lineend = "\n"); + std::string getNumbersName(); void UpdateNachkommaDecimalShift(); diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 9064d138..dde06571 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -397,6 +397,18 @@ esp_err_t handler_editflow(httpd_req_t *req) } } + if (_task.compare("namenumbers") == 0) + { + ESP_LOGI(TAGTFLITE, "Get NUMBER list"); + return get_numbers_file_handler(req); + } + + if (_task.compare("data") == 0) + { + ESP_LOGI(TAGTFLITE, "Get data list"); + return get_data_file_handler(req); + } + if (_task.compare("tflite") == 0) { ESP_LOGD(TAGTFLITE, "Get tflite list"); diff --git a/code/components/jomjol_tfliteclass/server_tflite.h b/code/components/jomjol_tfliteclass/server_tflite.h index 6a1d3564..ee39fe3d 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.h +++ b/code/components/jomjol_tfliteclass/server_tflite.h @@ -3,6 +3,7 @@ #include #include "CImageBasis.h" +#include "ClassFlowControll.h" //#include "ClassControllCamera.h" @@ -19,3 +20,5 @@ std::string GetMQTTMainTopic(); esp_err_t GetJPG(std::string _filename, httpd_req_t *req); esp_err_t GetRawJPG(httpd_req_t *req); + +extern ClassFlowControll tfliteflow; diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index edc6c947..8dbd750f 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -328,21 +328,6 @@ textarea { Time to keep the separated digit images (in days, resp. "0" = forever) - @@ -377,19 +362,6 @@ textarea { Time to keep the separated digit images (in days, resp. "0" = forever) - -

PostProcessing

@@ -1727,11 +1699,9 @@ function UpdateInput() { WriteParameter(param, category, "Digits", "CNNGoodThreshold", true); WriteParameter(param, category, "Digits", "LogImageLocation", true); WriteParameter(param, category, "Digits", "LogfileRetentionInDays", true); -// WriteParameter(param, category, "Digits", "ModelInputSize", false); WriteParameter(param, category, "Analog", "LogImageLocation", true); WriteParameter(param, category, "Analog", "LogfileRetentionInDays", true); -// WriteParameter(param, category, "Analog", "ModelInputSize", false); WriteParameter(param, category, "PostProcessing", "PreValueUse", true); WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true); @@ -1844,12 +1814,10 @@ function ReadParameterAll() ReadParameter(param, "Digits", "CNNGoodThreshold", true); ReadParameter(param, "Digits", "LogImageLocation", true); ReadParameter(param, "Digits", "LogfileRetentionInDays", true); -// ReadParameter(param, "Digits", "ModelInputSize", false); ReadParameter(param, "Analog", "Model", false); ReadParameter(param, "Analog", "LogImageLocation", true); ReadParameter(param, "Analog", "LogfileRetentionInDays", true); -// ReadParameter(param, "Analog", "ModelInputSize", false); ReadParameter(param, "PostProcessing", "PreValueUse", true); ReadParameter(param, "PostProcessing", "PreValueAgeStartup", true); diff --git a/sd-card/html/graph.html b/sd-card/html/graph.html index d3e15026..0c990b19 100644 --- a/sd-card/html/graph.html +++ b/sd-card/html/graph.html @@ -2,6 +2,11 @@ + + + + + - - - -
- - - - - - \ No newline at end of file diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 9e7eb8b7..ffacacf8 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -11,6 +11,68 @@ var NUMBERS = new Array(0); var REFERENCES = new Array(0); +function getNUMBERSList() { + _basepath = getbasepath(); + var datalist = ""; + + var xhttp = new XMLHttpRequest(); + xhttp.addEventListener('load', function(event) { + if (xhttp.status >= 200 && xhttp.status < 300) { + datalist = xhttp.responseText; + } else { + console.warn(request.statusText, request.responseText); + } + }); + + try { + url = _basepath + '/editflow.html?task=namenumbers'; + xhttp.open("GET", url, false); + xhttp.send(); + + } + catch (error) + { + alert("Loading Hostname failed"); + } + + datalist = datalist.split("\t"); +// datalist.pop(); + + return datalist; + } + + +function getDATAList() { + _basepath = getbasepath(); + tflitelist = ""; + + var xhttp = new XMLHttpRequest(); + xhttp.addEventListener('load', function(event) { + if (xhttp.status >= 200 && xhttp.status < 300) { + tflitelist = xhttp.responseText; + } else { + console.warn(request.statusText, request.responseText); + } + }); + + try { + url = _basepath + '/editflow.html?task=data'; + xhttp.open("GET", url, false); + xhttp.send(); + + } + catch (error) + { +// alert("Loading Hostname failed"); + } + + tflitelist = tflitelist.split("\t"); + tflitelist.pop(); + + return tflitelist; + } + + function getTFLITEList() { _basepath = getbasepath(); tflitelist = "";