ClassFlowControll.cpp 19 KB

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