From aa0bd46e8a183dc42a215fdb7b83c5f59684e4df Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Fri, 14 Jun 2019 16:31:13 +0200
Subject: [PATCH] bug fix: if data matching is disabled, do not send data twice

---
 src/DoocsPVFactory.cc | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/DoocsPVFactory.cc b/src/DoocsPVFactory.cc
index a938411..ff446a5 100644
--- a/src/DoocsPVFactory.cc
+++ b/src/DoocsPVFactory.cc
@@ -82,7 +82,9 @@ namespace ChimeraTK {
       }
       boost::dynamic_pointer_cast<DoocsProcessScalar<DOOCS_PRIMITIVE_T, DOOCS_T>>(doocsPV)->setMacroPulseNumberSource(
           mpnDecorated);
-      _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      if(propertyDescription.dataMatching != DataConsistencyGroup::MatchingMode::none) {
+        _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      }
     }
 
     // set data matching mode
@@ -110,8 +112,8 @@ namespace ChimeraTK {
 
     assert(processArray->getNumberOfChannels() == 1);
     assert(processArray->getNumberOfSamples() == 1); // array of strings is not supported
-    boost::shared_ptr<D_fct> doocsPV(
-        new DoocsProcessScalar<std::string, D_textUnifier>(_eqFct, propertyDescription.name.c_str(), processArray, _updater));
+    boost::shared_ptr<D_fct> doocsPV(new DoocsProcessScalar<std::string, D_textUnifier>(
+        _eqFct, propertyDescription.name.c_str(), processArray, _updater));
 
     // set read only mode if configures in the xml file or for output variables
     if(!processArray->isWriteable() || !propertyDescription.isWriteable) {
@@ -139,7 +141,9 @@ namespace ChimeraTK {
       }
       boost::dynamic_pointer_cast<DoocsProcessScalar<std::string, D_textUnifier>>(doocsPV)->setMacroPulseNumberSource(
           mpnDecorated);
-      _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      if(propertyDescription.dataMatching != DataConsistencyGroup::MatchingMode::none) {
+        _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      }
     }
 
     // set data matching mode
@@ -214,7 +218,9 @@ namespace ChimeraTK {
             "' is used as a macro pulse number source, but it is not readable.");
       }
       boost::dynamic_pointer_cast<DoocsSpectrum>(doocsPV)->setMacroPulseNumberSource(mpnDecorated);
-      _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      if(spectrumDescription.dataMatching != DataConsistencyGroup::MatchingMode::none) {
+        _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+      }
     }
 
     // set data matching mode
@@ -414,7 +420,9 @@ boost::shared_ptr<D_fct> DoocsPVFactory::typedCreateDoocsArray(AutoPropertyDescr
     }
     boost::dynamic_pointer_cast<DoocsProcessArray<DOOCS_T, DOOCS_PRIMITIVE_T>>(doocsPV)->setMacroPulseNumberSource(
         mpnDecorated);
-    _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+    if(propertyDescription.dataMatching != DataConsistencyGroup::MatchingMode::none) {
+      _updater.addVariable(ChimeraTK::ScalarRegisterAccessor<int64_t>(mpnDecorated), _eqFct, [] {});
+    }
   }
 
   // set data matching mode
-- 
GitLab