40#ifndef _uhal_ClientInterface_hpp_
41#define _uhal_ClientInterface_hpp_
52#include <boost/date_time/posix_time/posix_time_types.hpp>
64 class ClientInterface;
80 UHAL_DEFINE_EXCEPTION_CLASS ( BitsSetWhichAreForbiddenByBitMask , "Exception class to
handle the case where a masked write was attempted with a
data source which has non-zero bits outside the bit-mask's bounds." )
109 ClientInterface (
const std::string& aId,
const URI& aUri ,
const boost::posix_time::time_duration& aTimeoutPeriod );
136 const std::string& id()
const;
147 const std::string& uri()
const;
157 void setTimeoutPeriod (
const uint32_t& aTimeoutPeriod = 0 );
164 uint64_t getTimeoutPeriod();
172 const boost::posix_time::time_duration& getBoostTimeoutPeriod();
181 ValHeader write (
const uint32_t& aAddr,
const uint32_t& aValue );
189 ValHeader write (
const uint32_t& aAddr,
const uint32_t& aValue,
const uint32_t& aMask );
230 ValWord< uint32_t > rmw_bits (
const uint32_t& aAddr ,
const uint32_t& aANDterm ,
const uint32_t& aORterm );
248 virtual void Flush( );
305 virtual void preamble ( std::shared_ptr< Buffers > aBuffers );
308 virtual uint32_t getPreambleSize();
314 virtual void predispatch ( std::shared_ptr< Buffers > aBuffers );
320 std::pair < ValHeader , _ValHeader_* > CreateValHeader();
335 std::pair < ValVector<uint32_t> ,
_ValVector_<uint32_t>* > CreateValVector (
const uint32_t& aSize );
355 uint8_t* aSendBufferEnd ,
356 std::deque< std::pair< uint8_t* , uint32_t > >
::iterator aReplyStartIt ,
357 std::deque< std::pair< uint8_t* , uint32_t > >
::iterator aReplyEndIt ) = 0;
360 virtual void dispatchExceptionHandler();
366 void returnBufferToPool ( std::shared_ptr< Buffers >& aBuffers );
371 void returnBufferToPool ( std::deque< std::shared_ptr< Buffers > >& aBuffers );
376 void returnBufferToPool ( std::vector< std::shared_ptr< Buffers > >& aBuffers );
381 void returnBufferToPool ( std::deque< std::vector< std::shared_ptr< Buffers > > >& aBuffers );
388 void updateCurrentBuffers();
389 void deleteBuffers();
400 std::deque < std::shared_ptr< Buffers > >
mBuffers;
402#ifdef NO_PREEMPTIVE_DISPATCH
404 std::deque < std::shared_ptr< Buffers > > mNoPreemptiveDispatchBuffers;
436 virtual std::shared_ptr< Buffers > checkBufferSpace (
const uint32_t& aSendSize ,
const uint32_t& aReplySize , uint32_t& aAvailableSendSize , uint32_t& aAvailableReplySize );
Wrapper to generate a new Python exception type.
\rst Holds a reference to a Python object (no reference counting)
\rst Wraps a Python iterator so that it can also be used as a C++ input iterator
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
virtual ValHeader implementBOT()=0
Send a byte order transaction.
virtual uint32_t getMaxReplySize()=0
Return the maximum size of reply packet based on the buffer size in the target.
virtual exception::exception * validate(uint8_t *aSendBufferStart, uint8_t *aSendBufferEnd, std::deque< std::pair< uint8_t *, uint32_t > >::iterator aReplyStartIt, std::deque< std::pair< uint8_t *, uint32_t > >::iterator aReplyEndIt)=0
Function which the dispatch calls when the reply is received to check that the headers are as expecte...
virtual void implementDispatch(std::shared_ptr< Buffers > aBuffers)=0
Pure virtual function which actually performs the dispatch operation.
virtual ValHeader implementWriteBlock(const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)=0
Write a block of data to a block of registers or a block-write port.
std::mutex mUserSideMutex
A MutEx lock used to make sure the access functions are thread safe.
std::shared_ptr< Buffers > mCurrentBuffers
A pointer to a buffer-wrapper object.
virtual ValWord< uint32_t > implementRMWbits(const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)=0
Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new val...
boost::posix_time::time_duration mTimeoutPeriod
Timeout period for transactions.
virtual uint32_t getMaxSendSize()=0
Return the maximum size to be sent based on the buffer size in the target.
virtual ValWord< uint32_t > implementRead(const uint32_t &aAddr, const uint32_t &aMask=defs::NOMASK)=0
Read a single, masked, unsigned word.
virtual uint32_t getMaxNumberOfBuffers()=0
Return the maximum number of packets in flight.
virtual ValVector< uint32_t > implementReadBlock(const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)=0
Read a block of unsigned data from a block of registers or a block-read port.
std::deque< std::shared_ptr< Buffers > > mBuffers
A memory pool of buffers which will be dispatched.
URI mUri
a struct containing the full URI of the target for this client
std::string mId
the identifier of the target for this client
std::mutex mBufferMutex
A MutEx lock used to make sure the access to the buffers is thread safe.
std::weak_ptr< Node > mNode
virtual ValHeader implementWrite(const uint32_t &aAddr, const uint32_t &aValue)=0
Write a single, unmasked word to a register.
virtual ValWord< uint32_t > implementRMWsum(const uint32_t &aAddr, const int32_t &aAddend)=0
Read the value of a register, add the addend, set the register to this new value and return a copy of...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
A class providing the core IPbus packing functionality.
An abstract base exception class, including an interface to throw as the derived type (for passing ex...
#define UHAL_DEFINE_EXCEPTION_CLASS(ClassName, ClassDescription)
BlockReadWriteMode
define whether transactions target a single register, a block of registers, a block-read/write port o...
const uint32_t NOMASK
define what it means to have no mask
std::string getAddressDescription(const ClientInterface &, const uint32_t, const size_t &)
Generates a short string summarising which nodes match the specified address.
arr data(const arr &a, Ix... index)
A Template helper struct wrapping a block of IPbus header, a register for storing a block of data and...
A Template helper struct wrapping an IPbus header, a register for storing a single word of data,...
Struct to store a URI when parsed by boost spirit.