ClassFlow.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. std::string ClassFlow::GetParameterName(std::string _input)
  57. {
  58. string _param;
  59. int _pospunkt = _input.find_first_of(".");
  60. if (_pospunkt > -1)
  61. {
  62. _param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1);
  63. }
  64. else
  65. {
  66. _param = _input;
  67. }
  68. // ESP_LOGD(TAG, "Parameter: %s, Pospunkt: %d", _param.c_str(), _pospunkt);
  69. return _param;
  70. }
  71. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  72. {
  73. char zw[1024];
  74. if (pfile == NULL)
  75. {
  76. *rt = "";
  77. return false;
  78. }
  79. if (!fgets(zw, 1024, pfile))
  80. {
  81. *rt = "";
  82. ESP_LOGD(TAG, "END OF FILE");
  83. return false;
  84. }
  85. ESP_LOGD(TAG, "%s", zw);
  86. *rt = zw;
  87. *rt = trim(*rt);
  88. while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))
  89. {
  90. *rt = "";
  91. if (!fgets(zw, 1024, pfile))
  92. return false;
  93. ESP_LOGD(TAG, "%s", zw);
  94. *rt = zw;
  95. *rt = trim(*rt);
  96. }
  97. return true;
  98. }