ClassFlowWriteList.cpp 2.3 KB

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