Exemple #1
0
PvResult Source::StartStreaming()
{
	if ( !mStream->IsOpen() || // Not initialized yet
		 mPipeline->IsStarted() ) // Already streaming
	{
		return PvResult::Code::NOT_INITIALIZED;
	}

	// Start threads
	mDisplayThread->Start( mPipeline, NULL );
    mDisplayThread->SetPriority( QThread::HighPriority );

	// Configure acquisition state manager
	mAcquisitionManager = new PvAcquisitionStateManager( mDevice, mStream, mSourceIndex );
	mAcquisitionManager->RegisterEventSink( this );

	// Start pipeline
	PvResult lResult = mPipeline->Start();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	return PvResult::Code::OK;
}
Exemple #2
0
int ImperxStream::SetPreAmpGain(int gain)
{
    PvResult outcome;
    PvString value;
    switch(gain)
    {
    case -3: 
        value = "minus3dB";
        break;
    case 0: 
        value = "zero_dB";
        break;
    case 3: 
        value = "plus3dB";
        break;
    case 6:
        value = "plus6dB";
        break;
    default:
        return -1;
    }
    outcome = lDeviceParams->SetEnumValue("PreAmpRaw",value);
    if (outcome.IsSuccess())
    {
        return 0;
    }
    return -1;
}
Exemple #3
0
void MLTCam::WaitForExecution()
{
    qDebug() <<  "MLTCam::Wait for execution...";
    PvBuffer *lBuffer = NULL;
    PvResult lOperationResult;

    // Retrieve next buffer
    PvResult lResult = lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
    if ( lResult.IsOK() )
    {
        if ( lOperationResult.IsOK() )
        {
            qDebug() <<  "MLTCam::Get image complete";
            PvImage *lImage2 = lBuffer->GetImage();
            ushort * tdata = (ushort*)lImage2->GetDataPointer();

            memcpy(data, tdata, IMAGE_WIDTH*IMAGE_HEIGHT*2);

            timer->stop();
            delete timer;

            emit GetDataComplete(data);
            lDevice->StreamDisable();
        }

        // Re-queue the buffer in the stream object
        lStream->QueueBuffer( lBuffer );
    }

}
Exemple #4
0
PvResult Source::Close()
{
	// Stop image reception
	PvResult lResult = StopStreaming();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	// Close stream
	if ( mStream->IsOpen() )
	{
		lResult = mStream->Close();
		if ( !lResult.IsOK() )
		{
			return lResult;
		}
	}

	if ( ( mDevice != NULL ) && mDevice->IsConnected() )
	{
		// Unregister acquisition mode update notifications
		PvGenEnum *lMode = mDevice->GetGenParameters()->GetEnum( "AcquisitionMode" );
		if ( lMode != NULL )
		{
			lMode->UnregisterEventSink( this );
		}
	}

	// We don't own the device, let's just forget about it
	mDevice = NULL;

	return PvResult::Code::OK;
}
    // Pumps all the images out of the pipeline and return
    void RetrieveImages( PvUInt32 aTimeout )
    {
        // Set first wait timeout
        PvUInt32 lTimeout = aTimeout;

        // Loop for as long as images are available
        for ( ;; )
        {
            PvBuffer *lBuffer = NULL;
            PvResult lOperationResult;

            PvResult lResult = mPipeline->RetrieveNextBuffer( &lBuffer, aTimeout, &lOperationResult );
            if ( !lResult.IsOK() )
            {
                return;
            }

            // We got a buffer, check the acquisition result
            if ( lOperationResult.IsOK() )
            {
                // Here you would typically do your image manipulation/processing
                mDoodleIndex++;
                mDoodleIndex %= sDoodleLength;
            }

            // We made it here, at least release the buffer back to the pipeline
            mPipeline->ReleaseBuffer( lBuffer );

            // Set timeout to 0 for next RetrieveNextBufer operations
            lTimeout = 0;
        }
    }
