Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V14.1 backport to rolling #2058

Merged
merged 3 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## [Unreleased]

**Rolling**
Expand All @@ -24,6 +25,13 @@
- n.a.


## [14.1.0] - 2023-02-21

This release only migrates some parameters, see https://github.com/jomjol/AI-on-the-edge-device/pull/2023.

It does not change any functionality of the device!

If you want to revert from a future release to an older one, this is the first release using the new parameter naming. If you want to go to an older release than this `v14.1.0`, you have to update the `config.ini` manually to the old namings!

## [14.0.3] -2023-02-05

Expand Down Expand Up @@ -830,6 +838,7 @@ External Illumination
- Initial Version


[14.1.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v14.0.3...v14.1.0
[14.0.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v13.0.8...v14.0.2
[13.0.8]: https://github.com/jomjol/AI-on-the-edge-device/compare/v12.0.1...v13.0.8
[13.0.7]: https://github.com/jomjol/AI-on-the-edge-device/compare/v12.0.1...v13.0.7
Expand Down
8 changes: 4 additions & 4 deletions code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ClassFlowAlignment.h"
#include "ClassFlowMakeImage.h"
#include "ClassFlowTakeImage.h"
#include "ClassFlow.h"
#include "server_tflite.h"

Expand Down Expand Up @@ -46,9 +46,9 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)

for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowMakeImage") == 0)
if (((*ListFlowControll)[i])->name().compare("ClassFlowTakeImage") == 0)
{
ImageBasis = ((ClassFlowMakeImage*) (*ListFlowControll)[i])->rawImage;
ImageBasis = ((ClassFlowTakeImage*) (*ListFlowControll)[i])->rawImage;
}
}

Expand All @@ -74,7 +74,7 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
if (!this->GetNextParagraph(pfile, aktparamgraph))
return false;

if (aktparamgraph.compare("[Alignment]") != 0) //Paragraph does not fit MakeImage
if (aktparamgraph.compare("[Alignment]") != 0) //Paragraph does not fit Alignment
return false;

while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
Expand Down
10 changes: 5 additions & 5 deletions code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNTy
CNNType = AutoDetect;
CNNType = _cnntype;
flowpostalignment = _flowalign;
logfileRetentionInDays = 5;
imagesRetention = 5;
}


Expand Down Expand Up @@ -324,9 +324,9 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
splitted = ZerlegeZeile(aktparamgraph);
if ((toUpper(splitted[0]) == "LOGIMAGELOCATION") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "ROIIMAGESLOCATION") && (splitted.size() > 1))
{
this->LogImageLocation = "/sdcard" + splitted[1];
this->imagesLocation = "/sdcard" + splitted[1];
this->isLogImage = true;
}
if ((toUpper(splitted[0]) == "LOGIMAGESELECT") && (splitted.size() > 1))
Expand All @@ -335,9 +335,9 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
isLogImageSelect = true;
}

if ((toUpper(splitted[0]) == "LOGFILERETENTIONINDAYS") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "ROIIMAGESRETENTION") && (splitted.size() > 1))
{
this->logfileRetentionInDays = std::stoi(splitted[1]);
this->imagesRetention = std::stoi(splitted[1]);
}

if ((toUpper(splitted[0]) == "MODEL") && (splitted.size() > 1))
Expand Down
46 changes: 23 additions & 23 deletions code/components/jomjol_flowcontroll/ClassFlowControll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _

ESP_LOGD(TAG, "Step %s start", _stepname.c_str());

if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
_classname = "ClassFlowMakeImage";
if ((_stepname.compare("[TakeImage]") == 0) || (_stepname.compare(";[TakeImage]") == 0)){
_classname = "ClassFlowTakeImage";
}
if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
_classname = "ClassFlowAlignment";
Expand Down Expand Up @@ -67,7 +67,7 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _

