Skip to content
Snippets Groups Projects
Commit fa372bbe authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

partial fix for problems due to moving to new ControlSystemAdapter structure:...

partial fix for problems due to moving to new ControlSystemAdapter structure: allocate and use the buffer from the NDRegisterAccessor
tests still do not pass
parent 8230cac7
No related branches found
No related tags found
No related merge requests found
...@@ -24,77 +24,63 @@ namespace ChimeraTK { ...@@ -24,77 +24,63 @@ namespace ChimeraTK {
/** */ /** */
DeviceAccessor(boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> ndRegisterAccessor, VariableDirection direction, DeviceAccessor(boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> ndRegisterAccessor, VariableDirection direction,
UpdateMode mode) UpdateMode mode)
: impl(ndRegisterAccessor), _direction(direction), _mode(mode) : mtca4u::NDRegisterAccessor<UserType>(ndRegisterAccessor->getName()),
{} impl(ndRegisterAccessor),
_direction(direction),
public: _mode(mode)
{
void set(ChimeraTK::ProcessScalar<UserType> const & other) { mtca4u::NDRegisterAccessor<UserType>::buffer_2D.resize( impl->getNumberOfChannels() );
impl->accessData(0) = other.get(); for(size_t i=0; i<impl->getNumberOfChannels(); i++) {
} mtca4u::NDRegisterAccessor<UserType>::buffer_2D[i].resize( impl->getNumberOfSamples() );
}
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);
} }
bool isReadable() const { void read() {
return _direction == VariableDirection::consuming; impl->read();
mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0));
} }
bool isReadOnly() const { bool readNonBlocking() {
return _direction == VariableDirection::consuming; bool ret = impl->readNonBlocking();
mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0));
return ret;
} }
bool isWriteable() const { void write() {
return _direction == VariableDirection::feeding; 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 { unsigned int getNInputQueueElements() const {
return TimeStamp(); return impl->getNInputQueueElements();
} }
bool readNonBlocking() { bool isSameRegister(const boost::shared_ptr<const mtca4u::TransferElement>& other) const {
assert(_direction == VariableDirection::consuming); return impl->isSameRegister(other);
if(impl->getNInputQueueElements() == 0) return false;
impl->read();
return true;
} }
void read(){ bool isReadOnly() const {
throw std::logic_error("Blocking read is not supported by process array."); return impl->isReadOnly();
} }
void write() { bool isReadable() const {
assert(_direction == VariableDirection::feeding); return impl->isReadable();
impl->write();
} }
bool isSameRegister(const boost::shared_ptr<const mtca4u::TransferElement>& e) const{ bool isWriteable() const {
// only true if the very instance of the transfer element is the same return impl->isWriteable();
return e.get() == this;
} }
std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements(){ std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements() {
return { boost::enable_shared_from_this<mtca4u::TransferElement>::shared_from_this() }; return impl->getHardwareAccessingElements();
} }
void replaceTransferElement(boost::shared_ptr<mtca4u::TransferElement>){ void replaceTransferElement(boost::shared_ptr<mtca4u::TransferElement> other) {
// You can't replace anything here. Just do nothing. impl->replaceTransferElement(other);
} }
protected: protected:
boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> impl; boost::shared_ptr<mtca4u::NDRegisterAccessor<UserType>> impl;
VariableDirection _direction; VariableDirection _direction;
......
...@@ -33,6 +33,10 @@ namespace ChimeraTK { ...@@ -33,6 +33,10 @@ namespace ChimeraTK {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>( throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(
"The FanOut has been constructed with a wrong output implementation type!"); "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. */ /** Use this constructor if the FanOut should be a feeding implementation. */
...@@ -61,6 +65,10 @@ namespace ChimeraTK { ...@@ -61,6 +65,10 @@ namespace ChimeraTK {
} }
if(impl == nullptr) { // the first slave will be used as a "main" implementation, if if(impl == nullptr) { // the first slave will be used as a "main" implementation, if
impl = castedSlave; // none was specified at construction 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 { else {
slaves.push_back(castedSlave); slaves.push_back(castedSlave);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment