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.

91 lines
3.0 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/sensor_data_scan.hpp"
  30. #include "src/service/iflytop_can_host_device.hpp"
  31. /**
  32. * @brief
  33. *
  34. * service: MainControlService
  35. *
  36. * :
  37. * :
  38. * :
  39. * :
  40. *
  41. */
  42. namespace iflytop {
  43. using namespace std;
  44. using namespace core;
  45. class MainControlService : public enable_shared_from_this<MainControlService> {
  46. ENABLE_LOGGER(MainControlService);
  47. shared_ptr<GConfig> m_zconfig;
  48. shared_ptr<RestfulServer> m_restfulServer;
  49. shared_ptr<IflytopFrontEndService> m_iflytopwsService;
  50. shared_ptr<DBService> m_dbService;
  51. shared_ptr<DeviceStateService> m_deviceStateService;
  52. shared_ptr<DisinfectionCtrlService> m_disinfectionCtrlService;
  53. shared_ptr<SensorDataScan> m_sensorDataScan;
  54. shared_ptr<ZCanHost> m_zcanhost;
  55. unique_ptr<Thread> m_reportThread;
  56. unique_ptr<Thread> m_autoshutdownThread;
  57. public:
  58. MainControlService(){};
  59. void initialize();
  60. private:
  61. void dosystem(string order, bool dump) {
  62. if (dump) logger->info("do:{}", order);
  63. system(order.c_str());
  64. }
  65. private:
  66. HttpResponsePtr reactionConfigCardInfo_read(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  67. HttpResponsePtr reactionConfigCardInfo_trigger_once_report(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  68. HttpResponsePtr reactionConfigCardInfo_read_state(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  69. HttpResponsePtr hello_world(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  70. //
  71. HttpResponsePtr doscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  72. HttpResponsePtr doscriptblock(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  73. HttpResponsePtr stopscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
  74. void createReactionConfigCardInfoReportAndSend();
  75. void processFrontEndMessage(weak_ptr<WebSocket> webSocket, json& cmd, json& receipt);
  76. json createSensorDataJson();
  77. };
  78. } // namespace iflytop