ClassFlowPostProcessing.cpp 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. #include "ClassFlowPostProcessing.h"
  2. #include "Helper.h"
  3. #include "ClassFlowTakeImage.h"
  4. #include "ClassLogFile.h"
  5. #include <iomanip>
  6. #include <sstream>
  7. #include <time.h>
  8. #include "time_sntp.h"
  9. #include "esp_log.h"
  10. #include "../../include/defines.h"
  11. static const char* TAG = "POSTPROC";
  12. std::string ClassFlowPostProcessing::getNumbersName() {
  13. std::string ret="";
  14. for (int i = 0; i < NUMBERS.size(); ++i) {
  15. ret += NUMBERS[i]->name;
  16. if (i < NUMBERS.size()-1) {
  17. ret = ret + "\t";
  18. }
  19. }
  20. // ESP_LOGI(TAG, "Result ClassFlowPostProcessing::getNumbersName: %s", ret.c_str());
  21. return ret;
  22. }
  23. std::string ClassFlowPostProcessing::GetJSON(std::string _lineend) {
  24. std::string json="{" + _lineend;
  25. for (int i = 0; i < NUMBERS.size(); ++i) {
  26. json += "\"" + NUMBERS[i]->name + "\":" + _lineend;
  27. json += getJsonFromNumber(i, _lineend) + _lineend;
  28. if ((i+1) < NUMBERS.size()) {
  29. json += "," + _lineend;
  30. }
  31. }
  32. json += "}";
  33. return json;
  34. }
  35. string ClassFlowPostProcessing::getJsonFromNumber(int i, std::string _lineend) {
  36. std::string json = "";
  37. json += " {" + _lineend;
  38. if (NUMBERS[i]->ReturnValue.length() > 0) {
  39. json += " \"value\": \"" + NUMBERS[i]->ReturnValue + "\"," + _lineend;
  40. }
  41. else {
  42. json += " \"value\": \"\"," + _lineend;
  43. }
  44. json += " \"raw\": \"" + NUMBERS[i]->ReturnRawValue + "\"," + _lineend;
  45. json += " \"pre\": \"" + NUMBERS[i]->ReturnPreValue + "\"," + _lineend;
  46. json += " \"error\": \"" + NUMBERS[i]->ErrorMessageText + "\"," + _lineend;
  47. if (NUMBERS[i]->ReturnRateValue.length() > 0) {
  48. json += " \"rate\": \"" + NUMBERS[i]->ReturnRateValue + "\"," + _lineend;
  49. }
  50. else {
  51. json += " \"rate\": \"\"," + _lineend;
  52. }
  53. json += " \"timestamp\": \"" + NUMBERS[i]->timeStamp + "\"" + _lineend;
  54. json += " }" + _lineend;
  55. return json;
  56. }
  57. string ClassFlowPostProcessing::GetPreValue(std::string _number) {
  58. std::string result;
  59. int index = -1;
  60. if (_number == "") {
  61. _number = "default";
  62. }
  63. for (int i = 0; i < NUMBERS.size(); ++i) {
  64. if (NUMBERS[i]->name == _number) {
  65. index = i;
  66. }
  67. }
  68. if (index == -1) {
  69. return std::string("");
  70. }
  71. result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->Nachkomma);
  72. return result;
  73. }
  74. bool ClassFlowPostProcessing::SetPreValue(double _newvalue, string _numbers, bool _extern) {
  75. //ESP_LOGD(TAG, "SetPrevalue: %f, %s", zw, _numbers.c_str());
  76. for (int j = 0; j < NUMBERS.size(); ++j) {
  77. //ESP_LOGD(TAG, "Number %d, %s", j, NUMBERS[j]->name.c_str());
  78. if (NUMBERS[j]->name == _numbers) {
  79. if (_newvalue >= 0) {
  80. // if new value posivive, use provided value to preset PreValue
  81. NUMBERS[j]->PreValue = _newvalue;
  82. }
  83. else {
  84. // if new value negative, use last raw value to preset PreValue
  85. char* p;
  86. double ReturnRawValueAsDouble = strtod(NUMBERS[j]->ReturnRawValue.c_str(), &p);
  87. if (ReturnRawValueAsDouble == 0) {
  88. LogFile.WriteToFile(ESP_LOG_WARN, TAG, "SetPreValue: RawValue not a valid value for further processing: " + NUMBERS[j]->ReturnRawValue);
  89. return false;
  90. }
  91. NUMBERS[j]->PreValue = ReturnRawValueAsDouble;
  92. }
  93. NUMBERS[j]->ReturnPreValue = std::to_string(NUMBERS[j]->PreValue);
  94. NUMBERS[j]->PreValueOkay = true;
  95. if (_extern) {
  96. time(&(NUMBERS[j]->lastvalue));
  97. localtime(&(NUMBERS[j]->lastvalue));
  98. }
  99. //ESP_LOGD(TAG, "Found %d! - set to %.8f", j, NUMBERS[j]->PreValue);
  100. UpdatePreValueINI = true; // Only update prevalue file if a new value is set
  101. SavePreValue();
  102. LogFile.WriteToFile(ESP_LOG_INFO, TAG, "SetPreValue: PreValue for " + NUMBERS[j]->name + " set to " + std::to_string(NUMBERS[j]->PreValue));
  103. return true;
  104. }
  105. }
  106. LogFile.WriteToFile(ESP_LOG_WARN, TAG, "SetPreValue: Numbersname not found or not valid");
  107. return false; // No new value was set (e.g. wrong numbersname, no numbers at all)
  108. }
  109. bool ClassFlowPostProcessing::LoadPreValue(void) {
  110. std::vector<string> splitted;
  111. FILE* pFile;
  112. char zw[1024];
  113. string zwtime, zwvalue, name;
  114. bool _done = false;
  115. UpdatePreValueINI = false; // Conversion to the new format
  116. pFile = fopen(FilePreValue.c_str(), "r");
  117. if (pFile == NULL) {
  118. return false;
  119. }
  120. fgets(zw, 1024, pFile);
  121. ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
  122. zwtime = trim(std::string(zw));
  123. if (zwtime.length() == 0) {
  124. return false;
  125. }
  126. splitted = HelperZerlegeZeile(zwtime, "\t");
  127. // Conversion to the new format
  128. if (splitted.size() > 1) {
  129. while ((splitted.size() > 1) && !_done) {
  130. name = trim(splitted[0]);
  131. zwtime = trim(splitted[1]);
  132. zwvalue = trim(splitted[2]);
  133. for (int j = 0; j < NUMBERS.size(); ++j) {
  134. if (NUMBERS[j]->name == name) {
  135. NUMBERS[j]->PreValue = stod(zwvalue.c_str());
  136. NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma + 1); // To be on the safe side, 1 digit more, as Exgtended Resolution may be on (will only be set during the first run).
  137. time_t tStart;
  138. int yy, month, dd, hh, mm, ss;
  139. struct tm whenStart;
  140. sscanf(zwtime.c_str(), PREVALUE_TIME_FORMAT_INPUT, &yy, &month, &dd, &hh, &mm, &ss);
  141. whenStart.tm_year = yy - 1900;
  142. whenStart.tm_mon = month - 1;
  143. whenStart.tm_mday = dd;
  144. whenStart.tm_hour = hh;
  145. whenStart.tm_min = mm;
  146. whenStart.tm_sec = ss;
  147. whenStart.tm_isdst = -1;
  148. NUMBERS[j]->lastvalue = mktime(&whenStart);
  149. time(&tStart);
  150. localtime(&tStart);
  151. double difference = difftime(tStart, NUMBERS[j]->lastvalue);
  152. difference /= 60;
  153. if (difference > PreValueAgeStartup) {
  154. NUMBERS[j]->PreValueOkay = false;
  155. }
  156. else {
  157. NUMBERS[j]->PreValueOkay = true;
  158. }
  159. }
  160. }
  161. if (!fgets(zw, 1024, pFile)) {
  162. _done = true;
  163. }
  164. else {
  165. ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
  166. splitted = HelperZerlegeZeile(trim(std::string(zw)), "\t");
  167. if (splitted.size() > 1) {
  168. name = trim(splitted[0]);
  169. zwtime = trim(splitted[1]);
  170. zwvalue = trim(splitted[2]);
  171. }
  172. }
  173. }
  174. fclose(pFile);
  175. }
  176. else {
  177. // Old Format
  178. fgets(zw, 1024, pFile);
  179. fclose(pFile);
  180. ESP_LOGD(TAG, "%s", zw);
  181. zwvalue = trim(std::string(zw));
  182. NUMBERS[0]->PreValue = stod(zwvalue.c_str());
  183. time_t tStart;
  184. int yy, month, dd, hh, mm, ss;
  185. struct tm whenStart;
  186. sscanf(zwtime.c_str(), PREVALUE_TIME_FORMAT_INPUT, &yy, &month, &dd, &hh, &mm, &ss);
  187. whenStart.tm_year = yy - 1900;
  188. whenStart.tm_mon = month - 1;
  189. whenStart.tm_mday = dd;
  190. whenStart.tm_hour = hh;
  191. whenStart.tm_min = mm;
  192. whenStart.tm_sec = ss;
  193. whenStart.tm_isdst = -1;
  194. ESP_LOGD(TAG, "TIME: %d, %d, %d, %d, %d, %d", whenStart.tm_year, whenStart.tm_mon, whenStart.tm_wday, whenStart.tm_hour, whenStart.tm_min, whenStart.tm_sec);
  195. NUMBERS[0]->lastvalue = mktime(&whenStart);
  196. time(&tStart);
  197. localtime(&tStart);
  198. double difference = difftime(tStart, NUMBERS[0]->lastvalue);
  199. difference /= 60;
  200. if (difference > PreValueAgeStartup) {
  201. return false;
  202. }
  203. NUMBERS[0]->Value = NUMBERS[0]->PreValue;
  204. NUMBERS[0]->ReturnValue = to_string(NUMBERS[0]->Value);
  205. if (NUMBERS[0]->digit_roi || NUMBERS[0]->analog_roi) {
  206. NUMBERS[0]->ReturnValue = RundeOutput(NUMBERS[0]->Value, NUMBERS[0]->Nachkomma);
  207. }
  208. UpdatePreValueINI = true; // Conversion to the new format
  209. SavePreValue();
  210. }
  211. return true;
  212. }
  213. void ClassFlowPostProcessing::SavePreValue() {
  214. FILE* pFile;
  215. string _zw;
  216. // PreValues unchanged --> File does not have to be rewritten
  217. if (!UpdatePreValueINI) {
  218. return;
  219. }
  220. pFile = fopen(FilePreValue.c_str(), "w");
  221. for (int j = 0; j < NUMBERS.size(); ++j) {
  222. char buffer[80];
  223. struct tm* timeinfo = localtime(&NUMBERS[j]->lastvalue);
  224. strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
  225. NUMBERS[j]->timeStamp = std::string(buffer);
  226. NUMBERS[j]->timeStampTimeUTC = NUMBERS[j]->lastvalue;
  227. // ESP_LOGD(TAG, "SaverPreValue %d, Value: %f, Nachkomma %d", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
  228. _zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n";
  229. ESP_LOGD(TAG, "Write PreValue line: %s", _zw.c_str());
  230. if (pFile) {
  231. fputs(_zw.c_str(), pFile);
  232. }
  233. }
  234. UpdatePreValueINI = false;
  235. fclose(pFile);
  236. }
  237. ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc, ClassFlowCNNGeneral *_analog, ClassFlowCNNGeneral *_digit) {
  238. PreValueUse = false;
  239. PreValueAgeStartup = 30;
  240. ErrorMessage = false;
  241. ListFlowControll = NULL;
  242. FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
  243. ListFlowControll = lfc;
  244. flowTakeImage = NULL;
  245. UpdatePreValueINI = false;
  246. IgnoreLeadingNaN = false;
  247. flowAnalog = _analog;
  248. flowDigit = _digit;
  249. for (int i = 0; i < ListFlowControll->size(); ++i) {
  250. if (((*ListFlowControll)[i])->name().compare("ClassFlowTakeImage") == 0) {
  251. flowTakeImage = (ClassFlowTakeImage*) (*ListFlowControll)[i];
  252. }
  253. }
  254. }
  255. void ClassFlowPostProcessing::handleDecimalExtendedResolution(string _decsep, string _value) {
  256. string _digit, _decpos;
  257. int _pospunkt = _decsep.find_first_of(".");
  258. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  259. if (_pospunkt > -1) {
  260. _digit = _decsep.substr(0, _pospunkt);
  261. }
  262. else {
  263. _digit = "default";
  264. }
  265. for (int j = 0; j < NUMBERS.size(); ++j) {
  266. bool _zwdc = false;
  267. if (toUpper(_value) == "TRUE") {
  268. _zwdc = true;
  269. }
  270. // Set to default first (if nothing else is set)
  271. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  272. NUMBERS[j]->isExtendedResolution = _zwdc;
  273. }
  274. }
  275. }
  276. void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _value) {
  277. string _digit, _decpos;
  278. int _pospunkt = _decsep.find_first_of(".");
  279. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  280. if (_pospunkt > -1) {
  281. _digit = _decsep.substr(0, _pospunkt);
  282. }
  283. else {
  284. _digit = "default";
  285. }
  286. for (int j = 0; j < NUMBERS.size(); ++j) {
  287. int _zwdc = 0;
  288. _zwdc = stoi(_value);
  289. // Set to default first (if nothing else is set)
  290. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  291. NUMBERS[j]->DecimalShift = _zwdc;
  292. NUMBERS[j]->DecimalShiftInitial = _zwdc;
  293. }
  294. NUMBERS[j]->Nachkomma = NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift;
  295. }
  296. }
  297. void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep, string _value) {
  298. string _digit, _decpos;
  299. int _pospunkt = _decsep.find_first_of(".");
  300. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  301. if (_pospunkt > -1) {
  302. _digit = _decsep.substr(0, _pospunkt);
  303. }
  304. else {
  305. _digit = "default";
  306. }
  307. for (int j = 0; j < NUMBERS.size(); ++j) {
  308. float _zwdc = 9.2;
  309. _zwdc = stof(_value);
  310. // Set to default first (if nothing else is set)
  311. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  312. NUMBERS[j]->AnalogDigitalTransitionStart = _zwdc;
  313. }
  314. }
  315. }
  316. void ClassFlowPostProcessing::handleAllowNegativeRate(string _decsep, string _value) {
  317. string _digit, _decpos;
  318. int _pospunkt = _decsep.find_first_of(".");
  319. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  320. if (_pospunkt > -1) {
  321. _digit = _decsep.substr(0, _pospunkt);
  322. }
  323. else {
  324. _digit = "default";
  325. }
  326. for (int j = 0; j < NUMBERS.size(); ++j) {
  327. bool _rt = false;
  328. if (toUpper(_value) == "TRUE") {
  329. _rt = true;
  330. }
  331. // Set to default first (if nothing else is set)
  332. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  333. NUMBERS[j]->AllowNegativeRates = _rt;
  334. }
  335. }
  336. }
  337. void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value) {
  338. string _digit, _decpos;
  339. int _pospunkt = _decsep.find_first_of(".");
  340. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  341. if (_pospunkt > -1) {
  342. _digit = _decsep.substr(0, _pospunkt);
  343. }
  344. else {
  345. _digit = "default";
  346. }
  347. for (int j = 0; j < NUMBERS.size(); ++j) {
  348. t_RateType _rt = AbsoluteChange;
  349. if (toUpper(_value) == "RATECHANGE") {
  350. _rt = RateChange;
  351. }
  352. // Set to default first (if nothing else is set)
  353. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  354. NUMBERS[j]->RateType = _rt;
  355. }
  356. }
  357. }
  358. void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value) {
  359. string _digit, _decpos;
  360. int _pospunkt = _decsep.find_first_of(".");
  361. // ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
  362. if (_pospunkt > -1) {
  363. _digit = _decsep.substr(0, _pospunkt);
  364. }
  365. else {
  366. _digit = "default";
  367. }
  368. for (int j = 0; j < NUMBERS.size(); ++j) {
  369. float _zwdc = 1;
  370. _zwdc = stof(_value);
  371. // Set to default first (if nothing else is set)
  372. if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
  373. NUMBERS[j]->useMaxRateValue = true;
  374. NUMBERS[j]->MaxRateValue = _zwdc;
  375. }
  376. }
  377. }
  378. bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph) {
  379. std::vector<string> splitted;
  380. int _n;
  381. aktparamgraph = trim(aktparamgraph);
  382. if (aktparamgraph.size() == 0) {
  383. if (!this->GetNextParagraph(pfile, aktparamgraph)) {
  384. return false;
  385. }
  386. }
  387. // Paragraph does not fit PostProcessing
  388. if (aktparamgraph.compare("[PostProcessing]") != 0) {
  389. return false;
  390. }
  391. InitNUMBERS();
  392. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) {
  393. splitted = ZerlegeZeile(aktparamgraph);
  394. std::string _param = GetParameterName(splitted[0]);
  395. if ((toUpper(_param) == "EXTENDEDRESOLUTION") && (splitted.size() > 1)) {
  396. handleDecimalExtendedResolution(splitted[0], splitted[1]);
  397. }
  398. if ((toUpper(_param) == "DECIMALSHIFT") && (splitted.size() > 1)) {
  399. handleDecimalSeparator(splitted[0], splitted[1]);
  400. }
  401. if ((toUpper(_param) == "ANALOGDIGITALTRANSITIONSTART") && (splitted.size() > 1)) {
  402. handleAnalogDigitalTransitionStart(splitted[0], splitted[1]);
  403. }
  404. if ((toUpper(_param) == "MAXRATEVALUE") && (splitted.size() > 1)) {
  405. handleMaxRateValue(splitted[0], splitted[1]);
  406. }
  407. if ((toUpper(_param) == "MAXRATETYPE") && (splitted.size() > 1)) {
  408. handleMaxRateType(splitted[0], splitted[1]);
  409. }
  410. if ((toUpper(_param) == "PREVALUEUSE") && (splitted.size() > 1)) {
  411. if (toUpper(splitted[1]) == "TRUE") {
  412. PreValueUse = true;
  413. }
  414. }
  415. if ((toUpper(_param) == "CHECKDIGITINCREASECONSISTENCY") && (splitted.size() > 1)) {
  416. if (toUpper(splitted[1]) == "TRUE") {
  417. for (_n = 0; _n < NUMBERS.size(); ++_n) {
  418. NUMBERS[_n]->checkDigitIncreaseConsistency = true;
  419. }
  420. }
  421. }
  422. if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (splitted.size() > 1)) {
  423. handleAllowNegativeRate(splitted[0], splitted[1]);
  424. }
  425. if ((toUpper(_param) == "ERRORMESSAGE") && (splitted.size() > 1)) {
  426. if (toUpper(splitted[1]) == "TRUE") {
  427. ErrorMessage = true;
  428. }
  429. }
  430. if ((toUpper(_param) == "IGNORELEADINGNAN") && (splitted.size() > 1)) {
  431. if (toUpper(splitted[1]) == "TRUE") {
  432. IgnoreLeadingNaN = true;
  433. }
  434. }
  435. if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (splitted.size() > 1)) {
  436. PreValueAgeStartup = std::stoi(splitted[1]);
  437. }
  438. }
  439. if (PreValueUse) {
  440. LoadPreValue();
  441. }
  442. return true;
  443. }
  444. void ClassFlowPostProcessing::InitNUMBERS() {
  445. int anzDIGIT = 0;
  446. int anzANALOG = 0;
  447. std::vector<std::string> name_numbers;
  448. if (flowDigit) {
  449. anzDIGIT = flowDigit->getNumberGENERAL();
  450. flowDigit->UpdateNameNumbers(&name_numbers);
  451. }
  452. if (flowAnalog) {
  453. anzANALOG = flowAnalog->getNumberGENERAL();
  454. flowAnalog->UpdateNameNumbers(&name_numbers);
  455. }
  456. ESP_LOGD(TAG, "Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d", name_numbers.size(), anzDIGIT, anzANALOG);
  457. for (int _num = 0; _num < name_numbers.size(); ++_num) {
  458. NumberPost *_number = new NumberPost;
  459. _number->name = name_numbers[_num];
  460. _number->digit_roi = NULL;
  461. if (flowDigit) {
  462. _number->digit_roi = flowDigit->FindGENERAL(name_numbers[_num]);
  463. }
  464. if (_number->digit_roi) {
  465. _number->AnzahlDigital = _number->digit_roi->ROI.size();
  466. }
  467. else {
  468. _number->AnzahlDigital = 0;
  469. }
  470. _number->analog_roi = NULL;
  471. if (flowAnalog) {
  472. _number->analog_roi = flowAnalog->FindGENERAL(name_numbers[_num]);
  473. }
  474. if (_number->analog_roi) {
  475. _number->AnzahlAnalog = _number->analog_roi->ROI.size();
  476. }
  477. else {
  478. _number->AnzahlAnalog = 0;
  479. }
  480. _number->ReturnRawValue = ""; // Raw value (with N & leading 0).
  481. _number->ReturnValue = ""; // corrected return value, possibly with error message
  482. _number->ErrorMessageText = ""; // Error message for consistency check
  483. _number->ReturnPreValue = "";
  484. _number->PreValueOkay = false;
  485. _number->AllowNegativeRates = false;
  486. _number->MaxRateValue = 0.1;
  487. _number->RateType = AbsoluteChange;
  488. _number->useMaxRateValue = false;
  489. _number->checkDigitIncreaseConsistency = false;
  490. _number->DecimalShift = 0;
  491. _number->DecimalShiftInitial = 0;
  492. _number->isExtendedResolution = false;
  493. _number->AnalogDigitalTransitionStart=9.2;
  494. _number->FlowRateAct = 0; // m3 / min
  495. _number->PreValue = 0; // last value read out well
  496. _number->Value = 0; // last value read out, incl. corrections
  497. _number->ReturnRawValue = ""; // raw value (with N & leading 0)
  498. _number->ReturnValue = ""; // corrected return value, possibly with error message
  499. _number->ErrorMessageText = ""; // Error message for consistency check
  500. _number->Nachkomma = _number->AnzahlAnalog;
  501. NUMBERS.push_back(_number);
  502. }
  503. for (int i = 0; i < NUMBERS.size(); ++i) {
  504. ESP_LOGD(TAG, "Number %s, Anz DIG: %d, Anz ANA %d", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
  505. }
  506. }
  507. string ClassFlowPostProcessing::ShiftDecimal(string in, int _decShift) {
  508. if (_decShift == 0) {
  509. return in;
  510. }
  511. int _pos_dec_org, _pos_dec_neu;
  512. _pos_dec_org = findDelimiterPos(in, ".");
  513. if (_pos_dec_org == std::string::npos) {
  514. _pos_dec_org = in.length();
  515. }
  516. else {
  517. in = in.erase(_pos_dec_org, 1);
  518. }
  519. _pos_dec_neu = _pos_dec_org + _decShift;
  520. // comma is before the first digit
  521. if (_pos_dec_neu <= 0) {
  522. for (int i = 0; i > _pos_dec_neu; --i) {
  523. in = in.insert(0, "0");
  524. }
  525. in = "0." + in;
  526. return in;
  527. }
  528. // Comma should be after string (123 --> 1230)
  529. if (_pos_dec_neu > in.length()) {
  530. for (int i = in.length(); i < _pos_dec_neu; ++i) {
  531. in = in.insert(in.length(), "0");
  532. }
  533. return in;
  534. }
  535. string zw;
  536. zw = in.substr(0, _pos_dec_neu);
  537. zw = zw + ".";
  538. zw = zw + in.substr(_pos_dec_neu, in.length() - _pos_dec_neu);
  539. return zw;
  540. }
  541. bool ClassFlowPostProcessing::doFlow(string zwtime) {
  542. string result = "";
  543. string digit = "";
  544. string analog = "";
  545. string zwvalue;
  546. string zw;
  547. time_t imagetime = 0;
  548. string rohwert;
  549. // Update decimal point, as the decimal places can also change when changing from CNNType Auto --> xyz:
  550. imagetime = flowTakeImage->getTimeImageTaken();
  551. if (imagetime == 0) {
  552. time(&imagetime);
  553. }
  554. struct tm* timeinfo;
  555. timeinfo = localtime(&imagetime);
  556. char strftime_buf[64];
  557. strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo);
  558. zwtime = std::string(strftime_buf);
  559. ESP_LOGD(TAG, "Quantity NUMBERS: %d", NUMBERS.size());
  560. for (int j = 0; j < NUMBERS.size(); ++j) {
  561. NUMBERS[j]->ReturnRawValue = "";
  562. NUMBERS[j]->ReturnRateValue = "";
  563. NUMBERS[j]->ReturnValue = "";
  564. NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(0.0, NUMBERS[j]->Nachkomma); // always reset change absolute
  565. NUMBERS[j]->ErrorMessageText = "";
  566. NUMBERS[j]->Value = -1;
  567. // calculate time difference BEFORE we overwrite the 'lastvalue'
  568. double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in seconds
  569. // TODO:
  570. // We could call `NUMBERS[j]->lastvalue = imagetime;` here and remove all other such calls further down.
  571. // But we should check nothing breaks!
  572. UpdateNachkommaDecimalShift();
  573. int previous_value = -1;
  574. if (NUMBERS[j]->analog_roi) {
  575. NUMBERS[j]->ReturnRawValue = flowAnalog->getReadout(j, NUMBERS[j]->isExtendedResolution);
  576. if (NUMBERS[j]->ReturnRawValue.length() > 0) {
  577. char zw = NUMBERS[j]->ReturnRawValue[0];
  578. if (zw >= 48 && zw <=57) {
  579. previous_value = zw - 48;
  580. }
  581. }
  582. }
  583. #ifdef SERIAL_DEBUG
  584. ESP_LOGD(TAG, "After analog->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
  585. #endif
  586. if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) {
  587. NUMBERS[j]->ReturnRawValue = "." + NUMBERS[j]->ReturnRawValue;
  588. }
  589. if (NUMBERS[j]->digit_roi) {
  590. if (NUMBERS[j]->analog_roi) {
  591. NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogDigitalTransitionStart) + NUMBERS[j]->ReturnRawValue;
  592. }
  593. else {
  594. NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution only if there are no analogue digits
  595. }
  596. }
  597. #ifdef SERIAL_DEBUG
  598. ESP_LOGD(TAG, "After digital->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
  599. #endif
  600. NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift);
  601. #ifdef SERIAL_DEBUG
  602. ESP_LOGD(TAG, "After ShiftDecimal: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
  603. #endif
  604. if (IgnoreLeadingNaN) {
  605. while ((NUMBERS[j]->ReturnRawValue.length() > 1) && (NUMBERS[j]->ReturnRawValue[0] == 'N')) {
  606. NUMBERS[j]->ReturnRawValue.erase(0, 1);
  607. }
  608. }
  609. #ifdef SERIAL_DEBUG
  610. ESP_LOGD(TAG, "After IgnoreLeadingNaN: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
  611. #endif
  612. NUMBERS[j]->ReturnValue = NUMBERS[j]->ReturnRawValue;
  613. if (findDelimiterPos(NUMBERS[j]->ReturnValue, "N") != std::string::npos) {
  614. if (PreValueUse && NUMBERS[j]->PreValueOkay) {
  615. NUMBERS[j]->ReturnValue = ErsetzteN(NUMBERS[j]->ReturnValue, NUMBERS[j]->PreValue);
  616. }
  617. else {
  618. string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
  619. LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
  620. /* TODO to be discussed, see https://github.com/jomjol/AI-on-the-edge-device/issues/1617 */
  621. NUMBERS[j]->lastvalue = imagetime;
  622. WriteDataLog(j);
  623. continue; // there is no number because there is still an N.
  624. }
  625. }
  626. #ifdef SERIAL_DEBUG
  627. ESP_LOGD(TAG, "After findDelimiterPos: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
  628. #endif
  629. // Delete leading zeros (unless there is only one 0 left)
  630. while ((NUMBERS[j]->ReturnValue.length() > 1) && (NUMBERS[j]->ReturnValue[0] == '0')) {
  631. NUMBERS[j]->ReturnValue.erase(0, 1);
  632. }
  633. #ifdef SERIAL_DEBUG
  634. ESP_LOGD(TAG, "After removeLeadingZeros: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
  635. #endif
  636. NUMBERS[j]->Value = std::stod(NUMBERS[j]->ReturnValue);
  637. #ifdef SERIAL_DEBUG
  638. ESP_LOGD(TAG, "After setting the Value: Value %f and as double is %f", NUMBERS[j]->Value, std::stod(NUMBERS[j]->ReturnValue));
  639. #endif
  640. if (NUMBERS[j]->checkDigitIncreaseConsistency) {
  641. if (flowDigit) {
  642. if (flowDigit->getCNNType() != Digital) {
  643. ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)");
  644. }
  645. else {
  646. NUMBERS[j]->Value = checkDigitConsistency(NUMBERS[j]->Value, NUMBERS[j]->DecimalShift, NUMBERS[j]->analog_roi != NULL, NUMBERS[j]->PreValue);
  647. }
  648. }
  649. else {
  650. #ifdef SERIAL_DEBUG
  651. ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - no digital numbers defined!");
  652. #endif
  653. }
  654. }
  655. #ifdef SERIAL_DEBUG
  656. ESP_LOGD(TAG, "After checkDigitIncreaseConsistency: Value %f", NUMBERS[j]->Value);
  657. #endif
  658. if (!NUMBERS[j]->AllowNegativeRates) {
  659. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handleAllowNegativeRate for device: " + NUMBERS[j]->name);
  660. if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue)) {
  661. // more debug if extended resolution is on, see #2447
  662. if (NUMBERS[j]->isExtendedResolution) {
  663. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Neg: value=" + std::to_string(NUMBERS[j]->Value)
  664. + ", preValue=" + std::to_string(NUMBERS[j]->PreValue)
  665. + ", preToll=" + std::to_string(NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))));
  666. }
  667. // Include inaccuracy of 0.2 for isExtendedResolution.
  668. if ((NUMBERS[j]->Value >= (NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))) && NUMBERS[j]->isExtendedResolution)
  669. // not extended resolution allows -1 on the lowest digit
  670. || (NUMBERS[j]->Value >= (NUMBERS[j]->PreValue-(1/pow(10, NUMBERS[j]->Nachkomma))) && !NUMBERS[j]->isExtendedResolution)) {
  671. NUMBERS[j]->Value = NUMBERS[j]->PreValue;
  672. NUMBERS[j]->ReturnValue = to_string(NUMBERS[j]->PreValue);
  673. }
  674. else {
  675. NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
  676. NUMBERS[j]->Value = NUMBERS[j]->PreValue;
  677. NUMBERS[j]->ReturnValue = "";
  678. NUMBERS[j]->lastvalue = imagetime;
  679. string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
  680. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zw);
  681. WriteDataLog(j);
  682. continue;
  683. }
  684. }
  685. }
  686. #ifdef SERIAL_DEBUG
  687. ESP_LOGD(TAG, "After AllowNegativeRates: Value %f", NUMBERS[j]->Value);
  688. #endif
  689. difference /= 60;
  690. NUMBERS[j]->FlowRateAct = (NUMBERS[j]->Value - NUMBERS[j]->PreValue) / difference;
  691. NUMBERS[j]->ReturnRateValue = to_string(NUMBERS[j]->FlowRateAct);
  692. if (NUMBERS[j]->useMaxRateValue && PreValueUse && NUMBERS[j]->PreValueOkay) {
  693. double _ratedifference;
  694. if (NUMBERS[j]->RateType == RateChange) {
  695. _ratedifference = NUMBERS[j]->FlowRateAct;
  696. }
  697. else {
  698. _ratedifference = (NUMBERS[j]->Value - NUMBERS[j]->PreValue);
  699. }
  700. if (abs(_ratedifference) > abs(NUMBERS[j]->MaxRateValue)) {
  701. NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " - Rate: " + RundeOutput(_ratedifference, NUMBERS[j]->Nachkomma);
  702. NUMBERS[j]->Value = NUMBERS[j]->PreValue;
  703. NUMBERS[j]->ReturnValue = "";
  704. NUMBERS[j]->ReturnRateValue = "";
  705. NUMBERS[j]->lastvalue = imagetime;
  706. string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
  707. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zw);
  708. WriteDataLog(j);
  709. continue;
  710. }
  711. }
  712. #ifdef SERIAL_DEBUG
  713. ESP_LOGD(TAG, "After MaxRateCheck: Value %f", NUMBERS[j]->Value);
  714. #endif
  715. NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
  716. NUMBERS[j]->PreValue = NUMBERS[j]->Value;
  717. NUMBERS[j]->PreValueOkay = true;
  718. NUMBERS[j]->lastvalue = imagetime;
  719. NUMBERS[j]->ReturnValue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma);
  720. NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
  721. NUMBERS[j]->ErrorMessageText = "no error";
  722. UpdatePreValueINI = true;
  723. string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
  724. LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
  725. WriteDataLog(j);
  726. }
  727. SavePreValue();
  728. return true;
  729. }
  730. void ClassFlowPostProcessing::WriteDataLog(int _index) {
  731. if (!LogFile.GetDataLogToSD()) {
  732. return;
  733. }
  734. string analog = "";
  735. string digital = "";
  736. string timezw = "";
  737. char buffer[80];
  738. struct tm* timeinfo = localtime(&NUMBERS[_index]->lastvalue);
  739. strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
  740. timezw = std::string(buffer);
  741. if (flowAnalog) {
  742. analog = flowAnalog->getReadoutRawString(_index);
  743. }
  744. if (flowDigit) {
  745. digital = flowDigit->getReadoutRawString(_index);
  746. }
  747. LogFile.WriteToData(timezw, NUMBERS[_index]->name,
  748. NUMBERS[_index]->ReturnRawValue, NUMBERS[_index]->ReturnValue, NUMBERS[_index]->ReturnPreValue,
  749. NUMBERS[_index]->ReturnRateValue, NUMBERS[_index]->ReturnChangeAbsolute,
  750. NUMBERS[_index]->ErrorMessageText,
  751. digital, analog);
  752. ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_index]->ReturnRawValue.c_str(), NUMBERS[_index]->ReturnValue.c_str(), NUMBERS[_index]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
  753. }
  754. void ClassFlowPostProcessing::UpdateNachkommaDecimalShift() {
  755. for (int j = 0; j < NUMBERS.size(); ++j) {
  756. // There are only digital digits
  757. if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) {
  758. // ESP_LOGD(TAG, "Nurdigital");
  759. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
  760. // Extended resolution is on and should also be used for this digit.
  761. if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) {
  762. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1;
  763. }
  764. NUMBERS[j]->Nachkomma = -NUMBERS[j]->DecimalShift;
  765. }
  766. if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) {
  767. // ESP_LOGD(TAG, "Nur analog");
  768. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
  769. if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) {
  770. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1;
  771. }
  772. NUMBERS[j]->Nachkomma = -NUMBERS[j]->DecimalShift;
  773. }
  774. // digital + analog
  775. if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) {
  776. // ESP_LOGD(TAG, "Nur digital + analog");
  777. NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
  778. NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift;
  779. // Extended resolution is on and should also be used for this digit.
  780. if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) {
  781. NUMBERS[j]->Nachkomma = NUMBERS[j]->Nachkomma+1;
  782. }
  783. }
  784. ESP_LOGD(TAG, "UpdateNachkommaDecShift NUMBER%i: Nachkomma %i, DecShift %i", j, NUMBERS[j]->Nachkomma,NUMBERS[j]->DecimalShift);
  785. }
  786. }
  787. string ClassFlowPostProcessing::getReadout(int _number) {
  788. return NUMBERS[_number]->ReturnValue;
  789. }
  790. string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror, int _number) {
  791. if (_rawValue) {
  792. return NUMBERS[_number]->ReturnRawValue;
  793. }
  794. if (_noerror) {
  795. return NUMBERS[_number]->ReturnValue;
  796. }
  797. return NUMBERS[_number]->ReturnValue;
  798. }
  799. string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue) {
  800. int posN, posPunkt;
  801. int pot, ziffer;
  802. float zw;
  803. posN = findDelimiterPos(input, "N");
  804. posPunkt = findDelimiterPos(input, ".");
  805. if (posPunkt == std::string::npos) {
  806. posPunkt = input.length();
  807. }
  808. while (posN != std::string::npos) {
  809. if (posN < posPunkt) {
  810. pot = posPunkt - posN - 1;
  811. }
  812. else {
  813. pot = posPunkt - posN;
  814. }
  815. zw =_prevalue / pow(10, pot);
  816. ziffer = ((int) zw) % 10;
  817. input[posN] = ziffer + 48;
  818. posN = findDelimiterPos(input, "N");
  819. }
  820. return input;
  821. }
  822. float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilamshift, bool _isanalog, double _preValue) {
  823. int aktdigit, olddigit;
  824. int aktdigit_before, olddigit_before;
  825. int pot, pot_max;
  826. float zw;
  827. bool no_nulldurchgang = false;
  828. pot = _decilamshift;
  829. // if there are no analogue values, the last one cannot be evaluated
  830. if (!_isanalog) {
  831. pot++;
  832. }
  833. #ifdef SERIAL_DEBUG
  834. ESP_LOGD(TAG, "checkDigitConsistency: pot=%d, decimalshift=%d", pot, _decilamshift);
  835. #endif
  836. pot_max = ((int) log10(input)) + 1;
  837. while (pot <= pot_max) {
  838. zw = input / pow(10, pot-1);
  839. aktdigit_before = ((int) zw) % 10;
  840. zw = _preValue / pow(10, pot-1);
  841. olddigit_before = ((int) zw) % 10;
  842. zw = input / pow(10, pot);
  843. aktdigit = ((int) zw) % 10;
  844. zw = _preValue / pow(10, pot);
  845. olddigit = ((int) zw) % 10;
  846. no_nulldurchgang = (olddigit_before <= aktdigit_before);
  847. if (no_nulldurchgang) {
  848. if (aktdigit != olddigit) {
  849. input = input + ((float) (olddigit - aktdigit)) * pow(10, pot); // New Digit is replaced by old Digit;
  850. }
  851. }
  852. else {
  853. // despite zero crossing, digit was not incremented --> add 1
  854. if (aktdigit == olddigit) {
  855. input = input + ((float) (1)) * pow(10, pot); // add 1 at the point
  856. }
  857. }
  858. #ifdef SERIAL_DEBUG
  859. ESP_LOGD(TAG, "checkDigitConsistency: input=%f", input);
  860. #endif
  861. pot++;
  862. }
  863. return input;
  864. }
  865. string ClassFlowPostProcessing::getReadoutRate(int _number) {
  866. return std::to_string(NUMBERS[_number]->FlowRateAct);
  867. }
  868. string ClassFlowPostProcessing::getReadoutTimeStamp(int _number) {
  869. return NUMBERS[_number]->timeStamp;
  870. }
  871. string ClassFlowPostProcessing::getReadoutError(int _number) {
  872. return NUMBERS[_number]->ErrorMessageText;
  873. }