示例#1
0
void Source::GetAcquisitionModes( std::vector<QString> &aVector )
{
	aVector.clear();

	PvGenStateStack lState( mDevice->GetGenParameters() );
	if ( mMultiSource )
	{
		// Push change on stack, will be reset when lState goes out of scope
		lState.SetEnumValue( "SourceSelector", mSourceIndex );
	}

	PvGenEnum *lMode = mDevice->GetGenParameters()->GetEnum( "AcquisitionMode" );
	if ( lMode != NULL )
	{
		PvInt64 lCount;
		lMode->GetEntriesCount( lCount );

		for ( PvInt64 i = 0; i < lCount; i++ )
		{
			const PvGenEnumEntry *lEE = NULL;
			lMode->GetEntryByIndex( i, &lEE );
			if ( ( lEE != NULL ) && lEE->IsAvailable() )
			{
				PvString lName;
				lEE->GetName( lName );

				aVector.push_back( lName.GetAscii() );
			}
		}
	}
}
示例#2
0
void Source::GetAcquisitionMode( bool aSelectSourceIfNeeded, QString &aAcquisitionMode )
{
	aAcquisitionMode = "";

	PvGenStateStack lState( mDevice->GetGenParameters() );
	if ( mMultiSource )
	{
		PvInt64 lCurrentSource = 0;
		mDevice->GetGenParameters()->GetEnumValue( "SourceSelector", lCurrentSource );

		if ( lCurrentSource != mSourceIndex )
		{
			if ( aSelectSourceIfNeeded )
			{
				// Push change on stack, will be reset when lState goes out of scope
				lState.SetEnumValue( "SourceSelector", mSourceIndex );
			}
			else
			{
				return;
			}
		}
	}

	PvGenEnum *lMode = mDevice->GetGenParameters()->GetEnum( "AcquisitionMode" );
	if ( lMode != NULL )
	{
		PvString lValue;
		lMode->GetValue( lValue );

		aAcquisitionMode = lValue.GetAscii();
	}
}
示例#3
0
std::string PleoraVideo::GetParameter(const std::string& name) {
    PvGenParameter* par = lDeviceParams->Get(PvString(name.c_str()));
    if(par) {
        PvString ret = par->ToString();
        return std::string(ret.GetAscii());
    } else {
        pango_print_error("Parameter %s not recognized\n", name.c_str());
        return "";
    }
}
示例#4
0
// =============================================================================
void LogBuffer::Load( PvConfigurationReader &aReader )
{
    PvResult lResult;
    PvString lPvStr;

	// Always load from a blank setup!
	ResetConfig();

	// bool mGenICamEnabled;
    lResult = aReader.Restore( TAG_GENICAMENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mGenICamEnabled = ( lPvStr == VAL_TRUE );
    }

	// bool mBufferAllEnabled;
    lResult = aReader.Restore( TAG_BUFFERALLENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mBufferAllEnabled = ( lPvStr == VAL_TRUE );
    }

	// bool mBufferErrorEnabled;
    lResult = aReader.Restore( TAG_BUFFERERRORENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mBufferErrorEnabled = ( lPvStr == VAL_TRUE );
    }

	// QString mFilename;
    lResult = aReader.Restore( TAG_LOGFILENAME, lPvStr );
    if ( lResult.IsOK() )
	{
		SetFilename( lPvStr.GetAscii() );
	}

	// bool mWriteToFileEnabled;
    lResult = aReader.Restore( TAG_WRITETOFILEENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        SetWriteToFileEnabled( lPvStr == VAL_TRUE );
    }
}
示例#5
0
    // Open source: opens the stream, set destination, starts pipeline
    void Open()
    {
        cout << "Opening source " << mSource.GetAscii() << endl;

        // Select source (if applicable)
        PvGenStateStack lStack( mDevice->GetGenParameters() );
        SelectSource( &lStack );

        // Retrieve the source channel
        cout << "  Reading source channel on device" << endl;
        PvInt64 lSourceChannel = 0;
        PvResult lResult = mDevice->GetGenParameters()->GetIntegerValue( "SourceStreamChannel", lSourceChannel );
        PvUInt32 lChannel = static_cast<PvUInt32>( lSourceChannel );

        // Open stream
        cout << "  Opening stream to device" << endl;
        mStream.Open( mIPAddress, 0, lChannel );

        PvString lLocalIP = mStream.GetLocalIPAddress();
        PvUInt32 lLocalPort = mStream.GetLocalPort();

        // Set source destination on IP engine
        cout << "  Setting source destination on device (channel " << lChannel << ") " << endl;
        cout << "    to " << lLocalIP.GetAscii() << " port " << lLocalPort << endl;
        mDevice->SetStreamDestination( lLocalIP, lLocalPort, lChannel );

        // Reading payload size from device
        PvInt64 lSize = 0;
        mDevice->GetGenParameters()->GetIntegerValue( "PayloadSize", lSize );

        // Set the Buffer size and the Buffer count
        mPipeline->SetBufferSize( static_cast<PvUInt32>( lSize ) );
        mPipeline->SetBufferCount( BUFFER_COUNT ); // Increase for high frame rate without missing block IDs

        // Start pipeline thread
        cout << "  Starting pipeline thread" << endl;
        mPipeline->Start();
    }
