ClassFlow.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "ClassFlow.h"
  2. #include <fstream>
  3. #include <string>
  4. #include <iostream>
  5. #include <string.h>
  6. #include "esp_log.h"
  7. static const char *TAG = "FLOW CLASS";
  8. void ClassFlow::SetInitialParameter(void)
  9. {
  10. ListFlowControll = NULL;
  11. previousElement = NULL;
  12. disabled = false;
  13. }
  14. bool ClassFlow::isNewParagraph(string input)
  15. {
  16. if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
  17. {
  18. return true;
  19. }
  20. return false;
  21. }
  22. bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
  23. {
  24. while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
  25. if (isNewParagraph(aktparamgraph))
  26. return true;
  27. return false;
  28. }
  29. ClassFlow::ClassFlow(void)
  30. {
  31. SetInitialParameter();
  32. }
  33. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
  34. {
  35. SetInitialParameter();
  36. ListFlowControll = lfc;
  37. }
  38. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc, ClassFlow *_prev)
  39. {
  40. SetInitialParameter();
  41. ListFlowControll = lfc;
  42. previousElement = _prev;
  43. }
  44. bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
  45. {
  46. return false;
  47. }
  48. bool ClassFlow::doFlow(string time)
  49. {
  50. return false;
  51. }
  52. string ClassFlow::getHTMLSingleStep(string host){
  53. return "";
  54. }
  55. string ClassFlow::getReadout()
  56. {
  57. return string();
  58. }
  59. std::string ClassFlow::GetParameterName(std::string _input)
  60. {
  61. string _param;
  62. int _pospunkt = _input.find_first_of(".");
  63. if (_pospunkt > -1)
  64. {
  65. _param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1);
  66. }
  67. else
  68. {
  69. _param = _input;
  70. }
  71. // ESP_LOGD(TAG, "Parameter: %s, Pospunkt: %d", _param.c_str(), _pospunkt);
  72. return _param;
  73. }
  74. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  75. {
  76. char zw[1024];
  77. if (pfile == NULL)
  78. {
  79. *rt = "";
  80. return false;
  81. }
  82. if (!fgets(zw, 1024, pfile))
  83. {
  84. *rt = "";
  85. ESP_LOGD(TAG, "END OF FILE");
  86. return false;
  87. }
  88. ESP_LOGD(TAG, "%s", zw);
  89. *rt = zw;
  90. *rt = trim(*rt);
  91. while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
  92. {
  93. *rt = "";
  94. if (!fgets(zw, 1024, pfile))
  95. return false;
  96. ESP_LOGD(TAG, "%s", zw);
  97. *rt = zw;
  98. *rt = trim(*rt);
  99. }
  100. return true;
  101. }