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: LgAdvantechDeviceEnumerator.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of LgAdvantechDeviceEnumerator.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "LgAdvantechDeviceEnumerator.h"
CLgAdvantechDeviceEnumerator::CLgAdvantechDeviceEnumerator(){ m_pDeviceList = NULL; m_nDeviceCount = 0;}
CLgAdvantechDeviceEnumerator::~CLgAdvantechDeviceEnumerator(){ Destroy();}
BOOL CLgAdvantechDeviceEnumerator::Create(){ // destroy old creature
Destroy();
// get device count
SHORT NumOfDevices; if( DRV_DeviceGetNumOfList( &NumOfDevices ) != SUCCESS ) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgAdvantechDeviceEnumerator::Create", "DRV_DeviceGetNumOfList failed" ); return FALSE; };
// aloc memory for list
DEVLIST *pDeviceList = (DEVLIST*)malloc( sizeof(DEVLIST) * NumOfDevices ); if( !pDeviceList ) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgAdvantechDeviceEnumerator::Create", "Out of memory during device list allocation" ); return FALSE; }
// get devices info
SHORT FilledNumOfDevices; if( DRV_DeviceGetList( pDeviceList, NumOfDevices, &FilledNumOfDevices ) != SUCCESS ) { // free memory for device list
free( pDeviceList );
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgAdvantechDeviceEnumerator::Create", "DRV_DeviceGetList failed" ); return FALSE; }
m_pDeviceList = pDeviceList; m_nDeviceCount = NumOfDevices;
return TRUE;} void CLgAdvantechDeviceEnumerator::Destroy(){ if( m_pDeviceList ) { free( m_pDeviceList ); m_pDeviceList = NULL; }
m_nDeviceCount = 0;}
INT CLgAdvantechDeviceEnumerator::GetDeviceCount() { return m_nDeviceCount; }
DEVLIST* CLgAdvantechDeviceEnumerator::GetDevice( INT nDevice ) { return ( nDevice >= 0 && nDevice < m_nDeviceCount ) ? m_pDeviceList + nDevice : NULL;}
|