diff --git a/pom.xml b/pom.xml index 166adcb0e3f908b06bfa8b8ed693fa0d72aa05d8..04ca5d28c1471c806fa8bab4c2d0974c0f1950cc 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ <groupId>fr.soleil.device</groupId> <artifactId>PulseCounting-${aol}-${mode}</artifactId> - <version>1.6.3-SNAPSHOT</version> + <version>1.6.3</version> <packaging>nar</packaging> <name>PulseCounting</name> @@ -43,7 +43,7 @@ <dependency> <groupId>fr.soleil.lib</groupId> <artifactId>NI660Xsl-${aol}-${library}-${mode}</artifactId> - <version>1.5.0</version> + <version>1.5.1</version> </dependency> <dependency> <groupId>fr.soleil.lib</groupId> diff --git a/src/BufferedCounterDt.cpp b/src/BufferedCounterDt.cpp index e55d40a5fb4e3646cc3f527f5c39f8e6e94874ad..f5e87d15497c202cfcacf7ea7505e7197a688d3e 100644 --- a/src/BufferedCounterDt.cpp +++ b/src/BufferedCounterDt.cpp @@ -386,13 +386,27 @@ void BufferedCounterDt::stopCnt() try { //- from NI660Xsl - ni660Xsl::BufferedDTMeasurement::abort(); // we use abort to stop counting immediately - ni660Xsl::BufferedDTMeasurement::release(); // sets an UNKNOWN state in NI660Xsl lib ! + // we use abort to stop counting immediately + // sets an UNKNOWN state in NI660Xsl lib ! + ni660Xsl::BufferedDTMeasurement::abort_and_release(); } - catch(...) + catch(ni660Xsl::DAQException & nie) + { + if (nie.errors[0].code > 0) + { + WARN_STREAM << "BufferedCounterDt::stopCnt() - Trying to abort during buffer acquisition, retry once..." << std::endl; + ni660Xsl::BufferedDTMeasurement::abort_and_release(); + } + else + { + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterDt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + } + } + catch(...) { - // DAQmx 9.x abort pb workaround - ERROR_STREAM << "BufferedCounterDt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterDt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; } } diff --git a/src/BufferedCounterEvt.cpp b/src/BufferedCounterEvt.cpp index 72ba367c201a793bc03873044349ef5d022f4452..2c655d724207cac00647fea1b99d49fbfed683a7 100644 --- a/src/BufferedCounterEvt.cpp +++ b/src/BufferedCounterEvt.cpp @@ -419,13 +419,27 @@ void BufferedCounterEvt::stopCnt() try { //- from NI660Xsl - ni660Xsl::BufferedEventCounting::abort(); // we use abort to stop counting immediately - ni660Xsl::BufferedEventCounting::release(); // sets an UNKNOWN state in NI660Xsl lib ! + // we use abort to stop counting immediately + // sets an UNKNOWN state in NI660Xsl lib ! + ni660Xsl::BufferedEventCounting::abort_and_release(); } - catch(...) + catch(ni660Xsl::DAQException & nie) + { + if (nie.errors[0].code > 0) + { + WARN_STREAM << "BufferedCounterEvt::stopCnt() - Trying to abort during buffer acquisition, retry once..." << std::endl; + ni660Xsl::BufferedEventCounting::abort_and_release(); + } + else + { + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterEvt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + } + } + catch(...) { - // DAQmx 9.x abort pb workaround - ERROR_STREAM << "BufferedCounterEvt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterEvt::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; } } diff --git a/src/BufferedCounterPeriod.cpp b/src/BufferedCounterPeriod.cpp index 9e4033d5c6a2f59ce575e8f280be8644c8807509..3fbdc452f079c2bb4c92b0f57eeb790dd092d901 100644 --- a/src/BufferedCounterPeriod.cpp +++ b/src/BufferedCounterPeriod.cpp @@ -387,13 +387,27 @@ void BufferedCounterPeriod::stopCnt() try { //- from NI660Xsl - ni660Xsl::BufferedPeriodMeasurement::abort(); // we use abort to stop counting immediately - ni660Xsl::BufferedPeriodMeasurement::release(); // sets an UNKNOWN state in NI660Xsl lib ! + // we use abort to stop counting immediately + // sets an UNKNOWN state in NI660Xsl lib ! + ni660Xsl::BufferedPeriodMeasurement::abort_and_release(); } - catch(...) + catch(ni660Xsl::DAQException & nie) + { + if (nie.errors[0].code > 0) + { + WARN_STREAM << "BufferedCounterPeriod::stopCnt() - Trying to abort during buffer acquisition, retry once..." << std::endl; + ni660Xsl::BufferedPeriodMeasurement::abort_and_release(); + } + else + { + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterPeriod::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + } + } + catch(...) { - // DAQmx 9.x abort pb workaround - ERROR_STREAM << "BufferedCounterPeriod::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterPeriod::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; } } diff --git a/src/BufferedCounterPos.cpp b/src/BufferedCounterPos.cpp index 7dc900a9fd88d8e5c457c10edcc15e64c0e20f83..5025d4876c5273b249f55f93dcf4f93ab1789ab1 100644 --- a/src/BufferedCounterPos.cpp +++ b/src/BufferedCounterPos.cpp @@ -454,13 +454,27 @@ void BufferedCounterPos::stopCnt() try { //- from NI660Xsl - ni660Xsl::BufferedPositionMeasurement::abort(); // we use abort to stop counting immediately - ni660Xsl::BufferedPositionMeasurement::release(); // sets an UNKNOWN state in NI660Xsl lib ! + // we use abort to stop counting immediately + // sets an UNKNOWN state in NI660Xsl lib ! + ni660Xsl::BufferedPositionMeasurement::abort_and_release(); } - catch(...) + catch(ni660Xsl::DAQException & nie) + { + if (nie.errors[0].code > 0) + { + WARN_STREAM << "BufferedCounterPos::stopCnt() - Trying to abort during buffer acquisition, retry once..." << std::endl; + ni660Xsl::BufferedPositionMeasurement::abort_and_release(); + } + else + { + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterPos::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + } + } + catch(...) { - // DAQmx 9.x abort pb workaround - ERROR_STREAM << "BufferedCounterPos::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; + // DAQmx 9.x abort pb workaround + WARN_STREAM << "BufferedCounterPos::stopCnt() - Aborting counter generates exception, do nothing..." << std::endl; } } diff --git a/src/PulseCounting.cpp b/src/PulseCounting.cpp index baffb61496390d4d622b675ad044aa3d6bf9dbec..f0f8191b1e051b99450dd6f644e012b4e9cbfcfd 100644 --- a/src/PulseCounting.cpp +++ b/src/PulseCounting.cpp @@ -209,44 +209,43 @@ void PulseCounting::init_device() return; } + // initialize the manager //-------------------------------------------- - - //- set acquisition parameters try { - m_manager->set_acquisition_parameters(m_acq_param); + m_manager->init(m_board_arch); } catch (Tango::DevFailed & df) { ERROR_STREAM << df << std::endl; - m_status = "initialization failed [failed to set acquisition parameters"; + m_status = "initialization failed - Manager creation failed [see device log for details]"; m_state = Tango::FAULT; return; } catch (...) { - ERROR_STREAM << "initialization failed - failed to set acquisition parameters" << std::endl; - m_status = "initialization failed [failed to set acquisition parameters]"; + ERROR_STREAM << "initialization failed - failed to initialize manager" << std::endl; + m_status = "initialization failed [failed to initialize manager]"; m_state = Tango::FAULT; return; } - // initialize the manager + //- set acquisition parameters try { - m_manager->init(m_board_arch); + m_manager->set_acquisition_parameters(m_acq_param); } catch (Tango::DevFailed & df) { ERROR_STREAM << df << std::endl; - m_status = "initialization failed - Manager creation failed [see device log for details]"; + m_status = "initialization failed [failed to set acquisition parameters"; m_state = Tango::FAULT; return; } catch (...) { - ERROR_STREAM << "initialization failed - failed to initialize manager" << std::endl; - m_status = "initialization failed [failed to initialize manager]"; + ERROR_STREAM << "initialization failed - failed to set acquisition parameters" << std::endl; + m_status = "initialization failed [failed to set acquisition parameters]"; m_state = Tango::FAULT; return; } @@ -931,49 +930,48 @@ void PulseCounting::write_acquisitionMode(Tango::WAttribute &attr) _CPTC("PulseCounting::write_acquisitionMode")); } + // initialize the manager //-------------------------------------------- - - //- set acquisition parameters try { - m_manager->set_acquisition_parameters(m_acq_param); + m_manager->init(m_board_arch); } catch (Tango::DevFailed & df) { ERROR_STREAM << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("DEVICE_ERROR"), - _CPTC("Failed to set acquisition parameters"), + _CPTC("Failed to init manager"), _CPTC("PulseCounting::write_acquisitionMode")); } catch (...) { - ERROR_STREAM << "failed to set acquisition parameters" << std::endl; + ERROR_STREAM << "failed to init manager" << std::endl; THROW_DEVFAILED( _CPTC("DEVICE_ERROR"), - _CPTC("Failed to set acquisition parameters"), + _CPTC("Failed to init manager"), _CPTC("PulseCounting::write_acquisitionMode")); } - // initialize the manager + //- set acquisition parameters try { - m_manager->init(m_board_arch); + m_manager->set_acquisition_parameters(m_acq_param); } catch (Tango::DevFailed & df) { ERROR_STREAM << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("DEVICE_ERROR"), - _CPTC("Failed to init manager"), + _CPTC("Failed to set acquisition parameters"), _CPTC("PulseCounting::write_acquisitionMode")); } catch (...) { - ERROR_STREAM << "failed to init manager" << std::endl; + ERROR_STREAM << "failed to set acquisition parameters" << std::endl; THROW_DEVFAILED( _CPTC("DEVICE_ERROR"), - _CPTC("Failed to init manager"), + _CPTC("Failed to set acquisition parameters"), _CPTC("PulseCounting::write_acquisitionMode")); } diff --git a/src/PulseCountingManager.cpp b/src/PulseCountingManager.cpp index b36d83c86f4c22256ad279d9048493d83848e25b..752a2994d79a83126c24e781b7d9029973509749 100644 --- a/src/PulseCountingManager.cpp +++ b/src/PulseCountingManager.cpp @@ -73,7 +73,6 @@ PulseCountingManager::PulseCountingManager (Tango::DeviceImpl * hostDevice) m_requestedStop = false; m_acq_running = false; m_firstStart = true; - m_isHwInitNeeded = true; try { @@ -386,38 +385,6 @@ void PulseCountingManager::init(BoardArchitecture p_board_arch) _CPTC("Failed to create clock generator"), _CPTC("PulseCountingManager::init")); } - - if (m_isHwInitNeeded) - { - m_isHwInitNeeded = false; - - // Configure clock - ClockConfig l_cfg; - l_cfg.channelName = CLOCK_INTERNAL; - l_cfg.boardName = m_board_arch.boardList[0]; // take 1st board for clock - l_cfg.timebaseScaling = m_acq_param.timebaseScaling; - - try - { - this->m_clock_generator->init(l_cfg); - } - catch( Tango::DevFailed &df ) - { - ERROR_STREAM << "Init clock failed: " << df << std::endl; - RETHROW_DEVFAILED(df, - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManager::init")); - } - catch(...) - { - ERROR_STREAM << "Init clock failed." << std::endl; - THROW_DEVFAILED( - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManager::init")); - } - } } INFO_STREAM << "PulseCountingManager::init OK" << endl; @@ -1042,7 +1009,6 @@ void PulseCountingManager::write_integration_time(yat4tango::DynamicAttributeWri // memorize new value yat4tango::PropertyHelper::set_property<double>(this->m_board_arch.hostDevice, "__integrationTime", m_acq_param.integrationTime); - m_isHwInitNeeded = true; } } // namespace PulseCounting_ns diff --git a/src/PulseCountingManagerBuffered.cpp b/src/PulseCountingManagerBuffered.cpp index a9b170b8a9dbb708376518d7d5480e96d8b48e6f..2bcb12d6cd9dc324156d8c1aa67b4d0f4af9716b 100644 --- a/src/PulseCountingManagerBuffered.cpp +++ b/src/PulseCountingManagerBuffered.cpp @@ -498,37 +498,32 @@ void PulseCountingManagerBuffered::start_i() // then configure new clock (if needed) if (m_board_arch.clockGeneration) { - if (m_isHwInitNeeded) - { - m_isHwInitNeeded = false; - - // Configure clock - ClockConfig l_cfg; - l_cfg.channelName = CLOCK_INTERNAL; - l_cfg.boardName = m_board_arch.boardList[0]; // take 1st board for clock - l_cfg.timebaseScaling = m_acq_param.timebaseScaling; + // Configure clock + ClockConfig l_cfg; + l_cfg.channelName = CLOCK_INTERNAL; + l_cfg.boardName = m_board_arch.boardList[0]; // take 1st board for clock + l_cfg.timebaseScaling = m_acq_param.timebaseScaling; - try - { - this->m_clock_generator->init(l_cfg); - } - catch( Tango::DevFailed &df ) - { - ERROR_STREAM << "Init clock failed: " << df << std::endl; - RETHROW_DEVFAILED(df, - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManagerBuffered::start_i")); - } - catch(...) - { - ERROR_STREAM << "Init clock failed." << std::endl; - THROW_DEVFAILED( - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManagerBuffered::start_i")); - } - } + try + { + this->m_clock_generator->init(l_cfg); + } + catch( Tango::DevFailed &df ) + { + ERROR_STREAM << "Init clock failed: " << df << std::endl; + RETHROW_DEVFAILED(df, + _CPTC("SOFTWARE_FAILURE"), + _CPTC("Init clock failed."), + _CPTC("PulseCountingManagerBuffered::start_i")); + } + catch(...) + { + ERROR_STREAM << "Init clock failed." << std::endl; + THROW_DEVFAILED( + _CPTC("SOFTWARE_FAILURE"), + _CPTC("Init clock failed."), + _CPTC("PulseCountingManagerBuffered::start_i")); + } } // init nexus manager (if needed) diff --git a/src/PulseCountingManagerScalar.cpp b/src/PulseCountingManagerScalar.cpp index 96469f9dafdc4467e4e392e3b30fc994c2628673..c27d9fdd458fa27cb3e243b0fc2b4ea6721fa4fc 100644 --- a/src/PulseCountingManagerScalar.cpp +++ b/src/PulseCountingManagerScalar.cpp @@ -427,108 +427,103 @@ void PulseCountingManagerScalar::start_i() // then configure new clock (if needed) if (m_board_arch.clockGeneration) { - if (m_isHwInitNeeded) - { - m_isHwInitNeeded = false; - - // Configure clock - ClockConfig l_cfg; - l_cfg.channelName = CLOCK_INTERNAL; - l_cfg.boardName = m_board_arch.boardList[0]; // take 1st board for clock - l_cfg.timebaseScaling = m_acq_param.timebaseScaling; + // Configure clock + ClockConfig l_cfg; + l_cfg.channelName = CLOCK_INTERNAL; + l_cfg.boardName = m_board_arch.boardList[0]; // take 1st board for clock + l_cfg.timebaseScaling = m_acq_param.timebaseScaling; - try - { - this->m_clock_generator->init(l_cfg); - } - catch( Tango::DevFailed &df ) - { - ERROR_STREAM << "Init clock failed: " << df << std::endl; - RETHROW_DEVFAILED(df, - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManagerScalar::start_i")); - } - catch(...) - { - ERROR_STREAM << "Init clock failed." << std::endl; - THROW_DEVFAILED( - _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init clock failed."), - _CPTC("PulseCountingManagerScalar::start_i")); - } - } + try + { + this->m_clock_generator->init(l_cfg); + } + catch( Tango::DevFailed &df ) + { + ERROR_STREAM << "Init clock failed: " << df << std::endl; + RETHROW_DEVFAILED(df, + _CPTC("SOFTWARE_FAILURE"), + _CPTC("Init clock failed."), + _CPTC("PulseCountingManagerScalar::start_i")); + } + catch(...) + { + ERROR_STREAM << "Init clock failed." << std::endl; + THROW_DEVFAILED( + _CPTC("SOFTWARE_FAILURE"), + _CPTC("Init clock failed."), + _CPTC("PulseCountingManagerScalar::start_i")); + } } - // init nexus manager (if needed) + // init nexus manager (if needed) // do not re-initialize nexus file in continuous acquisition (except in 1st start) if (m_acq_param.nexusFileGeneration && m_firstStart) { // re-build nexus item list this->build_nexus_item_list(); - try - { - // Initialize nexus manager - m_nexus_manager->initNexusAcquisition( + try + { + // Initialize nexus manager + m_nexus_manager->initNexusAcquisition( m_acq_param.nexusTargetPath, m_acq_param.nexusFileName, 0, // infinite mode m_acq_param.nexusNbPerFile, m_nx_items); - } - catch( Tango::DevFailed &df ) - { + } + catch( Tango::DevFailed &df ) + { this->releaseObjects(); - ERROR_STREAM << "Init Nexus manager failed: " << df << std::endl; - RETHROW_DEVFAILED(df, + ERROR_STREAM << "Init Nexus manager failed: " << df << std::endl; + RETHROW_DEVFAILED(df, _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init Nexus manager failed."), - _CPTC("PulseCountingManagerScalar::start_i")); + _CPTC("Init Nexus manager failed."), + _CPTC("PulseCountingManagerScalar::start_i")); } catch(...) { this->releaseObjects(); ERROR_STREAM << "Init Nexus manager failed: caught[...]" << std::endl; - THROW_DEVFAILED( + THROW_DEVFAILED( _CPTC("SOFTWARE_FAILURE"), - _CPTC("Init Nexus manager failed."), - _CPTC("PulseCountingManagerScalar::start_i")); + _CPTC("Init Nexus manager failed."), + _CPTC("PulseCountingManagerScalar::start_i")); } } // configure counters - GenericCounterMap_t::iterator l_it; - for (l_it = m_counterList.begin(); l_it != m_counterList.end(); ++l_it) - { - GenericCounterInterface * l_int = l_it->second; - try - { - if (l_int) - { + GenericCounterMap_t::iterator l_it; + for (l_it = m_counterList.begin(); l_it != m_counterList.end(); ++l_it) + { + GenericCounterInterface * l_int = l_it->second; + try + { + if (l_int) + { l_int->init(m_counterListConfig[l_int]); - l_int->configure(m_counterListConfig[l_int]); - } - } - catch( Tango::DevFailed &df ) - { + l_int->configure(m_counterListConfig[l_int]); + } + } + catch( Tango::DevFailed &df ) + { this->releaseObjects(); ERROR_STREAM << "Counter configuration failed: " << df << std::endl; - RETHROW_DEVFAILED(df, + RETHROW_DEVFAILED(df, _CPTC("SOFTWARE_FAILURE"), - _CPTC("Counter configuration failed!"), - _CPTC("PulseCountingManagerScalar::start_i")); - } - catch(...) - { + _CPTC("Counter configuration failed!"), + _CPTC("PulseCountingManagerScalar::start_i")); + } + catch(...) + { this->releaseObjects(); ERROR_STREAM << "Counter configure failed: caught [...]" << std::endl; - THROW_DEVFAILED( + THROW_DEVFAILED( _CPTC("SOFTWARE_FAILURE"), - _CPTC("Counter configuration failed!"), - _CPTC("PulseCountingManagerScalar::start_i")); - } - } + _CPTC("Counter configuration failed!"), + _CPTC("PulseCountingManagerScalar::start_i")); + } + } // start counters for (l_it = m_counterList.begin(); l_it != m_counterList.end(); ++l_it)