Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SystemControler.h 1.6KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <memory>
  3. #include <vector>
  4. #include <thread>
  5. #include "DataAcquisition.h"
  6. #include "PublisherType.h"
  7. #include "Evaluator.h"
  8. #include "NetServer.h"
  9. class SystemControler
  10. {
  11. private:
  12. u_int serverPort;
  13. u_int alertReadInterval;
  14. std::unique_ptr<DataModel>& dataModel;
  15. std::shared_ptr<DataAcquisition> dataAcquire;
  16. std::shared_ptr<Evaluator> evaluator;
  17. //Estimated raw data which are collected over one hour of continous running in Bytes
  18. size_t dataSizePerHour = 0;
  19. std::shared_ptr<NetServer> server;
  20. //Continous server updating with fixed tick rate, spcified in ms
  21. std::thread* serverUpdateThread = nullptr;
  22. std::chrono::milliseconds serverTickRateMs { 100 };
  23. void initializePermanentStorage();
  24. public:
  25. SystemControler();
  26. ~SystemControler();
  27. void startIpTcpServer();
  28. //getter
  29. std::shared_ptr<DataAcquisition>& getDataAcquisitionRef() { return dataAcquire; }
  30. //Delegate read requests threaded to to acquire unit
  31. void startEnqueuingRegister();
  32. size_t getDataSizePerHour()const { return dataSizePerHour; };
  33. void cancelReadingModbusAlerts();
  34. void flushAfterNData();
  35. void startModbusWorkerThread(){ dataAcquire->startModbusThread(); }
  36. void test(){ }
  37. //delegate register Publisher
  38. void registerPublisher(std::unique_ptr<PublisherInterface> publisher);
  39. //call evaluation manually, delegates call
  40. void evaluate();
  41. unsigned long deleteFiles(std::chrono::seconds olderThan) { return (olderThan == seconds(0)) ? dataModel->removeStoredData() : dataModel->removeStoredData(olderThan); }
  42. };