rolling 20210823

This commit is contained in:
jomjol
2021-08-23 18:57:48 +02:00
parent f6b1a41a0b
commit 0dac0e87e4
18 changed files with 160 additions and 38 deletions

View File

@@ -12,6 +12,9 @@
#include "Helper.h"
#include "server_ota.h"
//#include "CImg.h"
#include "server_help.h"
//#define DEBUG_DETAIL_ON
@@ -51,6 +54,25 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
return result;
}
std::string ClassFlowControll::TranslateAktstatus(std::string _input)
{
if (_input.compare("ClassFlowMakeImage") == 0)
return ("Take Image");
if (_input.compare("ClassFlowAlignment") == 0)
return ("Aligning");
if (_input.compare("ClassFlowAnalog") == 0)
return ("Analog ROIs");
if (_input.compare("ClassFlowDigit") == 0)
return ("Digital ROIs");
if (_input.compare("ClassFlowMQTT") == 0)
return ("Sending MQTT");
if (_input.compare("ClassFlowPostProcessing") == 0)
return ("Processing");
return "Unkown Status";
}
std::vector<HTMLInfo*> ClassFlowControll::GetAllDigital()
{
for (int i = 0; i < FlowControll.size(); ++i)
@@ -95,7 +117,7 @@ void ClassFlowControll::SetInitialParameter(void)
flowpostprocessing = NULL;
disabled = false;
aktRunNr = 0;
aktstatus = "Startup";
aktstatus = "Booting ...";
}
@@ -209,9 +231,9 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
for (int i = 0; i < FlowControll.size(); ++i)
{
if (FlowControll[i]->name() == "ClassFlowMakeImage") {
zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": " + FlowControll[i]->name();
string zw = "FlowControll.doFlowMakeImageOnly - " + FlowControll[i]->name();
// zw_time = gettimestring("%Y%m%d-%H%M%S");
zw_time = gettimestring("%H:%M:%S");
aktstatus = TranslateAktstatus(FlowControll[i]->name()) + "(" + zw_time + ")";
FlowControll[i]->doFlow(time);
}
}
@@ -231,8 +253,11 @@ bool ClassFlowControll::doFlow(string time)
for (int i = 0; i < FlowControll.size(); ++i)
{
zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": " + FlowControll[i]->name();
zw_time = gettimestring("%H:%M:%S");
aktstatus = TranslateAktstatus(FlowControll[i]->name()) + "(" + zw_time + ")";
// zw_time = gettimestring("%Y%m%d-%H%M%S");
// aktstatus = zw_time + ": " + FlowControll[i]->name();
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
@@ -259,25 +284,11 @@ bool ClassFlowControll::doFlow(string time)
#endif
}
zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": Flow is done";
zw_time = gettimestring("%H:%M:%S");
aktstatus = "Flow finished (" + zw_time + ")";
return result;
}
void ClassFlowControll::UpdateAktStatus(std::string _flow)
{
aktstatus = gettimestring("%Y%m%d-%H%M%S");
aktstatus = aktstatus + "\t" + std::to_string(aktRunNr) + "\t";
if (_flow == "ClassFlowMakeImage")
aktstatus = aktstatus + "Taking Raw Image";
else
if (_flow == "ClassFlowAlignment")
aktstatus = aktstatus + "Aligning Image";
}
string ClassFlowControll::getReadoutAll(int _type)
{
@@ -289,10 +300,18 @@ string ClassFlowControll::getReadoutAll(int _type)
out = out + numbers[i]->name + "\t";
switch (_type) {
case READOUT_TYPE_VALUE:
out = out + numbers[i]->ReturnValue;
out = out + numbers[i]->ReturnValueNoError;
break;
case READOUT_TYPE_PREVALUE:
out = out + numbers[i]->ReturnPreValue;
if (flowpostprocessing->PreValueUse)
{
if (numbers[i]->PreValueOkay)
out = out + numbers[i]->ReturnPreValue;
else
out = out + "PreValue too old";
}
else
out = out + "PreValue deactivated";
break;
case READOUT_TYPE_RAWVALUE:
out = out + numbers[i]->ReturnRawValue;
@@ -523,6 +542,18 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
flowalignment->DrawRef(_imgzw);
if (flowdigit) flowdigit->DrawROI(_imgzw);
if (flowanalog) flowanalog->DrawROI(_imgzw);
/*/////////////////////////////////////
cimg_library::CImg<unsigned char> cimg(_imgzw->rgb_image, _imgzw->bpp, _imgzw->width, _imgzw->height, 1);
//Convert cimg type
// cimg.permute_axes("yzcx");
cimg.draw_text(300, 300, "Dies ist ein Test", "black");
//Convert back to stb type to save
// cimg.permute_axes("cxyz");
*////////////////////////////////////
_send = _imgzw;
Dodelete = true;
}

View File

@@ -36,8 +36,6 @@ protected:
std::string aktstatus;
int aktRunNr;
void UpdateAktStatus(std::string _flow);
public:
void InitFlow(std::string config);
bool doFlow(string time);
@@ -49,6 +47,8 @@ public:
string GetPrevalue(std::string _number = "");
bool ReadParameter(FILE* pfile, string& aktparamgraph);
string TranslateAktstatus(std::string _input);
string GetMQTTMainTopic();
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);

