From fa372bbe8db8b7ece27c9b32114153d3c16bd56e Mon Sep 17 00:00:00 2001 From: Martin Hierholzer <martin.hierholzer@desy.de> Date: Fri, 4 Nov 2016 17:07:28 +0100 Subject: [PATCH] partial fix for problems due to moving to new ControlSystemAdapter structure: allocate and use the buffer from the NDRegisterAccessor tests still do not pass --- include/DeviceAccessor.h | 90 +++++++++++++++++----------------------- include/FanOut.h | 8 ++++ 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/include/DeviceAccessor.h b/include/DeviceAccessor.h index fb26f4b3..7fa28eac 100644 --- a/include/DeviceAccessor.h +++ b/include/DeviceAccessor.h @@ -24,77 +24,63 @@ namespace ChimeraTK { /** */ DeviceAccessor(boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> ndRegisterAccessor, VariableDirection direction, UpdateMode mode) - : impl(ndRegisterAccessor), _direction(direction), _mode(mode) - {} - - public: - - void set(ChimeraTK::ProcessScalar<UserType> const & other) { - impl->accessData(0) = other.get(); - } - - void set(UserType const & t) { - impl->accessData(0) = t; - } - - operator UserType() const { - return impl->accessData(0); - } - - UserType get() const { - return impl->accessData(0); - } - - const std::type_info& getValueType() const { - return typeid(UserType); + : mtca4u::NDRegisterAccessor<UserType>(ndRegisterAccessor->getName()), + impl(ndRegisterAccessor), + _direction(direction), + _mode(mode) + { + mtca4u::NDRegisterAccessor<UserType>::buffer_2D.resize( impl->getNumberOfChannels() ); + for(size_t i=0; i<impl->getNumberOfChannels(); i++) { + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[i].resize( impl->getNumberOfSamples() ); + } } - - bool isReadable() const { - return _direction == VariableDirection::consuming; + + void read() { + impl->read(); + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0)); } - bool isReadOnly() const { - return _direction == VariableDirection::consuming; + bool readNonBlocking() { + bool ret = impl->readNonBlocking(); + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0)); + return ret; } - bool isWriteable() const { - return _direction == VariableDirection::feeding; + void write() { + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0)); + impl->write(); + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0)); } - - TimeStamp getTimeStamp() const { - return TimeStamp(); + + unsigned int getNInputQueueElements() const { + return impl->getNInputQueueElements(); } - - bool readNonBlocking() { - assert(_direction == VariableDirection::consuming); - if(impl->getNInputQueueElements() == 0) return false; - impl->read(); - return true; + + bool isSameRegister(const boost::shared_ptr<const mtca4u::TransferElement>& other) const { + return impl->isSameRegister(other); } - void read(){ - throw std::logic_error("Blocking read is not supported by process array."); + bool isReadOnly() const { + return impl->isReadOnly(); } - void write() { - assert(_direction == VariableDirection::feeding); - impl->write(); + bool isReadable() const { + return impl->isReadable(); } - bool isSameRegister(const boost::shared_ptr<const mtca4u::TransferElement>& e) const{ - // only true if the very instance of the transfer element is the same - return e.get() == this; + bool isWriteable() const { + return impl->isWriteable(); } - std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements(){ - return { boost::enable_shared_from_this<mtca4u::TransferElement>::shared_from_this() }; + std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements() { + return impl->getHardwareAccessingElements(); } - void replaceTransferElement(boost::shared_ptr<mtca4u::TransferElement>){ - // You can't replace anything here. Just do nothing. + void replaceTransferElement(boost::shared_ptr<mtca4u::TransferElement> other) { + impl->replaceTransferElement(other); } - protected: + protected: boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> impl; VariableDirection _direction; diff --git a/include/FanOut.h b/include/FanOut.h index 24c14c2d..ebbeb871 100644 --- a/include/FanOut.h +++ b/include/FanOut.h @@ -33,6 +33,10 @@ namespace ChimeraTK { throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>( "The FanOut has been constructed with a wrong output implementation type!"); } + mtca4u::NDRegisterAccessor<UserType>::buffer_2D.resize( impl->getNumberOfChannels() ); + for(size_t i=0; i<impl->getNumberOfChannels(); i++) { + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[i].resize( impl->getNumberOfSamples() ); + } } /** Use this constructor if the FanOut should be a feeding implementation. */ @@ -61,6 +65,10 @@ namespace ChimeraTK { } if(impl == nullptr) { // the first slave will be used as a "main" implementation, if impl = castedSlave; // none was specified at construction + mtca4u::NDRegisterAccessor<UserType>::buffer_2D.resize( impl->getNumberOfChannels() ); + for(size_t i=0; i<impl->getNumberOfChannels(); i++) { + mtca4u::NDRegisterAccessor<UserType>::buffer_2D[i].resize( impl->getNumberOfSamples() ); + } } else { slaves.push_back(castedSlave); -- GitLab