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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: VideoMatrix.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of VideoMatrix.cpp
//----------------------------------------------------------------------------
// VideoMatrix.cpp: implementation of the CVideoMatrix class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "chicago.h"
#include "VideoMatrix.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVideoMatrix::CVideoMatrix()
{
m_pDevice = NULL;
m_pOutput = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoMatrix::CVideoMatrix") );
}
CVideoMatrix::~CVideoMatrix()
{
if( m_pOutput )
delete [] m_pOutput;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoMatrix::~CVideoMatrix") );
}
void CVideoMatrix::ConnectToDevice( CDeviceVM *pDevice )
{
ASSERT( pDevice != NULL );
ASSERT( m_pOutput == NULL );
m_pDevice = pDevice;
m_pOutput = new int[ pDevice->GetOutputCount() ];
for( int j = 0; j < pDevice->GetOutputCount(); j++ )
m_pOutput[j] = VI_UNDEFINED;
CVideoDevice::SetIOCount( pDevice->GetInputCount(),
pDevice->GetOutputCount() );
pDevice->SetVideoMatrix( this );
}
void CVideoMatrix::CmdConnect( int nOutput, int nInput )
{
CheckQueue();
if( nInput < m_pDevice->GetInputCount() &&
nOutput < m_pDevice->GetOutputCount() )
{
if( m_pOutput[ nOutput ] != nInput )
{
m_pOutput[ nOutput ] = VI_UNDEFINED;
if( m_pDevice )
m_pDevice->PostConnect( nInput, nOutput );
}
}
}
BOOL CVideoMatrix::CmdGetInput( int nOutput, int *pInput )
{
CheckQueue();
if( nOutput < m_pDevice->GetOutputCount() )
{
if( m_pOutput[ nOutput ] != VI_UNDEFINED )
{
*pInput = m_pOutput[ nOutput ];
return TRUE;
}
}
return FALSE;
}
void CVideoMatrix::CheckQueue()
{
VMEVENT event;
while( m_Queue.Pop( event ) )
{
switch( event.id )
{
case VMC_CONNECTION:
m_pOutput[ event.nOutput ] = event.nInput;
break;
}
}
}
BOOL CVideoMatrix::PostConnect( int nInput, int nOutput )
{
VMEVENT event;
event.id = VMC_CONNECTION;
event.nInput = nInput;
event.nOutput = nOutput;
return m_Queue.Push( event );
}
BOOL CVideoMatrix::ForceConnection( int nInput, int nOutput )
{
if( m_pOutput[ nOutput ] != nInput )
{
CmdConnect( nOutput, nInput );
return FALSE;
}
return TRUE;
}