for (int i = 0; i < FlowControll.size(); ++i)
if (FlowControll[i]->name().compare(_classname) == 0){
if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // if it is a MakeImage, the image does not need to be included, this happens automatically with the html query.
if (!(FlowControll[i]->name().compare("ClassFlowTakeImage") == 0)) // if it is a TakeImage, the image does not need to be included, this happens automatically with the html query.
FlowControll[i]->doFlow("");
result = FlowControll[i]->getHTMLSingleStep(_host);
}
Expand All @@ -80,7 +80,7 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _

std::string ClassFlowControll::TranslateAktstatus(std::string _input)
{
if (_input.compare("ClassFlowMakeImage") == 0)
if (_input.compare("ClassFlowTakeImage") == 0)
return ("Take Image");
if (_input.compare("ClassFlowAlignment") == 0)
return ("Aligning");
Expand Down Expand Up @@ -176,7 +176,7 @@ bool ClassFlowControll::StartMQTTService() {
/* Start the MQTT service */
for (int i = 0; i < FlowControll.size(); ++i) {
if (FlowControll[i]->name().compare("ClassFlowMQTT") == 0) {
return ((ClassFlowMQTT*) (FlowControll[i]))->Start(AutoIntervall);
return ((ClassFlowMQTT*) (FlowControll[i]))->Start(AutoInterval);
}
}
return false;
Expand All @@ -188,7 +188,7 @@ void ClassFlowControll::SetInitialParameter(void)
{
AutoStart = false;
SetupModeActive = false;
AutoIntervall = 10; // Minutes
AutoInterval = 10; // Minutes
flowdigit = NULL;
flowanalog = NULL;
flowpostprocessing = NULL;
Expand All @@ -198,9 +198,9 @@ void ClassFlowControll::SetInitialParameter(void)
}


bool ClassFlowControll::isAutoStart(long &_intervall)
bool ClassFlowControll::isAutoStart(long &_interval)
{
_intervall = AutoIntervall * 60 * 1000; // AutoInterval: minutes -> ms
_interval = AutoInterval * 60 * 1000; // AutoInterval: minutes -> ms
return AutoStart;
}

Expand All @@ -211,10 +211,10 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)

_type = trim(_type);

if (toUpper(_type).compare("[MAKEIMAGE]") == 0)
if (toUpper(_type).compare("[TAKEIMAGE]") == 0)
{
cfc = new ClassFlowMakeImage(&FlowControll);
flowmakeimage = (ClassFlowMakeImage*) cfc;
cfc = new ClassFlowTakeImage(&FlowControll);
flowtakeimage = (ClassFlowTakeImage*) cfc;
}
if (toUpper(_type).compare("[ALIGNMENT]") == 0)
{
Expand Down Expand Up @@ -330,13 +330,13 @@ void ClassFlowControll::setActStatus(std::string _aktstatus)
}


void ClassFlowControll::doFlowMakeImageOnly(string time)
void ClassFlowControll::doFlowTakeImageOnly(string time)
{
std::string zw_time;

for (int i = 0; i < FlowControll.size(); ++i)
{
if (FlowControll[i]->name() == "ClassFlowMakeImage") {
if (FlowControll[i]->name() == "ClassFlowTakeImage") {
zw_time = getCurrentTimeString("%H:%M:%S");
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
aktstatus = flowStatus + " (" + zw_time + ")";
Expand Down Expand Up @@ -535,7 +535,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)


if ((toUpper(aktparamgraph).compare("[AUTOTIMER]") != 0) && (toUpper(aktparamgraph).compare("[DEBUG]") != 0) &&
(toUpper(aktparamgraph).compare("[SYSTEM]") != 0 && (toUpper(aktparamgraph).compare("[DATALOGGING]") != 0))) // Paragraph passt nicht zu MakeImage
(toUpper(aktparamgraph).compare("[SYSTEM]") != 0 && (toUpper(aktparamgraph).compare("[DATALOGGING]") != 0))) // Paragraph passt nicht zu Debug oder DataLogging
return false;

while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
Expand All @@ -549,9 +549,9 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
}
}

if ((toUpper(splitted[0]) == "INTERVALL") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "INTERVAL") && (splitted.size() > 1))
{
AutoIntervall = std::stof(splitted[1]);
AutoInterval = std::stof(splitted[1]);
}

