mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
Update 20200911
This commit is contained in:
@@ -31,6 +31,8 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
|
|||||||
|
|
||||||
##### Rolling - (2020-09-11)
|
##### Rolling - (2020-09-11)
|
||||||
|
|
||||||
|
* Improved handling of PreValue
|
||||||
|
* Improved error handling for automated processflow (reduce spontaneous reboot - see Issues)
|
||||||
* Support of spaces in WLan SSID or password
|
* Support of spaces in WLan SSID or password
|
||||||
|
|
||||||
2020-09-10
|
2020-09-10
|
||||||
|
|||||||
@@ -400,18 +400,21 @@ void task_reboot(void *pvParameter)
|
|||||||
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doReboot(){
|
||||||
|
LogFile.WriteToFile("Reboot - now");
|
||||||
|
KillTFliteTasks();
|
||||||
|
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_reboot(httpd_req_t *req)
|
esp_err_t handler_reboot(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_reboot");
|
LogFile.WriteToFile("handler_reboot");
|
||||||
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
||||||
|
|
||||||
const char* resp_str = "!!! System will restart within 5 sec!!!";
|
const char* resp_str = "!!! System will restart within 5 sec!!!";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
KillTFliteTasks();
|
doReboot();
|
||||||
|
|
||||||
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,5 @@
|
|||||||
static const char *TAGPARTOTA = "server_ota";
|
static const char *TAGPARTOTA = "server_ota";
|
||||||
|
|
||||||
void register_server_ota_sdcard_uri(httpd_handle_t server);
|
void register_server_ota_sdcard_uri(httpd_handle_t server);
|
||||||
void CheckOTAUpdate();
|
void CheckOTAUpdate();
|
||||||
|
void doReboot();
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "ClassFlowAlignment.h"
|
#include "ClassFlowAlignment.h"
|
||||||
|
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
ClassFlowAlignment::ClassFlowAlignment()
|
ClassFlowAlignment::ClassFlowAlignment()
|
||||||
{
|
{
|
||||||
initalrotate = 0;
|
initalrotate = 0;
|
||||||
@@ -83,11 +85,22 @@ bool ClassFlowAlignment::doFlow(string time)
|
|||||||
output = FormatFileName(output);
|
output = FormatFileName(output);
|
||||||
output2 = FormatFileName(output2);
|
output2 = FormatFileName(output2);
|
||||||
|
|
||||||
CRotate *rt;
|
|
||||||
|
|
||||||
if (initalrotate != 0)
|
if (initalrotate != 0)
|
||||||
{
|
{
|
||||||
|
CRotate *rt;
|
||||||
rt = new CRotate(input);
|
rt = new CRotate(input);
|
||||||
|
if (!rt->ImageOkay()){
|
||||||
|
LogFile.WriteToFile("ClassFlowAlignment::doFlow CRotate raw.jpg not okay!");
|
||||||
|
delete rt;
|
||||||
|
LogFile.WriteToFile("ClassFlowAlignment::doFlow 1x reload.");
|
||||||
|
rt = new CRotate(input);
|
||||||
|
if (!rt->ImageOkay()){
|
||||||
|
LogFile.WriteToFile("ClassFlowAlignment::doFlow Reload auch nicht erfolgreich!");
|
||||||
|
delete rt;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
rt->Rotate(this->initalrotate);
|
rt->Rotate(this->initalrotate);
|
||||||
rt->SaveToFile(output);
|
rt->SaveToFile(output);
|
||||||
delete rt;
|
delete rt;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
#include "server_ota.h"
|
||||||
|
|
||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@@ -144,13 +145,29 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
std::string zw_time;
|
std::string zw_time;
|
||||||
|
int repeat = 0;
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
{
|
{
|
||||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||||
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
||||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(zw);
|
||||||
result = result && FlowControll[i]->doFlow(time);
|
if (!FlowControll[i]->doFlow(time)){
|
||||||
|
repeat++;
|
||||||
|
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
||||||
|
i = i-2; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
|
||||||
|
result = false;
|
||||||
|
if (repeat > 5) {
|
||||||
|
LogFile.WriteToFile("Wiederholung 5x nicht erfolgreich --> reboot");
|
||||||
|
doReboot();
|
||||||
|
// Schritt wurde 5x wiederholt --> reboot
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||||
aktstatus = zw_time + ": Flow is done";
|
aktstatus = zw_time + ": Flow is done";
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
difference /= 60;
|
difference /= 60;
|
||||||
if (difference > PreValueAgeStartup)
|
if (difference > PreValueAgeStartup)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Value = PreValue;
|
||||||
|
ReturnValue = to_string(Value);
|
||||||
|
ReturnValueNoError = ReturnValue;
|
||||||
|
|
||||||
|
// falls es Analog gibt, dann die Anzahl der Nachkommastellen feststellen und entsprechend runden:
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
||||||
|
{
|
||||||
|
int AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||||
|
ReturnValue = stream.str();
|
||||||
|
ReturnValueNoError = ReturnValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,21 +162,6 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
{
|
{
|
||||||
PreValueUse = true;
|
PreValueUse = true;
|
||||||
PreValueOkay = LoadPreValue();
|
PreValueOkay = LoadPreValue();
|
||||||
if (PreValueOkay)
|
|
||||||
{
|
|
||||||
Value = PreValue;
|
|
||||||
for (int i = 0; i < ListFlowControll->size(); ++i)
|
|
||||||
{
|
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
|
||||||
{
|
|
||||||
int AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
|
||||||
ReturnValue = stream.str();
|
|
||||||
ReturnValueNoError = ReturnValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((zerlegt[0] == "CheckDigitIncreaseConsistency") && (zerlegt.size() > 1))
|
if ((zerlegt[0] == "CheckDigitIncreaseConsistency") && (zerlegt.size() > 1))
|
||||||
@@ -235,17 +239,17 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
// isdigit = true; digit = "12N";
|
// isdigit = true; digit = "12N";
|
||||||
// isanalog = true; analog = "456";
|
// isanalog = true; analog = "456";
|
||||||
|
|
||||||
|
if (isdigit)
|
||||||
|
ReturnRawValue = digit;
|
||||||
|
if (isdigit && isanalog)
|
||||||
|
ReturnRawValue = ReturnRawValue + ".";
|
||||||
|
if (isanalog)
|
||||||
|
ReturnRawValue = ReturnRawValue + analog;
|
||||||
|
|
||||||
if (!PreValueUse || !PreValueOkay)
|
if (!PreValueUse || !PreValueOkay)
|
||||||
{
|
{
|
||||||
if (isdigit)
|
ReturnValue = ReturnRawValue;
|
||||||
ReturnValue = digit;
|
ReturnValueNoError = ReturnRawValue;
|
||||||
if (isdigit && isanalog)
|
|
||||||
ReturnValue = ReturnValue + ".";
|
|
||||||
if (isanalog)
|
|
||||||
ReturnValue = ReturnValue + analog;
|
|
||||||
|
|
||||||
ReturnRawValue = ReturnValue;
|
|
||||||
|
|
||||||
if ((findDelimiterPos(ReturnValue, "N") == std::string::npos) && (ReturnValue.length() > 0))
|
if ((findDelimiterPos(ReturnValue, "N") == std::string::npos) && (ReturnValue.length() > 0))
|
||||||
{
|
{
|
||||||
@@ -254,19 +258,13 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
ReturnValue.erase(0, 1);
|
ReturnValue.erase(0, 1);
|
||||||
}
|
}
|
||||||
Value = std::stof(ReturnValue);
|
Value = std::stof(ReturnValue);
|
||||||
|
ReturnValueNoError = ReturnValue;
|
||||||
|
|
||||||
SavePreValue(Value, zwtime);
|
SavePreValue(Value, zwtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isdigit)
|
|
||||||
ReturnRawValue = digit;
|
|
||||||
if (isdigit && isanalog)
|
|
||||||
ReturnRawValue = ReturnRawValue + ".";
|
|
||||||
if (isanalog)
|
|
||||||
ReturnRawValue = ReturnRawValue + analog;
|
|
||||||
|
|
||||||
if (isdigit)
|
if (isdigit)
|
||||||
{
|
{
|
||||||
int lastanalog = -1;
|
int lastanalog = -1;
|
||||||
@@ -295,14 +293,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||||
zwvalue = stream.str();
|
zwvalue = stream.str();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
|
||||||
{
|
{
|
||||||
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
||||||
Value = PreValue;
|
{
|
||||||
stream.str("");
|
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
||||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
Value = PreValue;
|
||||||
zwvalue = stream.str();
|
stream.str("");
|
||||||
|
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||||
|
zwvalue = stream.str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValueNoError = zwvalue;
|
ReturnValueNoError = zwvalue;
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ protected:
|
|||||||
bool checkDigitIncreaseConsistency;
|
bool checkDigitIncreaseConsistency;
|
||||||
|
|
||||||
string FilePreValue;
|
string FilePreValue;
|
||||||
float PreValue;
|
float PreValue; // letzter Wert, der gut ausgelesen wurde
|
||||||
float Value;
|
float Value; // letzer ausgelesener Wert, inkl. Korrekturen
|
||||||
string ReturnValue;
|
string ReturnRawValue; // Rohwert (mit N & führenden 0)
|
||||||
string ReturnRawValue;
|
string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung
|
||||||
string ReturnValueNoError;
|
string ReturnValueNoError; // korrigierter Rückgabewert ohne Fehlermeldung
|
||||||
|
|
||||||
bool LoadPreValue(void);
|
bool LoadPreValue(void);
|
||||||
|
|
||||||
|
|
||||||
string ErsetzteN(string, int lastvalueanalog);
|
string ErsetzteN(string, int lastvalueanalog);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -374,6 +374,10 @@ CImageBasis::CImageBasis(std::string _image)
|
|||||||
// printf("w %d, h %d, b %d, c %d", this->width, this->height, this->bpp, this->channels);
|
// printf("w %d, h %d, b %d, c %d", this->width, this->height, this->bpp, this->channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CImageBasis::ImageOkay(){
|
||||||
|
return rgb_image != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
|
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
|
||||||
{
|
{
|
||||||
this->rgb_image = _rgb_image;
|
this->rgb_image = _rgb_image;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class CImageBasis
|
|||||||
void drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness = 1);
|
void drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness = 1);
|
||||||
void setPixelColor(int x, int y, int r, int g, int b);
|
void setPixelColor(int x, int y, int r, int g, int b);
|
||||||
void Contrast(float _contrast);
|
void Contrast(float _contrast);
|
||||||
|
bool ImageOkay();
|
||||||
|
|
||||||
|
|
||||||
CImageBasis();
|
CImageBasis();
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user