void MLTCam::Acquire( PvDevice *aDevice, PvStream *aStream ) { // Get device parameters need to control streaming PvGenParameterArray *lDeviceParams = aDevice->GetParameters(); // Map the GenICam AcquisitionStart and AcquisitionStop commands PvGenCommand *lStart = dynamic_cast<PvGenCommand *>( lDeviceParams->Get( "AcquisitionStart" ) ); PvGenCommand *lStop = dynamic_cast<PvGenCommand *>( lDeviceParams->Get( "AcquisitionStop" ) ); // Get stream parameters PvGenParameterArray *lStreamParams = aStream->GetParameters(); // Map a few GenICam stream stats counters PvGenFloat *lFrameRate = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "AcquisitionRate" ) ); PvGenFloat *lBandwidth = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "Bandwidth" ) ); // Enable streaming and send the AcquisitionStart command //qDebug() << "Enabling streaming and sending AcquisitionStart command." << endl; aDevice->StreamEnable(); lStart->Execute(); char lDoodle[] = "|\\-|-/"; int lDoodleIndex = 0; double lFrameRateVal = 0.0; double lBandwidthVal = 0.0; timer = new QTimer; connect(timer, SIGNAL(timeout()), SLOT(WaitForExecution())); timer->start(100); // Abort all buffers from the stream and dequeue // cout << "Aborting buffers still in stream" << endl; // aStream->AbortQueuedBuffers(); // while ( aStream->GetQueuedBufferCount() > 0 ) // { // PvBuffer *lBuffer = NULL; // PvResult lOperationResult; // aStream->RetrieveBuffer( &lBuffer, &lOperationResult ); // } }
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 PleoraVideo::SetDeviceParams(Params& p) { lStart = dynamic_cast<PvGenCommand*>( lDeviceParams->Get( "AcquisitionStart" ) ); lStop = dynamic_cast<PvGenCommand*>( lDeviceParams->Get( "AcquisitionStop" ) ); for(Params::ParamMap::iterator it = p.params.begin(); it != p.params.end(); it++) { if(it->first == "get_temperature"){ getTemp = p.Get<bool>("get_temperature",false); } else { if (it->second == "Execute") { // This is a command, deal with it accordingly. PvGenCommand* cmd = dynamic_cast<PvGenCommand*>(lDeviceParams->Get(it->first.c_str())); if(cmd) { PvResult r = cmd->Execute(); if(!r.IsOK()){ pango_print_error("Error executing command %s Reason:%s\n", it->first.c_str(), r.GetDescription().GetAscii()); } else { pango_print_info("Executed Command %s\n", it->first.c_str()); } bool done; int attempts = 20; do { cmd->IsDone(done); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); attempts--; } while(!done && (attempts > 0)); if(attempts == 0) { pango_print_error("Timeout while waiting for command %s done\n", it->first.c_str()); } } else { pango_print_error("Command %s not recognized\n", it->first.c_str()); } } else { try { PvGenParameter* par = lDeviceParams->Get(PvString(it->first.c_str())); if(par) { PvResult r = par->FromString(PvString(it->second.c_str())); if(!r.IsOK()){ pango_print_error("Error setting parameter %s to:%s Reason:%s\n", it->first.c_str(), it->second.c_str(), r.GetDescription().GetAscii()); } else { pango_print_info("Setting parameter %s to:%s\n", it->first.c_str(), it->second.c_str()); } } else { pango_print_error("Parameter %s not recognized\n", it->first.c_str()); } } catch(std::runtime_error e) { pango_print_error("Set parameter %s: %s\n", it->first.c_str(), e.what()); } } } } // Get Handles to properties we'll be using. lAnalogGain = lDeviceParams->GetInteger("AnalogGain"); lGamma = lDeviceParams->GetFloat("Gamma"); lAnalogBlackLevel = lDeviceParams->GetInteger("AnalogBlackLevel"); lExposure = lDeviceParams->GetFloat("ExposureTime"); lAquisitionMode = lDeviceParams->GetEnum("AcquisitionMode"); lTriggerSource = lDeviceParams->GetEnum("TriggerSource"); lTriggerMode = lDeviceParams->GetEnum("TriggerMode"); if(getTemp) { lTemperatureCelcius = lDeviceParams->GetFloat("DeviceTemperatureCelsius"); pango_print_warn("Warning: get_temperature might add a blocking call taking several ms to each frame read."); } }