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.

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