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.

main.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //Entry point of application, crates central controller class and initializes the publishers
  2. #include <iostream>
  3. #include <chrono>
  4. #include <filesystem>
  5. #include "SystemControler.h"
  6. #include "SystemConfig.h"
  7. #include <easylogging++.h>
  8. #include "PublisherBenderRcm.h"
  9. #include "PublisherPowercenter.h"
  10. INITIALIZE_EASYLOGGINGPP
  11. using namespace std;
  12. typedef std::unique_ptr<PublisherInterface> unique_publisher_ptr;
  13. typedef unsigned int u_int;
  14. int main() {
  15. //Load global System configuration for parameters
  16. SystemConfig configuration;
  17. configuration.readStandardConfig();
  18. //Load config file and apply on all loggers
  19. std::filesystem::create_directory("log");
  20. el::Configurations conf("log/logger_config.conf");
  21. el::Loggers::reconfigureAllLoggers(conf);
  22. LOG(INFO) << "Started execution";
  23. //Create the System Controller
  24. SystemControler controler;
  25. //register publisher at controler
  26. auto poc = std::make_unique<PublisherPowercenter>();
  27. auto bender = std::make_unique<PublisherBenderRcm>();
  28. //controler.registerPublisher(std::move(poc));
  29. controler.registerPublisher(std::move(bender));
  30. //Opens port for tcp/ip client connection
  31. controler.startIpTcpServer();
  32. //Modbus Worker Thread, processes the modbus register queue
  33. controler.startModbusWorkerThread();
  34. //Frequently enqueing of modbus register
  35. controler.startEnqueuingRegister();
  36. //Test environment on main thread
  37. while(true)
  38. {
  39. char key = cin.get();
  40. switch (key) {
  41. case 'l':
  42. controler.deleteFiles(std::chrono::seconds(0));
  43. break;
  44. case 'c':
  45. controler.cancelReadingModbusAlerts();
  46. break;
  47. case 'e':
  48. controler.evaluate();
  49. break;
  50. case 'q':
  51. return 0;
  52. case 'p':
  53. std::cout << configuration << std::endl;
  54. break;
  55. case 'f':
  56. controler.flushAfterNData();
  57. break;
  58. default:
  59. break;
  60. }
  61. }
  62. LOG(INFO) << "End of execution\n";
  63. return 0;
  64. }