ClassFlowWriteList.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include <sstream>
  2. #include "ClassFlowWriteList.h"
  3. #include "Helper.h"
  4. #include "time_sntp.h"
  5. #include "../../include/defines.h"
  6. #include <time.h>
  7. void ClassFlowWriteList::SetInitialParameter(void)
  8. {
  9. flowpostprocessing = NULL;
  10. previousElement = NULL;
  11. ListFlowControll = NULL;
  12. disabled = false;
  13. }
  14. ClassFlowWriteList::ClassFlowWriteList()
  15. {
  16. SetInitialParameter();
  17. }
  18. ClassFlowWriteList::ClassFlowWriteList(std::vector<ClassFlow*>* lfc)
  19. {
  20. SetInitialParameter();
  21. ListFlowControll = lfc;
  22. for (int i = 0; i < ListFlowControll->size(); ++i)
  23. {
  24. if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0)
  25. {
  26. flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
  27. }
  28. }
  29. }
  30. bool ClassFlowWriteList::ReadParameter(FILE* pfile, string& aktparamgraph)
  31. {
  32. std::vector<string> zerlegt;
  33. aktparamgraph = trim(aktparamgraph);
  34. if (aktparamgraph.size() == 0)
  35. if (!this->GetNextParagraph(pfile, aktparamgraph))
  36. return false;
  37. if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph passt nich zu MakeImage
  38. return false;
  39. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
  40. {
  41. zerlegt = ZerlegeZeile(aktparamgraph);
  42. /*
  43. if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
  44. {
  45. this->user = zerlegt[1];
  46. }
  47. */
  48. }
  49. return true;
  50. }
  51. bool ClassFlowWriteList::doFlow(string zwtime)
  52. {
  53. std::string line = "";
  54. std::string result;
  55. std::string resulterror = "";
  56. std::string resultraw = "";
  57. std::string resultrate = "";
  58. std::string resulttimestamp = "";
  59. string zw = "";
  60. string namenumber = "";
  61. if (flowpostprocessing)
  62. {
  63. std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
  64. for (int i = 0; i < (*NUMBERS).size(); ++i)
  65. {
  66. result = (*NUMBERS)[i]->ReturnValue;
  67. resultraw = (*NUMBERS)[i]->ReturnRawValue;
  68. resulterror = (*NUMBERS)[i]->ErrorMessageText;
  69. resultrate = (*NUMBERS)[i]->ReturnRateValue;
  70. resulttimestamp = (*NUMBERS)[i]->timeStamp;
  71. line = line + resulttimestamp + "\t" + resultraw + "\t" + result + "\t" + resultraw + "\t" + resultrate + "\t" + resulttimestamp + "\t";
  72. }
  73. }
  74. return true;
  75. }