|
@@ -154,12 +154,6 @@ void ClassFlowControll::AnalogDrawROI(CImageBasis *_zw)
|
|
|
if (flowanalog)
|
|
if (flowanalog)
|
|
|
flowanalog->DrawROI(_zw);
|
|
flowanalog->DrawROI(_zw);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-void ClassFlowControll::SetNewAlgROI(bool _value)
|
|
|
|
|
-{
|
|
|
|
|
- bNewAlgROI = _value;
|
|
|
|
|
-}
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
@@ -195,7 +189,7 @@ void ClassFlowControll::SetInitialParameter(void)
|
|
|
flowpostprocessing = NULL;
|
|
flowpostprocessing = NULL;
|
|
|
disabled = false;
|
|
disabled = false;
|
|
|
aktRunNr = 0;
|
|
aktRunNr = 0;
|
|
|
- aktstatus = "Booting ...";
|
|
|
|
|
|
|
+ aktstatus = "Flow task not yet created";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -270,8 +264,12 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|
|
|
|
|
|
|
void ClassFlowControll::InitFlow(std::string config)
|
|
void ClassFlowControll::InitFlow(std::string config)
|
|
|
{
|
|
{
|
|
|
|
|
+ aktstatus = "Initialization";
|
|
|
|
|
+ //#ifdef ENABLE_MQTT
|
|
|
|
|
+ //MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization", false); // Right now, not possible -> MQTT Service is going to be started later
|
|
|
|
|
+ //#endif //ENABLE_MQTT
|
|
|
|
|
+
|
|
|
string line;
|
|
string line;
|
|
|
-
|
|
|
|
|
flowpostprocessing = NULL;
|
|
flowpostprocessing = NULL;
|
|
|
|
|
|
|
|
ClassFlow* cfc;
|
|
ClassFlow* cfc;
|
|
@@ -318,6 +316,12 @@ std::string* ClassFlowControll::getActStatus()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+void ClassFlowControll::setActStatus(std::string _aktstatus)
|
|
|
|
|
+{
|
|
|
|
|
+ aktstatus = _aktstatus;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
void ClassFlowControll::doFlowMakeImageOnly(string time)
|
|
void ClassFlowControll::doFlowMakeImageOnly(string time)
|
|
|
{
|
|
{
|
|
|
std::string zw_time;
|
|
std::string zw_time;
|
|
@@ -672,12 +676,6 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|
|
esp_err_t result = ESP_FAIL;
|
|
esp_err_t result = ESP_FAIL;
|
|
|
bool _sendDelete = false;
|
|
bool _sendDelete = false;
|
|
|
|
|
|
|
|
- if (flowalignment == NULL)
|
|
|
|
|
- {
|
|
|
|
|
- ESP_LOGD(TAG, "ClassFloDControll::GetJPGStream: FloDalignment is not (yet) initialized. Interrupt serving!");
|
|
|
|
|
- return ESP_OK;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if (_fn == "alg.jpg") {
|
|
if (_fn == "alg.jpg") {
|
|
|
if (flowalignment && flowalignment->ImageBasis->ImageOkay()) {
|
|
if (flowalignment && flowalignment->ImageBasis->ImageOkay()) {
|
|
|
_send = flowalignment->ImageBasis;
|
|
_send = flowalignment->ImageBasis;
|
|
@@ -689,26 +687,119 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|
|
}
|
|
}
|
|
|
else if (_fn == "alg_roi.jpg") {
|
|
else if (_fn == "alg_roi.jpg") {
|
|
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG // no CImageBasis needed to create alg_roi.jpg (ca. 790kB less RAM)
|
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG // no CImageBasis needed to create alg_roi.jpg (ca. 790kB less RAM)
|
|
|
- if (bNewAlgROI) {
|
|
|
|
|
|
|
+ if (aktstatus.find("Initialization (delayed)") != -1) {
|
|
|
|
|
+ FILE* file = fopen("/sdcard/html/Flowstate_initialization_delayed.jpg", "rb");
|
|
|
|
|
+
|
|
|
|
|
+ if (!file) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_initialization_delayed.jpg not found");
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fseek(file, 0, SEEK_END);
|
|
|
|
|
+ long fileSize = ftell(file); /* how long is the file ? */
|
|
|
|
|
+ fseek(file, 0, SEEK_SET); /* reset */
|
|
|
|
|
+
|
|
|
|
|
+ unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
|
|
|
|
+
|
|
|
|
|
+ if (!fileBuffer) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: Not enough memory to create fileBuffer: " + std::to_string(fileSize));
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fread(fileBuffer, fileSize, 1, file);
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+
|
|
|
|
|
+ httpd_resp_set_type(req, "image/jpeg");
|
|
|
|
|
+ result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
|
|
|
|
+ delete fileBuffer;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (aktstatus.find("Initialization") != -1) {
|
|
|
|
|
+ FILE* file = fopen("/sdcard/html/Flowstate_initialization.jpg", "rb");
|
|
|
|
|
+
|
|
|
|
|
+ if (!file) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_initialization.jpg not found");
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fseek(file, 0, SEEK_END);
|
|
|
|
|
+ long fileSize = ftell(file); /* how long is the file ? */
|
|
|
|
|
+ fseek(file, 0, SEEK_SET); /* reset */
|
|
|
|
|
+
|
|
|
|
|
+ unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
|
|
|
|
+
|
|
|
|
|
+ if (!fileBuffer) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: Not enough memory to create fileBuffer: " + std::to_string(fileSize));
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fread(fileBuffer, fileSize, 1, file);
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+
|
|
|
|
|
+ httpd_resp_set_type(req, "image/jpeg");
|
|
|
|
|
+ result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
|
|
|
|
+ delete fileBuffer;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (aktstatus.find("Take Image") != -1) {
|
|
|
if (flowalignment && flowalignment->AlgROI) {
|
|
if (flowalignment && flowalignment->AlgROI) {
|
|
|
|
|
+ FILE* file = fopen("/sdcard/html/Flowstate_take_image.jpg", "rb");
|
|
|
|
|
+
|
|
|
|
|
+ if (!file) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg not found");
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fseek(file, 0, SEEK_END);
|
|
|
|
|
+ flowalignment->AlgROI->size = ftell(file); /* how long is the file ? */
|
|
|
|
|
+ fseek(file, 0, SEEK_SET); /* reset */
|
|
|
|
|
+
|
|
|
|
|
+ if (flowalignment->AlgROI->size > MAX_JPG_SIZE) {
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg too large: " + std::to_string(flowalignment->AlgROI->size));
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fread(flowalignment->AlgROI->data, flowalignment->AlgROI->size, 1, file);
|
|
|
|
|
+ fclose(file);
|
|
|
|
|
+
|
|
|
httpd_resp_set_type(req, "image/jpeg");
|
|
httpd_resp_set_type(req, "image/jpeg");
|
|
|
result = httpd_resp_send(req, (const char *)flowalignment->AlgROI->data, flowalignment->AlgROI->size);
|
|
result = httpd_resp_send(req, (const char *)flowalignment->AlgROI->data, flowalignment->AlgROI->size);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served");
|
|
|
|
|
- return ESP_FAIL;
|
|
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served -> alg.jpg is going to be served!");
|
|
|
|
|
+ if (flowalignment && flowalignment->ImageBasis->ImageOkay()) {
|
|
|
|
|
+ _send = flowalignment->ImageBasis;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ httpd_resp_send(req, NULL, 0);
|
|
|
|
|
+ return ESP_OK;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- if (flowalignment && flowalignment->ImageBasis->ImageOkay()) {
|
|
|
|
|
- _send = flowalignment->ImageBasis;
|
|
|
|
|
|
|
+ if (flowalignment && flowalignment->AlgROI) {
|
|
|
|
|
+ httpd_resp_set_type(req, "image/jpeg");
|
|
|
|
|
+ result = httpd_resp_send(req, (const char *)flowalignment->AlgROI->data, flowalignment->AlgROI->size);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- httpd_resp_send(req, NULL, 0);
|
|
|
|
|
- return ESP_OK;
|
|
|
|
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served -> alg.jpg is going to be served!");
|
|
|
|
|
+ if (flowalignment && flowalignment->ImageBasis->ImageOkay()) {
|
|
|
|
|
+ _send = flowalignment->ImageBasis;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ httpd_resp_send(req, NULL, 0);
|
|
|
|
|
+ return ESP_OK;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
#else
|
|
#else
|
|
|
|
|
+ if (!flowalignment) {
|
|
|
|
|
+ ESP_LOGD(TAG, "ClassFloDControll::GetJPGStream: FlowAlignment is not (yet) initialized. Interrupt serving!");
|
|
|
|
|
+ httpd_resp_send(req, NULL, 0);
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
_send = new CImageBasis(flowalignment->ImageBasis);
|
|
_send = new CImageBasis(flowalignment->ImageBasis);
|
|
|
|
|
|
|
|
if (_send->ImageOkay()) {
|
|
if (_send->ImageOkay()) {
|