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.

498 lines
7.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOLPTZ_H_INCL__
  2. #ifndef NO_PTZ_CAMERAS
  3. #define __PROTOCOLPTZ_H_INCL__
  4. #include "../../components/base/basicTransport.h"
  5. #include "../../components/base/basicTypes.h"
  6. #include "protocol.h"
  7. #define PPTZ_TAG_COM_PORT "COM_PORT"
  8. #define PPTZ_TAG_COM_SPEED "COM_SPEED"
  9. #define PPTZ_TAG_CAM_ID "CAMERA_ID"
  10. #define PPTZ_TAG_ONVIF_USER "ONVIF_USER"
  11. #define PPTZ_TAG_ONVIF_PASS "ONVIF_PASSWORD"
  12. #define PPTZ_TAG_ONVIF_DEV_URI "ONVIF_DEVICE_URI"
  13. #define PTZ_DRIVE_NONE 0x00000000
  14. #define PTZ_DRIVE_PAN_MASK 0x00000003
  15. #define PTZ_DRIVE_PAN_LEFT 0x00000001
  16. #define PTZ_DRIVE_PAN_RIGHT 0x00000002
  17. #define PTZ_DRIVE_TILT_MASK 0x0000000C
  18. #define PTZ_DRIVE_TILT_UP 0x00000004
  19. #define PTZ_DRIVE_TILT_DOWN 0x00000008
  20. #define PTZ_DRIVE_ZOOM_MASK 0x00000030
  21. #define PTZ_DRIVE_ZOOM_WIDE 0x00000010
  22. #define PTZ_DRIVE_ZOOM_TELE 0x00000020
  23. #define PTZ_DRIVE_ABS_MASK 0x000001C0
  24. #define PTZ_DRIVE_ABS_PAN 0x00000040
  25. #define PTZ_DRIVE_ABS_TILT 0x00000080
  26. #define PTZ_DRIVE_ABS_ZOOM 0x00000100
  27. typedef enum E_PTZ_CAMERA_PROTOCOL_TYPE
  28. {
  29. PTZ_PROTO_NONE = 0,
  30. PTZ_PROTO_VISCA = 1,
  31. PTZ_PROTO_PELCO = 2,
  32. PTZ_PROTO_ONVIF = 3,
  33. PTZ_PROTO_BRCP = 4
  34. } PTZ_CAMERA_PROTOCOL_TYPE;
  35. enum CAM_WB_MODE
  36. {
  37. WB_AUTO = 0,
  38. WB_INDOOR = 1,
  39. WB_OUTDOOR,
  40. WB_CUSTOM
  41. };
  42. enum CAM_EXP_MODE
  43. {
  44. EXP_AUTO = 0,
  45. EXP_MANUAL = 1,
  46. EXP_SHUTTER_PRIO,
  47. EXP_IRIS_PRIO,
  48. EXP_BRIGHT_PRIO
  49. };
  50. enum CAM_PTZ_COMMAND
  51. {
  52. CMD_PTZ_NOOP = 0,
  53. CMD_PTZ_INIT = 1,
  54. CMD_PTZ_IF_CLEAR = 2,
  55. CMD_PTZ_RESET = 3,
  56. CMD_PTZ_POWER_ON,
  57. CMD_PTZ_POWER_OFF
  58. };
  59. /**
  60. * TODO: Add class description
  61. *
  62. * @author gagua
  63. */
  64. class protocolPTZ : public protocolParser
  65. {
  66. protected:
  67. // basicTransport *m_pDataTransport;
  68. CAM_WB_MODE m_eWB_Mode;
  69. CAM_EXP_MODE m_eExp_Mode;
  70. U8 m_bLastCommandIssued;
  71. U8 m_bProtocolDeviceID;
  72. bool m_bPowerSave_Mode;
  73. bool m_bAutoFocus_Mode;
  74. bool m_bBackLight_Mode;
  75. bool m_bWideConversionLens;
  76. bool m_bReplyRequired;
  77. double m_dPan;
  78. double m_dTilt;
  79. double m_dZoom;
  80. double m_dFocus;
  81. double m_dWideConversionLens;
  82. double m_dTiltSpeed;
  83. double m_dPanSpeed;
  84. double m_dZoomSpeed;
  85. double m_dFocusSpeed;
  86. public:
  87. // Constructor
  88. protocolPTZ();
  89. // ToDo: change Serial to BaseClass of some kind of socket
  90. // protocolPTZ( basicTransport *Serial );
  91. // Destructor
  92. virtual ~protocolPTZ();
  93. virtual bool create(void);
  94. U8 getLastCommand(void)
  95. {
  96. return m_bLastCommandIssued;
  97. }
  98. virtual bool initCamera(void)
  99. {
  100. return true;
  101. }
  102. bool hasReply(void)
  103. {
  104. return m_bReplyRequired;
  105. }
  106. virtual bool cancelLastCommand(int backNumber)
  107. {
  108. if ( backNumber ) return true;
  109. return true;
  110. }
  111. virtual bool setPowerSaveMode(bool nMode)
  112. {
  113. m_bPowerSave_Mode = nMode;
  114. return true;
  115. }
  116. virtual bool getPowerSaveMode(void)
  117. {
  118. return m_bPowerSave_Mode;
  119. }
  120. virtual bool startZoomWide(void)
  121. {
  122. return true;
  123. }
  124. virtual bool startZoomTele(void)
  125. {
  126. return true;
  127. }
  128. virtual bool startZoomWide(double nSpeed)
  129. {
  130. m_dZoomSpeed = nSpeed;
  131. return true;
  132. }
  133. virtual bool startZoomTele(double nSpeed)
  134. {
  135. m_dZoomSpeed = nSpeed;
  136. return true;
  137. }
  138. virtual bool stopZoom(void)
  139. {
  140. return true;
  141. }
  142. virtual bool setPanPos(double dPan)
  143. {
  144. if ( dPan > 0 ) return true;
  145. return true;
  146. }
  147. virtual bool setTiltPos(double dTilt)
  148. {
  149. if ( dTilt > 0 ) return true;
  150. return true;
  151. }
  152. virtual bool setZoom(double nZoom)
  153. {
  154. if ( nZoom > 0 ) return true;
  155. return true;
  156. }
  157. void setProtocolDeviceID(U8 device_id)
  158. {
  159. m_bProtocolDeviceID = device_id;
  160. }
  161. virtual double getPan(void)
  162. {
  163. return m_dPan;
  164. }
  165. virtual double getTilt(void)
  166. {
  167. return m_dTilt;
  168. }
  169. virtual double getZoom(void)
  170. {
  171. return m_dZoom;
  172. }
  173. virtual bool startFocusFar(void)
  174. {
  175. return false;
  176. }
  177. virtual bool startFocusNear(void)
  178. {
  179. return false;
  180. }
  181. virtual bool setAutoFocus(bool nMode)
  182. {
  183. m_bAutoFocus_Mode = nMode;
  184. return true;
  185. }
  186. virtual bool getAutoFocus(void)
  187. {
  188. return m_bAutoFocus_Mode;
  189. }
  190. virtual bool setFocus(double nFocus)
  191. {
  192. m_dFocus = nFocus;
  193. return true;
  194. } // 0.0 -> 1.0
  195. virtual double getFocus(void)
  196. {
  197. return m_dFocus;
  198. }
  199. virtual bool setWhiteBalanceMode(CAM_WB_MODE nMode)
  200. {
  201. m_eWB_Mode = nMode;
  202. return true;
  203. }
  204. virtual bool triggerWBPoint(void)
  205. {
  206. return true;
  207. }
  208. virtual bool setExposureMode(CAM_EXP_MODE nMode)
  209. {
  210. m_eExp_Mode = nMode;
  211. return true;
  212. }
  213. virtual bool expBrightReset(void)
  214. {
  215. return true;
  216. }
  217. virtual bool expBrightUp(void)
  218. {
  219. return true;
  220. }
  221. virtual bool expBrightDown(void)
  222. {
  223. return true;
  224. }
  225. virtual bool expShutterReset(void)
  226. {
  227. return true;
  228. }
  229. virtual bool expShutterUp(void)
  230. {
  231. return true;
  232. }
  233. virtual bool expShutterDown(void)
  234. {
  235. return true;
  236. }
  237. virtual bool expIrisReset(void)
  238. {
  239. return true;
  240. }
  241. virtual bool expIrisUp(void)
  242. {
  243. return true;
  244. }
  245. virtual bool expIrisDown(void)
  246. {
  247. return true;
  248. }
  249. virtual bool expGainReset(void)
  250. {
  251. return true;
  252. }
  253. virtual bool expGainUp(void)
  254. {
  255. return true;
  256. }
  257. virtual bool expGainDown(void)
  258. {
  259. return true;
  260. }
  261. virtual bool setBackLightMode(bool nMode)
  262. {
  263. m_bBackLight_Mode = nMode;
  264. return true;
  265. }
  266. virtual bool getBackLightMode(void)
  267. {
  268. return m_bBackLight_Mode;
  269. }
  270. virtual bool saveSettings(int backNumber)
  271. {
  272. if ( backNumber )return true;
  273. return true;
  274. }
  275. virtual bool recallSetings(int backNumber)
  276. {
  277. if ( backNumber )return true;
  278. return true;
  279. }
  280. virtual bool setWideConversionLens(double Magnifier)
  281. {
  282. if (Magnifier > 0)
  283. {
  284. m_bWideConversionLens = true;
  285. m_dWideConversionLens = Magnifier;
  286. }
  287. else
  288. {
  289. m_bWideConversionLens = false;
  290. m_dWideConversionLens = 0;
  291. };
  292. return true;
  293. }
  294. virtual bool resetPTZDrive(void)
  295. {
  296. return true;
  297. }
  298. virtual bool goHomePosition(void)
  299. {
  300. return true;
  301. }
  302. virtual bool setPTZSpeed(double pSpeed, double tSpeed, double zSpeed)
  303. {
  304. m_dPanSpeed = pSpeed;
  305. m_dTiltSpeed = tSpeed;
  306. m_dZoomSpeed = zSpeed;
  307. return true;
  308. }
  309. virtual bool setPSpeed(double Speed)
  310. {
  311. m_dPanSpeed = Speed;
  312. return true;
  313. }
  314. virtual bool setTSpeed(double Speed)
  315. {
  316. m_dTiltSpeed = Speed;
  317. return true;
  318. }
  319. virtual bool setZSpeed(double Speed)
  320. {
  321. m_dZoomSpeed = Speed;
  322. return true;
  323. }
  324. virtual bool setFSpeed(double Speed)
  325. {
  326. m_dFocusSpeed = Speed;
  327. return true;
  328. }
  329. virtual double getPSpeed(void)
  330. {
  331. return m_dPanSpeed;
  332. }
  333. virtual double getTSpeed(void)
  334. {
  335. return m_dTiltSpeed;
  336. }
  337. virtual double getZSpeed(void)
  338. {
  339. return m_dZoomSpeed;
  340. }
  341. virtual bool getCameraPresets(void)
  342. {
  343. return false;
  344. }
  345. virtual bool move(uint32_t MoveMatrix)
  346. {
  347. if ( MoveMatrix )return true;
  348. return true;
  349. }
  350. virtual bool goUp(void)
  351. {
  352. return true;
  353. }
  354. virtual bool goDown(void)
  355. {
  356. return true;
  357. }
  358. virtual bool goLeft(void)
  359. {
  360. return true;
  361. }
  362. virtual bool goRight(void)
  363. {
  364. return true;
  365. }
  366. virtual bool goDownLeft(void)
  367. {
  368. return true;
  369. }
  370. virtual bool goDownRight(void)
  371. {
  372. return true;
  373. }
  374. virtual bool goUpLeft(void)
  375. {
  376. return true;
  377. }
  378. virtual bool goUpRight(void)
  379. {
  380. return true;
  381. }
  382. virtual bool goStop(void)
  383. {
  384. return true;
  385. }
  386. virtual bool goAbsolute(float dPan, float dTilt, float dZoom)
  387. {
  388. if ( dPan || dTilt || dZoom )return true;
  389. return true;
  390. }
  391. virtual bool goPreset(char * PresetToken)
  392. {
  393. if ( PresetToken == NULL )return true;
  394. return true;
  395. }
  396. virtual bool setOSD(bool nMode)
  397. {
  398. if ( !nMode )return true;
  399. return nMode;
  400. }
  401. virtual bool waitMoveIsDone(void)
  402. {
  403. return false;
  404. }
  405. virtual bool validate()
  406. {
  407. return true;
  408. }
  409. };
  410. #endif // NO_PTZ_CAMERAS
  411. #endif // __PROTOCOLPTZ_H_INCL__