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.

175 lines
4.8 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: DeviceCameraMic1300.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DeviceCameraMic1300.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "DeviceCameraMic1300.h"
  16. #include "..\..\LgLib\Net\LgNetDeviceMic1300PTZ.h"
  17. #include "..\..\LgLib\Net\LgNetSocketMic1300PTZ.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. CDeviceCameraMic1300::CDeviceCameraMic1300()
  25. {
  26. // m_bEnable = FALSE;
  27. // static DWORD nID = 0;
  28. // SetID( nID++ );
  29. // m_MessageDispatcher.SetID( nID++ );
  30. m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( this );
  31. SetDeviceType( DT_CAMERA_PTZ );
  32. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraMic1300::CDeviceCameraMic1300") );
  33. }
  34. CDeviceCameraMic1300::~CDeviceCameraMic1300()
  35. {
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraMic1300::~CDeviceCameraMic1300") );
  37. }
  38. BOOL CDeviceCameraMic1300::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
  39. {
  40. // check for demo mode
  41. BOOL bDemo = FALSE;
  42. if( CDevice::GetSocket() )
  43. {
  44. CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
  45. if( pSensorArray )
  46. bDemo = pSensorArray->IsDemo();
  47. }
  48. // if demo mode to do emulation
  49. if( bDemo )
  50. {
  51. // "process" commands
  52. PTZEVENT event;
  53. while( m_Queue.Pop( event ) )
  54. {
  55. switch( event.id )
  56. {
  57. case PTZC_INIT:
  58. case PTZC_GET_PTZ:
  59. CDevicePTZ::SetPTZ( 0, 0, 0 );
  60. break;
  61. case PTZC_SET_PTZ:
  62. CDevicePTZ::SetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom );
  63. break;
  64. case PTZC_RESET:
  65. case PTZC_PAN:
  66. case PTZC_TILT:
  67. case PTZC_ZOOM:
  68. case PTZC_IRIS:
  69. case PTZC_WIPER:
  70. break;
  71. }
  72. }
  73. // to prevent processor overheating
  74. Sleep( 10 );
  75. return TRUE;
  76. }
  77. // to do normal processing
  78. // call actual DeviceProc
  79. CLgNetDeviceMic1300PTZ::DeviceProc( (CSocketCameraMic1300*)pSocket, pProtocol );
  80. CLgNetMessageMic1300PTZ msg;
  81. msg.SetSenderID( m_MessageDispatcher.GetID() );
  82. msg.SetDistinationID( GetID() );
  83. // process commands
  84. PTZEVENT event;
  85. while( m_Queue.Pop( event ) )
  86. {
  87. switch( event.id )
  88. {
  89. case PTZC_INIT:
  90. msg.BuildCmdInit();
  91. m_MessageDispatcher.SendMessageToChild( msg );
  92. break;
  93. case PTZC_GET_PTZ:
  94. msg.BuildCmdGetPTZ();
  95. m_MessageDispatcher.SendMessageToChild( msg );
  96. break;
  97. case PTZC_RESET:
  98. // msg.BuildCmdWarmBoot();
  99. // m_MessageDispatcher.SendMessageToChild( msg );
  100. break;
  101. case PTZC_SET_PTZ:
  102. msg.BuildCmdSetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom * 100.0 );
  103. m_MessageDispatcher.SendMessageToChild( msg );
  104. break;
  105. case PTZC_PAN:
  106. msg.BuildCmdMovePan( event.move.nDir == PAN_RIGHT, ( event.move.nDir == PAN_STOP ) ? 0 : event.move.speed * 100 );
  107. m_MessageDispatcher.SendMessageToChild( msg );
  108. break;
  109. case PTZC_TILT:
  110. msg.BuildCmdMoveTilt( event.move.nDir == TILT_UP, ( event.move.nDir == TILT_STOP ) ? 0 : event.move.speed * 100 );
  111. m_MessageDispatcher.SendMessageToChild( msg );
  112. break;
  113. case PTZC_ZOOM:
  114. msg.BuildCmdMoveZoom( event.move.nDir == ZOOM_TELE, ( event.move.nDir == ZOOM_STOP ) ? 0 : event.move.speed * 100 );
  115. m_MessageDispatcher.SendMessageToChild( msg );
  116. break;
  117. case PTZC_IRIS:
  118. msg.BuildCmdSetIris( event.iris.value * 100 );
  119. m_MessageDispatcher.SendMessageToChild( msg );
  120. break;
  121. case PTZC_WIPER:
  122. msg.BuildCmdWiper( event.wiper.on );
  123. m_MessageDispatcher.SendMessageToChild( msg );
  124. break;
  125. default:
  126. break;
  127. }
  128. }
  129. // read messages
  130. while( m_MessageDispatcher.PopMessage( msg ) )
  131. {
  132. BYTE bCommand;
  133. if( msg.GetCommand(&bCommand) )
  134. {
  135. CLgDevicePTZ::PTZ_POSITION position;
  136. switch( bCommand )
  137. {
  138. case CLgDevicePTZMic1300::EVT_GET_PTZ:
  139. if( msg.GetPTZ( &position ) )
  140. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  141. break;
  142. case CLgDevicePTZMic1300::EVT_SET_PTZ:
  143. if( msg.GetPTZ( &position ) )
  144. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  145. break;
  146. case CLgDevicePTZMic1300::EVT_MOVE_PAN:
  147. case CLgDevicePTZMic1300::EVT_MOVE_TILT:
  148. case CLgDevicePTZMic1300::EVT_MOVE_ZOOM:
  149. case CLgDevicePTZMic1300::EVT_SET_IRIS:
  150. case CLgDevicePTZMic1300::EVT_WIPER:
  151. case CLgDevicePTZMic1300::EVT_COMMAND_ERROR:
  152. default:
  153. CDevicePTZ::SetReady();
  154. break;
  155. }
  156. }
  157. }
  158. return TRUE;
  159. }