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.

492 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: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: DPG3AD.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DPG3AD.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #ifdef __BORLANDC__
  16. #include "..\LgLib\Device\DHebron.h"
  17. #include "..\LgLib\Comm\ProtLGSm.h"
  18. #include "..\LgLib\Comm\Hebron.h"
  19. #else
  20. #include "DHebron.h"
  21. #endif
  22. #define POSITION_QUALYTY 3
  23. #define MAX_NO_REPLY_COUNT 20
  24. #define MAX_NOT_IN_POSITION_COUNT 10
  25. #define DELAY_BEFORE_GET_POSITION 500
  26. CLgDevicePTZHebron::CLgDevicePTZHebron()
  27. {
  28. m_nMode = CMD_NONE;
  29. m_nStage = STAGE_GET_POSITION;
  30. m_nNoReplyCount = 0;
  31. m_nNotInPositionCount = 0;
  32. m_bModeDopler = FALSE;
  33. m_nMaskIndex = 0;
  34. }
  35. CLgDevicePTZHebron::~CLgDevicePTZHebron()
  36. {
  37. }
  38. BOOL CLgDevicePTZHebron::CmdInit()
  39. {
  40. // check availibility
  41. return DoCmd( CMD_INIT );
  42. }
  43. void CLgDevicePTZHebron::OnPerformCmd()
  44. {
  45. // ready for new message
  46. ReleaseCmd();
  47. // ready to process new message
  48. m_nMode = CMD_NONE;
  49. }
  50. BOOL CLgDevicePTZHebron::WriteProc( void *pProtocol, PLONG pTimeout )
  51. {
  52. BYTE pSendBuffer[ CProtocolLGS::MAX_COMMAND_SIZE ];
  53. INT nSendCount = 0;
  54. // cast to protocol
  55. CProtocolLGS *pProtocolLGS = (CProtocolLGS*)pProtocol;
  56. // check input command
  57. if( m_nMode == CMD_NONE )
  58. {
  59. switch( GetCmd() )
  60. {
  61. case CMD_INIT:
  62. m_nMode = CMD_INIT;
  63. m_bModeDopler = FALSE;
  64. break;
  65. case CMD_GET_PTZ:
  66. m_nMode = CMD_GET_PTZ;
  67. break;
  68. case CMD_SET_PTZ:
  69. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CLgDevicePTZHebron::WriteProc"), _T("CMD_SET_PTZ %d,%d,%d"), m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  70. // validate positions
  71. PTZ_HEBRON::ValidatePan( m_Position.dPan );
  72. PTZ_HEBRON::ValidateTilt( m_Position.dTilt );
  73. PTZ_HEBRON::ValidateZoom( m_Position.dZoom );
  74. m_nMode = CMD_SET_PTZ;
  75. m_nStage = STAGE_GOTO_POSITION;
  76. m_nNotInPositionCount = 0;
  77. m_bModeDopler = FALSE;
  78. break;
  79. case CMD_MOVE_TILT:
  80. m_nMode = CMD_MOVE_TILT;
  81. m_bModeDopler = FALSE;
  82. break;
  83. case CMD_MOVE_PAN:
  84. m_nMode = CMD_MOVE_PAN;
  85. m_bModeDopler = FALSE;
  86. break;
  87. case CMD_MOVE_ZOOM:
  88. m_nMode = CMD_MOVE_ZOOM;
  89. m_bModeDopler = FALSE;
  90. break;
  91. case CMD_SET_DOPLER:
  92. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CLgDevicePTZHebron::WriteProc"), _T("CMD_SET_DOPLER %d,%d,%d"), m_Dopler.bEnable, m_Dopler.dPanStep, m_Dopler.dwTimeout );
  93. m_nMode = CMD_SET_DOPLER;
  94. m_bModeDopler = m_Dopler.bEnable;
  95. break;
  96. case CMD_GET_DOPLER:
  97. m_nMode = CMD_GET_DOPLER;
  98. break;
  99. case CMD_SET_IRIS:
  100. m_nMode = CMD_SET_IRIS;
  101. break;
  102. case CMD_SET_DOPLER_MASK:
  103. m_nMaskIndex = -1;
  104. m_nMode = CMD_SET_DOPLER_MASK;
  105. break;
  106. case CMD_GET_DOPLER_MASK:
  107. m_nMaskIndex = -1;
  108. m_nMode = CMD_GET_DOPLER_MASK;
  109. break;
  110. case CMD_NONE:
  111. // no new commands
  112. break;
  113. default:
  114. //command unsupported
  115. OnPerformCmd();
  116. OnEvtCommandError( m_nMode, _T("UNSUPPORTED") );
  117. break;
  118. }
  119. }
  120. LPBYTE pSendBufferPtr = pSendBuffer;
  121. // fill packet depend on command
  122. switch( m_nMode )
  123. {
  124. case CMD_SET_PTZ:
  125. switch( m_nStage )
  126. {
  127. case STAGE_GOTO_POSITION:
  128. // ask for pan position
  129. nSendCount += PTZ_HEBRON::BuildSetPosition( pSendBufferPtr, GetAddress(),
  130. PTZ_HEBRON::Degree2Pan( m_Position.dPan ),
  131. PTZ_HEBRON::Degree2Tilt( m_Position.dTilt ),
  132. PTZ_HEBRON::Percent2Zoom( m_Position.dZoom ) );
  133. break;
  134. case STAGE_GET_POSITION:
  135. // ask for pan position
  136. nSendCount += PTZ_HEBRON::BuildGetPosition( pSendBufferPtr, GetAddress() );
  137. break;
  138. }
  139. break;
  140. case CMD_SET_DOPLER:
  141. // ask for pan position
  142. nSendCount += PTZ_HEBRON::BuildSetDopler( pSendBufferPtr, GetAddress(),
  143. m_Dopler.bEnable,
  144. PTZ_HEBRON::DeltaDegree2Pan( m_Dopler.dPanStep ),
  145. m_Dopler.dwTimeout );
  146. break;
  147. case CMD_GET_DOPLER:
  148. // ask for pan position
  149. nSendCount += PTZ_HEBRON::BuildGetDopler( pSendBufferPtr, GetAddress() );
  150. break;
  151. case CMD_GET_PTZ:
  152. // ask for pan position
  153. nSendCount += PTZ_HEBRON::BuildGetPosition( pSendBufferPtr, GetAddress() );
  154. break;
  155. case CMD_INIT:
  156. // ask for pan position
  157. nSendCount += PTZ_HEBRON::BuildGetPosition( pSendBufferPtr, GetAddress() );
  158. break;
  159. case CMD_MOVE_PAN:
  160. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("SET HEBRON MOVE PAN"), _T("%d %d"), m_MovePan.bRight, m_MovePan.dSpeed );
  161. nSendCount += PTZ_HEBRON::BuildMove( pSendBufferPtr, GetAddress(), PTZ_HEBRON::MOVE_USE_PAN | ( m_MovePan.bRight ? PTZ_HEBRON::MOVE_PAN_RIGHT : 0 ), PTZ_HEBRON::Percent2PanSpeed(m_MovePan.dSpeed), 0, 0 );
  162. break;
  163. case CMD_MOVE_TILT:
  164. nSendCount += PTZ_HEBRON::BuildMove( pSendBufferPtr, GetAddress(), PTZ_HEBRON::MOVE_USE_TILT | ( m_MoveTilt.bUp ? PTZ_HEBRON::MOVE_TILT_UP : 0 ), 0, PTZ_HEBRON::Percent2TiltSpeed(m_MoveTilt.dSpeed), 0 );
  165. break;
  166. case CMD_MOVE_ZOOM:
  167. nSendCount += PTZ_HEBRON::BuildMove( pSendBufferPtr, GetAddress(), PTZ_HEBRON::MOVE_USE_ZOOM | ( m_MoveZoom.bTele ? PTZ_HEBRON::MOVE_ZOOM_TELE : 0 ), 0, 0, PTZ_HEBRON::Percent2ZoomSpeed(m_MoveZoom.dSpeed) );
  168. break;
  169. case CMD_SET_IRIS:
  170. nSendCount += PTZ_HEBRON::BuildSetIris( pSendBufferPtr, GetAddress(), PTZ_HEBRON::Percent2Iris(m_Iris) );
  171. break;
  172. case CMD_SET_DOPLER_MASK:
  173. if( m_nMaskIndex == -1 ) nSendCount += PTZ_HEBRON::BuildSetDoplerMask( pSendBufferPtr, GetAddress(), m_Mask.bEnable, m_Mask.nCount );
  174. else if( m_nMaskIndex == m_Mask.nCount ) nSendCount += PTZ_HEBRON::BuildSetDoplerMaskSave( pSendBufferPtr, GetAddress() );
  175. else nSendCount += PTZ_HEBRON::BuildSetDoplerMaskValue( pSendBufferPtr, GetAddress(), m_nMaskIndex, PTZ_HEBRON::Degree2Pan( m_Mask.pMask[m_nMaskIndex].nStartAngle ), PTZ_HEBRON::Degree2Pan( m_Mask.pMask[m_nMaskIndex].nStopAngle ) );
  176. break;
  177. case CMD_GET_DOPLER_MASK:
  178. if( m_nMaskIndex == -1 ) nSendCount += PTZ_HEBRON::BuildGetDoplerMask( pSendBufferPtr, GetAddress() );
  179. else nSendCount += PTZ_HEBRON::BuildGetDoplerMaskValue( pSendBufferPtr, GetAddress(), m_nMaskIndex );
  180. break;
  181. case CMD_NONE:
  182. default:
  183. if( m_bModeDopler )
  184. {
  185. nSendCount += PTZ_HEBRON::BuildGetDoplerAlarm( pSendBufferPtr, GetAddress() );
  186. }
  187. else
  188. {
  189. /* static int nTargetTime = 0;
  190. static int nTargetAngle = 0;
  191. if( nTargetTime++ > 100 )
  192. {
  193. nTargetAngle = (nTargetAngle + 10) % 360;
  194. OnEvtDoplerAlarm( TRUE, nTargetAngle );
  195. nTargetTime = 0;
  196. }
  197. */
  198. *pTimeout = 10L;
  199. return FALSE;
  200. }
  201. break;
  202. }
  203. // write packet
  204. if( !pProtocolLGS->Write( pSendBuffer, nSendCount, 1000UL, TRUE ) )
  205. return FALSE;
  206. *pTimeout = 250L; // TX + RX
  207. return TRUE;
  208. }
  209. BOOL CLgDevicePTZHebron::ReadProc( void *pProtocol, LONG lTimeout, BOOL bLastChance )
  210. {
  211. CProtocolLGS *pProtocolLGS = (CProtocolLGS*)pProtocol;
  212. // read reply
  213. PBYTE pReadBuffer = NULL;
  214. INT nReadCount = 0;
  215. if( !pProtocolLGS->Read( &pReadBuffer, &nReadCount, lTimeout, TRUE ) || !pReadBuffer || !nReadCount )
  216. {
  217. if( !bLastChance )
  218. return FALSE;
  219. m_nNoReplyCount++;
  220. if( m_nNoReplyCount > MAX_NO_REPLY_COUNT )
  221. {
  222. // perform goto idle state
  223. m_nMode = CMD_NONE;
  224. // have to be checked!!!!!!!!
  225. // ready to process new message
  226. OnPerformCmd();
  227. //notify
  228. OnEvtInit();
  229. }
  230. return FALSE;
  231. }
  232. DOPLER_ALARM alarm;
  233. // reset retry counter
  234. m_nNoReplyCount = 0;
  235. // switch mode
  236. switch( m_nMode )
  237. {
  238. case CMD_GET_PTZ:
  239. // store position
  240. m_Position.dPan = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[2], pReadBuffer[3] ) );
  241. m_Position.dTilt = PTZ_HEBRON::Tilt2Degree( PTZ_HEBRON::Tilt2Value( pReadBuffer[4], pReadBuffer[5] ) );
  242. m_Position.dZoom = PTZ_HEBRON::Zoom2Percent( PTZ_HEBRON::Zoom2Value( pReadBuffer[6], pReadBuffer[7] ) );
  243. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("HEBRON GET PTZ"), _T("%d(%d,%d),%d(%d,%d),%d(%d,%d)"), m_Position.dPan, (INT)pReadBuffer[2], (INT)pReadBuffer[3], m_Position.dTilt, (INT)pReadBuffer[4], (INT)pReadBuffer[5], m_Position.dZoom, (INT)pReadBuffer[6], (INT)pReadBuffer[7] );
  244. // ready to process new message
  245. OnPerformCmd();
  246. //notify
  247. OnEvtGetPTZ( m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  248. break;
  249. case CMD_INIT:
  250. // store position
  251. m_Position.dPan = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[2], pReadBuffer[3] ) );
  252. m_Position.dTilt = PTZ_HEBRON::Tilt2Degree( PTZ_HEBRON::Tilt2Value( pReadBuffer[4], pReadBuffer[5] ) );
  253. m_Position.dZoom = PTZ_HEBRON::Zoom2Percent( PTZ_HEBRON::Zoom2Value( pReadBuffer[6], pReadBuffer[7] ) );
  254. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("HEBRON INIT"), _T("%d(%d,%d),%d(%d,%d),%d(%d,%d)"),
  255. m_Position.dPan, (INT)pReadBuffer[2], (INT)pReadBuffer[3],
  256. m_Position.dTilt, (INT)pReadBuffer[4], (INT)pReadBuffer[5],
  257. m_Position.dZoom, (INT)pReadBuffer[6], (INT)pReadBuffer[7] );
  258. // ready to process new message
  259. OnPerformCmd();
  260. //notify
  261. OnEvtInit();
  262. break;
  263. case CMD_SET_PTZ:
  264. m_TempPosition.dPan = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[2], pReadBuffer[3] ) );
  265. m_TempPosition.dTilt = PTZ_HEBRON::Tilt2Degree( PTZ_HEBRON::Tilt2Value( pReadBuffer[4], pReadBuffer[5] ) );
  266. m_TempPosition.dZoom = PTZ_HEBRON::Zoom2Percent( PTZ_HEBRON::Zoom2Value( pReadBuffer[6], pReadBuffer[7] ) );
  267. // calculate difference between desired position and current position
  268. if( QualifyPosition( m_TempPosition.dPan - m_Position.dPan,
  269. m_TempPosition.dTilt - m_Position.dTilt,
  270. m_TempPosition.dZoom - m_Position.dZoom,
  271. POSITION_QUALYTY ) ||
  272. m_nNotInPositionCount >= MAX_NOT_IN_POSITION_COUNT )
  273. {
  274. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("HEBRON SET PTZ"), _T("%d(%d,%d),%d(%d,%d),%d(%d,%d)"),
  275. m_TempPosition.dPan, (INT)pReadBuffer[2], (INT)pReadBuffer[3],
  276. m_TempPosition.dTilt, (INT)pReadBuffer[4], (INT)pReadBuffer[5],
  277. m_TempPosition.dZoom, (INT)pReadBuffer[6], (INT)pReadBuffer[7] );
  278. // store position
  279. m_Position.dPan = m_TempPosition.dPan;
  280. m_Position.dTilt = m_TempPosition.dTilt;
  281. m_Position.dZoom = m_TempPosition.dZoom;
  282. // ready to process new message
  283. OnPerformCmd();
  284. //notify
  285. OnEvtSetPTZ( m_Position.dPan, m_Position.dTilt, m_Position.dZoom );
  286. }
  287. else
  288. {
  289. // does not in posiiton
  290. m_nStage = STAGE_GOTO_POSITION;
  291. // increate fault counter
  292. m_nNotInPositionCount++;
  293. return TRUE;
  294. }
  295. break;
  296. case CMD_MOVE_PAN:
  297. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON MOVE PAN"), _T("%d %d(%d)"), m_MovePan.bRight, m_MovePan.dSpeed, (INT)pReadBuffer[3] );
  298. // ready to process new message
  299. OnPerformCmd();
  300. OnEvtMovePan( m_MovePan.bRight, m_MovePan.dSpeed );
  301. break;
  302. case CMD_MOVE_TILT:
  303. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON MOVE TILT"), _T("%d %d"), m_MoveTilt.bUp, m_MoveTilt.dSpeed );
  304. // ready to process new message
  305. OnPerformCmd();
  306. OnEvtMoveTilt( m_MoveTilt.bUp, m_MoveTilt.dSpeed );
  307. break;
  308. case CMD_MOVE_ZOOM:
  309. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON MOVE ZOOM"), _T("%d %d"), m_MoveZoom.bTele, m_MoveZoom.dSpeed );
  310. // ready to process new message
  311. OnPerformCmd();
  312. OnEvtMoveZoom( m_MoveZoom.bTele, m_MoveZoom.dSpeed );
  313. break;
  314. case CMD_SET_DOPLER:
  315. m_Dopler.bEnable = pReadBuffer[2];
  316. m_Dopler.dPanStep = PTZ_HEBRON::DeltaPan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[3], pReadBuffer[4] ) );
  317. m_Dopler.dwTimeout = *(LPDWORD)(pReadBuffer + 5);
  318. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON SET DOPLER"), _T("%d,%d,%d"), m_Dopler.bEnable, m_Dopler.dPanStep, m_Dopler.dwTimeout );
  319. // ready to process new message
  320. OnPerformCmd();
  321. OnEvtSetDopler( m_Dopler.bEnable, m_Dopler.dPanStep, m_Dopler.dwTimeout );
  322. break;
  323. case CMD_GET_DOPLER:
  324. m_Dopler.bEnable = pReadBuffer[2];
  325. m_Dopler.dPanStep = PTZ_HEBRON::DeltaPan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[3], pReadBuffer[4] ) );
  326. m_Dopler.dwTimeout = *(LPDWORD)(pReadBuffer + 5);
  327. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON GET DOPLER"), _T("%d,%d,%d"), m_Dopler.bEnable, m_Dopler.dPanStep, m_Dopler.dwTimeout );
  328. // ready to process new message
  329. OnPerformCmd();
  330. OnEvtGetDopler( m_Dopler.bEnable, m_Dopler.dPanStep, m_Dopler.dwTimeout );
  331. break;
  332. case CMD_SET_IRIS:
  333. m_Iris = PTZ_HEBRON::Iris2Percent( pReadBuffer[2] );
  334. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON SET IRIS"), _T("%d"), m_Iris );
  335. // ready to process new message
  336. OnPerformCmd();
  337. OnEvtSetIris( m_Iris );
  338. break;
  339. case CMD_SET_DOPLER_MASK:
  340. if( m_nMaskIndex == -1 )
  341. {
  342. if( m_Mask.bEnable != pReadBuffer[2] || m_Mask.nCount != pReadBuffer[3] )
  343. break;
  344. }
  345. else
  346. {
  347. // if last command (store eeprom)
  348. if( m_nMaskIndex == m_Mask.nCount )
  349. ;
  350. else
  351. if( m_nMaskIndex != pReadBuffer[2] )
  352. break;
  353. else
  354. {
  355. WORD nStartAngle = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[3], pReadBuffer[4] ) );
  356. WORD nStopAngle = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[5], pReadBuffer[6] ) );
  357. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CMD_SET_DOPLER_MASK"), _T("%d %d %d %d"), m_Mask.nCount, m_nMaskIndex, nStartAngle, nStopAngle );
  358. }
  359. }
  360. m_nMaskIndex++;
  361. if( m_nMaskIndex <= m_Mask.nCount )
  362. break;
  363. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CMD_SET_DOPLER_MASK"), _T("DONE") );
  364. // ready to process new message
  365. OnPerformCmd();
  366. OnEvtSetDoplerMask( &m_Mask );
  367. break;
  368. case CMD_GET_DOPLER_MASK:
  369. if( m_nMaskIndex == -1 )
  370. {
  371. m_Mask.bEnable = pReadBuffer[2];
  372. m_Mask.nCount = pReadBuffer[3];
  373. }
  374. else
  375. {
  376. if( m_nMaskIndex != pReadBuffer[2] )
  377. break;
  378. INT nStartAngle = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[3], pReadBuffer[4] ) );
  379. INT nStopAngle = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[5], pReadBuffer[6] ) );
  380. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CMD_GET_DOPLER_MASK"), _T("%d %d %d %d"), m_Mask.nCount, m_nMaskIndex, nStartAngle, nStopAngle );
  381. m_Mask.pMask[m_nMaskIndex].nStartAngle = nStartAngle;
  382. m_Mask.pMask[m_nMaskIndex].nStopAngle = nStopAngle;
  383. }
  384. m_nMaskIndex++;
  385. if( m_nMaskIndex < m_Mask.nCount )
  386. break;
  387. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CMD_GET_DOPLER_MASK DONE"), _T("") );
  388. // ready to process new message
  389. OnPerformCmd();
  390. OnEvtGetDoplerMask( &m_Mask );
  391. break;
  392. case CMD_NONE:
  393. if( !m_bModeDopler )
  394. break;
  395. alarm.bAlarm = pReadBuffer[2];
  396. alarm.dPan = PTZ_HEBRON::Pan2Degree( PTZ_HEBRON::Pan2Value( pReadBuffer[3], pReadBuffer[4] ) );
  397. if( !alarm.bAlarm )
  398. break;
  399. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("GET HEBRON DOPLER ALARM"), _T("%d,%d"), alarm.bAlarm, alarm.dPan );
  400. // ready to process new message
  401. OnPerformCmd();
  402. OnEvtDoplerAlarm( alarm.bAlarm, alarm.dPan );
  403. break;
  404. }
  405. return TRUE;
  406. }