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.

127 lines
2.9 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: VideoMatrix.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of VideoMatrix.cpp
  13. //----------------------------------------------------------------------------
  14. // VideoMatrix.cpp: implementation of the CVideoMatrix class.
  15. //
  16. //////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. //#include "chicago.h"
  19. #include "VideoMatrix.h"
  20. #include "..\..\LgLib\Version.h"
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char THIS_FILE[]=__FILE__;
  24. #define new DEBUG_NEW
  25. #endif
  26. //////////////////////////////////////////////////////////////////////
  27. // Construction/Destruction
  28. //////////////////////////////////////////////////////////////////////
  29. CVideoMatrix::CVideoMatrix()
  30. {
  31. m_pDevice = NULL;
  32. m_pOutput = NULL;
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoMatrix::CVideoMatrix") );
  34. }
  35. CVideoMatrix::~CVideoMatrix()
  36. {
  37. if( m_pOutput )
  38. delete [] m_pOutput;
  39. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoMatrix::~CVideoMatrix") );
  40. }
  41. void CVideoMatrix::ConnectToDevice( CDeviceVM *pDevice )
  42. {
  43. ASSERT( pDevice != NULL );
  44. ASSERT( m_pOutput == NULL );
  45. m_pDevice = pDevice;
  46. m_pOutput = new int[ pDevice->GetOutputCount() ];
  47. for( int j = 0; j < pDevice->GetOutputCount(); j++ )
  48. m_pOutput[j] = VI_UNDEFINED;
  49. CVideoDevice::SetIOCount( pDevice->GetInputCount(),
  50. pDevice->GetOutputCount() );
  51. pDevice->SetVideoMatrix( this );
  52. }
  53. void CVideoMatrix::CmdConnect( int nOutput, int nInput )
  54. {
  55. CheckQueue();
  56. if( nInput < m_pDevice->GetInputCount() &&
  57. nOutput < m_pDevice->GetOutputCount() )
  58. {
  59. if( m_pOutput[ nOutput ] != nInput )
  60. {
  61. m_pOutput[ nOutput ] = VI_UNDEFINED;
  62. if( m_pDevice )
  63. m_pDevice->PostConnect( nInput, nOutput );
  64. }
  65. }
  66. }
  67. BOOL CVideoMatrix::CmdGetInput( int nOutput, int *pInput )
  68. {
  69. CheckQueue();
  70. if( nOutput < m_pDevice->GetOutputCount() )
  71. {
  72. if( m_pOutput[ nOutput ] != VI_UNDEFINED )
  73. {
  74. *pInput = m_pOutput[ nOutput ];
  75. return TRUE;
  76. }
  77. }
  78. return FALSE;
  79. }
  80. void CVideoMatrix::CheckQueue()
  81. {
  82. VMEVENT event;
  83. while( m_Queue.Pop( event ) )
  84. {
  85. switch( event.id )
  86. {
  87. case VMC_CONNECTION:
  88. m_pOutput[ event.nOutput ] = event.nInput;
  89. break;
  90. }
  91. }
  92. }
  93. BOOL CVideoMatrix::PostConnect( int nInput, int nOutput )
  94. {
  95. VMEVENT event;
  96. event.id = VMC_CONNECTION;
  97. event.nInput = nInput;
  98. event.nOutput = nOutput;
  99. return m_Queue.Push( event );
  100. }
  101. BOOL CVideoMatrix::ForceConnection( int nInput, int nOutput )
  102. {
  103. if( m_pOutput[ nOutput ] != nInput )
  104. {
  105. CmdConnect( nOutput, nInput );
  106. return FALSE;
  107. }
  108. return TRUE;
  109. }