if ((toUpper(splitted[0]) == "DATALOGACTIVE") && (splitted.size() > 1))
Expand All @@ -565,12 +565,12 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
}
}

if ((toUpper(splitted[0]) == "DATALOGRETENTIONINDAYS") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "DATAFILESRETENTION") && (splitted.size() > 1))
{
LogFile.SetDataLogRetention(std::stoi(splitted[1]));
}

if ((toUpper(splitted[0]) == "LOGFILE") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "LOGLEVEL") && (splitted.size() > 1))
{
/* matches esp_log_level_t */
if ((toUpper(splitted[1]) == "TRUE") || (toUpper(splitted[1]) == "2"))
Expand All @@ -590,20 +590,20 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
LogFile.setLogLevel(ESP_LOG_DEBUG);
}
}
if ((toUpper(splitted[0]) == "LOGFILERETENTIONINDAYS") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "LOGFILESRETENTION") && (splitted.size() > 1))
{
LogFile.SetLogFileRetention(std::stoi(splitted[1]));
}

/* TimeServer and TimeZone got already read from the config, see setupTime () */

if ((toUpper(splitted[0]) == "RSSITHREASHOLD") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "RSSITHRESHOLD") && (splitted.size() > 1))
{
if (ChangeRSSIThreashold(WLAN_CONFIG_FILE, atoi(splitted[1].c_str())))
if (ChangeRSSIThreshold(WLAN_CONFIG_FILE, atoi(splitted[1].c_str())))
{
// reboot necessary so that the new wlan.ini is also used !!!
fclose(pfile);
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Rebooting to activate new RSSITHREASHOLD ...");
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Rebooting to activate new RSSITHRESHOLD ...");
esp_restart();
hard_restart();
doReboot();
Expand Down Expand Up @@ -668,7 +668,7 @@ int ClassFlowControll::CleanTempFolder() {

esp_err_t ClassFlowControll::SendRawJPG(httpd_req_t *req)
{
return flowmakeimage != NULL ? flowmakeimage->SendRawJPG(req) : ESP_FAIL;
return flowtakeimage != NULL ? flowtakeimage->SendRawJPG(req) : ESP_FAIL;
}


Expand Down
10 changes: 5 additions & 5 deletions code/components/jomjol_flowcontroll/ClassFlowControll.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

#include "ClassFlow.h"
#include "ClassFlowMakeImage.h"
#include "ClassFlowTakeImage.h"
#include "ClassFlowAlignment.h"
#include "ClassFlowCNNGeneral.h"
#include "ClassFlowPostProcessing.h"
Expand All @@ -30,11 +30,11 @@ class ClassFlowControll :
ClassFlowCNNGeneral* flowanalog;
ClassFlowCNNGeneral* flowdigit;
// ClassFlowDigit* flowdigit;
ClassFlowMakeImage* flowmakeimage;
ClassFlowTakeImage* flowtakeimage;
ClassFlow* CreateClassFlow(std::string _type);

bool AutoStart;
float AutoIntervall;
float AutoInterval;
bool SetupModeActive;
void SetInitialParameter(void);
std::string aktstatus;
Expand All @@ -43,7 +43,7 @@ class ClassFlowControll :
public:
void InitFlow(std::string config);
bool doFlow(string time);
void doFlowMakeImageOnly(string time);
void doFlowTakeImageOnly(string time);
bool getStatusSetupModus(){return SetupModeActive;};
string getReadout(bool _rawvalue, bool _noerror);
string getReadoutAll(int _type);
Expand All @@ -69,7 +69,7 @@ class ClassFlowControll :

std::string doSingleStep(std::string _stepname, std::string _host);

bool isAutoStart(long &_intervall);
bool isAutoStart(long &_interval);

std::string* getActStatus();
void setActStatus(std::string _aktstatus);
Expand Down
20 changes: 10 additions & 10 deletions code/components/jomjol_flowcontroll/ClassFlowImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ ClassFlowImage::ClassFlowImage(const char* logTag)
this->logTag = logTag;
isLogImage = false;
disabled = false;
this->logfileRetentionInDays = 5;
this->imagesRetention = 5;
}

ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag) : ClassFlow(lfc)
{
this->logTag = logTag;
isLogImage = false;
disabled = false;
this->logfileRetentionInDays = 5;
this->imagesRetention = 5;
}

ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, ClassFlow *_prev, const char* logTag) : ClassFlow(lfc, _prev)
{
this->logTag = logTag;
isLogImage = false;
disabled = false;
this->logfileRetentionInDays = 5;
this->imagesRetention = 5;
}


