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.

487 lines
7.3 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. return true;
  108. }
  109. virtual bool setPowerSaveMode(bool nMode)
  110. {
  111. m_bPowerSave_Mode = nMode;
  112. return true;
  113. }
  114. virtual bool getPowerSaveMode(void)
  115. {
  116. return m_bPowerSave_Mode;
  117. }
  118. virtual bool startZoomWide(void)
  119. {
  120. return true;
  121. }
  122. virtual bool startZoomTele(void)
  123. {
  124. return true;
  125. }
  126. virtual bool startZoomWide(double nSpeed)
  127. {
  128. m_dZoomSpeed = nSpeed;
  129. return true;
  130. }
  131. virtual bool startZoomTele(double nSpeed)
  132. {
  133. m_dZoomSpeed = nSpeed;
  134. return true;
  135. }
  136. virtual bool stopZoom(void)
  137. {
  138. return true;
  139. }
  140. virtual bool setPanPos(double dPan)
  141. {
  142. return true;
  143. }
  144. virtual bool setTiltPos(double dTilt)
  145. {
  146. return true;
  147. }
  148. virtual bool setZoom(double nZoom)
  149. {
  150. return true;
  151. }
  152. void setProtocolDeviceID(U8 device_id)
  153. {
  154. m_bProtocolDeviceID = device_id;
  155. }
  156. virtual double getPan(void)
  157. {
  158. return m_dPan;
  159. }
  160. virtual double getTilt(void)
  161. {
  162. return m_dTilt;
  163. }
  164. virtual double getZoom(void)
  165. {
  166. return m_dZoom;
  167. }
  168. virtual bool startFocusFar(void)
  169. {
  170. return false;
  171. }
  172. virtual bool startFocusNear(void)
  173. {
  174. return false;
  175. }
  176. virtual bool setAutoFocus(bool nMode)
  177. {
  178. m_bAutoFocus_Mode = nMode;
  179. return true;
  180. }
  181. virtual bool getAutoFocus(void)
  182. {
  183. return m_bAutoFocus_Mode;
  184. }
  185. virtual bool setFocus(double nFocus)
  186. {
  187. m_dFocus = nFocus;
  188. return true;
  189. } // 0.0 -> 1.0
  190. virtual double getFocus(void)
  191. {
  192. return m_dFocus;
  193. }
  194. virtual bool setWhiteBalanceMode(CAM_WB_MODE nMode)
  195. {
  196. m_eWB_Mode = nMode;
  197. return true;
  198. }
  199. virtual bool triggerWBPoint(void)
  200. {
  201. return true;
  202. }
  203. virtual bool setExposureMode(CAM_EXP_MODE nMode)
  204. {
  205. m_eExp_Mode = nMode;
  206. return true;
  207. }
  208. virtual bool expBrightReset(void)
  209. {
  210. return true;
  211. }
  212. virtual bool expBrightUp(void)
  213. {
  214. return true;
  215. }
  216. virtual bool expBrightDown(void)
  217. {
  218. return true;
  219. }
  220. virtual bool expShutterReset(void)
  221. {
  222. return true;
  223. }
  224. virtual bool expShutterUp(void)
  225. {
  226. return true;
  227. }
  228. virtual bool expShutterDown(void)
  229. {
  230. return true;
  231. }
  232. virtual bool expIrisReset(void)
  233. {
  234. return true;
  235. }
  236. virtual bool expIrisUp(void)
  237. {
  238. return true;
  239. }
  240. virtual bool expIrisDown(void)
  241. {
  242. return true;
  243. }
  244. virtual bool expGainReset(void)
  245. {
  246. return true;
  247. }
  248. virtual bool expGainUp(void)
  249. {
  250. return true;
  251. }
  252. virtual bool expGainDown(void)
  253. {
  254. return true;
  255. }
  256. virtual bool setBackLightMode(bool nMode)
  257. {
  258. m_bBackLight_Mode = nMode;
  259. return true;
  260. }
  261. virtual bool getBackLightMode(void)
  262. {
  263. return m_bBackLight_Mode;
  264. }
  265. virtual bool saveSettings(int backNumber)
  266. {
  267. return true;
  268. }
  269. virtual bool recallSetings(int backNumber)
  270. {
  271. return true;
  272. }
  273. virtual bool setWideConversionLens(double Magnifier)
  274. {
  275. if (Magnifier > 0)
  276. {
  277. m_bWideConversionLens = true;
  278. m_dWideConversionLens = Magnifier;
  279. }
  280. else
  281. {
  282. m_bWideConversionLens = false;
  283. m_dWideConversionLens = 0;
  284. };
  285. return true;
  286. }
  287. virtual bool resetPTZDrive(void)
  288. {
  289. return true;
  290. }
  291. virtual bool goHomePosition(void)
  292. {
  293. return true;
  294. }
  295. virtual bool setPTZSpeed(double pSpeed, double tSpeed, double zSpeed)
  296. {
  297. m_dPanSpeed = pSpeed;
  298. m_dTiltSpeed = tSpeed;
  299. m_dZoomSpeed = zSpeed;
  300. return true;
  301. }
  302. virtual bool setPSpeed(double Speed)
  303. {
  304. m_dPanSpeed = Speed;
  305. return true;
  306. }
  307. virtual bool setTSpeed(double Speed)
  308. {
  309. m_dTiltSpeed = Speed;
  310. return true;
  311. }
  312. virtual bool setZSpeed(double Speed)
  313. {
  314. m_dZoomSpeed = Speed;
  315. return true;
  316. }
  317. virtual bool setFSpeed(double Speed)
  318. {
  319. m_dFocusSpeed = Speed;
  320. return true;
  321. }
  322. virtual double getPSpeed(void)
  323. {
  324. return m_dPanSpeed;
  325. }
  326. virtual double getTSpeed(void)
  327. {
  328. return m_dTiltSpeed;
  329. }
  330. virtual double getZSpeed(void)
  331. {
  332. return m_dZoomSpeed;
  333. }
  334. virtual bool getCameraPresets(void)
  335. {
  336. return false;
  337. }
  338. virtual bool move(uint32_t MoveMatrix)
  339. {
  340. return true;
  341. }
  342. virtual bool goUp(void)
  343. {
  344. return true;
  345. }
  346. virtual bool goDown(void)
  347. {
  348. return true;
  349. }
  350. virtual bool goLeft(void)
  351. {
  352. return true;
  353. }
  354. virtual bool goRight(void)
  355. {
  356. return true;
  357. }
  358. virtual bool goDownLeft(void)
  359. {
  360. return true;
  361. }
  362. virtual bool goDownRight(void)
  363. {
  364. return true;
  365. }
  366. virtual bool goUpLeft(void)
  367. {
  368. return true;
  369. }
  370. virtual bool goUpRight(void)
  371. {
  372. return true;
  373. }
  374. virtual bool goStop(void)
  375. {
  376. return true;
  377. }
  378. virtual bool goAbsolute(float dPan, float dTilt, float dZoom)
  379. {
  380. return true;
  381. }
  382. virtual bool goPreset(char * PresetToken)
  383. {
  384. return true;
  385. }
  386. virtual bool setOSD(bool nMode)
  387. {
  388. return true;
  389. }
  390. virtual bool waitMoveIsDone(void)
  391. {
  392. return false;
  393. }
  394. virtual bool validate()
  395. {
  396. return true;
  397. }
  398. };
  399. #endif // NO_PTZ_CAMERAS
  400. #endif // __PROTOCOLPTZ_H_INCL__