user_app.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * @Description: USERAPP
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2021-10-13 09:41:50
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-07-20 15:33:48
  8. */
  9. #pragma once
  10. #include <iostream>
  11. #include <signal.h>
  12. // ZLMediaKit
  13. #include "Util/logger.h"
  14. #include "Util/NoticeCenter.h"
  15. #include "Poller/EventPoller.h"
  16. #include "Util/SqlPool.h"
  17. #include "Network/TcpClient.h"
  18. #include "Poller/Timer.h"
  19. #include "inifile.h"
  20. #include <gst/gst.h>
  21. #include <vector>
  22. #include <map>
  23. #include <time.h>
  24. #include "inference.h"
  25. #include "DataSource.h"
  26. // dataType
  27. #include "SendLogin.h"
  28. #include "NettyServerCommandEnum.h"
  29. #include "NettyServerResultMsg.h"
  30. #include "NettyClientResultMsg.h"
  31. #include "SendLogin.h"
  32. #include "NettyClientCommandEnum.h"
  33. #include "InferData.h"
  34. #include "CrowdednessConfig.h"
  35. #include "CrowdednessTimeConfig.h"
  36. #include "SendPassengerFlow.h"
  37. #include "CNStreamInferData.h"
  38. #include "SendCarData.h"
  39. #include "Notices.h"
  40. #include "HttpClient.h"
  41. #include "recorder.h"
  42. #include "Cleaner.h"
  43. #include "monitor.h"
  44. #include "deviceState.h"
  45. #include "Manager.h"
  46. #include <httplib.h>
  47. #include "Disposition.hpp"
  48. #include "ExpelControler.hpp"
  49. #include <condition_variable>
  50. #include <mutex>
  51. using namespace toolkit;
  52. using namespace std;
  53. namespace gsd_ds
  54. {
  55. class UserApp
  56. {
  57. public:
  58. /**
  59. * @description: 创建对象
  60. * @param {*}
  61. * @return {std::shared_ptr<UserApp>} 智能指针
  62. * @author: lishengyin
  63. */
  64. static std::shared_ptr<UserApp> CreateNew();
  65. UserApp();
  66. ~UserApp();
  67. /**
  68. * @description: 模块初始化
  69. * @param {string} appName 应用名
  70. * @return {int} 是否成功
  71. * @author: lishengyin
  72. */
  73. int32_t Init(std::string appName);
  74. /**
  75. * @description: 释放数据
  76. * @param {*}
  77. * @return {*}
  78. * @author: lishengyin
  79. */
  80. void Destroy();
  81. /**
  82. * @description: 启动任务
  83. * @param {*}
  84. * @return {*}
  85. * @author: lishengyin
  86. */
  87. void StartTask();
  88. /**
  89. * @description: 赋值struct sockaddr
  90. * @param {sockaddr} *out
  91. * @param {char} *ip
  92. * @param {uint16_t} port
  93. * @return {*}
  94. * @author: lishengyin
  95. */
  96. static void makeAddr(struct sockaddr *out,const char *ip,uint16_t port);
  97. /**
  98. * @description: 监听推理模块广播
  99. * @param {int} Source_id 数据源ID
  100. * @param {CNStreamInferData} 推理指针
  101. * @return {*}
  102. * @author: lishengyin
  103. */
  104. void ListenInfer(int Source_id, CNStreamInferData::Ptr data);
  105. /**
  106. * @description: 监听推理模块广播
  107. */
  108. void ExperControler(int Source_id, int num);
  109. /**
  110. * @description: 启动推理
  111. * @return {*}
  112. */
  113. void StartInfer();
  114. private:
  115. std::string m_appName;
  116. int device_id;
  117. Timer::Ptr m_timer1;
  118. // Infer推理
  119. std::shared_ptr<Inference> m_Infer = nullptr;
  120. // Infer数据
  121. std::shared_ptr<InferInfo> m_InferInfo = nullptr;
  122. HttpClient::Ptr m_httpClient = nullptr;
  123. // 驱鸟设备状态
  124. bool m_DevPowerState = false;
  125. bool stop = false;
  126. std::condition_variable condition;
  127. std::mutex m_mutex;
  128. private:
  129. /**
  130. * 上报推理数据到Netty
  131. * @param {*}
  132. * @return {*}
  133. */
  134. void ReportInferData();
  135. /**
  136. * 监听数据
  137. * @param {*}
  138. * @return {*}
  139. */
  140. void MonitorData();
  141. };
  142. }