string ClassFlowImage::CreateLogFolder(string time) {
if (!isLogImage)
return "";

string logPath = LogImageLocation + "/" + time.LOGFILE_TIME_FORMAT_DATE_EXTR + "/" + time.LOGFILE_TIME_FORMAT_HOUR_EXTR;
string logPath = imagesLocation + "/" + time.LOGFILE_TIME_FORMAT_DATE_EXTR + "/" + time.LOGFILE_TIME_FORMAT_HOUR_EXTR;
isLogImage = mkdir_r(logPath.c_str(), S_IRWXU) == 0;
if (!isLogImage) {
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't create log folder for analog images. Path " + logPath);
Expand Down Expand Up @@ -95,7 +95,7 @@ void ClassFlowImage::RemoveOldLogs()
return;

ESP_LOGD(TAG, "remove old images");
if (logfileRetentionInDays == 0) {
if (imagesRetention == 0) {
return;
}

Expand All @@ -104,25 +104,25 @@ void ClassFlowImage::RemoveOldLogs()
char cmpfilename[30];

time(&rawtime);
rawtime = addDays(rawtime, -logfileRetentionInDays + 1);
rawtime = addDays(rawtime, -1 * imagesRetention + 1);
timeinfo = localtime(&rawtime);
//ESP_LOGD(TAG, "ImagefileRetentionInDays: %d", logfileRetentionInDays);
//ESP_LOGD(TAG, "ImagefileRetentionInDays: %d", imagesRetention);

strftime(cmpfilename, 30, LOGFILE_TIME_FORMAT, timeinfo);
//ESP_LOGD(TAG, "file name to compare: %s", cmpfilename);
string folderName = string(cmpfilename).LOGFILE_TIME_FORMAT_DATE_EXTR;

DIR *dir = opendir(LogImageLocation.c_str());
DIR *dir = opendir(imagesLocation.c_str());
if (!dir) {
ESP_LOGE(TAG, "Failed to stat dir: %s", LogImageLocation.c_str());
ESP_LOGE(TAG, "Failed to stat dir: %s", imagesLocation.c_str());
return;
}

struct dirent *entry;
int deleted = 0;
int notDeleted = 0;
while ((entry = readdir(dir)) != NULL) {
string folderPath = LogImageLocation + "/" + entry->d_name;
string folderPath = imagesLocation + "/" + entry->d_name;
if (entry->d_type == DT_DIR) {
//ESP_LOGD(TAG, "Compare %s to %s", entry->d_name, folderName.c_str());
if ((strlen(entry->d_name) == folderName.length()) && (strcmp(entry->d_name, folderName.c_str()) < 0)) {
Expand Down
4 changes: 2 additions & 2 deletions code/components/jomjol_flowcontroll/ClassFlowImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ using namespace std;
class ClassFlowImage : public ClassFlow
{
protected:
string LogImageLocation;
string imagesLocation;
bool isLogImage;
unsigned short logfileRetentionInDays;
unsigned short imagesRetention;
const char* logTag;

string CreateLogFolder(string time);
Expand Down
Loading