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.

193 lines
5.3 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: DeviceCameraHebron.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DeviceCameraHebron.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "DeviceCameraHebron.h"
  16. #include "SocketMD.h"
  17. #include "SensorArray.h"
  18. #include "..\..\LgLib\Version.h"
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[]=__FILE__;
  22. #define new DEBUG_NEW
  23. #endif
  24. CDeviceCameraHebron::CDeviceCameraHebron()
  25. {
  26. // static DWORD nID = 0;
  27. // SetID( nID++ );
  28. // m_MessageDispatcher.SetID( nID++ );
  29. m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( this );
  30. SetDeviceType( DT_CAMERA_PTZ );
  31. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraHebron::CDeviceCameraHebron") );
  32. }
  33. CDeviceCameraHebron::~CDeviceCameraHebron()
  34. {
  35. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraHebron::~CDeviceCameraHebron") );
  36. }
  37. BOOL CDeviceCameraHebron::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
  38. {
  39. // check for demo mode
  40. BOOL bDemo = FALSE;
  41. if( CDevice::GetSocket() )
  42. {
  43. CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
  44. if( pSensorArray )
  45. bDemo = pSensorArray->IsDemo();
  46. }
  47. // if demo mode to do emulation
  48. if( bDemo )
  49. {
  50. // "process" commands
  51. PTZEVENT event;
  52. while( m_Queue.Pop( event ) )
  53. {
  54. switch( event.id )
  55. {
  56. case PTZC_INIT:
  57. case PTZC_GET_PTZ:
  58. CDevicePTZ::SetPTZ( 0, 0, 0 );
  59. break;
  60. case PTZC_SET_PTZ:
  61. CDevicePTZ::SetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom );
  62. break;
  63. case PTZC_RESET:
  64. case PTZC_PAN:
  65. case PTZC_TILT:
  66. case PTZC_ZOOM:
  67. case PTZC_IRIS:
  68. break;
  69. }
  70. }
  71. // to prevent processor overheating
  72. Sleep( 10 );
  73. return TRUE;
  74. }
  75. // to do normal processing
  76. // call actual DeviceProc
  77. CLgNetDevicePTZHebron::DeviceProc( (CSocketMD*)pSocket, pProtocol );
  78. CLgNetMessageDopler msg;
  79. msg.SetSenderID( m_MessageDispatcher.GetID() );
  80. msg.SetDistinationID( GetID() );
  81. // process commands
  82. PTZEVENT event;
  83. while( m_Queue.Pop( event ) )
  84. {
  85. switch( event.id )
  86. {
  87. /* case PTZC_INIT:
  88. msg.BuildCmdInit();
  89. m_MessageDispatcher.SendMessageToChild( msg );
  90. break;
  91. */ case PTZC_GET_PTZ:
  92. msg.BuildCmdGetPTZ();
  93. m_MessageDispatcher.SendMessageToChild( msg );
  94. break;
  95. case PTZC_RESET:
  96. // msg.BuildCmdWarmBoot();
  97. // m_MessageDispatcher.SendMessageToChild( msg );
  98. break;
  99. case PTZC_SET_PTZ:
  100. msg.BuildCmdSetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom * 100.0 );
  101. m_MessageDispatcher.SendMessageToChild( msg );
  102. break;
  103. case PTZC_PAN:
  104. msg.BuildCmdMovePan( event.move.nDir == PAN_RIGHT, ( event.move.nDir == PAN_STOP ) ? 0 : event.move.speed * 100 );
  105. m_MessageDispatcher.SendMessageToChild( msg );
  106. break;
  107. case PTZC_TILT:
  108. msg.BuildCmdMoveTilt( event.move.nDir == TILT_UP, ( event.move.nDir == TILT_STOP ) ? 0 : event.move.speed * 100 );
  109. m_MessageDispatcher.SendMessageToChild( msg );
  110. break;
  111. case PTZC_ZOOM:
  112. msg.BuildCmdMoveZoom( event.move.nDir == ZOOM_TELE, ( event.move.nDir == ZOOM_STOP ) ? 0 : event.move.speed * 100 );
  113. m_MessageDispatcher.SendMessageToChild( msg );
  114. break;
  115. case PTZC_IRIS:
  116. msg.BuildCmdSetIris( event.iris.value * 100 );
  117. m_MessageDispatcher.SendMessageToChild( msg );
  118. break;
  119. case PTZC_GET_DOPLER_MASK:
  120. msg.BuildCmdGetDoplerMask();
  121. m_MessageDispatcher.SendMessageToChild( msg );
  122. break;
  123. case PTZC_SET_DOPLER:
  124. msg.BuildCmdSetDopler( event.dopler.bOn, event.dopler.angle, event.dopler.dwTimeout );
  125. m_MessageDispatcher.SendMessageToChild( msg );
  126. break;
  127. default:
  128. break;
  129. }
  130. }
  131. // read messages
  132. while( m_MessageDispatcher.PopMessage( msg ) )
  133. {
  134. BYTE bCommand;
  135. if( msg.GetCommand(&bCommand) )
  136. {
  137. CLgDevicePTZ::PTZ_POSITION position;
  138. CLgDeviceDopler::DOPLER_MASK_ARRAY mask;
  139. CLgDeviceDopler::DOPLER_ALARM alarm;
  140. CLgDeviceDopler::DOPLER dopler;
  141. switch( bCommand )
  142. {
  143. case CLgDevicePTZ::EVT_GET_PTZ:
  144. if( msg.GetPTZ( &position ) )
  145. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  146. break;
  147. case CLgDevicePTZ::EVT_SET_PTZ:
  148. if( msg.GetPTZ( &position ) )
  149. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  150. break;
  151. case CLgDeviceDopler::EVT_GET_DOPLER_MASK:
  152. if( msg.GetDoplerMask( &mask ) )
  153. CDevicePTZ::SetDoplerMask( &mask );
  154. break;
  155. case CLgDeviceDopler::EVT_DOPLER_ALARM:
  156. if( msg.GetDoplerAlarm( &alarm ) )
  157. CDevicePTZ::SetDoplerAlarm( &alarm );
  158. break;
  159. case CLgDeviceDopler::EVT_GET_DOPLER:
  160. case CLgDeviceDopler::EVT_SET_DOPLER:
  161. if( msg.GetDopler( &dopler ) )
  162. CDevicePTZ::SetDopler( &dopler );
  163. break;
  164. case CLgDevicePTZ::EVT_MOVE_PAN:
  165. case CLgDevicePTZ::EVT_MOVE_TILT:
  166. case CLgDevicePTZ::EVT_MOVE_ZOOM:
  167. case CLgDevicePTZ::EVT_SET_IRIS:
  168. case CLgDevicePTZ::EVT_COMMAND_ERROR:
  169. default:
  170. CDevicePTZ::SetReady();
  171. break;
  172. }
  173. }
  174. }
  175. return TRUE;
  176. }