View File

@@ -28,6 +28,7 @@ void ClassFlowDigit::SetInitialParameter(void)
disabled = false;
DecimalShift = 0;
DecimalShiftEnabled = false;
isLogImageSelect = false;
}
ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
@@ -119,6 +120,13 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
LogImageLocation = "/sdcard" + zerlegt[1];
isLogImage = true;
}
if ((zerlegt[0] == "LogImageSelect") && (zerlegt.size() > 1))
{
LogImageSelect = zerlegt[1];
isLogImageSelect = true;
}
if ((zerlegt[0] == "Model") && (zerlegt.size() > 1))
{
cnnmodelfile = zerlegt[1];
@@ -328,7 +336,17 @@ bool ClassFlowDigit::doNeuralNetwork(string time)
if (isLogImage)
{
LogImage(logPath, DIGIT[_dig]->ROI[i]->name, NULL, &DIGIT[_dig]->ROI[i]->resultklasse, time, DIGIT[_dig]->ROI[i]->image_org);
if (isLogImageSelect)
{
if (LogImageSelect.find(DIGIT[_dig]->ROI[i]->name) != std::string::npos)
{
LogImage(logPath, DIGIT[_dig]->ROI[i]->name, NULL, &DIGIT[_dig]->ROI[i]->resultklasse, time, DIGIT[_dig]->ROI[i]->image_org);
}
}
else
{
LogImage(logPath, DIGIT[_dig]->ROI[i]->name, NULL, &DIGIT[_dig]->ROI[i]->resultklasse, time, DIGIT[_dig]->ROI[i]->image_org);
}
}
}
#ifndef OHNETFLITE

View File

@@ -33,6 +33,9 @@ protected:
int DecimalShift;
bool DecimalShiftEnabled;
bool isLogImageSelect;
string LogImageSelect;
ClassFlowAlignment* flowpostalignment;

View File

@@ -51,7 +51,6 @@ protected:
std::vector<NumberPost*> NUMBERS;
bool UpdatePreValueINI;
bool PreValueUse;
int PreValueAgeStartup;
bool ErrorMessage;
@@ -77,6 +76,8 @@ protected:
public:
bool PreValueUse;
ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc);
bool ReadParameter(FILE* pfile, string& aktparamgraph);
bool doFlow(string time);

View File

@@ -17,6 +17,7 @@ float CTfLiteClass::GetOutputValue(int nr)
return output2->data.f[nr];
}
int CTfLiteClass::GetClassFromImageBasis(CImageBasis *rs)
{
if (!LoadInputImageBasis(rs))

View File

@@ -64,6 +64,7 @@ class CTfLiteClass
void GetOutPut();
int GetOutClassification();
int GetClassFromImageBasis(CImageBasis *rs);
std::string GetStatusFlow();
float GetOutputValue(int nr);
void GetInputDimension(bool silent);

View File

@@ -530,6 +530,36 @@ esp_err_t handler_editflow(httpd_req_t *req)
};
esp_err_t handler_statusflow(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif
const char* resp_str;
string zw;
#ifdef DEBUG_DETAIL_ON
printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
#endif
zw = tfliteflow.getActStatus();
resp_str = zw.c_str();
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif
return ESP_OK;
};
esp_err_t handler_prevalue(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
@@ -684,6 +714,10 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/statusflow.html";
camuri.handler = handler_statusflow;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/editflow.html";
camuri.handler = handler_editflow;