From 7b077c128a45e79f6ac10304efd4f1a9c21149b2 Mon Sep 17 00:00:00 2001 From: vargheseg <19566373+vargheseg@users.noreply.github.com> Date: Wed, 13 May 2020 11:13:55 +0200 Subject: [PATCH] Check IFFF sources for consistency All IFFF sources must be consistently readable/writable. A logic error is thrown if this is not the case. --- include/DoocsIfff.h | 1 + src/DoocsIfff.cc | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/DoocsIfff.h b/include/DoocsIfff.h index 4d277e0..943d6a9 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 68fbdb7..f411e5a 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)); -- GitLab