diff --git a/src/m2k_impl.cpp b/src/m2k_impl.cpp index d4631531..68bd08ed 100644 --- a/src/m2k_impl.cpp +++ b/src/m2k_impl.cpp @@ -144,6 +144,11 @@ void M2kImpl::deinitialize() if (aout_impl) { aout_impl->deinitialize(); } + + auto trigger_impl = dynamic_cast(m_trigger); + if (trigger_impl) { + trigger_impl->deinitialize(); + } } void M2kImpl::reset() diff --git a/src/m2khardwaretrigger_impl.cpp b/src/m2khardwaretrigger_impl.cpp index 05fecc49..a77ced18 100644 --- a/src/m2khardwaretrigger_impl.cpp +++ b/src/m2khardwaretrigger_impl.cpp @@ -181,6 +181,16 @@ void M2kHardwareTriggerImpl::M2kHardwareTriggerImpl::reset() setDigitalExternalCondition(NO_TRIGGER_DIGITAL); } +void libm2k::M2kHardwareTriggerImpl::deinitialize() +{ + for (unsigned int i = 0; i < m_analog_channels.size(); i++) { + setAnalogMode(i, ALWAYS); + } + for (unsigned int i = 0; i < m_digital_channels.size(); i++) { + setDigitalCondition(i, NO_TRIGGER_DIGITAL); + } +} + bool M2kHardwareTriggerImpl::hasExternalTriggerOut() const { return m_logic_channels.at(1)->hasAttribute("out_select"); @@ -622,4 +632,4 @@ M2K_TRIGGER_STATUS_ANALOG_OUT M2kHardwareTriggerImpl::getAnalogOutTriggerStatus( "the current board; Check the firmware version.", libm2k::EXC_INVALID_FIRMWARE_VERSION); return DISABLED; -} \ No newline at end of file +} diff --git a/src/m2khardwaretrigger_impl.hpp b/src/m2khardwaretrigger_impl.hpp index e5901a90..4b4b5104 100644 --- a/src/m2khardwaretrigger_impl.hpp +++ b/src/m2khardwaretrigger_impl.hpp @@ -44,6 +44,7 @@ class M2kHardwareTriggerImpl : public M2kHardwareTrigger virtual ~M2kHardwareTriggerImpl() override; void reset() override; + virtual void deinitialize(); int getAnalogLevelRaw(unsigned int chnIdx) override; void setAnalogLevelRaw(unsigned int chnIdx, int level) override; diff --git a/src/m2khardwaretrigger_v0.24_impl.cpp b/src/m2khardwaretrigger_v0.24_impl.cpp index f43d8ef5..155293b3 100644 --- a/src/m2khardwaretrigger_v0.24_impl.cpp +++ b/src/m2khardwaretrigger_v0.24_impl.cpp @@ -85,6 +85,11 @@ void M2kHardwareTriggerV024Impl::reset() setDigitalSource(SRC_NONE); } +void libm2k::M2kHardwareTriggerV024Impl::deinitialize() +{ + M2kHardwareTriggerImpl::deinitialize(); +} + void M2kHardwareTriggerV024Impl::setAnalogExternalOutSelect(M2K_TRIGGER_OUT_SELECT out_select) { unsigned int TRIGGER_OUT_PIN = 1; diff --git a/src/m2khardwaretrigger_v0.24_impl.hpp b/src/m2khardwaretrigger_v0.24_impl.hpp index 85869975..cb49c20f 100644 --- a/src/m2khardwaretrigger_v0.24_impl.hpp +++ b/src/m2khardwaretrigger_v0.24_impl.hpp @@ -44,6 +44,7 @@ class M2kHardwareTriggerV024Impl : public M2kHardwareTriggerImpl virtual ~M2kHardwareTriggerV024Impl(); void reset(); + void deinitialize() override; void setAnalogExternalOutSelect(M2K_TRIGGER_OUT_SELECT output_select); M2K_TRIGGER_OUT_SELECT getAnalogExternalOutSelect(); diff --git a/src/m2khardwaretrigger_v0.33_impl.cpp b/src/m2khardwaretrigger_v0.33_impl.cpp index 7b8aaa53..101e1324 100644 --- a/src/m2khardwaretrigger_v0.33_impl.cpp +++ b/src/m2khardwaretrigger_v0.33_impl.cpp @@ -75,6 +75,12 @@ void M2kHardwareTriggerV033Impl::reset() setAnalogOutTriggerStatus(DISABLED); } +void libm2k::M2kHardwareTriggerV033Impl::deinitialize() +{ + M2kHardwareTriggerV024Impl::deinitialize(); + setAnalogOutTriggerStatus(DISABLED); +} + void M2kHardwareTriggerV033Impl::setAnalogOutTriggerSource(M2K_TRIGGER_SOURCE_OUT src) { if (src < 0 || src >= m_trigger_source_out.size()) diff --git a/src/m2khardwaretrigger_v0.33_impl.hpp b/src/m2khardwaretrigger_v0.33_impl.hpp index 4f8b1c6c..f46cc53a 100644 --- a/src/m2khardwaretrigger_v0.33_impl.hpp +++ b/src/m2khardwaretrigger_v0.33_impl.hpp @@ -43,6 +43,7 @@ class M2kHardwareTriggerV033Impl : public M2kHardwareTriggerV024Impl virtual ~M2kHardwareTriggerV033Impl(); void reset(); + void deinitialize() override; void setAnalogOutTriggerSource(M2K_TRIGGER_SOURCE_OUT src); M2K_TRIGGER_SOURCE_OUT getAnalogOutTriggerSource() const;