当前位置: 首页>>代码示例>>C++>>正文


C++ DeviceManager::getDeviceBySerial方法代码示例

本文整理汇总了C++中DeviceManager::getDeviceBySerial方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceManager::getDeviceBySerial方法的具体用法?C++ DeviceManager::getDeviceBySerial怎么用?C++ DeviceManager::getDeviceBySerial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeviceManager的用法示例。


在下文中一共展示了DeviceManager::getDeviceBySerial方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

//-----------------------------------------------------------------------------
int main( int argc, char* argv[])
//-----------------------------------------------------------------------------
{
	const char* pDevSerial = "BF*";

	cout << "\n ++ Start PowerDownTest sample: " << __DATE__ << "/" << __TIME__ << endl;

	if( argc > 1 )
	{
		pDevSerial = argv[1];
	}

	unsigned int uiDevCount = 0;
	DeviceManager DevMgr;
	if( ( uiDevCount = DevMgr.deviceCount() ) == 0 )
	{
		cout << "*** Error: No MATRIX VISION device found! Unable to continue!" << endl;
		return 0;
	}

	cout << "Have found " << uiDevCount << " devices on this platform!" << endl;

	for( unsigned i=0; i<uiDevCount; i++ )
	{
		Device* pDevTmp = DevMgr.getDevice( i );
		cout << " " << i << " Serial: " << pDevTmp->serial.read() << endl;
	}

	cout << "Initialising the device: "<< pDevSerial << ". This might take some time..." << endl;
	// create an interface to the first MATRIX VISION device with the serila number pDevSerial
	Device* pDev = DevMgr.getDeviceBySerial( pDevSerial );

	try
	{
		pDev->open();
	}
	catch( ImpactAcquireException& e )
	{
		// this e.g. might happen if the same device is already opened in another process...
		cout << "*** Error: An error occurred while opening the device(error code: " << e.getErrorCode() << ")." << endl;
		return 0;
	}

	FunctionInterface fi( pDev );

	// only 8Bit/pixel destination image are supported by the \c writeFile() function
	ImageDestination imgDst( pDev );
	imgDst.pixelFormat.write( idpfMono8 );

	// get mvBF system settings
	SystemBlueFOX sbf( pDev );

	bool bPowerDown = false;
	do
	{
		cout << "Ready to snap. Press 'p'<return> to power down, 'q'<return> to quit or <return> to snap an image.." << endl;
		char ch = getchar();

		if( ch == 'p' )
		{	// for mvBlueFOX only: test power down / up
			cout << "Power off!" << endl;
			sbf.powerMode.write( dpmOff );
			bPowerDown = true;
			// read and discard the <return> 
			getchar();
		}
		else if( ch == 'q' )
		{	// break out of loop to finish application
			// read and discard the <return> 
			getchar();
			break;
		}
		else
		{	// snap
			if( bPowerDown )
			{	// first we need to power up again
				CTime timer1;
				sbf.powerMode.write( dpmOn );
				bPowerDown = false;
				cout << "Power On!" << ". Power On took " << timer1.elapsed() << "s., " << endl;
			}

			CTime timer;

			// send a request to the default request queue of the device and wait for the result.
			fi.imageRequestSingle();
			const int iMaxWaitTime_ms = 5000;

			// wait for results from the default capture queue
			int iRequestNr = fi.imageRequestWaitFor( iMaxWaitTime_ms );

			cout << "Request Nr.: " << iRequestNr << ". Snap took " << timer.elapsed() << "s., " << endl;
			// check if the image has been captured without any problems
			if( !fi.isRequestNrValid( iRequestNr ) )
			{
				// this can not happen in this sample, but may happen if you wait for a request without
				// sending one to the driver before
				cout << "*** Error: No request has been sent to the driver." << endl;
				// unlock the buffer to let the driver know that you no longer need this buffer
//.........这里部分代码省略.........
开发者ID:magic-upenn,项目名称:magic2010,代码行数:101,代码来源:PowerDownTest.cpp

示例2: main

//-----------------------------------------------------------------------------
int main( int argc, char* argv[])
//-----------------------------------------------------------------------------
{
	if( argc > 2 )
	{
		cout << "Invalid input parameter count" << endl
			<< endl;
		printHelp();
		return 0;
	}

	unsigned int devCnt = 0;
	DeviceManager devMgr;
	if(( devCnt = devMgr.deviceCount()) == 0 )
	{
		cout << "*** Error: No MATRIX VISION device found! Unable to continue!" << endl;
		return 0;
	}

	cout << "Have found " << devCnt << " devices on this platform!" << endl
		<< "Please note that this application will only work for mvBlueFOX devices" <<endl;

	if( argc == 1 )
	{
		int index = 0;
		Device* pDev = 0;
		while( ( pDev = devMgr.getDeviceByFamily( "mvBlueFOX", index ) ) != 0 )
		{
			updateFirmware( pDev );
			++index;
		}
	}
	else
	{
		string command(argv[1]);
		if( command == "-sel" )
		{
			Device* pDev = getDeviceFromUserInput( devMgr );
			if( !pDev )
			{
				return 0;
			}
			updateFirmware( pDev );
		}
		else if( command.find( "-d" ) == 0 )
		{
			string serial(command.substr( 2 ));
			Device* pDev = devMgr.getDeviceBySerial( serial );
			if( !pDev )
			{
				cout << "Can't find Device " << serial << endl;
				return 0;
			}
			updateFirmware( pDev );
		}
		else if( command == "-help" )
		{
			printHelp();
		}
		else
		{
			cout << "Invalid input parameter: " << command << endl
				<< endl;
			printHelp();
			return 0;
		}
	}

	return 0;
}
开发者ID:magic-upenn,项目名称:magic2010,代码行数:71,代码来源:FirmwareUpgrade.cpp

示例3: main

//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
//-----------------------------------------------------------------------------
{
#ifdef MALLOC_TRACE
    mtrace();
#endif  // MALLOC_TRACE

    cout << " ++ starting application...." << endl;

    bool boStoreFrames = false;
    string settingName;
    int width = -1;
    int height = -1;
    string pixelFormat;
    string acquisitionMode;
    string deviceSerial;
    int defaultRequestCount = -1;
    for( int i = 1; i < argc; i++ )
    {
        string arg( argv[i] );
        if( string( argv[i] ) == "-sf" )
        {
            boStoreFrames = true;
        }
        else if( arg.find( "-a" ) == 0 )
        {
            acquisitionMode = arg.substr( 2 );
        }
        else if( arg.find( "-drc" ) == 0 )
        {
            defaultRequestCount = atoi( arg.substr( 4 ).c_str() );
        }
        else if( arg.find( "-h" ) == 0 )
        {
            height = atoi( arg.substr( 2 ).c_str() );
        }
        else if( arg.find( "-s" ) == 0 )
        {
            deviceSerial = arg.substr( 2 );
        }
        else if( arg.find( "-w" ) == 0 )
        {
            width = atoi( arg.substr( 2 ).c_str() );
        }
        else
        {
            // try to load this setting later on...
            settingName = string( argv[1] );
        }
    }

    if( argc <= 1 )
    {
        cout << "Available command line parameters:" << endl
             << endl
             << "-sf to store every 100th frame in raw format" << endl
             << "-a<mode> to set the acquisition mode" << endl
             << "-h<height> to set the AOI width" << endl
             << "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl
             << "-w<width> to set the AOI width" << endl
             << "-drc<bufferCount> to specify the default request count" << endl
             << "any other string will be interpreted as a name of a setting to load" << endl;
    }

    DeviceManager devMgr;
    Device* pDev = 0;
    if( !deviceSerial.empty() )
    {
        pDev = devMgr.getDeviceBySerial( deviceSerial );
        if( pDev )
        {
            // if this device offers the 'GenICam' interface switch it on, as this will
            // allow are better control over GenICam compliant devices
            conditionalSetProperty( pDev->interfaceLayout, dilGenICam );
            // if this device offers a user defined acquisition start/stop behaviour
            // enable it as this allows finer control about the streaming behaviour
            conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser );
        }
    }
    if( !pDev )
    {
        // this will automatically set the interface layout etc. to the values from the branch above
        pDev = getDeviceFromUserInput( devMgr );
    }
    if( pDev == 0 )
    {
        cout << "Unable to continue!";
        PRESS_A_KEY_AND_RETURN
    }
开发者ID:qintony,项目名称:sensor_drivers,代码行数:90,代码来源:LiveSnapFLTK.cpp

示例4: main

//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
//-----------------------------------------------------------------------------
{
#ifdef MALLOC_TRACE
    mtrace();
#endif  // MALLOC_TRACE
    cout << " ++ starting application...." << endl;

    string settingName;
    int width = -1;
    int height = -1;
    string pixelFormat;
    string acquisitionMode;
    string deviceSerial;
    int defaultRequestCount = -1;
    for( int i = 1; i < argc; i++ )
    {
        string arg( argv[i] );
        if( arg.find( "-a" ) == 0 )
        {
            acquisitionMode = arg.substr( 2 );
        }
        else if( arg.find( "-drc" ) == 0 )
        {
            defaultRequestCount = atoi( arg.substr( 4 ).c_str() );
        }
        else if( arg.find( "-h" ) == 0 )
        {
            height = atoi( arg.substr( 2 ).c_str() );
        }
        else if( arg.find( "-p" ) == 0 )
        {
            pixelFormat = arg.substr( 2 );
        }
        else if( arg.find( "-s" ) == 0 )
        {
            deviceSerial = arg.substr( 2 );
        }
        else if( arg.find( "-w" ) == 0 )
        {
            width = atoi( arg.substr( 2 ).c_str() );
        }
        else
        {
            // try to load this setting later on...
            settingName = string( argv[1] );
        }
    }

    if( argc <= 1 )
    {
        cout << "Available command line parameters:" << endl
             << endl
             << "-sf to store every 100th frame in raw format" << endl
             << "-a<mode> to set the acquisition mode" << endl
             << "-h<height> to set the AOI width" << endl
             << "-p<pixelFormat> to set the pixel format" << endl
             << "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl
             << "-w<width> to set the AOI width" << endl
             << "-drc<bufferCount> to specify the default request count" << endl
             << "any other string will be interpreted as a name of a setting to load" << endl;
    }

    DeviceManager devMgr;
    Device* pDev = 0;
    bool bGoOn( true );
    while( bGoOn )
    {
        if( !deviceSerial.empty() )
        {
            pDev = devMgr.getDeviceBySerial( deviceSerial );
            if( pDev )
            {
                // if this device offers the 'GenICam' interface switch it on, as this will
                // allow are better control over GenICam compliant devices
                conditionalSetProperty( pDev->interfaceLayout, dilGenICam );
                // if this device offers a user defined acquisition start/stop behaviour
                // enable it as this allows finer control about the streaming behaviour
                conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser );
            }
        }
        if( !pDev )
        {
            // this will automatically set the interface layout etc. to the values from the branch above
            pDev = getDeviceFromUserInput( devMgr );
        }
        if( pDev )
        {
            deviceSerial = pDev->serial.read();
            cout << "Initialising device: " << pDev->serial.read() << ". This might take some time..." << endl
                 << "Using interface layout '" << pDev->interfaceLayout.readS() << "'." << endl;
            try
            {
                if( defaultRequestCount > 0 )
                {
                    cout << "Setting default request count to " << defaultRequestCount << endl;
                    pDev->defaultRequestCount.write( defaultRequestCount );
                }
                pDev->open();
//.........这里部分代码省略.........
开发者ID:alperaydemir,项目名称:idd,代码行数:101,代码来源:LiveSnap.cpp

示例5: main

//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
//-----------------------------------------------------------------------------
{
#ifdef MALLOC_TRACE
	mtrace();
#endif	// MALLOC_TRACE
	cout << " ++ starting application...." << endl;

	bool boStoreFrames = false;
	string settingName;
	int width = -1;
	int height = -1;
	string pixelFormat;
	string acquisitionMode;
	string deviceSerial;
	for( int i=1; i<argc; i++ )
	{
		string arg(argv[i]);
		if( string( argv[i] ) == "-sf" )
		{
			boStoreFrames = true;
		}
		else if( arg.find( "-a" ) == 0 )
		{
			acquisitionMode = arg.substr( 2 );
		}
		else if( arg.find( "-h" ) == 0 )
		{
			height = atoi( arg.substr( 2 ).c_str() );
		}
		else if( arg.find( "-p" ) == 0 )
		{
			pixelFormat = arg.substr( 2 );
		}
		else if( arg.find( "-s" ) == 0 )
		{
			deviceSerial = arg.substr( 2 );
		}
		else if( arg.find( "-w" ) == 0 )
		{
			width = atoi( arg.substr( 2 ).c_str() );
		}
		else
		{
			// try to load this setting later on...
			settingName = string(argv[1]);
		}
	}

	if( argc <= 1 )
	{
		cout << "Available command line parameters:" << endl
			<< endl
			<< "-sf to store every 100th frame in raw format" << endl
			<< "-a<mode> to set the acquisition mode" << endl
			<< "-h<height> to set the AOI width" << endl
			<< "-p<pixelFormat> to set the pixel format" << endl
			<< "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl
			<< "-w<width> to set the AOI width" << endl
			<< "any other string will be interpreted as a name of a setting to load" << endl;
	}

	DeviceManager devMgr;
	Device* pDev = 0;
	if( !deviceSerial.empty() )
	{
		pDev = devMgr.getDeviceBySerial( deviceSerial );
		if( pDev )
		{
			switchFromGenericToGenICamInterface( pDev );
		}
	}
	if( !pDev )
	{
		pDev = getDeviceFromUserInput( devMgr );
	}
	if( pDev == 0 )
	{
		cout << "Unable to continue!";
		PRESS_A_KEY_AND_RETURN
	}
开发者ID:magic-upenn,项目名称:magic2010,代码行数:82,代码来源:LiveSnap.cpp


注:本文中的DeviceManager::getDeviceBySerial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。