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.

112 lines
2.7 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: 19/05/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgNetSocketPTZ.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgNetSocketPTZ.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgNetSocketPTZ.h"
  16. CLgNetSocketPTZ::CLgNetSocketPTZ()
  17. {
  18. m_eType = NET_SOCKET_PTZ_NONE;
  19. }
  20. CLgNetSocketPTZ::~CLgNetSocketPTZ()
  21. {
  22. Destroy();
  23. }
  24. BOOL CLgNetSocketPTZ::Create( E_NET_SOCKET_PTZ_TYPE eType, LPCTSTR pCommPort, BOOL bDemo )
  25. {
  26. Destroy();
  27. if( !bDemo )
  28. {
  29. switch( eType )
  30. {
  31. case NET_SOCKET_PTZ_TKS576:
  32. if( !m_Connection.Create( pCommPort, 9600, 8, EVENPARITY, ONESTOPBIT, 1024, 1024 ) )
  33. return FALSE;
  34. if( !m_ProtocolTKS576.Create( &m_Connection ) )
  35. return FALSE;
  36. break;
  37. case NET_SOCKET_PTZ_PG3AD:
  38. if( !m_Connection.Create( pCommPort, 9600, 8, NOPARITY, ONESTOPBIT, 1024, 1024 ) )
  39. return FALSE;
  40. if( !m_ProtocolPG3AD.Create( &m_Connection ) )
  41. return FALSE;
  42. break;
  43. case NET_SOCKET_PTZ_MIGVAN:
  44. if( !m_Connection.Create( pCommPort, 4800, 8, NOPARITY, ONESTOPBIT, 1024, 1024 ) )
  45. return FALSE;
  46. if( !m_ProtocolMigvan.Create( &m_Connection ) )
  47. return FALSE;
  48. break;
  49. case NET_SOCKET_PTZ_MIC1300:
  50. if( !m_Connection.Create( pCommPort, 9600, 8, ODDPARITY, ONESTOPBIT, 1024, 1024 ) )
  51. return FALSE;
  52. if( !m_ProtocolMic1300.Create( &m_Connection ) )
  53. return FALSE;
  54. break;
  55. default:
  56. return FALSE;
  57. }
  58. }
  59. switch( eType )
  60. {
  61. case NET_SOCKET_PTZ_TKS576:
  62. if( !CLgNetSocket::Create( &m_ProtocolTKS576 ) )
  63. return FALSE;
  64. break;
  65. case NET_SOCKET_PTZ_PG3AD:
  66. if( !CLgNetSocket::Create( &m_ProtocolPG3AD ) )
  67. return FALSE;
  68. break;
  69. case NET_SOCKET_PTZ_MIGVAN:
  70. if( !CLgNetSocket::Create( &m_ProtocolMigvan ) )
  71. return FALSE;
  72. break;
  73. case NET_SOCKET_PTZ_MIC1300:
  74. if( !CLgNetSocket::Create( &m_ProtocolMic1300 ) )
  75. return FALSE;
  76. break;
  77. default:
  78. return FALSE;
  79. }
  80. m_eType = eType;
  81. return TRUE;
  82. }
  83. void CLgNetSocketPTZ::Destroy()
  84. {
  85. CLgNetSocket::Destroy();
  86. m_ProtocolTKS576.Destroy();
  87. m_ProtocolPG3AD.Destroy();
  88. m_ProtocolMigvan.Destroy();
  89. m_ProtocolMic1300.Destroy();
  90. m_Connection.Destroy();
  91. }
  92. BOOL CLgNetSocketPTZ::SetBaudrate( DWORD nBaudrate )
  93. {
  94. DCB dcb;
  95. if( !m_Connection.GetCommState( &dcb ) )
  96. return FALSE;
  97. if( dcb.BaudRate == nBaudrate )
  98. return TRUE;
  99. dcb.BaudRate = nBaudrate;
  100. return m_Connection.SetCommState( &dcb );
  101. }