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.

100 lines
3.1 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include "zmain.hpp"
  2. //
  3. #include "configs/config.hpp"
  4. #include "iflytopcpp/core/spdlogfactory/logger.hpp"
  5. #include "iflytopcpp/core/thread/thread.hpp"
  6. #include "spdlog/spdlog.h"
  7. #include "version.hpp"
  8. #include "zlinuxcomponents/rootfs_auto_update.hpp"
  9. #include "zservice_container/zservice_container.hpp"
  10. #include "zwebservice/zwebservice.hpp"
  11. //
  12. #include "service/device_io_service.hpp"
  13. #include "service/device_io_service_mock.hpp"
  14. #include "service/light_control_service.hpp"
  15. #include "service/main_control_service.hpp"
  16. #include "service/report_service.hpp"
  17. //
  18. #include "zlinuxcomponents/audio/audio_recoder.hpp"
  19. //
  20. using namespace iflytop;
  21. using namespace core;
  22. using namespace std;
  23. using namespace clipp;
  24. ZMAIN();
  25. /***********************************************************************************************************************
  26. * =======================================================Main======================================================== *
  27. ***********************************************************************************************************************/
  28. void Main::onSIGINT() { exit(0); }
  29. int Main::main(int argc, char *argv[]) {
  30. string g_host_server_ip;
  31. string g_device_id;
  32. #if 0
  33. auto cli = ( //
  34. (required("-device_id") & value("device_id", g_device_id)).doc("device_id") //
  35. );
  36. if (!parse(argc, argv, cli)) {
  37. cout << make_man_page(cli, argv[0]);
  38. exit(-1);
  39. }
  40. #endif
  41. logger->info("system setup start.");
  42. spdlog::flush_on(spdlog::level::debug);
  43. logger->info("#");
  44. logger->info("# company:{}", "ifytop");
  45. logger->info("# version:{}", VERSION);
  46. logger->info("#");
  47. BUILD_AND_REG_SERRVICE(Config);
  48. GET_SERVICE(Config)->initialize();
  49. if (!g_device_id.empty()) GET_SERVICE(Config)->set_deviceId(g_device_id);
  50. /**
  51. * @brief rootfs目录中的文件和系统中对应路径的文件是否一致
  52. *
  53. *
  54. * ./rootfs/etc/asound.conf /etc/asound.conf
  55. *
  56. */
  57. auto rootfsAutoUpdate = make_shared<RootfsAutoUpdate>();
  58. rootfsAutoUpdate->compareAndReplace();
  59. logger->info("rootfs changed:{}", rootfsAutoUpdate->isChanged() ? "yes" : "no");
  60. if (rootfsAutoUpdate->isChanged()) {
  61. logger->info("reboot system.");
  62. logger->warn("not auto reboot, please reboot manually.");
  63. // system("reboot");
  64. }
  65. // AudioRecoder::get().initialize();
  66. shared_ptr<AudioRecoder> audioRecoder(new AudioRecoder());
  67. #if 0
  68. BUILD_AND_REG_SERRVICE(DeviceIOService);
  69. #else
  70. BUILD_AND_REG_MOCK_SERRVICE(DeviceIOService, DeviceIOServiceMock);
  71. #endif
  72. GET_SERVICE(DeviceIOService)->initialize();
  73. BUILD_AND_REG_SERRVICE(ZWebService);
  74. GET_SERVICE(ZWebService)->initialize();
  75. BUILD_AND_REG_SERRVICE(LightControlService);
  76. GET_SERVICE(LightControlService)->initialize();
  77. GET_SERVICE(LightControlService)->start();
  78. BUILD_AND_REG_SERRVICE(ReportService);
  79. GET_SERVICE(ReportService)->initialize();
  80. GET_SERVICE(ReportService)->start();
  81. BUILD_AND_REG_SERRVICE(MainControlService);
  82. GET_SERVICE(MainControlService)->initialize();
  83. logger->info("system setup end.");
  84. while (true) sleep(1000);
  85. }