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.
|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: BoardReceiverSwitcher.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of BoardReceiverSwitcher.cpp
//----------------------------------------------------------------------------
// BoardReceiverSwitcher.cpp: implementation of the CBoardReceiverSwitcher class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "BoardReceiver.h"
#include "BoardReceiverSwitcher.h"
//#include "..\testlgs\siteprocessor.h"
#include "..\lglib\net\lgnetsocketmd.h"
#include "..\lglib\net\lgnetdevicelgs.h"
CBoardReceiverSwitcher::CBoardReceiverSwitcher(){
}
CBoardReceiverSwitcher::~CBoardReceiverSwitcher(){
}
BOOL CBoardReceiverSwitcher::Switch( INT nDevice, LPCTSTR pPort, INT nCount, DWORD dwTimeout ){ BOOL bResult = FALSE; // __try
{ bResult = Switch_( nDevice, pPort, nCount, dwTimeout ); }// __except( EXCEPTION_CONTINUE_EXECUTION )
{// LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CBoardReceiverSwitcher::Switch"), _T("Exception 0x%08X"), _exception_code() );
}
return bResult;}
BOOL CBoardReceiverSwitcher::Switch_( INT nDevice, LPCTSTR pPort, INT nCount, DWORD dwTimeout ){ CLgNetDeviceLGS *device = new CLgNetDeviceLGS; CLgNetSocketMD *socket = new CLgNetSocketMD;
device->SetAddress( 0 ); device->SetAutoBaudrate( FALSE ); device->SetSpyMode( FALSE );
if( !socket->CLgLinkP<CLgNetObject,CLgNetObject,CLgNetObjectChild>::Link( device ) ) return FALSE;
if( !socket->Create( pPort, LGS_COMM_BAUDRATE, FALSE, FALSE ) ) return FALSE;
if( !socket->CLgLinkP<CLgNetSocket,CLgNetSocketDevice>::Link( device ) ) return FALSE;
CLgNetMessageLGS msg; msg.BuildCmdSendBoardData( nDevice ); msg.SetDistinationID( device->GetID() ); msg.SetSenderID( socket->GetID() );
DWORD dwStartTime = ::GetTickCount(); for( INT i = 0; i < nCount; i++ ) { socket->SendMessageToChild( msg ); Sleep( dwTimeout ); }
socket->Destroy(); return TRUE;}
|