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)
|
||||
|
||||
* Improved handling of PreValue
|
||||
* Improved error handling for automated processflow (reduce spontaneous reboot - see Issues)
|
||||
* Support of spaces in WLan SSID or password
|
||||
|
||||
2020-09-10
|
||||
|
||||
@@ -400,18 +400,21 @@ void task_reboot(void *pvParameter)
|
||||
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)
|
||||
{
|
||||
LogFile.WriteToFile("handler_reboot");
|
||||
ESP_LOGI(TAGPARTOTA, "!!! 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));
|
||||
|
||||
KillTFliteTasks();
|
||||
|
||||
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
||||
doReboot();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,4 @@ static const char *TAGPARTOTA = "server_ota";
|
||||
|
||||
void register_server_ota_sdcard_uri(httpd_handle_t server);
|
||||
void CheckOTAUpdate();
|
||||
void doReboot();
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "ClassFlowAlignment.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
|
||||
ClassFlowAlignment::ClassFlowAlignment()
|
||||
{
|
||||
initalrotate = 0;
|
||||
@@ -83,11 +85,22 @@ bool ClassFlowAlignment::doFlow(string time)
|
||||
output = FormatFileName(output);
|
||||
output2 = FormatFileName(output2);
|
||||
|
||||
CRotate *rt;
|
||||
|
||||
if (initalrotate != 0)
|
||||
{
|
||||
CRotate *rt;
|
||||
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->SaveToFile(output);
|
||||
delete rt;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ClassLogFile.h"
|
||||
#include "time_sntp.h"
|
||||
#include "Helper.h"
|
||||
#include "server_ota.h"
|
||||
|
||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||
bool found = false;
|
||||
@@ -144,13 +145,29 @@ bool ClassFlowControll::doFlow(string time)
|
||||
{
|
||||
bool result = true;
|
||||
std::string zw_time;
|
||||
int repeat = 0;
|
||||
|
||||
for (int i = 0; i < FlowControll.size(); ++i)
|
||||
{
|
||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||
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");
|
||||
aktstatus = zw_time + ": Flow is done";
|
||||
|
||||
@@ -56,6 +56,25 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
||||
difference /= 60;
|
||||
if (difference > PreValueAgeStartup)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -143,21 +162,6 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
{
|
||||
PreValueUse = true;
|
||||
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))
|
||||
@@ -235,17 +239,17 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
||||
// isdigit = true; digit = "12N";
|
||||
// isanalog = true; analog = "456";
|
||||
|
||||
if (isdigit)
|
||||
ReturnRawValue = digit;
|
||||
if (isdigit && isanalog)
|
||||
ReturnRawValue = ReturnRawValue + ".";
|
||||
if (isanalog)
|
||||
ReturnRawValue = ReturnRawValue + analog;
|
||||
|
||||
if (!PreValueUse || !PreValueOkay)
|
||||
{
|
||||
if (isdigit)
|
||||
ReturnValue = digit;
|
||||
if (isdigit && isanalog)
|
||||
ReturnValue = ReturnValue + ".";
|
||||
if (isanalog)
|
||||
ReturnValue = ReturnValue + analog;
|
||||
|
||||
ReturnRawValue = ReturnValue;
|
||||
ReturnValue = ReturnRawValue;
|
||||
ReturnValueNoError = ReturnRawValue;
|
||||
|
||||
if ((findDelimiterPos(ReturnValue, "N") == std::string::npos) && (ReturnValue.length() > 0))
|
||||
{
|
||||
@@ -254,19 +258,13 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
||||
ReturnValue.erase(0, 1);
|
||||
}
|
||||
Value = std::stof(ReturnValue);
|
||||
ReturnValueNoError = ReturnValue;
|
||||
|
||||
SavePreValue(Value, zwtime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isdigit)
|
||||
ReturnRawValue = digit;
|
||||
if (isdigit && isanalog)
|
||||
ReturnRawValue = ReturnRawValue + ".";
|
||||
if (isanalog)
|
||||
ReturnRawValue = ReturnRawValue + analog;
|
||||
|
||||
if (isdigit)
|
||||
{
|
||||
int lastanalog = -1;
|
||||
@@ -295,14 +293,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||
zwvalue = stream.str();
|
||||
}
|
||||
|
||||
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
||||
else
|
||||
{
|
||||
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
||||
Value = PreValue;
|
||||
stream.str("");
|
||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||
zwvalue = stream.str();
|
||||
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
||||
{
|
||||
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
||||
Value = PreValue;
|
||||
stream.str("");
|
||||
stream << std::fixed << std::setprecision(AnzahlNachkomma) << Value;
|
||||
zwvalue = stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValueNoError = zwvalue;
|
||||
|
||||
@@ -18,15 +18,14 @@ protected:
|
||||
bool checkDigitIncreaseConsistency;
|
||||
|
||||
string FilePreValue;
|
||||
float PreValue;
|
||||
float Value;
|
||||
string ReturnValue;
|
||||
string ReturnRawValue;
|
||||
string ReturnValueNoError;
|
||||
float PreValue; // letzter Wert, der gut ausgelesen wurde
|
||||
float Value; // letzer ausgelesener Wert, inkl. Korrekturen
|
||||
string ReturnRawValue; // Rohwert (mit N & führenden 0)
|
||||
string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung
|
||||
string ReturnValueNoError; // korrigierter Rückgabewert ohne Fehlermeldung
|
||||
|
||||
bool LoadPreValue(void);
|
||||
|
||||
|
||||
string ErsetzteN(string, int lastvalueanalog);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool CImageBasis::ImageOkay(){
|
||||
return rgb_image != NULL;
|
||||
}
|
||||
|
||||
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
|
||||
{
|
||||
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 setPixelColor(int x, int y, int r, int g, int b);
|
||||
void Contrast(float _contrast);
|
||||
bool ImageOkay();
|
||||
|
||||
|
||||
CImageBasis();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user