ClassFlowPostProcessing.cpp 37 KB

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