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.

135 lines
2.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: cpelco.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ctks576.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "cpelco.h"
  16. #ifdef EMBEDDED_CAMERA_PELCO
  17. #include "..\lglib\comm\ptzpelco.cpp"
  18. #include "..\lglib\device\dpelco.cpp"
  19. CCameraPelcoPTZ::CCameraPelcoPTZ()
  20. {
  21. m_pComm = NULL;
  22. m_pCamera = NULL;
  23. }
  24. CCameraPelcoPTZ::~CCameraPelcoPTZ()
  25. {
  26. Destroy();
  27. }
  28. BOOL CCameraPelcoPTZ::Create( CCamera *pCamera, CComm485* pComm, CComm485::PORTS nPort, LGS::PCAMERA_PARAMETERS pParameters )
  29. {
  30. // destroy old incarnation :)
  31. Destroy();
  32. m_pComm = pComm;
  33. m_pCamera = pCamera;
  34. if( !m_pComm->Create( nPort, 2400L, 8, CComm485::_NOPARITY ) )
  35. return FALSE;
  36. if( !m_Protocol.Create( m_pComm ) )
  37. return FALSE;
  38. SetProtocol( &m_Protocol );
  39. SetAddress( 2 );
  40. return CmdInit();
  41. }
  42. void CCameraPelcoPTZ::Destroy()
  43. {
  44. m_Protocol.Destroy();
  45. if( m_pComm )
  46. {
  47. m_pComm->Destroy();
  48. m_pComm = NULL;
  49. }
  50. }
  51. /*
  52. void CCameraPelcoPTZ::Invalidate( DWORD nSlowTimer, WORD nFastTimer, BOOL bFastTimeValid )
  53. {
  54. if( bFastTimeValid )
  55. {
  56. // update timeout
  57. if( m_lTimeout > 0 && m_dwLastTime != nFastTimer )
  58. {
  59. m_lTimeout--;
  60. m_dwLastTime = nFastTimer;
  61. }
  62. // write command
  63. if( m_lTimeout <= 0 )
  64. {
  65. if( m_bRead )
  66. ReadProc( &m_Protocol, 0, TRUE );
  67. m_bRead = WriteProc( &m_Protocol, &m_lTimeout );
  68. m_lTimeout <<= 3;
  69. }
  70. // read reply
  71. if( m_bRead )
  72. {
  73. BOOL bSuccess = ReadProc( &m_Protocol, 0, FALSE );
  74. // if read successeful
  75. if( bSuccess )
  76. m_lTimeout = 0;
  77. m_bRead = !bSuccess;
  78. }
  79. }
  80. else
  81. {
  82. // update timeout
  83. if( m_lTimeout > 0 && m_dwLastTime != nSlowTimer )
  84. {
  85. m_lTimeout --;
  86. m_dwLastTime = nSlowTimer;
  87. }
  88. // write command
  89. if( m_lTimeout <= 0 )
  90. {
  91. if( m_bRead )
  92. ReadProc( &m_Protocol, 0, TRUE );
  93. m_bRead = WriteProc( &m_Protocol, &m_lTimeout );
  94. // at least one timeout should exist
  95. m_lTimeout = ( m_lTimeout + 18 ) / 18;
  96. }
  97. // read reply
  98. if( m_bRead )
  99. {
  100. BOOL bSuccess = ReadProc( &m_Protocol, 0, FALSE );
  101. // if read successeful
  102. if( bSuccess )
  103. m_lTimeout = 0;
  104. m_bRead = !bSuccess;
  105. }
  106. }
  107. }
  108. */
  109. #endif // EMBEDDED_CAMERA_PELCO