EventSubscribe.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. #ifndef __DAHUA_GENICAM_IEVENTSUBSCRIBE_H__
  2. #define __DAHUA_GENICAM_IEVENTSUBSCRIBE_H__
  3. #include "Defs.h"
  4. #include "Memory/SharedPtr.h"
  5. #include "Infra/Function.h"
  6. #include "Infra/Vector.h"
  7. #include "Infra/String.h"
  8. GENICAM_NAMESPACE_BEGIN
  9. /// \~chinese
  10. /// \brief Struct 连接事件参数封装
  11. /// \~english
  12. /// \brief Struct connection event parameters encapsulation
  13. struct SConnectArg
  14. {
  15. enum EVType
  16. {
  17. offLine, ///< \~chinese 设备离线通知 ///< \~english device offline notification
  18. onLine ///< \~chinese 设备在线通知 ///< \~english device online notification
  19. };
  20. EVType m_event; ///< \~chinese 事件类型 ///< \~english event type
  21. uint32_t reserve[15]; ///< \~chinese 预留字段 ///< \~english reserved field
  22. };
  23. /// \~chinese
  24. /// \brief Struct 参数更新事件参数封装
  25. /// \~english
  26. /// \brief Struct updating parameters event encapsulation
  27. struct SParamUpdataArg
  28. {
  29. bool isPoll; ///< \~chinese 是否是定时更新,1表示是定时更新,0表示非定时更新 ///< \~english update periodically or not. 1 : update periodically, 0 : not update periodically
  30. uint32_t reserve[10]; ///< \~chinese 预留字段 ///< \~english reserved field
  31. Infra::TVector<Infra::CString> paramNames; ///< \~chinese 更新的参数名称集合,约定更新的参数不超过1000个,每个参数的字符串长度不超过256 ///< \~english array of parameter's name which need to be updated. the maximum number of parameters is 1000. and the max length of strings of each parameter is 255.
  32. };
  33. /// \~chinese
  34. ///枚举:流事件状态
  35. /// \~english
  36. /// enumeration:stream event status
  37. enum EEventStatus
  38. {
  39. streamEventNormal = 1, ///< \~chinese 正常流事件 ///< \~english normal stream event
  40. streamEventLostFrame = 2, ///< \~chinese 丢帧事件 ///< \~english lost frame event
  41. streamEventLostPacket = 3,///< \~chinese 丢包事件 ///< \~english lost packet event
  42. streamEventImageError = 4, ///< \~chinese 图像错误事件 ///< \~english error image event
  43. streamEventStreamChannelError ///< \~chinese 取流错误事件 ///< \~english stream channel error event
  44. };
  45. /// \~chinese
  46. /// \brief Struct 流事件参数封装
  47. /// \~english
  48. /// \brief Struct stream event parameters encapsulation
  49. struct SStreamArg
  50. {
  51. uint32_t channel; ///< \~chinese 流通道号 ///< \~english stream channel no.
  52. uint64_t blockID; ///< \~chinese 流数据BlockID ///< \~english block ID of stream data
  53. uint64_t timestamp; ///< \~chinese 时间戳 ///< \~english event timestamp
  54. EEventStatus eStreamEventStatus; ///< \~chinese 流事件状态码 ///< \~english stream event status code
  55. uint32_t status; ///< \~chinese 事件状态错误码 ///< \~english status error code
  56. uint32_t reserve[9]; ///< \~chinese 预留字段 ///< \~english reserved field
  57. };
  58. /// \~chinese
  59. /// 消息通道事件ID列表
  60. /// \~english
  61. /// message channel event id list
  62. #define MSG_EVENT_ID_EXPOSURE_END 0x9001
  63. #define MSG_EVENT_ID_FRAME_TRIGGER 0x9002
  64. #define MSG_EVENT_ID_FRAME_START 0x9003
  65. #define MSG_EVENT_ID_ACQ_START 0x9004
  66. #define MSG_EVENT_ID_ACQ_TRIGGER 0x9005
  67. #define MSG_EVENT_ID_DATA_READ_OUT 0x9006
  68. /// \~chinese
  69. /// \brief Struct 消息通道事件参数封装
  70. /// \~english
  71. /// \brief Struct message channel event parameters encapsulation
  72. struct SMsgChannelArg
  73. {
  74. uint16_t eventID; ///< \~chinese 事件Id ///< \~english event id
  75. uint16_t channelID; ///< \~chinese 消息通道号 ///< \~english channel id
  76. uint64_t blockID; ///< \~chinese 流数据BlockID ///< \~english block ID of stream data
  77. uint64_t timeStamp; ///< \~chinese 时间戳 ///< \~english event timestamp
  78. uint32_t reserve[8]; ///< \~chinese 预留字段 ///< \~english reserved field
  79. Infra::TVector<Infra::CString> paramNames; ///< \~chinese 事件相关的属性名列表。约定属性名不超过1000个,每个属性名的字符串长度不超过256 ///< \~english array of parameter's name which is related. the maximum number of parameters is 1000. and the max length of strings of each parameter is 255.
  80. };
  81. /// \~chinese
  82. /// \brief 设备连接状态事件回调函数声明
  83. /// \~english
  84. /// \brief call back function declaration of camera connection status event
  85. typedef Infra::TFunction1<void, const SConnectArg&> ConnectArgProc;
  86. /// \~chinese
  87. /// \brief 设备连接状态事件回调函数声明
  88. /// \~english
  89. /// \brief call back function declaration of camera connection status event
  90. typedef Infra::TFunction2<void, const SConnectArg&, void*> ConnectArgProcEx;
  91. /// \~chinese
  92. /// \brief 参数更新事件回调函数声明
  93. /// \~english
  94. /// \brief call back function declaration of camera parameter update event
  95. typedef Infra::TFunction1<void, const SParamUpdataArg&> ParamUpdataProc;
  96. /// \~chinese
  97. /// \brief 参数更新事件回调函数声明
  98. /// \~english
  99. /// \brief call back function declaration of camera parameter update event
  100. typedef Infra::TFunction2<void, const SParamUpdataArg&, void*> ParamUpdataProcEx;
  101. /// \~chinese
  102. /// \brief 设备流事件回调函数声明
  103. /// \~english
  104. /// \brief call back function declaration of stream event
  105. typedef Infra::TFunction1<void, const SStreamArg&> StreamArgProc;
  106. /// \~chinese
  107. /// \brief 设备流事件回调函数声明
  108. /// \~english
  109. /// \brief call back function declaration of stream event
  110. typedef Infra::TFunction2<void, const SStreamArg&, void*> StreamArgProcEx;
  111. /// \brief 消息通道事件回调函数声明
  112. /// \~english
  113. /// \brief call back function declaration of message channel event
  114. typedef Infra::TFunction1<void, const SMsgChannelArg&> MsgChannelProc;
  115. /// \brief 消息通道事件回调函数声明
  116. /// \~english
  117. /// \brief call back function declaration of message channel event
  118. typedef Infra::TFunction2<void, const SMsgChannelArg&, void*> MsgChannelProcEx;
  119. /// \~chinese
  120. /// \brief 事件注册回调对象接口类
  121. /// \defgroup Event 相机事件订阅注册与去注册接口
  122. /// @{
  123. /// \~english
  124. /// \brief event register callback function interface class
  125. /// \defgroup Event Event Notification subscribe and unsubscribe interface
  126. /// @{
  127. /// \~chinese
  128. /// \brief Class IEventSubscribe 事件注册回调对象接口类,其中包括设备状态事件、流通道事件及参数更新事件
  129. /// \~english
  130. /// \brief Class IEventSubscribe Event subscribe callback object interface class,including device status events、stream channel events and parameter update events
  131. class GENICAM_API IEventSubscribe
  132. {
  133. public:
  134. /// \~chinese
  135. /// \brief 析构函数
  136. /// \~english
  137. /// \brief destructor
  138. virtual ~IEventSubscribe(){}
  139. public:
  140. /// \~chinese
  141. /// \brief 设备连接状态事件回调注册
  142. /// \param [in] proc 设备连接状态事件回调注册函数
  143. /// \return 注册是否成功
  144. /// \~english
  145. /// \brief regist call back function of camera connection status event. only one call back function is supported.
  146. /// \param [in] proc call back function of camera connection status event
  147. /// \return the result of registration ( Success or fail )
  148. virtual bool subscribeConnectArgs(ConnectArgProc const& proc) = 0;
  149. /// \~chinese
  150. /// \brief 设备连接状态事件回调去注册
  151. /// \param [in] proc 设备连接状态事件回调去注册函数
  152. /// \return 去注册是否成功
  153. /// \~english
  154. /// \brief unregister call back function of camera connection status event.
  155. /// \param [in] proc Unregister call back function of camera connection status event
  156. /// \return the result of unregistration ( Success or fail )
  157. virtual bool unsubscribeConnectArgs(ConnectArgProc const& proc) = 0;
  158. /// \~chinese
  159. /// \brief 参数更新事件回调注册
  160. /// \param [in] proc 参数更新注册的事件回调函数
  161. /// \return 注册是否成功
  162. /// \~english
  163. /// \brief regist call back function of parameter update event. only one call back function is supported.
  164. /// \param [in] proc call back function of parameter update event
  165. /// \return the result of registration ( Success or fail )
  166. virtual bool subscribeParamUpdate(ParamUpdataProc const& proc) = 0;
  167. /// \~chinese
  168. /// \brief 参数更新事件回调去注册
  169. /// \param [in] proc 参数更新事件去注册的回调函数
  170. /// \return 去注册是否成功
  171. /// \~english
  172. /// \brief unregister call back function of parameter update event.
  173. /// \param [in] proc unregister call back function of parameter update event
  174. /// \return the result of unregistration ( Success or fail )
  175. virtual bool unsubscribeParamUpdate(ParamUpdataProc const& proc) = 0;
  176. /// \~chinese
  177. /// \brief 流通道事件回调注册
  178. /// \param [in] proc 流通道事件回调注册函数
  179. /// \return 注册是否成功
  180. /// \~english
  181. /// \brief register call back function of stream channel event. only one call back function is supported.
  182. /// \param [in] proc register call back function of stream channel event
  183. /// \return the result of registration ( Success or fail )
  184. virtual bool subscribeStreamArg(StreamArgProc const& proc) = 0;
  185. /// \~chinese
  186. /// \brief 流通道事件回调去注册
  187. /// \param [in] proc 流通道事件回调去注册函数
  188. /// \return 去注册是否成功
  189. /// \~english
  190. /// \brief unregister call back function of stream channel event.
  191. /// \param [in] proc unregister call back function of tream channel event
  192. /// \return the result of unregistration ( Success or fail )
  193. virtual bool unsubscribeStreamArg(StreamArgProc const& proc) = 0;
  194. /// \~chinese
  195. /// \brief 设备连接状态事件回调注册
  196. /// \param [in] proc 设备连接状态事件回调注册函数
  197. /// \param [in] pUser 用户自定义数据
  198. /// \return 注册是否成功
  199. /// \~english
  200. /// \brief regist call back function of camera connection status event. only one call back function is supported.
  201. /// \param [in] proc call back function of camera connection status event
  202. /// \param [in] pUser user data
  203. /// \return the result of registration ( Success or fail )
  204. virtual bool subscribeConnectArgsEx(ConnectArgProcEx const& proc, void* pUser) = 0;
  205. /// \~chinese
  206. /// \brief 设备连接状态事件回调去注册
  207. /// \param [in] proc 设备连接状态事件回调去注册函数
  208. /// \param [in] pUser 用户自定义数据
  209. /// \return 去注册是否成功
  210. /// \~english
  211. /// \brief unregister call back function of camera connection status event.
  212. /// \param [in] proc Unregister call back function of camera connection status event
  213. /// \param [in] pUser user data
  214. /// \return the result of unregistration ( Success or fail )
  215. virtual bool unsubscribeConnectArgsEx(ConnectArgProcEx const& proc, void* pUser) = 0;
  216. /// \~chinese
  217. /// \brief 参数更新事件回调注册
  218. /// \param [in] proc 参数更新注册的事件回调函数
  219. /// \param [in] pUser 用户自定义数据
  220. /// \return 注册是否成功
  221. /// \~english
  222. /// \brief regist call back function of parameter update event. only one call back function is supported.
  223. /// \param [in] proc call back function of parameter update event
  224. /// \param [in] pUser user data
  225. /// \return the result of registration ( Success or fail )
  226. virtual bool subscribeParamUpdateEx(ParamUpdataProcEx const& proc, void* pUser) = 0;
  227. /// \~chinese
  228. /// \brief 参数更新事件回调去注册
  229. /// \param [in] proc 参数更新事件去注册的回调函数
  230. /// \param [in] pUser 用户自定义数据
  231. /// \return 去注册是否成功
  232. /// \~english
  233. /// \brief unregister call back function of parameter update event.
  234. /// \param [in] proc unregister call back function of parameter update event
  235. /// \param [in] pUser user data
  236. /// \return the result of unregistration ( Success or fail )
  237. virtual bool unsubscribeParamUpdateEx(ParamUpdataProcEx const& proc, void* pUser) = 0;
  238. /// \~chinese
  239. /// \brief 流通道事件回调注册
  240. /// \param [in] proc 流通道事件回调注册函数
  241. /// \param [in] pUser 用户自定义数据
  242. /// \return 注册是否成功
  243. /// \~english
  244. /// \brief register call back function of stream channel event. only one call back function is supported.
  245. /// \param [in] proc register call back function of stream channel event
  246. /// \param [in] pUser user data
  247. /// \return the result of registration ( Success or fail )
  248. virtual bool subscribeStreamArgEx(StreamArgProcEx const& proc, void* pUser) = 0;
  249. /// \~chinese
  250. /// \brief 流通道事件回调去注册
  251. /// \param [in] proc 流通道事件回调去注册函数
  252. /// \param [in] pUser 用户自定义数据
  253. /// \return 去注册是否成功
  254. /// \~english
  255. /// \brief unregister call back function of stream channel event.
  256. /// \param [in] proc unregister call back function of tream channel event
  257. /// \param [in] pUser user data
  258. /// \return the result of unregistration ( Success or fail )
  259. virtual bool unsubscribeStreamArgEx(StreamArgProcEx const& proc, void* pUser) = 0;
  260. /// \~chinese
  261. /// \brief 消息通道事件回调注册
  262. /// \param [in] proc 消息通道事件回调注册函数
  263. /// \return 注册是否成功
  264. /// \~english
  265. /// \brief register call back function of message channel event. only one call back function is supported.
  266. /// \param [in] proc register call back function of message channel event
  267. /// \return the result of registration ( Success or fail )
  268. virtual bool subscribeMsgChannel(MsgChannelProc const& proc) = 0;
  269. /// \~chinese
  270. /// \brief 消息通道事件回调去注册
  271. /// \param [in] proc 消息通道事件回调去注册函数
  272. /// \return 去注册是否成功
  273. /// \~english
  274. /// \brief unregister call back function of message channel event.
  275. /// \param [in] proc unregister call back function of message channel event
  276. /// \return the result of unregistration ( Success or fail )
  277. virtual bool unsubscribeMsgChannel(MsgChannelProc const& proc) = 0;
  278. /// \~chinese
  279. /// \brief 消息通道事件回调注册
  280. /// \param [in] proc 消息通道事件回调注册函数
  281. /// \param [in] pUser 用户自定义数据
  282. /// \return 注册是否成功
  283. /// \~english
  284. /// \brief register call back function of message channel event. only one call back function is supported.
  285. /// \param [in] proc register call back function of message channel event
  286. /// \param [in] pUser user data
  287. /// \return the result of registration ( Success or fail )
  288. virtual bool subscribeMsgChannelEx(MsgChannelProcEx const& proc, void* pUser) = 0;
  289. /// \~chinese
  290. /// \brief 消息通道事件回调去注册
  291. /// \param [in] proc 消息通道事件回调去注册函数
  292. /// \param [in] pUser 用户自定义数据
  293. /// \return 去注册是否成功
  294. /// \~english
  295. /// \brief unregister call back function of message channel event.
  296. /// \param [in] proc unregister call back function of message channel event
  297. /// \param [in] pUser user data
  298. /// \return the result of unregistration ( Success or fail )
  299. virtual bool unsubscribeMsgChannelEx(MsgChannelProcEx const& proc, void* pUser) = 0;
  300. };
  301. typedef Memory::TSharedPtr<IEventSubscribe> IEventSubscribePtr;
  302. /// @}
  303. GENICAM_NAMESPACE_END
  304. #endif //__DAHUA_GENICAM_IEVENTSUBSCRIBE_H__