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.

166 lines
4.5 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 "DeviceCameraPhilipsG3AD.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. CDeviceCameraPhilipsG3AD::CDeviceCameraPhilipsG3AD()
  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("CDeviceCameraPhilipsG3AD::CDeviceCameraPhilipsG3AD") );
  31. }
  32. CDeviceCameraPhilipsG3AD::~CDeviceCameraPhilipsG3AD()
  33. {
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceCameraPhilipsG3AD::~CDeviceCameraPhilipsG3AD") );
  35. }
  36. BOOL CDeviceCameraPhilipsG3AD::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. // if demo mode to do emulation
  47. if( bDemo )
  48. {
  49. // "process" commands
  50. PTZEVENT event;
  51. while( m_Queue.Pop( event ) )
  52. {
  53. switch( event.id )
  54. {
  55. case PTZC_INIT:
  56. case PTZC_GET_PTZ:
  57. CDevicePTZ::SetPTZ( 0, 0, 0 );
  58. break;
  59. case PTZC_SET_PTZ:
  60. CDevicePTZ::SetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom );
  61. break;
  62. case PTZC_RESET:
  63. case PTZC_PAN:
  64. case PTZC_TILT:
  65. case PTZC_ZOOM:
  66. case PTZC_IRIS:
  67. break;
  68. }
  69. }
  70. // to prevent processor overheating
  71. Sleep( 10 );
  72. return TRUE;
  73. }
  74. // to do normal processing
  75. // call actual DeviceProc
  76. CLgNetDevicePTZPG3AD::DeviceProc( (CSocketCameraPhilipsG3AD*)pSocket, pProtocol );
  77. CLgNetMessagePTZ msg;
  78. msg.SetSenderID( m_MessageDispatcher.GetID() );
  79. msg.SetDistinationID( GetID() );
  80. // process commands
  81. PTZEVENT event;
  82. while( m_Queue.Pop( event ) )
  83. {
  84. switch( event.id )
  85. {
  86. /* case PTZC_INIT:
  87. msg.BuildCmdInit();
  88. m_MessageDispatcher.SendMessageToChild( msg );
  89. break;
  90. */ case PTZC_GET_PTZ:
  91. msg.BuildCmdGetPTZ();
  92. m_MessageDispatcher.SendMessageToChild( msg );
  93. break;
  94. case PTZC_RESET:
  95. // msg.BuildCmdWarmBoot();
  96. // m_MessageDispatcher.SendMessageToChild( msg );
  97. break;
  98. case PTZC_SET_PTZ:
  99. msg.BuildCmdSetPTZ( event.ptz.pan, event.ptz.tilt, event.ptz.zoom * 100.0 );
  100. m_MessageDispatcher.SendMessageToChild( msg );
  101. break;
  102. case PTZC_PAN:
  103. msg.BuildCmdMovePan( event.move.nDir == PAN_RIGHT, ( event.move.nDir == PAN_STOP ) ? 0 : event.move.speed * 100 );
  104. m_MessageDispatcher.SendMessageToChild( msg );
  105. break;
  106. case PTZC_TILT:
  107. msg.BuildCmdMoveTilt( event.move.nDir == TILT_UP, ( event.move.nDir == TILT_STOP ) ? 0 : event.move.speed * 100 );
  108. m_MessageDispatcher.SendMessageToChild( msg );
  109. break;
  110. case PTZC_ZOOM:
  111. msg.BuildCmdMoveZoom( event.move.nDir == ZOOM_TELE, ( event.move.nDir == ZOOM_STOP ) ? 0 : event.move.speed * 100 );
  112. m_MessageDispatcher.SendMessageToChild( msg );
  113. break;
  114. case PTZC_IRIS:
  115. msg.BuildCmdSetIris( event.iris.value * 100 );
  116. m_MessageDispatcher.SendMessageToChild( msg );
  117. break;
  118. default:
  119. break;
  120. }
  121. }
  122. // read messages
  123. while( m_MessageDispatcher.PopMessage( msg ) )
  124. {
  125. BYTE bCommand;
  126. if( msg.GetCommand(&bCommand) )
  127. {
  128. CLgDevicePTZ::PTZ_POSITION position;
  129. switch( bCommand )
  130. {
  131. case CLgDevicePTZ::EVT_GET_PTZ:
  132. if( msg.GetPTZ( &position ) )
  133. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  134. break;
  135. case CLgDevicePTZ::EVT_SET_PTZ:
  136. if( msg.GetPTZ( &position ) )
  137. CDevicePTZ::SetPTZ( position.dPan, position.dTilt, position.dZoom / 100.0 );
  138. break;
  139. case CLgDevicePTZ::EVT_MOVE_PAN:
  140. case CLgDevicePTZ::EVT_MOVE_TILT:
  141. case CLgDevicePTZ::EVT_MOVE_ZOOM:
  142. case CLgDevicePTZ::EVT_SET_IRIS:
  143. case CLgDevicePTZ::EVT_COMMAND_ERROR:
  144. default:
  145. CDevicePTZ::SetReady();
  146. break;
  147. }
  148. }
  149. }
  150. return TRUE;
  151. }