ClassFlowControll.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #include "ClassFlowControll.h"
  2. #include "connect_wlan.h"
  3. #include "read_wlanini.h"
  4. #include "freertos/task.h"
  5. #include <sys/stat.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include <dirent.h>
  10. #ifdef __cplusplus
  11. }
  12. #endif
  13. #include "ClassLogFile.h"
  14. #include "time_sntp.h"
  15. #include "Helper.h"
  16. #include "server_ota.h"
  17. //#include "CImg.h"
  18. #include "server_help.h"
  19. //#define DEBUG_DETAIL_ON
  20. static const char* TAG = "FLOW CTRL";
  21. std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
  22. std::string _classname = "";
  23. std::string result = "";
  24. // ESP_LOGD(TAG, "_stepname: %s", _stepname.c_str());
  25. if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
  26. _classname = "ClassFlowMakeImage";
  27. }
  28. if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
  29. _classname = "ClassFlowAlignment";
  30. }
  31. if ((_stepname.compare(0, 7, "[Digits") == 0) || (_stepname.compare(0, 8, ";[Digits") == 0)) {
  32. _classname = "ClassFlowCNNGeneral";
  33. }
  34. if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
  35. _classname = "ClassFlowCNNGeneral";
  36. }
  37. if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
  38. _classname = "ClassFlowMQTT";
  39. }
  40. if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
  41. _classname = "ClassFlowInfluxDB";
  42. }
  43. for (int i = 0; i < FlowControll.size(); ++i)
  44. if (FlowControll[i]->name().compare(_classname) == 0){
  45. if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // falls es ein MakeImage ist, braucht das Bild nicht extra aufgenommen zu werden, dass passiert bei html-Abfrage automatisch
  46. FlowControll[i]->doFlow("");
  47. result = FlowControll[i]->getHTMLSingleStep(_host);
  48. }
  49. return result;
  50. }
  51. std::string ClassFlowControll::TranslateAktstatus(std::string _input)
  52. {
  53. if (_input.compare("ClassFlowMakeImage") == 0)
  54. return ("Take Image");
  55. if (_input.compare("ClassFlowAlignment") == 0)
  56. return ("Aligning");
  57. if (_input.compare("ClassFlowCNNGeneral") == 0)
  58. return ("Digitalization of ROIs");
  59. if (_input.compare("ClassFlowMQTT") == 0)
  60. return ("Sending MQTT");
  61. if (_input.compare("ClassFlowInfluxDB") == 0)
  62. return ("Sending InfluxDB");
  63. if (_input.compare("ClassFlowPostProcessing") == 0)
  64. return ("Processing");
  65. if (_input.compare("ClassFlowWriteList") == 0)
  66. return ("Processing");
  67. return "Unkown Status";
  68. }
  69. std::vector<HTMLInfo*> ClassFlowControll::GetAllDigital()
  70. {
  71. if (flowdigit)
  72. {
  73. ESP_LOGD(TAG, "ClassFlowControll::GetAllDigital - flowdigit != NULL");
  74. return flowdigit->GetHTMLInfo();
  75. }
  76. std::vector<HTMLInfo*> empty;
  77. return empty;
  78. }
  79. std::vector<HTMLInfo*> ClassFlowControll::GetAllAnalog()
  80. {
  81. if (flowanalog)
  82. return flowanalog->GetHTMLInfo();
  83. std::vector<HTMLInfo*> empty;
  84. return empty;
  85. }
  86. t_CNNType ClassFlowControll::GetTypeDigital()
  87. {
  88. if (flowdigit)
  89. return flowdigit->getCNNType();
  90. return t_CNNType::None;
  91. }
  92. t_CNNType ClassFlowControll::GetTypeAnalog()
  93. {
  94. if (flowanalog)
  95. return flowanalog->getCNNType();
  96. return t_CNNType::None;
  97. }
  98. string ClassFlowControll::GetMQTTMainTopic()
  99. {
  100. for (int i = 0; i < FlowControll.size(); ++i)
  101. if (FlowControll[i]->name().compare("ClassFlowMQTT") == 0)
  102. return ((ClassFlowMQTT*) (FlowControll[i]))->GetMQTTMainTopic();
  103. return "";
  104. }
  105. void ClassFlowControll::SetInitialParameter(void)
  106. {
  107. AutoStart = false;
  108. SetupModeActive = false;
  109. AutoIntervall = 10; // Minutes
  110. flowdigit = NULL;
  111. flowanalog = NULL;
  112. flowpostprocessing = NULL;
  113. disabled = false;
  114. aktRunNr = 0;
  115. aktstatus = "Booting ...";
  116. }
  117. bool ClassFlowControll::isAutoStart(long &_intervall)
  118. {
  119. _intervall = AutoIntervall * 60 * 1000; // AutoIntervall: Minuten -> ms
  120. return AutoStart;
  121. }
  122. ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
  123. {
  124. ClassFlow* cfc = NULL;
  125. _type = trim(_type);
  126. if (toUpper(_type).compare("[MAKEIMAGE]") == 0)
  127. {
  128. cfc = new ClassFlowMakeImage(&FlowControll);
  129. flowmakeimage = (ClassFlowMakeImage*) cfc;
  130. }
  131. if (toUpper(_type).compare("[ALIGNMENT]") == 0)
  132. {
  133. cfc = new ClassFlowAlignment(&FlowControll);
  134. flowalignment = (ClassFlowAlignment*) cfc;
  135. }
  136. if (toUpper(_type).compare("[ANALOG]") == 0)
  137. {
  138. cfc = new ClassFlowCNNGeneral(flowalignment);
  139. flowanalog = (ClassFlowCNNGeneral*) cfc;
  140. }
  141. if (toUpper(_type).compare(0, 7, "[DIGITS") == 0)
  142. {
  143. cfc = new ClassFlowCNNGeneral(flowalignment);
  144. flowdigit = (ClassFlowCNNGeneral*) cfc;
  145. }
  146. if (toUpper(_type).compare("[MQTT]") == 0)
  147. cfc = new ClassFlowMQTT(&FlowControll);
  148. if (toUpper(_type).compare("[INFLUXDB]") == 0)
  149. cfc = new ClassFlowInfluxDB(&FlowControll);
  150. if (toUpper(_type).compare("[WRITELIST]") == 0)
  151. cfc = new ClassFlowWriteList(&FlowControll);
  152. if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
  153. {
  154. cfc = new ClassFlowPostProcessing(&FlowControll, flowanalog, flowdigit);
  155. flowpostprocessing = (ClassFlowPostProcessing*) cfc;
  156. }
  157. if (cfc) // Wird nur angehangen, falls es nicht [AutoTimer] ist, denn dieses ist für FlowControll
  158. FlowControll.push_back(cfc);
  159. if (toUpper(_type).compare("[AUTOTIMER]") == 0)
  160. cfc = this;
  161. if (toUpper(_type).compare("[DATALOGGING]") == 0)
  162. cfc = this;
  163. if (toUpper(_type).compare("[DEBUG]") == 0)
  164. cfc = this;
  165. if (toUpper(_type).compare("[SYSTEM]") == 0)
  166. cfc = this;
  167. return cfc;
  168. }
  169. void ClassFlowControll::InitFlow(std::string config)
  170. {
  171. string line;
  172. flowpostprocessing = NULL;
  173. ClassFlow* cfc;
  174. FILE* pFile;
  175. config = FormatFileName(config);
  176. pFile = OpenFileAndWait(config.c_str(), "r");
  177. line = "";
  178. char zw[1024];
  179. if (pFile != NULL)
  180. {
  181. fgets(zw, 1024, pFile);
  182. ESP_LOGD(TAG, "%s", zw);
  183. line = std::string(zw);
  184. }
  185. while ((line.size() > 0) && !(feof(pFile)))
  186. {
  187. cfc = CreateClassFlow(line);
  188. if (cfc)
  189. {
  190. ESP_LOGD(TAG, "Start ReadParameter (%s)", line.c_str());
  191. cfc->ReadParameter(pFile, line);
  192. }
  193. else
  194. {
  195. line = "";
  196. if (fgets(zw, 1024, pFile) && !feof(pFile))
  197. {
  198. ESP_LOGD(TAG, "Read: %s", zw);
  199. line = std::string(zw);
  200. }
  201. }
  202. }
  203. fclose(pFile);
  204. }
  205. std::string* ClassFlowControll::getActStatus(){
  206. return &aktstatus;
  207. }
  208. void ClassFlowControll::doFlowMakeImageOnly(string time){
  209. std::string zw_time;
  210. for (int i = 0; i < FlowControll.size(); ++i)
  211. {
  212. if (FlowControll[i]->name() == "ClassFlowMakeImage") {
  213. // zw_time = gettimestring("%Y%m%d-%H%M%S");
  214. zw_time = gettimestring("%H:%M:%S");
  215. aktstatus = TranslateAktstatus(FlowControll[i]->name()) + " (" + zw_time + ")";
  216. FlowControll[i]->doFlow(time);
  217. }
  218. }
  219. }
  220. bool ClassFlowControll::doFlow(string time)
  221. {
  222. // CleanTempFolder(); // dazu muss man noch eine Rolling einführen
  223. bool result = true;
  224. std::string zw_time;
  225. int repeat = 0;
  226. #ifdef DEBUG_DETAIL_ON
  227. LogFile.WriteHeapInfo("ClassFlowControll::doFlow - Start");
  228. #endif
  229. /* Check if we have a valid date/time and if not restart the NTP client */
  230. if (! getTimeIsSet()) {
  231. LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Time not set, restarting NTP Client!");
  232. restartNtpClient();
  233. }
  234. for (int i = 0; i < FlowControll.size(); ++i)
  235. {
  236. zw_time = gettimestring("%H:%M:%S");
  237. aktstatus = TranslateAktstatus(FlowControll[i]->name()) + " (" + zw_time + ")";
  238. // zw_time = gettimestring("%Y%m%d-%H%M%S");
  239. // aktstatus = zw_time + ": " + FlowControll[i]->name();
  240. string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
  241. LogFile.WriteHeapInfo(zw);
  242. if (!FlowControll[i]->doFlow(time)){
  243. repeat++;
  244. LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
  245. if (i) i -= 1; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
  246. result = false;
  247. if (repeat > 5) {
  248. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Wiederholung 5x nicht erfolgreich --> reboot");
  249. doReboot();
  250. // Schritt wurde 5x wiederholt --> reboot
  251. }
  252. }
  253. else
  254. {
  255. result = true;
  256. }
  257. #ifdef DEBUG_DETAIL_ON
  258. LogFile.WriteHeapInfo("ClassFlowControll::doFlow");
  259. #endif
  260. }
  261. zw_time = gettimestring("%H:%M:%S");
  262. aktstatus = "Flow finished (" + zw_time + ")";
  263. return result;
  264. }
  265. string ClassFlowControll::getReadoutAll(int _type)
  266. {
  267. std::string out = "";
  268. if (flowpostprocessing)
  269. {
  270. std::vector<NumberPost*> *numbers = flowpostprocessing->GetNumbers();
  271. for (int i = 0; i < (*numbers).size(); ++i)
  272. {
  273. out = out + (*numbers)[i]->name + "\t";
  274. switch (_type) {
  275. case READOUT_TYPE_VALUE:
  276. out = out + (*numbers)[i]->ReturnValue;
  277. break;
  278. case READOUT_TYPE_PREVALUE:
  279. if (flowpostprocessing->PreValueUse)
  280. {
  281. if ((*numbers)[i]->PreValueOkay)
  282. out = out + (*numbers)[i]->ReturnPreValue;
  283. else
  284. out = out + "PreValue too old";
  285. }
  286. else
  287. out = out + "PreValue deactivated";
  288. break;
  289. case READOUT_TYPE_RAWVALUE:
  290. out = out + (*numbers)[i]->ReturnRawValue;
  291. break;
  292. case READOUT_TYPE_ERROR:
  293. out = out + (*numbers)[i]->ErrorMessageText;
  294. break;
  295. }
  296. if (i < (*numbers).size()-1)
  297. out = out + "\r\n";
  298. }
  299. // ESP_LOGD(TAG, "OUT: %s", out.c_str());
  300. }
  301. return out;
  302. }
  303. string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false)
  304. {
  305. if (flowpostprocessing)
  306. return flowpostprocessing->getReadoutParam(_rawvalue, _noerror);
  307. string zw = "";
  308. string result = "";
  309. for (int i = 0; i < FlowControll.size(); ++i)
  310. {
  311. zw = FlowControll[i]->getReadout();
  312. if (zw.length() > 0)
  313. {
  314. if (result.length() == 0)
  315. result = zw;
  316. else
  317. result = result + "\t" + zw;
  318. }
  319. }
  320. return result;
  321. }
  322. string ClassFlowControll::GetPrevalue(std::string _number)
  323. {
  324. if (flowpostprocessing)
  325. {
  326. return flowpostprocessing->GetPreValue(_number);
  327. }
  328. return std::string("");
  329. }
  330. std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern)
  331. {
  332. double zw;
  333. char* p;
  334. _newvalue = trim(_newvalue);
  335. // ESP_LOGD(TAG, "Input UpdatePreValue: %s", _newvalue.c_str());
  336. if (_newvalue.compare("0.0") == 0)
  337. {
  338. zw = 0;
  339. }
  340. else
  341. {
  342. zw = strtod(_newvalue.c_str(), &p);
  343. if (zw == 0)
  344. return "- Error in String to Value Conversion!!! Must be of format value=123.456";
  345. }
  346. if (flowpostprocessing)
  347. {
  348. flowpostprocessing->SetPreValue(zw, _numbers, _extern);
  349. return _newvalue;
  350. }
  351. return std::string();
  352. }
  353. bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
  354. {
  355. std::vector<string> zerlegt;
  356. aktparamgraph = trim(aktparamgraph);
  357. if (aktparamgraph.size() == 0)
  358. if (!this->GetNextParagraph(pfile, aktparamgraph))
  359. return false;
  360. if ((toUpper(aktparamgraph).compare("[AUTOTIMER]") != 0) && (toUpper(aktparamgraph).compare("[DEBUG]") != 0) &&
  361. (toUpper(aktparamgraph).compare("[SYSTEM]") != 0 && (toUpper(aktparamgraph).compare("[DATALOGGING]") != 0))) // Paragraph passt nicht zu MakeImage
  362. return false;
  363. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
  364. {
  365. zerlegt = ZerlegeZeile(aktparamgraph, " =");
  366. if ((toUpper(zerlegt[0]) == "AUTOSTART") && (zerlegt.size() > 1))
  367. {
  368. if (toUpper(zerlegt[1]) == "TRUE")
  369. {
  370. AutoStart = true;
  371. }
  372. }
  373. if ((toUpper(zerlegt[0]) == "INTERVALL") && (zerlegt.size() > 1))
  374. {
  375. AutoIntervall = std::stof(zerlegt[1]);
  376. }
  377. if ((toUpper(zerlegt[0]) == "DATALOGACTIVE") && (zerlegt.size() > 1))
  378. {
  379. if (toUpper(zerlegt[1]) == "TRUE")
  380. {
  381. LogFile.SetDataLogToSD(true);
  382. }
  383. else {
  384. LogFile.SetDataLogToSD(false);
  385. }
  386. }
  387. if ((toUpper(zerlegt[0]) == "DATALOGRETENTIONINDAYS") && (zerlegt.size() > 1))
  388. {
  389. LogFile.SetDataLogRetention(std::stoi(zerlegt[1]));
  390. }
  391. if ((toUpper(zerlegt[0]) == "LOGFILE") && (zerlegt.size() > 1))
  392. {
  393. /* matches esp_log_level_t */
  394. if ((toUpper(zerlegt[1]) == "TRUE") || (toUpper(zerlegt[1]) == "2"))
  395. {
  396. LogFile.setLogLevel(ESP_LOG_WARN);
  397. }
  398. else if ((toUpper(zerlegt[1]) == "FALSE") || (toUpper(zerlegt[1]) == "0") || (toUpper(zerlegt[1]) == "1"))
  399. {
  400. LogFile.setLogLevel(ESP_LOG_ERROR);
  401. }
  402. else if (toUpper(zerlegt[1]) == "3")
  403. {
  404. LogFile.setLogLevel(ESP_LOG_INFO);
  405. }
  406. else if (toUpper(zerlegt[1]) == "4")
  407. {
  408. LogFile.setLogLevel(ESP_LOG_DEBUG);
  409. }
  410. }
  411. if ((toUpper(zerlegt[0]) == "LOGFILERETENTIONINDAYS") && (zerlegt.size() > 1))
  412. {
  413. LogFile.SetLogFileRetention(std::stoi(zerlegt[1]));
  414. }
  415. if ((toUpper(zerlegt[0]) == "TIMEZONE") && (zerlegt.size() > 1))
  416. {
  417. string zw = "Set TimeZone: " + zerlegt[1];
  418. setTimeZone(zerlegt[1]);
  419. }
  420. if ((toUpper(zerlegt[0]) == "TIMESERVER") && (zerlegt.size() > 1))
  421. {
  422. string zw = "Set TimeZone: " + zerlegt[1];
  423. reset_servername(zerlegt[1]);
  424. }
  425. if ((toUpper(zerlegt[0]) == "HOSTNAME") && (zerlegt.size() > 1))
  426. {
  427. if (ChangeHostName("/sdcard/wlan.ini", zerlegt[1]))
  428. {
  429. // reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
  430. fclose(pfile);
  431. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Rebooting to activate new HOSTNAME...");
  432. esp_restart();
  433. hard_restart();
  434. doReboot();
  435. }
  436. }
  437. if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1))
  438. {
  439. if (toUpper(zerlegt[1]) == "TRUE")
  440. {
  441. SetupModeActive = true;
  442. }
  443. }
  444. }
  445. /* Start the MQTT service */
  446. for (int i = 0; i < FlowControll.size(); ++i)
  447. if (FlowControll[i]->name().compare("ClassFlowMQTT") == 0)
  448. return ((ClassFlowMQTT*) (FlowControll[i]))->Start(AutoIntervall);
  449. return true;
  450. }
  451. int ClassFlowControll::CleanTempFolder() {
  452. const char* folderPath = "/sdcard/img_tmp";
  453. ESP_LOGI(TAG, "Clean up temporary folder to avoid damage of sdcard sectors : %s", folderPath);
  454. DIR *dir = opendir(folderPath);
  455. if (!dir) {
  456. ESP_LOGE(TAG, "Failed to stat dir : %s", folderPath);
  457. return -1;
  458. }
  459. struct dirent *entry;
  460. int deleted = 0;
  461. while ((entry = readdir(dir)) != NULL) {
  462. std::string path = string(folderPath) + "/" + entry->d_name;
  463. if (entry->d_type == DT_REG) {
  464. if (unlink(path.c_str()) == 0) {
  465. deleted ++;
  466. } else {
  467. ESP_LOGE(TAG, "can't delete file : %s", path.c_str());
  468. }
  469. } else if (entry->d_type == DT_DIR) {
  470. deleted += removeFolder(path.c_str(), TAG);
  471. }
  472. }
  473. closedir(dir);
  474. ESP_LOGI(TAG, "%d files deleted", deleted);
  475. return 0;
  476. }
  477. esp_err_t ClassFlowControll::SendRawJPG(httpd_req_t *req)
  478. {
  479. return flowmakeimage != NULL ? flowmakeimage->SendRawJPG(req) : ESP_FAIL;
  480. }
  481. esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
  482. {
  483. ESP_LOGD(TAG, "ClassFlowControll::GetJPGStream %s", _fn.c_str());
  484. CImageBasis *_send = NULL;
  485. esp_err_t result = ESP_FAIL;
  486. bool Dodelete = false;
  487. if (flowalignment == NULL)
  488. {
  489. ESP_LOGD(TAG, "Can't continue, flowalignment is NULL");
  490. return ESP_FAIL;
  491. }
  492. if (_fn == "alg.jpg")
  493. {
  494. _send = flowalignment->ImageBasis;
  495. }
  496. else
  497. {
  498. if (_fn == "alg_roi.jpg")
  499. {
  500. CImageBasis* _imgzw = new CImageBasis(flowalignment->ImageBasis);
  501. flowalignment->DrawRef(_imgzw);
  502. if (flowdigit) flowdigit->DrawROI(_imgzw);
  503. if (flowanalog) flowanalog->DrawROI(_imgzw);
  504. _send = _imgzw;
  505. Dodelete = true;
  506. }
  507. else
  508. {
  509. std::vector<HTMLInfo*> htmlinfo;
  510. htmlinfo = GetAllDigital();
  511. ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigital");
  512. for (int i = 0; i < htmlinfo.size(); ++i)
  513. {
  514. if (_fn == htmlinfo[i]->filename)
  515. {
  516. if (htmlinfo[i]->image)
  517. _send = htmlinfo[i]->image;
  518. }
  519. if (_fn == htmlinfo[i]->filename_org)
  520. {
  521. if (htmlinfo[i]->image_org)
  522. _send = htmlinfo[i]->image_org;
  523. }
  524. delete htmlinfo[i];
  525. }
  526. htmlinfo.clear();
  527. if (!_send)
  528. {
  529. htmlinfo = GetAllAnalog();
  530. for (int i = 0; i < htmlinfo.size(); ++i)
  531. {
  532. if (_fn == htmlinfo[i]->filename)
  533. {
  534. if (htmlinfo[i]->image)
  535. _send = htmlinfo[i]->image;
  536. }
  537. if (_fn == htmlinfo[i]->filename_org)
  538. {
  539. if (htmlinfo[i]->image_org)
  540. _send = htmlinfo[i]->image_org;
  541. }
  542. delete htmlinfo[i];
  543. }
  544. htmlinfo.clear();
  545. }
  546. }
  547. }
  548. if (_send)
  549. {
  550. ESP_LOGI(TAG, "Sending file : %s ...", _fn.c_str());
  551. set_content_type_from_file(req, _fn.c_str());
  552. result = _send->SendJPGtoHTTP(req);
  553. ESP_LOGI(TAG, "File sending complete");
  554. /* Respond with an empty chunk to signal HTTP response completion */
  555. httpd_resp_send_chunk(req, NULL, 0);
  556. }
  557. if (Dodelete)
  558. {
  559. delete _send;
  560. }
  561. return result;
  562. }
  563. string ClassFlowControll::getNumbersName()
  564. {
  565. return flowpostprocessing->getNumbersName();
  566. }
  567. string ClassFlowControll::getJSON(std::string _id, std::string _mac)
  568. {
  569. return flowpostprocessing->GetJSON(_id, _mac);
  570. }