Jelajahi Sumber

Clean up ClassFlowControll by removing unused code

Removed commented-out MQTT and file handling code from ClassFlowControll.cpp.
SybexXx 1 hari lalu
induk
melakukan
d61c4a3bee
1 mengubah file dengan 2 tambahan dan 93 penghapusan
  1. 2 93
      code/components/jomjol_flowcontroll/ClassFlowControll.cpp

+ 2 - 93
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -338,10 +338,6 @@ void ClassFlowControll::InitFlow(std::string config)
 {
 {
     setStatus("Initialization", "Initialization");
     setStatus("Initialization", "Initialization");
 
 
-    //#ifdef ENABLE_MQTT
-        //MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization", 1, false); // Right now, not possible -> MQTT Service is going to be started later
-    //#endif //ENABLE_MQTT
-    
     string line;
     string line;
     flowpostprocessing = NULL;
     flowpostprocessing = NULL;
 
 
@@ -435,14 +431,6 @@ bool ClassFlowControll::doFlow(string time)
         LogFile.WriteHeapInfo("ClassFlowControll::doFlow - Start");
         LogFile.WriteHeapInfo("ClassFlowControll::doFlow - Start");
     #endif
     #endif
 
 
-    /* Check if we have a valid date/time and if not restart the NTP client */
-   /* if (! getTimeIsSet()) {
-        LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Time not set, restarting NTP Client!");
-        restartNtpClient();
-    }*/
-
-    //checkNtpStatus(0);
-
     for (int i = 0; i < FlowControll.size(); ++i) {
     for (int i = 0; i < FlowControll.size(); ++i) {
         zw_time = getCurrentTimeString("%H:%M:%S");
         zw_time = getCurrentTimeString("%H:%M:%S");
         std::string status = TranslateAktstatus(FlowControll[i]->name());
         std::string status = TranslateAktstatus(FlowControll[i]->name());
@@ -746,94 +734,15 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
             if (status.find("Initialization (delayed)") != -1) {
             if (status.find("Initialization (delayed)") != -1) {
                 std::string filename = "/sdcard/html/Flowstate_initialization_delayed.jpg";
                 std::string filename = "/sdcard/html/Flowstate_initialization_delayed.jpg";
                 result = send_file(req, filename);
                 result = send_file(req, filename);
-                /*    
-                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); 
-                free(fileBuffer);
-                */
             }
             }
             else if (status.find("Initialization") != -1) {
             else if (status.find("Initialization") != -1) {
                 std::string filename = "/sdcard/html/Flowstate_initialization.jpg";
                 std::string filename = "/sdcard/html/Flowstate_initialization.jpg";
                 result = send_file(req, filename);
                 result = send_file(req, filename);
-                /*
-                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); 
-                free(fileBuffer);
-                */
             }
             }
             else if (status.find("Take Image") != -1) {
             else if (status.find("Take Image") != -1) {
                 if (flowalignment != NULL) {
                 if (flowalignment != NULL) {
                     std::string filename = "/sdcard/html/Flowstate_take_image.jpg";
                     std::string filename = "/sdcard/html/Flowstate_take_image.jpg";
                     result = send_file(req, filename);
                     result = send_file(req, filename);
-                    /*
-                    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 (" + std::to_string(flowalignment->AlgROI->size) +
-                                                                ") > allocated buffer (" + std::to_string(MAX_JPG_SIZE) + ")");
-                        fclose(file);
-                        return ESP_FAIL;
-                    }
-
-                    fread(flowalignment->AlgROI->data, flowalignment->AlgROI->size, 1, file);
-                    fclose(file);
-
-                    httpd_resp_set_type(req, "image/jpeg");
-                    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 -> alg.jpg is going to be served!");
                     LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served -> alg.jpg is going to be served!");
@@ -841,8 +750,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
                         _send = flowalignment->ImageBasis;
                         _send = flowalignment->ImageBasis;
                     }
                     }
                     else {
                     else {
-                        httpd_resp_send(req, NULL, 0);
-                        return ESP_OK;
+                        std::string filename = "/sdcard/html/Flowstate_at_work.jpg";
+                        result = send_file(req, filename);
                     }
                     }
                 }
                 }
             }
             }