Old fashion design for PC-104
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.

545 lines
15 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 13/10/2002
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: DTKS576.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DTKS576.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\..\LgLib\Device\DTKS576.h"
  16. #define POSITION_QUALYTY 2
  17. #define MAX_NO_REPLY_COUNT 20
  18. #define MAX_NOT_IN_POSITION_COUNT 1
  19. #define DELAY_BETWEEN_COMMANDS 150
  20. #define ONLY_WAIT_AFTER_MOVEMENT 250
  21. CLgDevicePTZTKS576::CLgDevicePTZTKS576()
  22. {
  23. m_nMode = CMD_NONE;
  24. m_nStage = STAGE_GET_PAN;
  25. m_nNoReplyCount = 0;
  26. m_nNotInPositionCount = 0;
  27. m_bReadOnlyHeader = TRUE;
  28. }
  29. CLgDevicePTZTKS576::~CLgDevicePTZTKS576()
  30. {
  31. }
  32. void CLgDevicePTZTKS576::OnPerformCmd()
  33. {
  34. // ready for new message
  35. ReleaseCmd();
  36. // ready to process new message
  37. m_nMode = CMD_NONE;
  38. }
  39. BOOL CLgDevicePTZTKS576::CmdInit()
  40. {
  41. // check availibility
  42. return DoCmd( CMD_INIT );
  43. }
  44. BOOL CLgDevicePTZTKS576::WriteProc( void *pProtocol, PLONG pTimeout )
  45. {
  46. BYTE pSendBuffer[ CProtocolPTZTKS576::MAX_COMMAND_SIZE ];
  47. BYTE nSendCount = 0;
  48. // cast to protocol
  49. CProtocolPTZTKS576 *pProtocolPTZ = (CProtocolPTZTKS576*)pProtocol;
  50. // set working address
  51. pProtocolPTZ->SetAddress( GetAddress() );
  52. // check input command
  53. if( m_nMode == CMD_NONE )
  54. {
  55. switch( GetCmd() )
  56. {
  57. case CMD_INIT:
  58. m_nMode = CMD_INIT;
  59. m_nStage = STAGE_SET_AUTO_FOCUS;
  60. break;
  61. case CMD_GET_PTZ:
  62. m_nMode = CMD_GET_PTZ;
  63. m_nStage = STAGE_GET_PAN;
  64. break;
  65. case CMD_SET_PTZ:
  66. m_nMode = CMD_SET_PTZ;
  67. m_nStage = STAGE_SET_PAN;
  68. m_nNotInPositionCount = 0;
  69. break;
  70. case CMD_MOVE_TILT:
  71. m_nMode = CMD_MOVE_TILT;
  72. m_nStage = STAGE_TILT;
  73. break;
  74. case CMD_MOVE_PAN:
  75. m_nMode = CMD_MOVE_PAN;
  76. m_nStage = STAGE_PAN;
  77. break;
  78. case CMD_MOVE_ZOOM:
  79. m_nMode = CMD_MOVE_ZOOM;
  80. m_nStage = STAGE_ZOOM;
  81. break;
  82. case CMD_MOVE_FOCUS:
  83. m_nMode = CMD_MOVE_FOCUS;
  84. m_nStage = STAGE_FOCUS;
  85. break;
  86. case CMD_SET_FOCUS:
  87. m_nMode = CMD_SET_FOCUS;
  88. m_nStage = STAGE_FOCUS;
  89. break;
  90. case CMD_GET_FOCUS:
  91. m_nMode = CMD_GET_FOCUS;
  92. m_nStage = STAGE_FOCUS;
  93. break;
  94. case CMD_NONE:
  95. // no new commands
  96. break;
  97. case CMD_WIPER:
  98. case CMD_SET_IRIS:
  99. default:
  100. //command unsupported
  101. OnPerformCmd();
  102. OnEvtUnsupported();
  103. break;
  104. }
  105. }
  106. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  107. BOOL bOnlyWait = FALSE;
  108. #endif
  109. // fill packet depend on command
  110. switch( m_nMode )
  111. {
  112. case CMD_SET_PTZ:
  113. switch( m_nStage )
  114. {
  115. case STAGE_SET_PAN:
  116. // ask for pan position
  117. nSendCount += PTZ_JVC_TK_S576::BuildSetPanPosition( pSendBuffer, GetAddress(), PTZ_JVC_TK_S576::Degree2Pan( m_Position.dPan ) );
  118. // short response
  119. m_bReadOnlyHeader = TRUE;
  120. break;
  121. case STAGE_SET_TILT:
  122. // ask for pan position
  123. nSendCount += PTZ_JVC_TK_S576::BuildSetTiltPosition( pSendBuffer, GetAddress(), PTZ_JVC_TK_S576::Degree2Tilt( m_Position.dTilt ) );
  124. // short response
  125. m_bReadOnlyHeader = TRUE;
  126. break;
  127. case STAGE_SET_ZOOM:
  128. // ask for pan position
  129. nSendCount += PTZ_JVC_TK_S576::BuildSetZoomPosition( pSendBuffer, GetAddress(), PTZ_JVC_TK_S576::Percent2Zoom( m_Position.dZoom ) );
  130. // short response
  131. m_bReadOnlyHeader = TRUE;
  132. break;
  133. case STAGE_SET_PAN_DELAY:
  134. m_nStage = STAGE_SET_TILT;
  135. *pTimeout = DELAY_BETWEEN_COMMANDS;
  136. return FALSE;
  137. case STAGE_SET_TILT_DELAY:
  138. m_nStage = STAGE_SET_ZOOM;
  139. *pTimeout = DELAY_BETWEEN_COMMANDS;
  140. return FALSE;
  141. case STAGE_SET_ZOOM_DELAY:
  142. m_nStage = STAGE_GET_PAN;
  143. *pTimeout = DELAY_BETWEEN_COMMANDS;// * 6;
  144. return FALSE;
  145. case STAGE_GET_PAN:
  146. // ready to process new message
  147. OnPerformCmd();
  148. //notify
  149. OnEvtSetPTZ( m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  150. // default delay
  151. *pTimeout = 10;
  152. return FALSE;
  153. }
  154. break;
  155. case CMD_INIT:
  156. switch( m_nStage )
  157. {
  158. case STAGE_SET_AUTO_FOCUS:
  159. // ask for pan position
  160. nSendCount += PTZ_JVC_TK_S576::BuildSetAutoFocus( pSendBuffer, GetAddress() );
  161. // long response
  162. m_bReadOnlyHeader = TRUE;
  163. break;
  164. }
  165. // next steps like in "get position"
  166. case CMD_GET_PTZ:
  167. switch( m_nStage )
  168. {
  169. case STAGE_GET_PAN:
  170. // ask for pan position
  171. nSendCount += PTZ_JVC_TK_S576::BuildGetPanPosition( pSendBuffer, GetAddress() );
  172. // long response
  173. m_bReadOnlyHeader = FALSE;
  174. break;
  175. case STAGE_GET_TILT:
  176. // ask for pan position
  177. nSendCount += PTZ_JVC_TK_S576::BuildGetTiltPosition( pSendBuffer, GetAddress() );
  178. // long response
  179. m_bReadOnlyHeader = FALSE;
  180. break;
  181. case STAGE_GET_ZOOM:
  182. // ask for pan position
  183. nSendCount += PTZ_JVC_TK_S576::BuildGetZoomPosition( pSendBuffer, GetAddress() );
  184. // long response
  185. m_bReadOnlyHeader = FALSE;
  186. break;
  187. case STAGE_GET_PAN_DELAY:
  188. m_nStage = STAGE_GET_TILT;
  189. *pTimeout = DELAY_BETWEEN_COMMANDS;
  190. return FALSE;
  191. case STAGE_GET_TILT_DELAY:
  192. m_nStage = STAGE_GET_ZOOM;
  193. *pTimeout = DELAY_BETWEEN_COMMANDS;
  194. return FALSE;
  195. }
  196. break;
  197. case CMD_MOVE_PAN:
  198. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  199. switch( m_nStage )
  200. {
  201. case STAGE_PAN:
  202. // write command
  203. nSendCount += PTZ_JVC_TK_S576::BuildPan( pSendBuffer, GetAddress(), m_MovePan.dSpeed > 0 ? ( m_MovePan.bRight ? PTZ_JVC_TK_S576::PAN_RIGHT : PTZ_JVC_TK_S576::PAN_LEFT ) : PTZ_JVC_TK_S576::PAN_STOP, PTZ_JVC_TK_S576::Percent2PanSpeed( m_MovePan.dSpeed ) );
  204. // set next stage
  205. m_nStage = STAGE_PAN_DELAY;
  206. // don't read reply
  207. bOnlyWait = TRUE;
  208. break;
  209. case STAGE_PAN_DELAY:
  210. // ready to process new message
  211. OnPerformCmd();
  212. //notify
  213. OnEvtMovePan( m_MovePan.bRight, m_MovePan.dSpeed );
  214. // no timeout
  215. *pTimeout = 0;
  216. return FALSE;
  217. }
  218. #else
  219. // write command
  220. nSendCount += PTZ_JVC_TK_S576::BuildPan( pSendBuffer, GetAddress(), m_MovePan.dSpeed > 0 ? ( m_MovePan.bRight ? PTZ_JVC_TK_S576::PAN_RIGHT : PTZ_JVC_TK_S576::PAN_LEFT ) : PTZ_JVC_TK_S576::PAN_STOP, PTZ_JVC_TK_S576::Percent2PanSpeed( m_MovePan.dSpeed ) );
  221. // short response
  222. m_bReadOnlyHeader = TRUE;
  223. #endif
  224. break;
  225. case CMD_MOVE_TILT:
  226. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  227. switch( m_nStage )
  228. {
  229. case STAGE_TILT:
  230. // write command
  231. nSendCount += PTZ_JVC_TK_S576::BuildTilt( pSendBuffer, GetAddress(), m_MoveTilt.dSpeed > 0 ? ( m_MoveTilt.bUp ? PTZ_JVC_TK_S576::TILT_UP : PTZ_JVC_TK_S576::TILT_DOWN ) : PTZ_JVC_TK_S576::TILT_STOP, PTZ_JVC_TK_S576::Percent2TiltSpeed( m_MoveTilt.dSpeed ) );
  232. // set next stage
  233. m_nStage = STAGE_TILT_DELAY;
  234. // don't read reply
  235. bOnlyWait = TRUE;
  236. break;
  237. case STAGE_TILT_DELAY:
  238. // ready to process new message
  239. OnPerformCmd();
  240. //notify
  241. OnEvtMoveTilt( m_MoveTilt.bUp, m_MoveTilt.dSpeed );
  242. // no timeout
  243. *pTimeout = 0;
  244. return FALSE;
  245. }
  246. #else
  247. // write command
  248. nSendCount += PTZ_JVC_TK_S576::BuildTilt( pSendBuffer, GetAddress(), m_MoveTilt.dSpeed > 0 ? ( m_MoveTilt.bUp ? PTZ_JVC_TK_S576::TILT_UP : PTZ_JVC_TK_S576::TILT_DOWN ) : PTZ_JVC_TK_S576::TILT_STOP, PTZ_JVC_TK_S576::Percent2TiltSpeed( m_MoveTilt.dSpeed ) );
  249. // short response
  250. m_bReadOnlyHeader = TRUE;
  251. #endif
  252. break;
  253. case CMD_MOVE_ZOOM:
  254. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  255. switch( m_nStage )
  256. {
  257. case STAGE_ZOOM:
  258. // write command
  259. nSendCount += PTZ_JVC_TK_S576::BuildZoom( pSendBuffer, GetAddress(), m_MoveZoom.dSpeed > 0 ? ( m_MoveZoom.bTele ? PTZ_JVC_TK_S576::ZOOM_TELE : PTZ_JVC_TK_S576::ZOOM_WIDE ) : PTZ_JVC_TK_S576::ZOOM_STOP, PTZ_JVC_TK_S576::Percent2ZoomSpeed( m_MoveZoom.dSpeed ) );
  260. // set next stage
  261. m_nStage = STAGE_ZOOM_DELAY;
  262. // don't read reply
  263. bOnlyWait = TRUE;
  264. break;
  265. case STAGE_ZOOM_DELAY:
  266. // ready to process new message
  267. OnPerformCmd();
  268. //notify
  269. OnEvtMoveZoom( m_MoveZoom.bTele, m_MoveZoom.dSpeed );
  270. // no timeout
  271. *pTimeout = 0;
  272. return FALSE;
  273. }
  274. #else
  275. // write command
  276. nSendCount += PTZ_JVC_TK_S576::BuildZoom( pSendBuffer, GetAddress(), m_MoveZoom.dSpeed > 0 ? ( m_MoveZoom.bTele ? PTZ_JVC_TK_S576::ZOOM_TELE : PTZ_JVC_TK_S576::ZOOM_WIDE ) : PTZ_JVC_TK_S576::ZOOM_STOP, PTZ_JVC_TK_S576::Percent2ZoomSpeed( m_MoveZoom.dSpeed ) );
  277. // short response
  278. m_bReadOnlyHeader = TRUE;
  279. #endif
  280. break;
  281. case CMD_MOVE_FOCUS:
  282. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  283. switch( m_nStage )
  284. {
  285. case STAGE_FOCUS:
  286. // write command
  287. nSendCount += PTZ_JVC_TK_S576::BuildMoveFocus( pSendBuffer, GetAddress(), m_MoveFocus.dSpeed > 0 ? ( m_MoveFocus.bFar ? PTZ_JVC_TK_S576::FOCUS_FAR : PTZ_JVC_TK_S576::FOCUS_NEAR ) : PTZ_JVC_TK_S576::FOCUS_STOP, PTZ_JVC_TK_S576::Percent2FocusSpeed( m_MoveFocus.dSpeed ) );
  288. // set next stage
  289. m_nStage = STAGE_FOCUS_DELAY;
  290. // don't read reply
  291. bOnlyWait = TRUE;
  292. break;
  293. case STAGE_FOCUS_DELAY:
  294. // ready to process new message
  295. OnPerformCmd();
  296. //notify
  297. OnEvtMoveFocus( m_MoveFocus.bFar, m_MoveFocus.dSpeed );
  298. // no timeout
  299. *pTimeout = 0;
  300. return FALSE;
  301. }
  302. #else
  303. // write command
  304. nSendCount += PTZ_JVC_TK_S576::BuildMoveFocus( pSendBuffer, GetAddress(), m_MoveFocus.dSpeed > 0 ? ( m_MoveFocus.bFar ? PTZ_JVC_TK_S576::FOCUS_FAR : PTZ_JVC_TK_S576::FOCUS_NEAR ) : PTZ_JVC_TK_S576::FOCUS_STOP, PTZ_JVC_TK_S576::Percent2FocusSpeed( m_MoveFocus.dSpeed ) );
  305. // short response
  306. m_bReadOnlyHeader = TRUE;
  307. #endif
  308. break;
  309. case CMD_SET_FOCUS:
  310. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  311. switch( m_nStage )
  312. {
  313. case STAGE_FOCUS:
  314. // write data
  315. nSendCount += PTZ_JVC_TK_S576::BuildSetFocusPosition( pSendBuffer, GetAddress(), PTZ_JVC_TK_S576::Percent2Focus( m_Focus ) );
  316. // set next stage
  317. m_nStage = STAGE_FOCUS_DELAY;
  318. // don't read reply
  319. bOnlyWait = TRUE;
  320. break;
  321. case STAGE_FOCUS_DELAY:
  322. // ready to process new message
  323. OnPerformCmd();
  324. //notify
  325. OnEvtSetFocus( m_Focus );
  326. // no timeout
  327. *pTimeout = 0;
  328. return FALSE;
  329. }
  330. #else
  331. // write data
  332. nSendCount += PTZ_JVC_TK_S576::BuildSetFocusPosition( pSendBuffer, GetAddress(), PTZ_JVC_TK_S576::Percent2Focus( m_Focus ) );
  333. // short response
  334. m_bReadOnlyHeader = TRUE;
  335. #endif
  336. break;
  337. case CMD_GET_FOCUS:
  338. // write command
  339. nSendCount += PTZ_JVC_TK_S576::BuildGetFocusPosition( pSendBuffer, GetAddress() );
  340. // short response
  341. m_bReadOnlyHeader = FALSE;
  342. break;
  343. case CMD_NONE:
  344. default:
  345. *pTimeout = 10L;
  346. return FALSE;
  347. }
  348. // write packet
  349. if( !pProtocolPTZ->Write( pSendBuffer, nSendCount, 1000UL, TRUE ) )
  350. return FALSE;
  351. #ifdef ONLY_WAIT_AFTER_MOVEMENT
  352. if( bOnlyWait )
  353. // only wait
  354. *pTimeout = ONLY_WAIT_AFTER_MOVEMENT;
  355. else
  356. #endif
  357. *pTimeout = m_bReadOnlyHeader ? 250L : 1000L; // TX + RX
  358. return TRUE;
  359. }
  360. BOOL CLgDevicePTZTKS576::ReadProc( void *pProtocol, LONG lTimeout, BOOL bLastChance )
  361. {
  362. CProtocolPTZTKS576 *pProtocolPTZ = (CProtocolPTZTKS576*) pProtocol;
  363. // set protocol read mode
  364. pProtocolPTZ->SetReadOnlyHeaderMode( m_bReadOnlyHeader );
  365. // read reply
  366. PBYTE pReadBuffer = NULL;
  367. INT nReadCount = 0;
  368. if( !pProtocolPTZ->Read( &pReadBuffer, &nReadCount, lTimeout, TRUE ) || !pReadBuffer || !nReadCount )
  369. {
  370. if( !bLastChance )
  371. return FALSE;
  372. m_nNoReplyCount++;
  373. if( m_nNoReplyCount > MAX_NO_REPLY_COUNT )
  374. {
  375. // perform reinitialization
  376. m_nMode = CMD_INIT;
  377. m_nStage = STAGE_SET_AUTO_FOCUS;
  378. }
  379. return FALSE;
  380. }
  381. printf( "\nOK" );
  382. // reset retry counter
  383. m_nNoReplyCount = 0;
  384. // switch mode
  385. switch( m_nMode )
  386. {
  387. case CMD_INIT:
  388. switch( m_nStage )
  389. {
  390. case STAGE_SET_AUTO_FOCUS:
  391. // next stage
  392. m_nStage = STAGE_GET_PAN;
  393. return TRUE;
  394. }
  395. // next steps like in get position
  396. case CMD_GET_PTZ:
  397. switch( m_nStage )
  398. {
  399. case STAGE_GET_PAN:
  400. // store position
  401. m_Position.dPan = PTZ_JVC_TK_S576::Pan2Degree( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  402. // next stage
  403. m_nStage = STAGE_GET_PAN_DELAY;
  404. return TRUE;
  405. case STAGE_GET_TILT:
  406. // store position
  407. m_Position.dTilt = PTZ_JVC_TK_S576::Tilt2Degree( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  408. // next stage
  409. m_nStage = STAGE_GET_TILT_DELAY;
  410. return TRUE;
  411. case STAGE_GET_ZOOM:
  412. // store position
  413. m_Position.dZoom = PTZ_JVC_TK_S576::Zoom2Percent( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  414. // ready to process new message
  415. OnPerformCmd();
  416. //notify
  417. if( m_nMode == CMD_INIT )
  418. OnEvtInit();
  419. else
  420. OnEvtGetPTZ( m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  421. break;
  422. }
  423. break;
  424. case CMD_SET_PTZ:
  425. switch( m_nStage )
  426. {
  427. case STAGE_SET_PAN: m_nStage = STAGE_SET_PAN_DELAY; return TRUE;
  428. case STAGE_SET_TILT: m_nStage = STAGE_SET_TILT_DELAY; return TRUE;
  429. case STAGE_SET_ZOOM: m_nStage = STAGE_SET_ZOOM_DELAY; return TRUE;
  430. /*
  431. case STAGE_GET_PAN:
  432. // store position
  433. m_TempPosition.dPan = PTZ_JVC_TK_S576::Pan2Degree( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  434. // next stage
  435. m_nStage = STAGE_GET_PAN_DELAY;
  436. return TRUE;
  437. case STAGE_GET_TILT:
  438. // store position
  439. m_TempPosition.dTilt = PTZ_JVC_TK_S576::Tilt2Degree( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  440. // next stage
  441. m_nStage = STAGE_GET_TILT_DELAY;
  442. return TRUE;
  443. case STAGE_GET_ZOOM:
  444. // store position
  445. m_TempPosition.dZoom = PTZ_JVC_TK_S576::Zoom2Percent( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  446. // calculate difference between desired position and current position
  447. if( PTZ_JVC_TK_S576::QualifyPosition( m_TempPosition.dPan - m_Position.dPan,
  448. m_TempPosition.dTilt - m_Position.dTilt,
  449. m_TempPosition.dZoom - m_Position.dZoom,
  450. POSITION_QUALYTY ) ||
  451. m_nNotInPositionCount >= MAX_NOT_IN_POSITION_COUNT )
  452. {
  453. // store position
  454. m_Position.dPan = m_TempPosition.dPan;
  455. m_Position.dTilt = m_TempPosition.dTilt;
  456. m_Position.dZoom = m_TempPosition.dZoom;
  457. // ready to process new message
  458. OnPerformCmd();
  459. //notify
  460. OnEvtGotoPosition( m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  461. }
  462. else
  463. {
  464. // does not in posiiton
  465. m_nStage = STAGE_SET_PAN;
  466. // increate fault counter
  467. m_nNotInPositionCount++;
  468. return TRUE;
  469. }
  470. break;
  471. */
  472. }
  473. break;
  474. case CMD_MOVE_PAN:
  475. // ready to process new message
  476. OnPerformCmd();
  477. //notify
  478. OnEvtMovePan( m_MovePan.bRight, m_MovePan.dSpeed );
  479. break;
  480. case CMD_MOVE_TILT:
  481. // ready to process new message
  482. OnPerformCmd();
  483. //notify
  484. OnEvtMoveTilt( m_MoveTilt.bUp, m_MoveTilt.dSpeed );
  485. break;
  486. case CMD_MOVE_ZOOM:
  487. // ready to process new message
  488. OnPerformCmd();
  489. //notify
  490. OnEvtMoveZoom( m_MoveZoom.bTele, m_MoveZoom.dSpeed );
  491. break;
  492. case CMD_MOVE_FOCUS:
  493. // ready to process new message
  494. OnPerformCmd();
  495. //notify
  496. OnEvtMoveFocus( m_MoveFocus.bFar, m_MoveFocus.dSpeed );
  497. break;
  498. case CMD_SET_FOCUS:
  499. // ready to process new message
  500. OnPerformCmd();
  501. //notify
  502. OnEvtSetFocus( m_Focus );
  503. break;
  504. case CMD_GET_FOCUS:
  505. // store position
  506. m_Focus = PTZ_JVC_TK_S576::Focus2Percent( PTZ_JVC_TK_S576::ToValue( pReadBuffer[1], pReadBuffer[4], pReadBuffer[5] ) );
  507. // ready to process new message
  508. OnPerformCmd();
  509. //notify
  510. OnEvtGetFocus( m_Focus );
  511. break;
  512. }
  513. return TRUE;
  514. }