123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #pragma once
- #include <memory>
- #include <vector>
- #include <thread>
- #include "DataAcquisition.h"
- #include "PublisherType.h"
- #include "Evaluator.h"
- #include "NetServer.h"
-
-
- class SystemControler
- {
- private:
- u_int serverPort;
- u_int alertReadInterval;
-
- std::unique_ptr<DataModel>& dataModel;
- std::shared_ptr<DataAcquisition> dataAcquire;
- std::shared_ptr<Evaluator> evaluator;
-
- //Estimated raw data which are collected over one hour of continous running in Bytes
- size_t dataSizePerHour = 0;
- std::shared_ptr<NetServer> server;
-
- //Continous server updating with fixed tick rate, spcified in ms
- std::thread* serverUpdateThread = nullptr;
- std::chrono::milliseconds serverTickRateMs { 100 };
-
- void initializePermanentStorage();
-
- public:
- SystemControler();
- ~SystemControler();
-
- void startIpTcpServer();
-
- //getter
- std::shared_ptr<DataAcquisition>& getDataAcquisitionRef() { return dataAcquire; }
-
- //Delegate read requests threaded to to acquire unit
- void startEnqueuingRegister();
-
- size_t getDataSizePerHour()const { return dataSizePerHour; };
-
- void cancelReadingModbusAlerts();
-
- void flushAfterNData();
-
- void startModbusWorkerThread(){ dataAcquire->startModbusThread(); }
-
- void test(){ }
-
- //delegate register Publisher
- void registerPublisher(std::unique_ptr<PublisherInterface> publisher);
-
- //call evaluation manually, delegates call
- void evaluate();
-
- unsigned long deleteFiles(std::chrono::seconds olderThan) { return (olderThan == seconds(0)) ? dataModel->removeStoredData() : dataModel->removeStoredData(olderThan); }
- };
|