📄 baccdemo.cpp
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: baccdemo.cpp, 3, 02.10.2002 15:38:15, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
\file baccdemo.cpp
\brief Defines the entry point for the console application.
*/
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
/// The one and only application object
CWinApp theApp;
using namespace std;
using namespace Bcam;
typedef std::list< CBcamAdapter* > AdapterList;
/// Visit the node and then the child nodes
static void Visit( CNode* p, int indent, ostream& os )
{
if (! p)
return;
CString s;
s.Format( _T( "%*d, %s -- %s -- %X -- %X%08X" ),
indent, p->PhysicalId(), (LPCSTR)p->VendorName(), (LPCSTR)p->ModelName(),
p->NodeID().LowPart >> 4, p->NodeID().LowPart & 0xff, p->NodeID().HighPart );
os << (LPCTSTR) s << endl;
for (int i= 0; i<p->NumPorts(); i++)
{
CNodePtr ptr;
ptr.Attach( p->Child( i ), false );
Visit( ptr, indent+2, os );
}
}
/// Main entry point
int _tmain()
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
AdapterList m_Adapters; ///< list with all adapters found
try
{
list<CString>&devs = CBcamAdapter::DeviceNames();
for (list<CString>::iterator sit = devs.begin(); sit != devs.end(); sit++)
{
(*m_Adapters.insert( m_Adapters.end(), new CBcamAdapter() )) -> Open( *sit );
}
for (AdapterList::iterator it = m_Adapters.begin(); it != m_Adapters.end(); it++)
{
CNodePtr ptrRoot;
ptrRoot.Attach( (*it)->GetTree(), false );
Visit( ptrRoot, 0, cout );
ptrRoot = 0;
(*it)->Close();
}
}
catch (std::exception &e)
{
cerr << e.what() << endl;
nRetCode = 1;
}
catch (BcamException &e)
{
cerr << _T( "0x" ) << hex << e.Error() << " : " << (LPCTSTR) e.Description() << endl;
nRetCode = 1;
}
catch (...)
{
BcamException e( ::GetLastError() );
cerr << _T( "setUp: unexpected error" );
cerr << _T( "0x" ) << hex << e.Error() << " : " << (LPCTSTR) e.Description() << endl;
nRetCode = 1;
}
}
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -