Extend Graph.html

This commit is contained in:
jomjol
2022-10-24 21:20:46 +02:00
parent 716c23fed3
commit e0ae9b8e4f
12 changed files with 245 additions and 142 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();

View File

@@ -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");

View File

@@ -3,6 +3,7 @@
#include <esp_http_server.h>
#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;