Exemple #6
0
int ImperxStream::Snap(cv::Mat &frame, int timeout)
{
//  std::cout << "ImperxStream::Snap starting" << std::endl;
    // The pipeline is already "armed", we just have to tell the device
    // to start sending us images
    lDeviceParams->ExecuteCommand( "AcquisitionStart" );
    int lWidth, lHeight, result = 0;
    // Retrieve next buffer             
    PvBuffer *lBuffer = NULL;
    PvResult lOperationResult;
    PvResult lResult = lPipeline.RetrieveNextBuffer( &lBuffer, timeout, &lOperationResult );
        
    if ( lResult.IsOK() )
    {
        if ( lOperationResult.IsOK() )
        {
            // Process Buffer
            
            if ( lBuffer->GetPayloadType() == PvPayloadTypeImage )
            {
//              std::cout << "ImperxStream::Snap Copying frame" << std::endl;
                // Get image specific buffer interface
                PvImage *lImage = lBuffer->GetImage();
              
                // Read width, height
                lWidth = (int) lImage->GetWidth();
                lHeight = (int) lImage->GetHeight();
                unsigned char *img = lImage->GetDataPointer();
                cv::Mat lframe(lHeight,lWidth,CV_8UC1,img, cv::Mat::AUTO_STEP);
                lframe.copyTo(frame);
                result = 0;
            }
            else
            {
                std::cout << "ImperxStream::Snap No image in buffer" << std::endl;
                result = 1;
            }
        }
        else
        {
            std::cout << "ImperxStream::Snap Operation result: " << lOperationResult << std::endl;
            result = 1;;
        }
        // We have an image - do some processing (...) and VERY IMPORTANT,
        // release the buffer back to the pipeline
    }
    else
    {
        std::cout << "ImperxStream::Snap Timeout: " << lResult << std::endl;
        result = 1;
    }
    
    lPipeline.ReleaseBuffer( lBuffer );
//    std::cout << "ImperxStream::Snap Exiting" << std::endl;
    return result;
}
Exemple #7
0
void PleoraVideo::InitStream()
{
    // Setup Stream
    PvResult lResult;
    lStream = PvStream::CreateAndOpen( lDeviceInfo->GetConnectionID(), &lResult );
    if ( !lStream ) {
        DeinitDevice();
        throw pangolin::VideoException("Pleora: Unable to open stream", lResult.GetDescription().GetAscii() );
    }
    lStreamParams = lStream->GetParameters();
}
Exemple #8
0
void MLTCam::SetAccumulationTime(int time)
{
    PvResult aResult;
    aResult = lDevice->GetParameters()->SetEnumValue("AcquisitionMode", "SingleFrame");
    if ( !aResult.IsOK()) qDebug() << "Error!";
    aResult = lDevice->GetParameters()->SetEnumValue("SyncMode", "SoftwareTrigger");
    if ( !aResult.IsOK()) qDebug() << "Error!";
    aResult = lDevice->GetParameters()->SetIntegerValue("ExposureTimeInt", time);
    if ( !aResult.IsOK()) qDebug() << "Error!";
    qDebug() << "MLTCam::Exposure time set to " << time ;
}
void PvDualSourceSample::Connect( PvDeviceInfo *aDeviceInfo )
{
    // Just in case we came here still connected...
    Disconnect();

    // Connect to device using device info
    PvResult lResult = mDevice.Connect( aDeviceInfo );
    if ( !lResult.IsOK() )
    {
        PvMessageBox( this, lResult );
        return;
    }

    Source *lSources[ 2 ] = { mSource1, mSource2 };

    // Open channels
    PvGenEnum *lSourceSelector = mDevice.GetGenParameters()->GetEnum( "SourceSelector" );
    PvGenInteger *lSourceStreamChannel = mDevice.GetGenParameters()->GetInteger( "SourceStreamChannel" );
    if ( lSourceSelector != NULL )
    {
        for ( PvUInt16 i = 0; i < 2; i++ )
        {
            QString lValue;
            lValue.sprintf( "Source%d", i + 1 );

            lSourceSelector->SetValue( lValue.toAscii().data() );

            PvInt64 lChannel = 0;
            lSourceStreamChannel->GetValue( lChannel );

            lResult = lSources[i]->Open( &mDevice, aDeviceInfo->GetIPAddress(), static_cast<PvUInt16>( lChannel ) );
            if ( !lResult.IsOK() )
            {
                PvMessageBox( this, lResult );
                return;
            }
        }
    }
    else
    {
        // No source selector, if transmitter assume 1 on channel 0
        lResult = mSource1->Open( &mDevice, aDeviceInfo->GetIPAddress(), 0 );
        if ( !lResult.IsOK() )
        {
            PvMessageBox( this, lResult );
            return;
        }
    }

    // Sync the UI with our new status
    EnableInterface();
}
Exemple #10
0
int ImperxStream::SetAnalogGain(int gain)
{
    PvResult outcome;
    if (gain >= 0 && gain <= 1023)
    {
        outcome = lDeviceParams->SetIntegerValue("GainRaw",gain);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #11
0
int ImperxStream::SetBlackLevel(int black)
{
    PvResult outcome;
    if (black >= 0 && black <= 1023)
    {
        outcome = lDeviceParams->SetIntegerValue("BlackLevelRaw",black);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #12
0
int ImperxStream::SetROIOffsetY(int y)
{
    PvResult outcome;
    if (y >= 0 && y <= 1295)
    {
        outcome = lDeviceParams->SetIntegerValue("OffsetY", y);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #13
0
int ImperxStream::SetROIOffsetX(int x)
{
    PvResult outcome;
    if (x >= 0 && x <= 965)
    {
        outcome = lDeviceParams->SetIntegerValue("OffsetX", x);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #14
0
int ImperxStream::SetROIHeight(int height)
{
    PvResult outcome;
    if (height >= 1 && height <= 966)
    {
        outcome = lDeviceParams->SetIntegerValue("Height", height);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #15
0
int ImperxStream::SetROIWidth(int width)
{
    PvResult outcome;
    if (width >= 8 && width <= 1296 && (width % 8) == 0)
    {
        outcome = lDeviceParams->SetIntegerValue("Width", width);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;   
}
Exemple #16
0
void PleoraVideo::SetParameter(const std::string& name, const std::string& value) {
    PvGenParameter* par = lDeviceParams->Get(PvString(name.c_str()));
    if(par) {
        PvResult r = par->FromString(PvString(value.c_str()));
        if(!r.IsOK()){
            pango_print_error("Error setting parameter %s to:%s Reason:%s\n", name.c_str(), value.c_str(), r.GetDescription().GetAscii());
        } else {
            pango_print_info("Setting parameter %s to:%s\n", name.c_str(), value.c_str());
        }
    } else {
        pango_print_error("Parameter %s not recognized\n", name.c_str());
    }
}
Exemple #17
0
int ImperxStream::SetExposure(int exposureTime)
{
    PvResult outcome;
    if (exposureTime >= 5 && exposureTime <= 38221)
    {
        outcome = lDeviceParams->SetIntegerValue("ExposureTimeRaw",exposureTime);
        if (outcome.IsSuccess())
        {
            return 0;
        }
    }
    return -1;
}
Exemple #18
0
int ImperxStream::Initialize()
{
    std::cout << "ImperxStream::Initialize starting" << std::endl;
    if(lDeviceInfo == NULL)
    {
        std::cout << "ImperxStream::Initialize No device connected!" << std::endl;
        return -1;
    }

    // Negotiate streaming packet size
    lDevice.NegotiatePacketSize();

    // Open stream - have the PvDevice do it for us
    std::cout << "ImperxStream::Initialize Opening Stream to Device" << std::endl;
    PvResult lResult = lStream.Open( lDeviceInfo->GetIPAddress() );
    if(!lResult.IsOK()) {
        std::cout << "ImperxStream::Initialize error on opening stream: " << lResult << std::endl;
        return -1;
    }

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

    // Set the Buffer size and the Buffer count
    std::cout << "ImperxStream::Initialize Setting Buffer Size" << std::endl;
    lPipeline.SetBufferSize( static_cast<PvUInt32>( lSize ) );
    lPipeline.SetBufferCount( 32 ); // Increase for high frame rate without missing block IDs

    // Have to set the Device IP destination to the Stream
    lDevice.SetStreamDestination( lStream.GetLocalIPAddress(), lStream.GetLocalPort() ); 
    // IMPORTANT: the pipeline needs to be "armed", or started before 
    // we instruct the device to send us images
    std::cout << "ImperxStream::Initialize Starting Pipeline" << std::endl;
    lPipeline.Start();

    // Get stream parameters/stats
    std::cout << "ImperxStream::Initialize Get Stream Parameters" << std::endl;
    lStreamParams = lStream.GetParameters();

    // TLParamsLocked is optional but when present, it MUST be set to 1
    // before sending the AcquisitionStart command
    lDeviceParams->SetIntegerValue( "TLParamsLocked", 1 );

    
    std::cout << "ImperxStream::Initialize Resetting timestamp counter..." << std::endl;
    lDeviceParams->ExecuteCommand( "GevTimestampControlReset" );
    std::cout << "ImperxStream::Initialize Exiting" << std::endl;
    return 0;
}
Exemple #19
0
T GetParam(PvGenParameterArray* params, const char* name)
{
    typedef typename PleoraParamTraits<T>::PvType PvType;
    PvType* param = dynamic_cast<PvType*>( params->Get(name) );
    if(!param) {
        throw std::runtime_error("Incorrect type");
    }
    T ret;
    PvResult res = param->GetValue(ret);
    if(res.IsFailure()) {
        throw std::runtime_error("Cannot get value: " + std::string(res.GetCodeString().GetAscii()) );
    }
    return ret;
}
Exemple #20
0
PvResult Source::Open( PvDevice *aDevice, const PvString &aIPAddress, const PvString &aLocalIPAddress, PvUInt16 aChannel )
{
	// The device should already be connected
	mDevice = aDevice;

    // Is the device multisource?
	PvGenEnum *lSourceSelector = dynamic_cast<PvGenEnum *>( mDevice->GetGenParameters()->Get( "SourceSelector" ) );
	if ( lSourceSelector != NULL )
	{
		PvInt64 lCount;
		lSourceSelector->GetEntriesCount( lCount );

		mMultiSource = ( lCount > 1 );
	}

	// Register acquisition mode update notifications
	PvGenEnum *lMode = mDevice->GetGenParameters()->GetEnum( "AcquisitionMode" );
	if ( lMode != NULL )
	{
		lMode->RegisterEventSink( this );
	}

	// Open stream
	PvResult lResult = mStream->Open( aIPAddress, 0, aChannel, aLocalIPAddress );
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	// Negotiate packet size. On failure, assume the device is set to a valid packet size.
	mDevice->NegotiatePacketSize( aChannel, 1476 );

	// Set stream destination
	lResult = mDevice->SetStreamDestination( mStream->GetLocalIPAddress(), mStream->GetLocalPort(), aChannel );
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

    QCoreApplication::sendEvent( mWidget, new QEvent( static_cast<QEvent::Type>( WM_UPDATEACQMODES ) ) );

    // Ready image reception
	lResult = StartStreaming();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	return PvResult::Code::OK;
}
Exemple #21
0
PvResult Source::StopAcquisition()
{
	PvGenStateStack lState( mDevice->GetGenParameters() );
	if ( mMultiSource )
	{
		// Push change on stack, will be reset when lState goes out of scope
		lState.SetEnumValue( "SourceSelector", mSourceIndex );
	}

	// Use acquisition manager to send the acquisition stop command to the device
	PvResult lResult = mAcquisitionManager->Stop();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	return PvResult::Code::OK;
}
Exemple #22
0
bool SetParam(PvGenParameterArray* params, const char* name, T val)
{
    typedef typename PleoraParamTraits<T>::PvType PvType;
    PvType* param = dynamic_cast<PvType*>( params->Get(name) );
    if(!param) {
        throw std::runtime_error("Unable to get parameter handle: " + std::string(name) );
    }

    if(!param->IsWritable()) {
        throw std::runtime_error("Cannot set value for " + std::string(name) );
    }

    PvResult res = param->SetValue(val);
    if(res.IsFailure()) {
        throw std::runtime_error("Cannot set value: " + std::string(res.GetCodeString().GetAscii()) );
    }
    return true;
}
Exemple #23
0
MLTCam::MLTCam()
{
    data = new ushort[IMAGE_WIDTH*IMAGE_HEIGHT];

    PvDeviceFinderWnd lFinderWnd;
    if (! lFinderWnd.ShowModal().IsOK() )
    {
        return;
    }

    lDeviceInfo = (PvDeviceInfo*)lFinderWnd.GetSelected();

    PvResult lResult;

    if( lDeviceInfo != NULL )
    {
        qDebug() << "MLTCam::Connecting to"
                 << lDeviceInfo->GetManufacturerInfo().GetAscii();

        lDevice = PvDevice::CreateAndConnect(lDeviceInfo, &lResult );
        if ( lResult.IsOK() )
        {
            qDebug() <<  "MLTCam::Connected";
        }
    }
    else
    {
        qDebug() <<   "MLTCam::No device found";
    }


    lResult = lDevice->GetParameters()->GetIntegerValue("Height",height);
    if ( height !=  2944) InitializationCam();

    lStream = OpenStream( lDeviceInfo);
    qDebug() << "MLTCam::OpenStream";
    ConfigureStream( lDevice, lStream );
    qDebug() << "MLTCam::ConfigureStream";
    CreateStreamBuffers( lDevice, lStream, &lBufferList );
    qDebug() << "MLTCam::CreateStreamBuffers";


}
Exemple #24
0
PvResult Source::SetAcquisitionMode( const QString &aAcquisitionMode )
{
	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 )
	{
		PvResult lResult = lMode->SetValue( aAcquisitionMode.toAscii().data() );
	    if ( !lResult.IsOK() )
	    {
	    	return lResult;
	    }
	}

	return PvResult::Code::OK;
}
Exemple #25
0
bool PleoraVideo::GrabNewest( unsigned char* image, bool wait )
{
    PvBuffer *lBuffer0 = NULL;
    PvBuffer *lBuffer = NULL;
    PvResult lOperationResult;

    const uint32_t timeout = wait ? 0xFFFFFFFF : 0;

    PvResult lResult = lStream->RetrieveBuffer( &lBuffer, &lOperationResult, timeout );
    if ( !lResult.IsOK() ) {
        pango_print_warn("Pleora error: %s\n", lResult.GetCodeString().GetAscii() );
        return false;
    }else if( !lOperationResult.IsOK() ) {
        pango_print_warn("Pleora error: %s\n", lOperationResult.GetCodeString().GetAscii() );
        lStream->QueueBuffer( lBuffer );
        return false;
    }

    // We have at least one frame. Capture more until we fail, 0 timeout
    while(true) {
        PvResult lResult = lStream->RetrieveBuffer( &lBuffer0, &lOperationResult, 0 );
        if ( !lResult.IsOK() ) {
            break;
        }else if( !lOperationResult.IsOK() ) {
            lStream->QueueBuffer( lBuffer0 );
            break;
        }else{
            lStream->QueueBuffer( lBuffer );
            lBuffer = lBuffer0;
        }
    }

    bool good = false;

    PvPayloadType lType = lBuffer->GetPayloadType();
    if ( lType == PvPayloadTypeImage )
    {
        PvImage *lImage = lBuffer->GetImage();
        std::memcpy(image, lImage->GetDataPointer(), size_bytes);
        good = true;
    }

    lStream->QueueBuffer( lBuffer );
    return good;
}
Exemple #26
0
bool PleoraVideo::GrabNext( unsigned char* image, bool /*wait*/ )
{
    PvBuffer *lBuffer = NULL;
    PvResult lOperationResult;

    // Retrieve next buffer
    PvResult lResult = lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
    if ( !lResult.IsOK() ) {
        pango_print_warn("Pleora error: %s\n", lResult.GetCodeString().GetAscii() );
        return false;
    }

    bool good = false;

    if ( lOperationResult.IsOK() )
    {
        PvPayloadType lType = lBuffer->GetPayloadType();
        if ( lType == PvPayloadTypeImage )
        {
            PvImage *lImage = lBuffer->GetImage();
            std::memcpy(image, lImage->GetDataPointer(), size_bytes);
            good = true;
        }
    } else {
        pango_print_warn("Pleora error: %s\n", lOperationResult.GetCodeString().GetAscii() );
    }

    lStream->QueueBuffer( lBuffer );
    return good;
}
Exemple #27
0
PvResult Source::StopStreaming()
{
	if ( !mStream->IsOpen() || // Not initialized yet
		 !mPipeline->IsStarted() ) // Not streaming
	{
		return PvResult::Code::NOT_INITIALIZED;
	}

	// Stop display thread
	if ( mDisplayThread->IsRunning() )
	{
	    mDisplayThread->Stop( false );
	}

	// Release acquisition manager
	if ( mAcquisitionManager != NULL )
	{
		mAcquisitionManager->UnregisterEventSink( this );

		delete mAcquisitionManager;
		mAcquisitionManager = NULL;
	}

	// Stop pipeline
	PvResult lResult = mPipeline->Stop();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	// Wait for the display thread to be completed
	if ( mDisplayThread != NULL )
	{
		mDisplayThread->WaitComplete();
	}


	return PvResult::Code::OK;
}
Exemple #28
0
void PleoraVideo::InitDevice(
        const char* model_name, const char* serial_num, size_t index
) {
    lPvSystem = new PvSystem();
    if ( !lPvSystem ) {
        throw pangolin::VideoException("Pleora: Unable to create PvSystem");
    }

    lDeviceInfo = SelectDevice(*lPvSystem, model_name, serial_num, index);
    if ( !lDeviceInfo ) {
        delete lPvSystem;
        throw pangolin::VideoException("Pleora: Unable to select device");
    }

    PvResult lResult;
    lDevice = PvDevice::CreateAndConnect( lDeviceInfo, &lResult );
    if ( !lDevice ) {
        delete lPvSystem;
        throw pangolin::VideoException("Pleora: Unable to connect to device", lResult.GetDescription().GetAscii() );
    }

    lDeviceParams = lDevice->GetParameters();
}
Exemple #29
0
PvResult Source::StartAcquisition()
{
	PvGenStateStack lState( mDevice->GetGenParameters() );
	if ( mMultiSource )
	{
		// Push change on stack, will be reset when lState goes out of scope
		lState.SetEnumValue( "SourceSelector", mSourceIndex );
	}

	// Get payload size
	PvUInt32 lPayloadSize = GetPayloadSize();
	if ( lPayloadSize > 0 )
	{
		// Propagate to pipeline to make sure buffers are big enough
		mPipeline->SetBufferSize( lPayloadSize );
	}

	// Reset pipeline
	mPipeline->Reset();
	mBuffersReallocated = false;

	// Reset stream statistics
	PvGenCommand *lResetStats = mStream->GetParameters()->GetCommand( "Reset" );
	lResetStats->Execute();

	// Reset dislay thread stats (mostly frames displayed per seconds)
	mDisplayThread->ResetStatistics();

	// Use acquisition manager to send the acquisition start command to the device
	PvResult lResult = mAcquisitionManager->Start();
	if ( !lResult.IsOK() )
	{
		return lResult;
	}

	return PvResult::Code::OK;
}
void SavingThread::run()
{
    PvResult lResult = PvResult::Code::NOT_CONNECTED;

    try
    {
        assert( mDevice != NULL );
        assert( mStream != NULL );
        assert( mDlg != NULL );

        if ( ( mSetupDlg->GetRole() == SetupDlg::RoleCtrlData ) ||
             ( mSetupDlg->GetRole() == SetupDlg::RoleCtrl ) ||
             ( mSetupDlg->GetRole() == SetupDlg::RoleMonitor ) )
        {
            mDlg->SetStatus( "Saving the device parameters..." );

            SetPrefix( tr( "Device state save error. " ) );
            lResult = mWriter->Store( mDevice );
            if ( !lResult.IsOK() )
            {
                mResult = lResult.GetCode();
                return;
            }
        }

        if ( ( mSetupDlg->GetRole() == SetupDlg::RoleCtrlData ) ||
            ( mSetupDlg->GetRole() == SetupDlg::RoleData ) )
        {
            mDlg->SetStatus( "Saving the stream parameters..." );

            lResult = mWriter->Store( mStream );
            if ( !lResult.IsOK() )
            {
                mResult = lResult.GetCode();
                return;
            }
        }
    }
    catch ( ... )
    {
        lResult = PvResult::Code::ABORTED;
    }

    mResult = lResult.GetCode();
    return;
}