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 {
/** */
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;
......
......@@ -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);
......
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