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.

168 lines
4.6 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: DeviceCameraPhilipsG3AD.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DeviceCameraPhilipsG3AD.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "DeviceCameraPelco.h"
  16. #include "SensorArray.h"
  17. #include "..\..\LgLib\Version.h"
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[]=__FILE__;
  21. #define new DEBUG_NEW
  22. #endif
  23. CDeviceCameraPelco::CDeviceCameraPelco()
  24. {
  25. // static DWORD nID = 0;
  26. // SetID( nID++ );
  27. // m_MessageDispatcher.SetID( nID++ );
  28. m_MessageDispatcher.CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( this );
  29. SetDeviceType( DT_CAMERA_PTZ );
  30. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraPelco::CDeviceCameraPelco") );
  31. }
  32. CDeviceCameraPelco::~CDeviceCameraPelco()
  33. {
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraPelco::~CDeviceCameraPelco") );
  35. }
  36. BOOL CDeviceCameraPelco::DeviceProc( CLgNetSocket *pSocket, CProtocol *pProtocol )
  37. {
  38. // check for demo mode
  39. BOOL bDemo = FALSE;
  40. if( CDevice::GetSocket() )
  41. {
  42. CSensorArray *pSensorArray = CDevice::GetSocket()->GetSensorArray();
  43. if( pSensorArray )
  44. bDemo = pSensorArray->IsDemo();
  45. }
  46. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDeviceCameraPelco::DeviceProc", "%d start...", 0 );
  47. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CDeviceCameraPelco::DeviceProc", "%d start...", 0 );
  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. break;
  70. }
  71. }
  72. // to prevent processor overheating
  73. Sleep( 10 );
  74. return TRUE;
  75. }
  76. // to do normal processing
  77. // call actual DeviceProc
  78. CLgNetDevicePTZPelco::DeviceProc( (CSocketCameraPelco*)pSocket, pProtocol );
  79. CLgNetMessagePTZ msg;
  80. msg.SetSenderID( m_MessageDispatcher.GetID() );
  81. msg.SetDistinationID( GetID() );
  82. // process commands
  83. PTZEVENT event;
  84. while( m_Queue.Pop( event ) )
  85. {
  86. switch( event.id )
  87. {
  88. /* case PTZC_INIT:
  89. msg.BuildCmdInit();
  90. m_MessageDispatcher.SendMessageToChild( msg );
  91. break;
  92. */ case PTZC_GET_PTZ:
  93. msg.BuildCmdGetPTZ();
  94. m_MessageDispatcher.SendMessageToChild( msg );
  95. break;
  96. case PTZC_RESET:
  97. // msg.BuildCmdWarmBoot();
  98. // m_MessageDispatcher.SendMessageToChild( msg );
  99. break;
  100. case PTZC_SET_PTZ:
  101. msg.BuildCmdSetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom * 100.0 );
  102. m_MessageDispatcher.SendMessageToChild( msg );
  103. break;
  104. case PTZC_PAN:
  105. msg.BuildCmdMovePan( event.move.nDir == PAN_RIGHT, ( event.move.nDir == PAN_STOP ) ? 0 : event.move.speed * 100 );
  106. m_MessageDispatcher.SendMessageToChild( msg );
  107. break;
  108. case PTZC_TILT:
  109. msg.BuildCmdMoveTilt( event.move.nDir == TILT_UP, ( event.move.nDir == TILT_STOP ) ? 0 : event.move.speed * 100 );
  110. m_MessageDispatcher.SendMessageToChild( msg );
  111. break;
  112. case PTZC_ZOOM:
  113. msg.BuildCmdMoveZoom( event.move.nDir == ZOOM_TELE, ( event.move.nDir == ZOOM_STOP ) ? 0 : event.move.speed * 100 );
  114. m_MessageDispatcher.SendMessageToChild( msg );
  115. break;
  116. case PTZC_IRIS:
  117. msg.BuildCmdSetIris( event.iris.value * 100 );
  118. m_MessageDispatcher.SendMessageToChild( msg );
  119. break;
  120. default:
  121. break;
  122. }
  123. }
  124. // read messages
  125. while( m_MessageDispatcher.PopMessage( msg ) )
  126. {
  127. BYTE bCommand;
  128. if( msg.GetCommand(&bCommand) )
  129. {
  130. CLgDevicePTZ::PTZ_POSITION position;
  131. switch( bCommand )
  132. {
  133. case CLgDevicePTZ::EVT_GET_PTZ:
  134. if( msg.GetPTZ( &position ) )
  135. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  136. break;
  137. case CLgDevicePTZ::EVT_SET_PTZ:
  138. if( msg.GetPTZ( &position ) )
  139. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  140. break;
  141. case CLgDevicePTZ::EVT_MOVE_PAN:
  142. case CLgDevicePTZ::EVT_MOVE_TILT:
  143. case CLgDevicePTZ::EVT_MOVE_ZOOM:
  144. case CLgDevicePTZ::EVT_SET_IRIS:
  145. case CLgDevicePTZ::EVT_COMMAND_ERROR:
  146. default:
  147. CDevicePTZ::SetReady();
  148. break;
  149. }
  150. }
  151. }
  152. return TRUE;
  153. }