diff --git a/include/DoocsIfff.h b/include/DoocsIfff.h index 4d277e01dcf1be4ef691d2f4f24113fd283337cc..943d6a972caa010d0fe634963499215b337e715f 100644 --- a/include/DoocsIfff.h +++ b/include/DoocsIfff.h @@ -39,6 +39,7 @@ namespace ChimeraTK { void sendToApplication(); void registerVariable(const ChimeraTK::TransferElementAbstractor& var); void registerIfffSources(); + void checkSourceConsistency(); boost::shared_ptr<NDRegisterAccessor<int>> _i1Value; boost::shared_ptr<NDRegisterAccessor<float>> _f1Value; diff --git a/src/DoocsIfff.cc b/src/DoocsIfff.cc index 68fbdb799902004b12742a0a03b6de9ee6241aa7..f411e5a159beaf2c1baf02a234e8a3cf55352b70 100644 --- a/src/DoocsIfff.cc +++ b/src/DoocsIfff.cc @@ -1,6 +1,7 @@ #include "DoocsIfff.h" #include "DoocsUpdater.h" +#include <ChimeraTK/Exception.h> #include <ChimeraTK/OneDRegisterAccessor.h> #include <ChimeraTK/ScalarRegisterAccessor.h> #include <doocs/EventId.h> @@ -14,6 +15,7 @@ namespace ChimeraTK { : D_ifff(eqFct, doocsPropertyName), _i1Value(i1Value), _f1Value(f1Value), _f2Value(f2Value), _f3Value(f3Value), _updater(updater), _eqFct(eqFct), isWriteable(_i1Value->isWriteable() && _f1Value->isWriteable() && _f2Value->isWriteable() && _f3Value->isWriteable()) { + checkSourceConsistency(); registerIfffSources(); } @@ -26,12 +28,24 @@ namespace ChimeraTK { : D_ifff(doocsPropertyName, eqFct), _i1Value(i1Value), _f1Value(f1Value), _f2Value(f2Value), _f3Value(f3Value), _updater(updater), _eqFct(eqFct), isWriteable(_i1Value->isWriteable() && _f1Value->isWriteable() && _f2Value->isWriteable() && _f3Value->isWriteable()) { + checkSourceConsistency(); registerIfffSources(); } + void DoocsIfff::checkSourceConsistency() { + bool areAllSourcesReadable = + (_i1Value->isReadable() && _f1Value->isReadable() && _f2Value->isReadable() && _f3Value->isReadable()); + if(not areAllSourcesReadable) { + ChimeraTK::logic_error("Doocs Adapter IFFF configuration Error: not all IFFF sources are readable"); + } + + bool areAllSourcesWritable = + (_i1Value->isWriteable() && _f1Value->isWriteable() && _f2Value->isWriteable() && _f3Value->isWriteable()); + if(not areAllSourcesWritable) { + ChimeraTK::logic_error("Doocs Adapter IFFF configuration Error: not all IFFF sources are writable"); + } + } void DoocsIfff::registerIfffSources() { - // FIXME: What if not all 4 are readable? is it still valid to add - // all to a consistency group then? registerVariable(OneDRegisterAccessor<int>(_i1Value)); registerVariable(OneDRegisterAccessor<float>(_f1Value)); registerVariable(OneDRegisterAccessor<float>(_f2Value));