ClassFlow.cpp 2.2 KB

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