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.

651 lines
18 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
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: DeviceLGSm.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DeviceLGSm.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "SocketMD.h"
  16. #include "SensorLGS.h"
  17. #include "DeviceLGSm.h"
  18. #include "..\..\LgLib\Version.h"
  19. #include "SensorArray.h"
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char THIS_FILE[]=__FILE__;
  23. #define new DEBUG_NEW
  24. #endif
  25. CDeviceLGSm::CDeviceLGSm()
  26. {
  27. m_pThisValid = this;
  28. m_bEnable = FALSE;
  29. m_bDemoOperationMode = TRUE;
  30. m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( static_cast<CLgNetDeviceLGS*>(this) );
  31. SetDeviceType( DT_LGS );
  32. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceLGSm::CDeviceLGSm") );
  33. }
  34. CDeviceLGSm::~CDeviceLGSm()
  35. {
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceLGSm::~CDeviceLGSm") );
  37. }
  38. BOOL CDeviceLGSm::LGS_PostReset()
  39. {
  40. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  41. BOOL bResult = CDeviceLGS::LGS_PostReset();
  42. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  43. return bResult;
  44. }
  45. BOOL CDeviceLGSm::LGS_PostRestart()
  46. {
  47. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  48. BOOL bResult = CDeviceLGS::LGS_PostRestart();
  49. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  50. return bResult;
  51. }
  52. BOOL CDeviceLGSm::LGS_PostEnable( BOOL bEnable )
  53. {
  54. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  55. BOOL bResult = CDeviceLGS::LGS_PostEnable( bEnable );
  56. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  57. return bResult;
  58. }
  59. void CDeviceLGSm::PTZ_PostSetPTZ( double pan, double tilt, double zoom )
  60. {
  61. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  62. CDevicePTZ::PTZ_PostSetPTZ( pan, tilt, zoom );
  63. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  64. }
  65. void CDeviceLGSm::PTZ_PostGetPTZ()
  66. {
  67. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  68. CDevicePTZ::PTZ_PostGetPTZ();
  69. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  70. }
  71. void CDeviceLGSm::PTZ_PostPan( double speed, int nDir )
  72. {
  73. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  74. CDevicePTZ::PTZ_PostPan( speed, nDir );
  75. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  76. }
  77. void CDeviceLGSm::PTZ_PostTilt( double speed, int nDir )
  78. {
  79. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  80. CDevicePTZ::PTZ_PostTilt( speed, nDir );
  81. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  82. }
  83. void CDeviceLGSm::PTZ_PostZoom( double speed, int nDir )
  84. {
  85. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  86. CDevicePTZ::PTZ_PostZoom( speed, nDir );
  87. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  88. }
  89. void CDeviceLGSm::PTZ_PostIris( double value )
  90. {
  91. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  92. CDevicePTZ::PTZ_PostIris( value );
  93. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  94. }
  95. void CDeviceLGSm::PTZ_PostWiper( BOOL bOn )
  96. {
  97. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  98. CDevicePTZ::PTZ_PostWiper( bOn );
  99. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  100. }
  101. BOOL CDeviceLGSm::LGS_PostGetHiddenZones()
  102. {
  103. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  104. BOOL bResult = CDeviceLGS::LGS_PostGetHiddenZones();
  105. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  106. return bResult;
  107. }
  108. BOOL CDeviceLGSm::LGS_PostSetHiddenZones( CLgDeviceLGS::LGS_HZ_ARRAY& HzArray )
  109. {
  110. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  111. BOOL bResult = CDeviceLGS::LGS_PostSetHiddenZones( HzArray );
  112. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  113. return bResult;
  114. }
  115. BOOL CDeviceLGSm::LGS_PostGetCalibrationTable( INT nDevice )
  116. {
  117. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  118. BOOL bResult = CDeviceLGS::LGS_PostGetCalibrationTable( nDevice );
  119. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  120. return bResult;
  121. }
  122. BOOL CDeviceLGSm::LGS_PostSetCalibrationTable( CLgDeviceLGS::LGS_CALIBRATION_TABLE& cTable )
  123. {
  124. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  125. BOOL bResult = CDeviceLGS::LGS_PostSetCalibrationTable( cTable );
  126. if( m_pSocket ) static_cast<CSocketMD*>(m_pSocket)->Resume();
  127. return bResult;
  128. }
  129. BOOL CDeviceLGSm::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
  130. {
  131. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  132. BOOL bResult = TRUE;
  133. __try
  134. {
  135. bResult = DeviceProc_( pSocket, pProtocol );
  136. }
  137. __except( EXCEPTION_EXECUTE_HANDLER )
  138. {
  139. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("Exception 0x%08X"), _exception_code() );
  140. }
  141. return bResult;
  142. }
  143. BOOL CDeviceLGSm::DeviceProc_( CLgNetSocket *pSocket, CProtocol *pProtocol )
  144. {
  145. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  146. if( DeviceProcDemo_() )
  147. return TRUE;
  148. ////////////////////////////////// to do normal work ///////////////////////////////////////////////////
  149. // call actual DeviceProc
  150. BOOL bTransaction = CLgNetDeviceLGS::DeviceProc( static_cast<CLgNetSocketMD*>(static_cast<CSocketMD*>(GetSocket())), pProtocol );
  151. __try
  152. {
  153. DeviceProcLGS_();
  154. }
  155. __except( EXCEPTION_EXECUTE_HANDLER )
  156. {
  157. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcLGS_ rises exception 0x%08X"), _exception_code() );
  158. }
  159. __try
  160. {
  161. DeviceProcPTZ_();
  162. }
  163. __except( EXCEPTION_EXECUTE_HANDLER )
  164. {
  165. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcPTZ_ rises exception 0x%08X"), _exception_code() );
  166. }
  167. __try
  168. {
  169. DeviceProcDispatcher_();
  170. }
  171. __except( EXCEPTION_EXECUTE_HANDLER )
  172. {
  173. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProc"), _T("DeviceProcDispatcher_ rises exception 0x%08X"), _exception_code() );
  174. }
  175. // test
  176. // GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, 0, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), "test" );
  177. // m_pSensor->PostTarget( TT_MASTER, rand()%360, rand() % 100 );
  178. return bTransaction;
  179. }
  180. BOOL CDeviceLGSm::DeviceProcDemo_()
  181. {
  182. // check for demo mode
  183. BOOL bDemo = FALSE;
  184. if( CDevice::GetSocket() )
  185. {
  186. CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
  187. if( pSensorArray )
  188. bDemo = pSensorArray->IsDemo();
  189. }
  190. // if demo mode to do emulation
  191. if( !bDemo )
  192. return FALSE;
  193. // "process" camera commands
  194. PTZEVENT event_ptz;
  195. while( CDevicePTZ::m_Queue.Pop( event_ptz ) )
  196. {
  197. switch( event_ptz.id )
  198. {
  199. case PTZC_INIT:
  200. case PTZC_GET_PTZ:
  201. CDevicePTZ::SetPTZ( 0, 0, 0 );
  202. break;
  203. case PTZC_SET_PTZ:
  204. CDevicePTZ::SetPTZ( event_ptz.ptz.pan, event_ptz.ptz.tilt, event_ptz.ptz.zoom );
  205. break;
  206. case PTZC_RESET:
  207. case PTZC_PAN:
  208. case PTZC_TILT:
  209. case PTZC_ZOOM:
  210. case PTZC_IRIS:
  211. case PTZC_WIPER:
  212. break;
  213. }
  214. }
  215. // process LGS commands
  216. LGSEVENT event;
  217. while( CDeviceLGS::m_Queue.Pop( event ) )
  218. {
  219. CLgDeviceLGS::LGS_CALIBRATION_TABLE table;
  220. switch( event.id )
  221. {
  222. case LGSC_RESET:
  223. case LGSC_RESTART:
  224. case LGSC_ENABLE:
  225. break;
  226. case LGSC_GET_HZ:
  227. m_pSensor->PostGetCalibrationTable( table );
  228. break;
  229. case LGSC_SET_HZ:
  230. m_pSensor->PostSetCalibrationTable( table );
  231. break;
  232. }
  233. }
  234. // process socket events
  235. EVENT se;
  236. if( GetSocket()->GetEventQueue()->GetEvent( se ) )
  237. {
  238. if( se.pDemoDevice == this )
  239. m_pSensor->PostTarget( 0, LGS::TT_NORMAL, se.dDemoAngle, se.dDemoRange );
  240. }
  241. // emulate oprational mode
  242. if( m_bDemoOperationMode )
  243. {
  244. m_bDemoOperationMode = FALSE;
  245. m_pSensor->PostOperationMode( LGS_OM_DETECTION );
  246. }
  247. // to prevent processor overheating :-)
  248. Sleep(10);
  249. return TRUE;
  250. }
  251. BOOL CDeviceLGSm::DeviceProcLGS_()
  252. {
  253. CLgNetMessageLGS msg;
  254. msg.SetSenderID( m_MessageDispatcher.GetID() );
  255. msg.SetDistinationID( CLgNetDeviceLGS::GetID() );
  256. // process LGS commands
  257. LGSEVENT event_lgs;
  258. while( CDeviceLGS::m_Queue.Pop( event_lgs ) )
  259. {
  260. switch( event_lgs.id )
  261. {
  262. case LGSC_RESET:
  263. msg.BuildCmdReset();
  264. m_MessageDispatcher.SendMessageToChild( msg );
  265. // log info
  266. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received LGSC_RESET" );
  267. break;
  268. case LGSC_RESTART:
  269. msg.BuildCmdRestart();
  270. m_MessageDispatcher.SendMessageToChild( msg );
  271. // log info
  272. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received LGSC_RESTART" );
  273. break;
  274. case LGSC_GET_HZ:
  275. msg.BuildCmdGetHzData( FALSE );
  276. m_MessageDispatcher.SendMessageToChild( msg );
  277. break;
  278. case LGSC_SET_HZ:
  279. msg.BuildCmdSetHzData( event_lgs.HzArray );
  280. m_MessageDispatcher.SendMessageToChild( msg );
  281. break;
  282. case LGSC_GET_CT:
  283. msg.BuildCmdGetCalibrationTable( event_lgs.CtTable.nDevice );
  284. m_MessageDispatcher.SendMessageToChild( msg );
  285. break;
  286. case LGSC_SET_CT:
  287. msg.BuildCmdSetCalibrationTable( event_lgs.CtTable );
  288. m_MessageDispatcher.SendMessageToChild( msg );
  289. break;
  290. case LGSC_ENABLE:
  291. // m_bEnable = event_lgs.bEnable;
  292. break;
  293. }
  294. }
  295. return TRUE;
  296. }
  297. BOOL CDeviceLGSm::DeviceProcPTZ_()
  298. {
  299. CLgNetMessageLGS msg;
  300. msg.SetSenderID( m_MessageDispatcher.GetID() );
  301. msg.SetDistinationID( CLgNetDeviceLGS::GetID() );
  302. // process PTZ commands
  303. PTZEVENT event_ptz;
  304. while( CDevicePTZ::m_Queue.Pop( event_ptz ) )
  305. {
  306. switch( event_ptz.id )
  307. {
  308. case PTZC_GET_PTZ:
  309. msg.BuildCmdGetPTZ();
  310. m_MessageDispatcher.SendMessageToChild( msg );
  311. break;
  312. case PTZC_SET_PTZ:
  313. msg.BuildCmdSetPTZ( event_ptz.ptz.pan, event_ptz.ptz.tilt, event_ptz.ptz.zoom * 100.0 );
  314. m_MessageDispatcher.SendMessageToChild( msg );
  315. break;
  316. case PTZC_PAN:
  317. msg.BuildCmdMovePan( event_ptz.move.nDir == PAN_RIGHT, ( event_ptz.move.nDir == PAN_STOP ) ? 0 : event_ptz.move.speed * 100 );
  318. m_MessageDispatcher.SendMessageToChild( msg );
  319. break;
  320. case PTZC_TILT:
  321. msg.BuildCmdMoveTilt( event_ptz.move.nDir == TILT_UP, ( event_ptz.move.nDir == TILT_STOP ) ? 0 : event_ptz.move.speed * 100 );
  322. m_MessageDispatcher.SendMessageToChild( msg );
  323. break;
  324. case PTZC_ZOOM:
  325. msg.BuildCmdMoveZoom( event_ptz.move.nDir == ZOOM_TELE, ( event_ptz.move.nDir == ZOOM_STOP ) ? 0 : event_ptz.move.speed * 100 );
  326. m_MessageDispatcher.SendMessageToChild( msg );
  327. break;
  328. case PTZC_IRIS:
  329. msg.BuildCmdSetIris( event_ptz.iris.value * 100 );
  330. m_MessageDispatcher.SendMessageToChild( msg );
  331. break;
  332. case PTZC_WIPER:
  333. msg.BuildCmdWiper( event_ptz.wiper.on );
  334. m_MessageDispatcher.SendMessageToChild( msg );
  335. break;
  336. default:
  337. CDevicePTZ::SetReady();
  338. break;
  339. case PTZC_INIT:
  340. CDevicePTZ::SetReady();
  341. // log info
  342. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received PTZC_INIT" );
  343. break;
  344. case PTZC_RESET:
  345. CDevicePTZ::SetReady();
  346. // log info
  347. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received PTZC_RESET" );
  348. break;
  349. }
  350. }
  351. return TRUE;
  352. }
  353. BOOL CDeviceLGSm::DeviceProcDispatcher_()
  354. {
  355. try
  356. {
  357. CLgNetDeviceLGS::LGS_TARGET target;
  358. CLgDevicePTZ::PTZ_POSITION position;
  359. CLgDeviceLGS::LGS_ERROR error;
  360. CLgDeviceLGS::LGS_HZ_ARRAY HzArray;
  361. CLgDeviceLGS::LGS_CALIBRATION_TABLE cTable;
  362. CLgDeviceLGS::LGS_OPERATION_MODE eMode;
  363. BOOL bPowered;
  364. BOOL dConnected;
  365. INT nProgress;
  366. CLgNetMessageLGS msg;
  367. // read messages
  368. while( m_MessageDispatcher.PopMessage( msg ) )
  369. {
  370. BYTE bCommand;
  371. try
  372. {
  373. if( !msg.GetCommand(&bCommand) )
  374. continue;
  375. }
  376. catch(...)
  377. {
  378. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during GetCommand") );
  379. }
  380. switch( bCommand )
  381. {
  382. case CLgDeviceLGS::EVT_ERROR:
  383. try
  384. {
  385. if( msg.GetEvtError( &error ) )
  386. {
  387. if( error.eErrorLevel == LGS_ERROR_LEVEL_CRITICAL )
  388. {
  389. TCHAR pErrorText[MAX_PATH];
  390. _sntprintf( pErrorText, MAX_PATH, _T("%s technical event type <%d>"), (LPCTSTR)m_pSensor->GetName(), error.eErrorID );
  391. pErrorText[MAX_PATH-1] = 0;
  392. GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, LGS_EVENT_ERROR_CRITICAL, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), (LPSTR)(LPCTSTR)pErrorText );
  393. }
  394. else
  395. GetSocket()->GetSensorArray()->GetEventQueue()->PostEvent( LGS_EVENT_ERROR, LGS_EVENT_ERROR_NORMAL, 0, (DWORD)m_pSensor, RGB( 0xFF, 0, 0 ), (LPSTR)(LPCTSTR)error.pErrorText );
  396. }
  397. }
  398. catch(...)
  399. {
  400. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_ERROR") );
  401. }
  402. break;
  403. case CLgDeviceLGS::EVT_TARGET:
  404. try
  405. {
  406. if( msg.GetTarget( &target ) )
  407. {
  408. switch( target.bType )
  409. {
  410. case LGS::TT_FLIP:
  411. case LGS::TT_CAMERA:
  412. break;
  413. case LGS::TT_BLIND:
  414. m_pSensor->PostTarget( target.bDevice, LGS::TT_BLIND, target.dAngle, 0 );
  415. break;
  416. default:
  417. LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "%d %d", target.bDevice, target.bType );
  418. switch( target.bDevice )
  419. {
  420. case 0: m_pSensor->PostTarget( 0, target.bType, target.dAngle, target.dRange ); break;
  421. case 1: m_pSensor->PostTarget( 1, target.bType, target.dAngle, target.dRange ); break;
  422. default:
  423. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_TARGET with unknown type %d", target.bType );
  424. break;
  425. }
  426. break;
  427. }
  428. }
  429. }
  430. catch(...)
  431. {
  432. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_TARGET") );
  433. }
  434. break;
  435. case CLgDeviceLGS::EVT_RESET:
  436. m_pSensor->PostReset();
  437. // log info
  438. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_RESET" );
  439. break;
  440. case CLgDeviceLGS::EVT_RESTART:
  441. m_pSensor->PostReset();
  442. // log info
  443. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_RESTART" );
  444. break;
  445. case CLgDeviceLGS::EVT_FULL_RESET:
  446. m_pSensor->PostReset();
  447. // log info
  448. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received CLgNetMessageLGS::EVT_FULL_RESET" );
  449. break;
  450. case CLgDeviceLGS::EVT_QUIT:
  451. m_pSensor->PostReset();
  452. break;
  453. case CLgDeviceLGS::EVT_VOLTAGE:
  454. if( msg.GetEvtVoltage( &bPowered ) )
  455. m_pSensor->PostPower( bPowered );
  456. break;
  457. case CLgDeviceLGS::EVT_CONNECTION:
  458. try
  459. {
  460. if( msg.GetEvtConnection( &dConnected ) )
  461. m_pSensor->PostConnection( dConnected );
  462. }
  463. catch(...)
  464. {
  465. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_CONNECTION") );
  466. }
  467. break;
  468. case CLgDeviceLGS::EVT_OPERATION_MODE:
  469. LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("CLgDeviceLGS::EVT_OPERATION_MODE") );
  470. try
  471. {
  472. if( msg.GetEvtOperationMode( &eMode ) )
  473. m_pSensor->PostOperationMode( eMode );
  474. }
  475. catch(...)
  476. {
  477. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_OPERATION_MODE") );
  478. }
  479. break;
  480. case CLgDeviceLGS::EVT_GET_HZ_DATA:
  481. if( msg.GetEvtGetHzData( HzArray ) )
  482. m_pSensor->PostGetHiddenZones( HzArray );
  483. break;
  484. case CLgDeviceLGS::EVT_GET_HZ_DATA_PROGRESS:
  485. if( msg.GetEvtGetHzDataProgress( &nProgress ) )
  486. m_pSensor->PostGetHiddenZonesProgress( nProgress );
  487. break;
  488. case CLgDeviceLGS::EVT_SET_HZ_DATA:
  489. if( msg.GetEvtSetHzData( HzArray ) )
  490. m_pSensor->PostSetHiddenZones( HzArray );
  491. break;
  492. case CLgDeviceLGS::EVT_SET_HZ_DATA_PROGRESS:
  493. if( msg.GetEvtSetHzDataProgress( &nProgress ) )
  494. m_pSensor->PostSetHiddenZonesProgress( nProgress );
  495. break;
  496. case CLgDeviceLGS::EVT_GET_CALIBRATION_TABLE:
  497. if( msg.GetEvtGetCalibrationTable( cTable ) )
  498. m_pSensor->PostGetCalibrationTable( cTable );
  499. break;
  500. case CLgDeviceLGS::EVT_GET_CALIBRATION_TABLE_PROGRESS:
  501. if( msg.GetEvtGetCalibrationTableProgress( &nProgress ) )
  502. m_pSensor->PostGetCalibrationTableProgress( nProgress );
  503. break;
  504. case CLgDeviceLGS::EVT_SET_CALIBRATION_TABLE:
  505. try
  506. {
  507. if( msg.GetEvtSetCalibrationTable( cTable ) )
  508. m_pSensor->PostSetCalibrationTable( cTable );
  509. }
  510. catch(...)
  511. {
  512. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception during EVT_SET_CALIBRATION_TABLE") );
  513. }
  514. break;
  515. case CLgDeviceLGS::EVT_SET_CALIBRATION_TABLE_PROGRESS:
  516. if( msg.GetEvtSetCalibrationTableProgress( &nProgress ) )
  517. m_pSensor->PostSetCalibrationTableProgress( nProgress );
  518. break;
  519. //////////////////////////////////////////////////////////////////////////////////////////
  520. case CLgDeviceLGS::EVT_GET_PTZ:
  521. if( msg.GetPTZ( &position ) )
  522. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  523. break;
  524. case CLgDeviceLGS::EVT_SET_PTZ:
  525. if( msg.GetPTZ( &position ) )
  526. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  527. break;
  528. case CLgDeviceLGS::EVT_MOVE_PAN:
  529. case CLgDeviceLGS::EVT_MOVE_TILT:
  530. case CLgDeviceLGS::EVT_MOVE_ZOOM:
  531. case CLgDeviceLGS::EVT_SET_IRIS:
  532. case CLgDeviceLGS::EVT_WIPER:
  533. case CLgDeviceLGS::EVT_COMMAND_ERROR:
  534. CDevicePTZ::SetReady();
  535. break;
  536. default:
  537. // log info
  538. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceLGSm::DeviceProc", "received unknown message %d", bCommand );
  539. break;
  540. }
  541. }
  542. }
  543. catch(...)
  544. {
  545. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CDeviceLGSm::DeviceProcDispatcher_"), _T("Exception") );
  546. }
  547. return TRUE;
  548. }
  549. void CDeviceLGSm::SetSpyMode( BOOL bSpyMode )
  550. {
  551. ASSERT( m_pThisValid == static_cast<CDeviceLGSm*>(this) );
  552. // call base class
  553. CLgNetDeviceLGS::SetSpyMode( bSpyMode );
  554. if( m_pSensor )
  555. m_pSensor->SetSpyMode( bSpyMode );
  556. }