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.
113 lines
2.7 KiB
113 lines
2.7 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgsBR.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgsBR.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LgsBR.h"
|
|
#include "..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
CLgsBR::CLgsBR()
|
|
{
|
|
m_hEventGetChannelProperties = NULL;
|
|
m_pChannelProperties = NULL;
|
|
m_nChannelCount = 0;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgsBR::CLgsBR" );
|
|
}
|
|
|
|
CLgsBR::~CLgsBR()
|
|
{
|
|
Destroy();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgsBR::~CLgsBR" );
|
|
}
|
|
|
|
BOOL CLgsBR::OnRemoteBRChannelConnect( INT nChannel, BOOL bResult )
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgsBR::OnRemoteBRGetChannelProperties( INT nChannelCount, LG_TCP_PACKET_BOARD_RECEIVER::PCHANNEL_PROPERTIES pProperties )
|
|
{
|
|
INT nSize = sizeof(LG_TCP_PACKET_BOARD_RECEIVER::CHANNEL_PROPERTIES) * nChannelCount;
|
|
|
|
m_pChannelProperties = (LG_TCP_PACKET_BOARD_RECEIVER::PCHANNEL_PROPERTIES)realloc( m_pChannelProperties, nSize );
|
|
if( !m_pChannelProperties )
|
|
return FALSE;
|
|
|
|
// story data
|
|
m_nChannelCount = nChannelCount;
|
|
memcpy( m_pChannelProperties, pProperties, nSize );
|
|
|
|
// notify about completion
|
|
return SetEvent(m_hEventGetChannelProperties);
|
|
}
|
|
|
|
BOOL CLgsBR::Create()
|
|
{
|
|
// initialize event object
|
|
if( !m_hEventGetChannelProperties )
|
|
m_hEventGetChannelProperties = ::CreateEvent( NULL, FALSE, FALSE, NULL );
|
|
|
|
// test event object
|
|
if( !m_hEventGetChannelProperties )
|
|
return FALSE;
|
|
|
|
// reset event
|
|
::ResetEvent( m_hEventGetChannelProperties );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CLgsBR::Destroy()
|
|
{
|
|
// delete event
|
|
if( m_hEventGetChannelProperties )
|
|
{
|
|
::CloseHandle( m_hEventGetChannelProperties );
|
|
m_hEventGetChannelProperties = NULL;
|
|
}
|
|
|
|
// delete stored data
|
|
if( m_pChannelProperties )
|
|
{
|
|
free( m_pChannelProperties );
|
|
m_pChannelProperties = NULL;
|
|
}
|
|
}
|
|
|
|
BOOL CLgsBR::EnumPorts( DWORD Level, LPBYTE pPorts, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned, DWORD dwTimeout )
|
|
{
|
|
// channel count
|
|
m_nChannelCount = 0;
|
|
|
|
// reset notification event
|
|
ResetEvent( m_hEventGetChannelProperties );
|
|
|
|
// acquare server
|
|
if( !DoRemoteBRGetChannelProperties() )
|
|
return FALSE;
|
|
|
|
// if answer don't returned in requested time
|
|
if( ::WaitForSingleObject( m_hEventGetChannelProperties, dwTimeout ) != WAIT_OBJECT_0 )
|
|
return FALSE;
|
|
|
|
// prepare info
|
|
|
|
return TRUE;
|
|
}
|