123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- //Entry point of application, crates central controller class and initializes the publishers
-
- #include <iostream>
- #include <chrono>
- #include <filesystem>
- #include "SystemControler.h"
- #include "SystemConfig.h"
- #include <easylogging++.h>
- #include "PublisherBenderRcm.h"
- #include "PublisherPowercenter.h"
- INITIALIZE_EASYLOGGINGPP
-
- using namespace std;
-
- typedef std::unique_ptr<PublisherInterface> unique_publisher_ptr;
- typedef unsigned int u_int;
-
-
- int main() {
-
- //Load global System configuration for parameters
- SystemConfig configuration;
- configuration.readStandardConfig();
-
-
- //Load config file and apply on all loggers
- std::filesystem::create_directory("log");
- el::Configurations conf("log/logger_config.conf");
- el::Loggers::reconfigureAllLoggers(conf);
-
- LOG(INFO) << "Started execution";
-
- //Create the System Controller
- SystemControler controler;
-
- //register publisher at controler
- auto poc = std::make_unique<PublisherPowercenter>();
- auto bender = std::make_unique<PublisherBenderRcm>();
-
- //controler.registerPublisher(std::move(poc));
- controler.registerPublisher(std::move(bender));
-
- //Opens port for tcp/ip client connection
- controler.startIpTcpServer();
-
- //Modbus Worker Thread, processes the modbus register queue
- controler.startModbusWorkerThread();
-
- //Frequently enqueing of modbus register
- controler.startEnqueuingRegister();
-
-
- //Test environment on main thread
- while(true)
- {
- char key = cin.get();
- switch (key) {
- case 'l':
- controler.deleteFiles(std::chrono::seconds(0));
- break;
-
- case 'c':
- controler.cancelReadingModbusAlerts();
- break;
- case 'e':
- controler.evaluate();
- break;
- case 'q':
- return 0;
- case 'p':
- std::cout << configuration << std::endl;
- break;
- case 'f':
- controler.flushAfterNData();
- break;
- default:
- break;
- }
- }
-
- LOG(INFO) << "End of execution\n";
-
- return 0;
- }
|