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.

93 lines
3.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. //
  2. // Created by zwsd
  3. //
  4. #pragma once
  5. #include <fstream>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <memory>
  10. #include <set>
  11. #include <sstream>
  12. #include <string>
  13. #include <vector>
  14. #include "iflytop/components/restful_server/restful_server.hpp"
  15. #include "iflytop/core/components/jobs/work_queue.hpp"
  16. #include "iflytop/core/components/timer/simple_timer.hpp"
  17. #include "iflytop/core/spdlogfactory/logger.hpp"
  18. #include "iflytoplinuxsdk/src/iflytop/components/iflytop_front_end_service/iflytop_front_end_service.hpp"
  19. #include "service/device_state_service.hpp"
  20. #include "service/disinfection_ctl_service.hpp"
  21. //
  22. #include "configs/gconfig.hpp"
  23. #include "iflytop/components/iflytop_front_end_service/iflytop_front_end_service.hpp"
  24. #include "zservice_container/zservice_container.hpp"
  25. //
  26. //
  27. #include "db/db_service.hpp"
  28. #include "iflytop/components/zcanreceiver/zcanhost.hpp"
  29. #include "service/device_io_control_service.hpp"
  30. #include "service/disinfection_logs_manager.hpp"
  31. #include "src/service/iflytop_can_host_device.hpp"
  32. /**
  33. * @brief
  34. *
  35. * service: MainControlService
  36. *
  37. * :
  38. * :
  39. * :
  40. * :
  41. *
  42. */
  43. namespace iflytop {
  44. using namespace std;
  45. using namespace core;
  46. class MainControlService : public enable_shared_from_this<MainControlService> {
  47. ENABLE_LOGGER(MainControlService);
  48. shared_ptr<GConfig> m_zconfig;
  49. shared_ptr<RestfulServer> m_restfulServer;
  50. shared_ptr<IflytopFrontEndService> m_iflytopwsService;
  51. shared_ptr<DBService> m_dbService;
  52. shared_ptr<DeviceStateService> m_deviceStateService;
  53. shared_ptr<DisinfectionCtrlService> m_disinfectionCtrlService;
  54. shared_ptr<DeviceIoControlService> m_deviceIoControlService;
  55. shared_ptr<DisinfectionLogsManager> m_disinfectionLogsManager;
  56. shared_ptr<ZCanHost> m_zcanhost;
  57. unique_ptr<Thread> m_reportThread;
  58. unique_ptr<Thread> m_autoshutdownThread;
  59. public:
  60. MainControlService(){};
  61. void initialize();
  62. private:
  63. void dosystem(string order, bool dump) {
  64. if (dump) logger->info("do:{}", order);
  65. system(order.c_str());
  66. }
  67. private:
  68. HttpResponsePtr reactionConfigCardInfo_read(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  69. HttpResponsePtr reactionConfigCardInfo_trigger_once_report(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  70. HttpResponsePtr reactionConfigCardInfo_read_state(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  71. HttpResponsePtr hello_world(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  72. //
  73. HttpResponsePtr doscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  74. HttpResponsePtr doscriptblock(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  75. HttpResponsePtr stopscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  76. void createReactionConfigCardInfoReportAndSend();
  77. void processFrontEndMessage(weak_ptr<WebSocket> webSocket, json& cmd, json& receipt);
  78. json createSensorDataJson();
  79. };
  80. } // namespace iflytop