ClassFlow.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #include "defines.h"
  2. #include "ClassFlow.h"
  3. #include <fstream>
  4. #include <string>
  5. #include <iostream>
  6. #include <string.h>
  7. #include "esp_log.h"
  8. static const char *TAG = "CLASS";
  9. void ClassFlow::SetInitialParameter(void)
  10. {
  11. ListFlowControll = NULL;
  12. previousElement = NULL;
  13. disabled = false;
  14. }
  15. ClassFlow::ClassFlow(void)
  16. {
  17. SetInitialParameter();
  18. }
  19. ClassFlow::ClassFlow(std::vector<ClassFlow *> *lfc)
  20. {
  21. SetInitialParameter();
  22. ListFlowControll = lfc;
  23. }
  24. ClassFlow::ClassFlow(std::vector<ClassFlow *> *lfc, ClassFlow *_prev)
  25. {
  26. SetInitialParameter();
  27. ListFlowControll = lfc;
  28. previousElement = _prev;
  29. }
  30. bool ClassFlow::ReadParameter(FILE *pFile, std::string &aktparamgraph)
  31. {
  32. return false;
  33. }
  34. bool ClassFlow::doFlow(std::string time)
  35. {
  36. return false;
  37. }
  38. std::string ClassFlow::getHTMLSingleStep(std::string host)
  39. {
  40. return "";
  41. }
  42. std::string ClassFlow::GetParameterName(std::string _input)
  43. {
  44. std::string _param;
  45. int _pospunkt = _input.find_first_of(".");
  46. if (_pospunkt > -1)
  47. {
  48. _param = _input.substr(_pospunkt + 1, _input.length() - _pospunkt - 1);
  49. }
  50. else
  51. {
  52. _param = _input;
  53. }
  54. return _param;
  55. }
  56. bool ClassFlow::isNewParagraph(std::string input)
  57. {
  58. if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
  59. {
  60. return true;
  61. }
  62. return false;
  63. }
  64. bool ClassFlow::GetNextParagraph(FILE *pFile, std::string &aktparamgraph)
  65. {
  66. while (getNextLine(pFile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
  67. if (isNewParagraph(aktparamgraph))
  68. {
  69. return true;
  70. }
  71. return false;
  72. }
  73. /*
  74. bool ClassFlow::GetNextParagraph(FILE *pFile, std::string &aktparamgraph, bool &disabled, bool &eof)
  75. {
  76. while (getNextLine_new(pFile, &aktparamgraph, disabled, eof) && !isNewParagraph(aktparamgraph));
  77. if (isNewParagraph(aktparamgraph))
  78. {
  79. return true;
  80. }
  81. return false;
  82. }
  83. */
  84. bool ClassFlow::getNextLine(FILE *pFile, std::string *rt)
  85. {
  86. char temp_char[1024];
  87. if (pFile == NULL)
  88. {
  89. *rt = "";
  90. return false;
  91. }
  92. if (!fgets(temp_char, 1024, pFile))
  93. {
  94. *rt = "";
  95. ESP_LOGD(TAG, "END OF FILE");
  96. return false;
  97. }
  98. ESP_LOGD(TAG, "%s", temp_char);
  99. *rt = temp_char;
  100. *rt = trim_string_left_right(*rt);
  101. while ((temp_char[0] == ';' || temp_char[0] == '#' || (rt->size() == 0)) && !(temp_char[1] == '['))
  102. {
  103. *rt = "";
  104. if (!fgets(temp_char, 1024, pFile))
  105. {
  106. return false;
  107. }
  108. ESP_LOGD(TAG, "%s", temp_char);
  109. *rt = temp_char;
  110. *rt = trim_string_left_right(*rt);
  111. }
  112. return true;
  113. }
  114. /*
  115. bool ClassFlow::getNextLine(FILE *pFile, std::string *rt, bool &disabled, bool &eof)
  116. {
  117. eof = false;
  118. char zw[1024] = "";
  119. if (pFile == NULL)
  120. {
  121. *rt = "";
  122. return false;
  123. }
  124. if (fgets(zw, 1024, pFile))
  125. {
  126. ESP_LOGD(TAG, "%s", zw);
  127. if ((strlen(zw) == 0) && feof(pFile))
  128. {
  129. *rt = "";
  130. eof = true;
  131. return false;
  132. }
  133. }
  134. else
  135. {
  136. *rt = "";
  137. eof = true;
  138. return false;
  139. }
  140. *rt = zw;
  141. *rt = trim_string_left_right(*rt);
  142. while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))
  143. {
  144. fgets(zw, 1024, pFile);
  145. ESP_LOGD(TAG, "%s", zw);
  146. if (feof(pFile))
  147. {
  148. *rt = "";
  149. eof = true;
  150. return false;
  151. }
  152. *rt = zw;
  153. *rt = trim_string_left_right(*rt);
  154. }
  155. disabled = ((*rt)[0] == ';');
  156. return true;
  157. }
  158. */