示例#6
0
bool AcquireImages()
{
    // Create a GEV Device finder dialog
    PvDeviceFinderWnd lDeviceFinderWnd;

    // Prompt the user to select a GEV Device
    lDeviceFinderWnd.ShowModal();

    // Get the connectivity information for the selected GEV Device
    PvDeviceInfo* lDeviceInfo = lDeviceFinderWnd.GetSelected();

    // If no device is selected, abort
    if( lDeviceInfo == NULL )
    {
        cout << "No device selected." << endl;
        return false;
    }

    PvString lMACAddress = lDeviceInfo->GetMACAddress();
    PvString lIPAddress = lDeviceInfo->GetIPAddress();

    // Connect to the GEV Device
    PvDevice lDevice;
    cout << "Connecting to " << lMACAddress.GetAscii() << endl;
    // if ( !lDevice.Connect( lDeviceInfo ).IsOK() )
    if ( !lDevice.Connect( lDeviceInfo ).IsOK() )
    {
        cout << "Unable to connect to " << lMACAddress.GetAscii() << endl;
        return false;
    }
    cout << "Successfully connected to " << lMACAddress.GetAscii() << endl;

    cout << endl;

    SourceList lSources;

    // Get source selector
    PvGenEnum *lSourceSelector = lDevice.GetGenParameters()->GetEnum( "SourceSelector" );
    if ( lSourceSelector != NULL )
    {
        // Go through all sources, create source objects
        PvInt64 lCount = 0;
        lSourceSelector->GetEntriesCount( lCount );
        for ( PvInt64 i = 0; i < lCount; i++ )
        {
            // Get source enum entry
            const PvGenEnumEntry *lEE = NULL;
            lSourceSelector->GetEntryByIndex( i, &lEE );

            // If available, create source
            if ( ( lEE != NULL ) && lEE->IsAvailable() )
            {
                // Get source name
                PvString lSourceName;
                lEE->GetName( lSourceName );

                // Create source
                Source *lSource = new Source( &lDevice, lIPAddress, lSourceName );
                lSource->Open();

                // Add to sources list
                lSources.push_back( lSource );

                cout << endl;
            }
        }
    }
    else
    {
        // If no source selector, just create a single source
        Source *lSource = new Source( &lDevice, lIPAddress, "" );
        lSource->Open();

        // Add to sources list
        lSources.push_back( lSource );

        cout << endl;
    }

    // Start the acquisiton on all sources
    SourceList::iterator lIt = lSources.begin();
    while ( lIt != lSources.end() )
    {
        ( *( lIt++ ) )->StartAcquisition();
        cout << endl;
    }

    // Aggressive initial value, will be adjusted vs frame rate
    PvUInt32 lTimeout = 1;

    // Acquire images until the user instructs us to stop
    cout << "<press a key to stop streaming>" << endl;
    while ( !PvKbHit() )
    {
        double lNewTimeout = 1000.0;

        lIt = lSources.begin();
        while ( lIt != lSources.end() )
        {
            ( *lIt )->RetrieveImages( lTimeout );
            ( *lIt )->PrintStatistics();

            // Always use the smallest recommended timeout
            double lRecommendedTimeout = ( *lIt )->GetRecommendedTimeout();
            if ( lRecommendedTimeout < lNewTimeout )
            {
                lNewTimeout = lRecommendedTimeout;
            }

            lIt++;
        }

        // Update timeout for next round - smallest recommended divided by number of sources
        lTimeout = static_cast<PvUInt32>( lNewTimeout / static_cast<double>( lSources.size() ) + 0.5 );

        cout << "\r";
    }

    PvGetChar(); // Flush key buffer for next stop
    cout << endl << endl;

    // Stop the acquisiton on all sources
    lIt = lSources.begin();
    while ( lIt != lSources.end() )
    {
        ( *( lIt++ ) )->StopAcquisition();
        cout << endl;
    }

    // Close and delete sources
    lIt = lSources.begin();
    while ( lIt != lSources.end() )
    {
        ( *lIt )->Close();
        cout << endl;

        delete *lIt;

        lIt++;
    }

    // Finally disconnect the device. Optional, still nice to have
    cout << "Disconnecting device" << endl;
    lDevice.Disconnect();

    return true;
}
void ImageSaveDlg::Load( PvConfigurationReader &aReader )
{
    PvString lSaveEnabled;
    PvString lSaveEnabledTag("saveenabled");
    aReader.Restore(lSaveEnabledTag, lSaveEnabled);
    if (strcmp(lSaveEnabled.GetAscii(),"1") == 0 )
    {
        mSaveEnabled = true;
    }
    else
    {
        mSaveEnabled = false;
    }

    PvString lOneOutOf;
    aReader.Restore( "oneoutof", lOneOutOf );
    mOneOutOf = atoi( lOneOutOf.GetAscii() );

    PvString lMaxRate;
    aReader.Restore( "maxrate", lMaxRate );
    mMaxRate = atoi( lMaxRate.GetAscii() );

    PvString lAverageThroughput;
    aReader.Restore( "averagethroughput", lAverageThroughput );
    mAverageThroughput = atoi(lAverageThroughput.GetAscii());

    PvString lSaveThrottleOption;
    aReader.Restore( "savethrottleoption", lSaveThrottleOption );
    mSaveThrottling = (SaveThrottleOption)atoi( lSaveThrottleOption.GetAscii() );

    PvString lSavePath;
    aReader.Restore( "savepath", lSavePath );
    mSavePath = lSavePath.GetAscii();

    PvString lFormat;
    aReader.Restore( "saveformat", lFormat );
    QString lStr( lFormat.GetAscii() );
    QString lLower = lStr.toLower();
    if ( lLower == "bmp" )
    {
        mFormat = FORMAT_BMP;
    }
    else if ( lLower == "raw" )
    {
        mFormat = FORMAT_RAW;
    }
    else
    {
        // Default. Can be expected as the user can end up manually
        // editing the persistence file.
        mFormat = FORMAT_BMP;
    }
}