μHAL (v2.7.9)
Part of the IPbus software repository
ClientInterface.cpp
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 
4  This file is part of uHAL.
5 
6  uHAL is a hardware access library and programming framework
7  originally developed for upgrades of the Level-1 trigger of the CMS
8  experiment at CERN.
9 
10  uHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  uHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Andrew Rose, Imperial College, London
25  email: awr01 <AT> imperial.ac.uk
26 
27  Marc Magrans de Abril, CERN
28  email: marc.magrans.de.abril <AT> cern.ch
29 
30 ---------------------------------------------------------------------------
31 */
32 
33 #include "uhal/ClientInterface.hpp"
34 
35 
36 #include <sstream>
37 
38 #include <boost/shared_ptr.hpp>
39 #include <boost/thread/lock_guard.hpp>
40 
41 #include "uhal/Buffers.hpp"
42 #include "uhal/log/LogLevels.hpp" // for BaseLo...
43 #include "uhal/log/log_inserters.integer.hpp" // for Integer
44 #include "uhal/log/log.hpp"
45 #include "uhal/utilities/bits.hpp"
46 
47 
48 namespace uhal
49 {
50 
51  ClientInterface::ClientInterface ( const std::string& aId, const URI& aUri, const boost::posix_time::time_duration& aTimeoutPeriod ) :
52  mBuffers(),
53 #ifdef NO_PREEMPTIVE_DISPATCH
54  mNoPreemptiveDispatchBuffers(),
55 #endif
56  mId ( aId ),
57  mTimeoutPeriod ( aTimeoutPeriod ),
58  mUri ( aUri ),
59  mUriString( toString(aUri) )
60  {
61  }
62 
63 
65  mBuffers(),
66 #ifdef NO_PREEMPTIVE_DISPATCH
67  mNoPreemptiveDispatchBuffers(),
68 #endif
69  mId ( ),
70  mTimeoutPeriod ( boost::posix_time::pos_infin ),
71  mUri ( ),
72  mUriString( "" )
73  {
74  }
75 
76 
77  ClientInterface::ClientInterface ( const ClientInterface& aClientInterface ) :
78  mBuffers(),
79 #ifdef NO_PREEMPTIVE_DISPATCH
80  mNoPreemptiveDispatchBuffers(),
81 #endif
82  mId ( aClientInterface.mId ),
83  mTimeoutPeriod ( aClientInterface.mTimeoutPeriod ),
84  mUri ( aClientInterface.mUri ),
85  mUriString( aClientInterface.mUriString )
86  {
87  }
88 
89 
91  {
92  deleteBuffers();
93  mId = aClientInterface.mId;
94  mUri = aClientInterface.mUri;
95  mUriString = aClientInterface.mUriString;
96  mTimeoutPeriod = aClientInterface.mTimeoutPeriod;
97  return *this;
98  }
99 
100 
102  {
103  deleteBuffers();
104  }
105 
106  const std::string& ClientInterface::id() const
107  {
108  return mId;
109  }
110 
111 
112  // void ClientInterface::ping()
113  // {
114  // try
115  // {
116  // std::string lInstruction ( "ping -q -c 1 " + mUri.mHostname + " &> /dev/null" );
117  // log ( Info() , "Pinging " , Quote ( mId ) , " with instruction : " , lInstruction );
118  // //Cant use ICMP here because it requires raw socket (and hence superuser) access, so use system PING instead
119  // int lPingStatus = system ( lInstruction.c_str() );
120 
121  // if ( WEXITSTATUS ( lPingStatus ) )
122  // {
123  // log ( Error() , "Pinging " , Quote ( mId ) , " at address " , Quote( mUri.mHostname ) , " returned exit status ", Integer ( WEXITSTATUS ( lPingStatus ) ) );
124  // throw exception::// PingFailed();
125  // }
126  // }
127  // catch ( uhal::exception& aExc )
128  // {
129  // aExc.throw r;
130  // }
131  // catch ( const std::exception& aExc )
132  // {
133  // throw // StdException ( aExc );
134  // }
135  // }
136 
137 
138  const std::string& ClientInterface::uri() const
139  {
140  return mUriString;
141  }
142 
143 
145  {
146  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
147 
148  try
149  {
150 #ifdef NO_PREEMPTIVE_DISPATCH
151  log ( Info() , "mNoPreemptiveDispatchBuffers.size() = " , Integer ( mNoPreemptiveDispatchBuffers.size() ) );
152 
153  for ( std::deque < boost::shared_ptr< Buffers > >::iterator lIt = mNoPreemptiveDispatchBuffers.begin(); lIt != mNoPreemptiveDispatchBuffers.end(); ++lIt )
154  {
155  this->predispatch ( *lIt );
156  this->implementDispatch ( *lIt ); //responsibility for *lIt passed to the implementDispatch function
157  lIt->reset();
158  }
159 
160  {
161  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
162  mNoPreemptiveDispatchBuffers.clear();
163  }
164 
165  this->Flush();
166 #endif
167 
168  if ( mCurrentBuffers )
169  {
170  this->predispatch ( mCurrentBuffers );
171  this->implementDispatch ( mCurrentBuffers ); //responsibility for mCurrentBuffers passed to the implementDispatch function
172  mCurrentBuffers.reset();
173  this->Flush();
174  }
175  }
176  catch ( ... )
177  {
178  this->dispatchExceptionHandler();
179  throw;
180  }
181  }
182 
183 
185  {}
186 
187 
189  {
190  exception::exception* lRet = this->validate ( aBuffers->getSendBuffer() ,
191  aBuffers->getSendBuffer() + aBuffers->sendCounter() ,
192  aBuffers->getReplyBuffer().begin() ,
193  aBuffers->getReplyBuffer().end() );
194 
195  //results are valid, so mark returned data as valid
196  if ( !lRet )
197  {
198  aBuffers->validate ();
199  }
200 
201  returnBufferToPool ( aBuffers );
202  return lRet;
203  }
204 
205 
207  {
208  return 0;
209  }
210 
211 
213  {}
214 
215 
217  {}
218 
219 
220 
222  {
223  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
224 
225  if ( aBuffers )
226  {
227  mBuffers.push_back ( aBuffers );
228  aBuffers.reset();
229  }
230  }
231 
232 
234  {
235  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
236 
237  for ( std::deque < boost::shared_ptr< Buffers > >::iterator lIt = aBuffers.begin(); lIt != aBuffers.end(); ++lIt )
238  {
239  if ( *lIt )
240  {
241  mBuffers.push_back ( *lIt );
242  }
243  }
244 
245  aBuffers.clear();
246  }
247 
248 
250  {
251  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
252 
253  for ( std::vector < boost::shared_ptr< Buffers > >::iterator lIt = aBuffers.begin(); lIt != aBuffers.end(); ++lIt )
254  {
255  if ( *lIt )
256  {
257  mBuffers.push_back ( *lIt );
258  }
259  }
260 
261  aBuffers.clear();
262  }
263 
264 
265  void ClientInterface::returnBufferToPool ( std::deque< std::vector< boost::shared_ptr<Buffers> > >& aBuffers )
266  {
267  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
268 
269  for ( std::deque < std::vector < boost::shared_ptr< Buffers > > >::iterator lIt1 = aBuffers.begin(); lIt1 != aBuffers.end(); ++lIt1 )
270  {
271  for ( std::vector< boost::shared_ptr<Buffers> >::iterator lIt2 = lIt1->begin(); lIt2 != lIt1->end(); ++lIt2 )
272  {
273  if ( *lIt2 )
274  {
275  mBuffers.push_back ( *lIt2 );
276  }
277  }
278  }
279 
280  aBuffers.clear();
281  }
282 
283 
284  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
285  boost::shared_ptr< Buffers > ClientInterface::checkBufferSpace ( const uint32_t& aRequestedSendSize , const uint32_t& aRequestedReplySize , uint32_t& aAvailableSendSize , uint32_t& aAvailableReplySize )
286  {
287  log ( Debug() , "Checking buffer space" );
288  //if there are no existing buffers in the pool, create them
290  uint32_t lSendBufferFreeSpace ( this->getMaxSendSize() - mCurrentBuffers->sendCounter() );
291  uint32_t lReplyBufferFreeSpace ( this->getMaxReplySize() - mCurrentBuffers->replyCounter() );
292 
293  if ( ( aRequestedSendSize <= lSendBufferFreeSpace ) && ( aRequestedReplySize <= lReplyBufferFreeSpace ) )
294  {
295  aAvailableSendSize = aRequestedSendSize;
296  aAvailableReplySize = aRequestedReplySize;
297  return mCurrentBuffers;
298  }
299 
300  if ( ( lSendBufferFreeSpace > 16 ) && ( lReplyBufferFreeSpace > 16 ) )
301  {
302  aAvailableSendSize = lSendBufferFreeSpace;
303  aAvailableReplySize = lReplyBufferFreeSpace;
304  return mCurrentBuffers;
305  }
306 
307 #ifdef NO_PREEMPTIVE_DISPATCH
308  mNoPreemptiveDispatchBuffers.push_back ( mCurrentBuffers );
309  mCurrentBuffers.reset();
310 #else
311  log ( Debug() , "Triggering automated dispatch" );
312 
313  try
314  {
315  this->predispatch ( mCurrentBuffers );
317  mCurrentBuffers.reset();
318  }
319  catch ( ... )
320  {
321  this->dispatchExceptionHandler();
322  throw;
323  }
324 
325 #endif
327  lSendBufferFreeSpace = this->getMaxSendSize() - mCurrentBuffers->sendCounter();
328  lReplyBufferFreeSpace = this->getMaxReplySize() - mCurrentBuffers->replyCounter();
329 
330  if ( ( aRequestedSendSize <= lSendBufferFreeSpace ) && ( aRequestedReplySize <= lReplyBufferFreeSpace ) )
331  {
332  aAvailableSendSize = aRequestedSendSize;
333  aAvailableReplySize = aRequestedReplySize;
334  return mCurrentBuffers;
335  }
336 
337  aAvailableSendSize = lSendBufferFreeSpace;
338  aAvailableReplySize = lReplyBufferFreeSpace;
339  return mCurrentBuffers;
340  }
341  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
342 
343 
345  {
346  if ( ! mCurrentBuffers )
347  {
348  {
349  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
350 
351  if ( mBuffers.size() == 0 )
352  {
353  for ( uint32_t i=0; i!=10; ++i )
354  {
355  mBuffers.push_back ( boost::shared_ptr< Buffers > ( new Buffers ( this->getMaxSendSize() ) ) );
356  }
357  }
358 
359  mCurrentBuffers = mBuffers.front();
360  mBuffers.pop_front();
361  mCurrentBuffers->clear();
362  }
363  this->preamble ( mCurrentBuffers );
364  }
365  }
366 
367 
369  {
370  boost::lock_guard<boost::mutex> lLock ( mBufferMutex );
371  mBuffers.clear();
372 
373 #ifdef NO_PREEMPTIVE_DISPATCH
374  mNoPreemptiveDispatchBuffers.clear();
375 #endif
376 
377  if ( mCurrentBuffers )
378  {
379  mCurrentBuffers.reset();
380  }
381 
382  }
383 
384 
386  {
387  deleteBuffers();
388  }
389 
390 
391  std::pair < ValHeader , _ValHeader_* > ClientInterface::CreateValHeader()
392  {
393  ValHeader lReply;
394  return std::make_pair ( lReply , & ( * ( lReply.mMembers ) ) );
395  }
396 
397 
398  std::pair < ValWord<uint32_t> , _ValWord_<uint32_t>* > ClientInterface::CreateValWord ( const uint32_t& aValue , const uint32_t& aMask )
399  {
400  ValWord<uint32_t> lReply ( aValue , aMask );
401  return std::make_pair ( lReply , & ( * ( lReply.mMembers ) ) );
402  }
403 
404 
405  std::pair < ValVector<uint32_t> , _ValVector_<uint32_t>* > ClientInterface::CreateValVector ( const uint32_t& aSize )
406  {
407  ValVector<uint32_t> lReply ( aSize );
408  return std::make_pair ( lReply , & ( * ( lReply.mMembers ) ) );
409  }
410 
411 
412  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
413  ValHeader ClientInterface::write ( const uint32_t& aAddr, const uint32_t& aSource )
414  {
415  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
416  return implementWrite ( aAddr , aSource );
417  }
418 
419 
420  ValHeader ClientInterface::write ( const uint32_t& aAddr, const uint32_t& aSource, const uint32_t& aMask )
421  {
422  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
423  uint32_t lShiftSize ( utilities::TrailingRightBits ( aMask ) );
424  uint32_t lBitShiftedSource ( aSource << lShiftSize );
425 
426  if ( ( lBitShiftedSource >> lShiftSize ) != aSource )
427  {
428  exception::BitsSetWhichAreForbiddenByBitMask lExc;
429  log ( lExc , "Source data (" , Integer ( aSource , IntFmt<hex,fixed>() ) , ") has bits which would be shifted outside the register " );
430  throw lExc;
431  }
432 
433  uint32_t lOverlap ( lBitShiftedSource & ~aMask );
434 
435  if ( lOverlap )
436  {
437  exception::BitsSetWhichAreForbiddenByBitMask lExc;
438  log ( lExc , "Source data (" , Integer ( aSource , IntFmt<hex,fixed>() ) , ")"
439  " has the following bits set outside the bounds allowed by the bit-mask ( ", Integer ( aSource , IntFmt<hex,fixed>() ) , ") : " ,
440  Integer ( lOverlap , IntFmt<hex,fixed>() )
441  );
442  throw lExc;
443  }
444 
445  return ( ValHeader ) ( implementRMWbits ( aAddr , ~aMask , lBitShiftedSource & aMask ) );
446  }
447 
448 
449  ValHeader ClientInterface::writeBlock ( const uint32_t& aAddr, const std::vector< uint32_t >& aSource, const defs::BlockReadWriteMode& aMode )
450  {
451  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
452  return implementWriteBlock ( aAddr, aSource, aMode );
453  }
454  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
455 
456 
457  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
458  ValWord< uint32_t > ClientInterface::read ( const uint32_t& aAddr )
459  {
460  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
461  return implementRead ( aAddr );
462  }
463 
464 
465  ValWord< uint32_t > ClientInterface::read ( const uint32_t& aAddr, const uint32_t& aMask )
466  {
467  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
468  return implementRead ( aAddr, aMask );
469  }
470 
471 
472  ValVector< uint32_t > ClientInterface::readBlock ( const uint32_t& aAddr, const uint32_t& aSize, const defs::BlockReadWriteMode& aMode )
473  {
474  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
475  return implementReadBlock ( aAddr, aSize, aMode );
476  }
477  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
478 
479 
480  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
481  ValWord< uint32_t > ClientInterface::rmw_bits ( const uint32_t& aAddr , const uint32_t& aANDterm , const uint32_t& aORterm )
482  {
483  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
484  return implementRMWbits ( aAddr , aANDterm , aORterm );
485  }
486  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
487 
488 
489  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
490  ValWord< uint32_t > ClientInterface::rmw_sum ( const uint32_t& aAddr , const int32_t& aAddend )
491  {
492  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
493  return implementRMWsum ( aAddr , aAddend );
494  }
495  //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
496 
497 
498  void ClientInterface::setTimeoutPeriod ( const uint32_t& aTimeoutPeriod )
499  {
500  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
501 
502  if ( aTimeoutPeriod == 0 )
503  {
504  mTimeoutPeriod = boost::posix_time::pos_infin;
505  }
506  else
507  {
508  mTimeoutPeriod = boost::posix_time::milliseconds ( aTimeoutPeriod );
509  }
510  }
511 
512 
514  {
515  boost::lock_guard<boost::mutex> lLock ( mUserSideMutex );
516  return mTimeoutPeriod.total_milliseconds();
517  }
518 
519 
520  const boost::posix_time::time_duration& ClientInterface::getBoostTimeoutPeriod()
521  {
522  return mTimeoutPeriod;
523  }
524 
525 }
uhal::ValVector< uint32_t >
uhal::ClientInterface::id
const std::string & id() const
Return the identifier of the target for this client.
Definition: ClientInterface.cpp:106
uhal::ClientInterface::ClientInterface
ClientInterface()
Default Constructor.
Definition: ClientInterface.cpp:64
uhal::ClientInterface::writeBlock
ValHeader writeBlock(const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Write a block of data to a block of registers or a block-write port.
Definition: ClientInterface.cpp:449
uhal::ClientInterface::predispatch
virtual void predispatch(boost::shared_ptr< Buffers > aBuffers)
Finalize the buffer before it is transmitted.
Definition: ClientInterface.cpp:216
boost::shared_ptr
Definition: DerivedNodeFactory.hpp:52
uhal::ClientInterface::dispatch
void dispatch()
Method to dispatch all queued transactions, and wait until all corresponding responses have been rece...
Definition: ClientInterface.cpp:144
uhal::ClientInterface::mCurrentBuffers
boost::shared_ptr< Buffers > mCurrentBuffers
A pointer to a buffer-wrapper object.
Definition: ClientInterface.hpp:407
uhal::ClientInterface::implementWriteBlock
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.
uhal::ValHeader::mMembers
boost::shared_ptr< _ValHeader_ > mMembers
A shared pointer to a ValWord struct, so that every copy of this ValWord points to the same underlyin...
Definition: ValMem.hpp:183
uhal::ClientInterface::implementRMWbits
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...
uhal::ClientInterface
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
Definition: ClientInterface.hpp:100
uhal::ClientInterface::dispatchExceptionHandler
virtual void dispatchExceptionHandler()
Function which is called when an exception is thrown.
Definition: ClientInterface.cpp:385
boost
Definition: log.hpp:13
uhal::ClientInterface::updateCurrentBuffers
void updateCurrentBuffers()
If the current buffer is null, allocate a buffer from the buffer pool for it If the buffer pool is em...
Definition: ClientInterface.cpp:344
uhal::IntFmt
Empty struct which acts as a dummy variable for passing the formatting information around.
Definition: log_inserters.integer.hpp:68
uhal::ClientInterface::Flush
virtual void Flush()
Virtual function to dispatch all buffers and block until all replies are received.
Definition: ClientInterface.cpp:184
uhal::exception::exception
An abstract base exception class, including an interface to throw as the derived type (for passing ex...
Definition: exception.hpp:71
uhal::ClientInterface::deleteBuffers
void deleteBuffers()
Definition: ClientInterface.cpp:368
uhal::ClientInterface::implementDispatch
virtual void implementDispatch(boost::shared_ptr< Buffers > aBuffers)=0
Pure virtual function which actually performs the dispatch operation.
uhal::ValHeader
A class which wraps a single word of data and marks whether or not it is valid.
Definition: ValMem.hpp:148
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::ValWord::mMembers
boost::shared_ptr< _ValWord_< T > > mMembers
A shared pointer to a ValWord struct, so that every copy of this ValWord points to the same underlyin...
Definition: ValMem.hpp:266
uhal::ClientInterface::getMaxSendSize
virtual uint32_t getMaxSendSize()=0
Return the maximum size to be sent based on the buffer size in the target.
uhal::ClientInterface::getTimeoutPeriod
uint64_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
Definition: ClientInterface.cpp:513
uhal::ClientInterface::checkBufferSpace
virtual boost::shared_ptr< Buffers > checkBufferSpace(const uint32_t &aSendSize, const uint32_t &aReplySize, uint32_t &aAvailableSendSize, uint32_t &aAvailableReplySize)
Function which checks the available space in the currently filling buffer against requested send and ...
Definition: ClientInterface.cpp:285
uhal::ClientInterface::mId
std::string mId
the identifier of the target for this client
Definition: ClientInterface.hpp:410
uhal::defs::BlockReadWriteMode
BlockReadWriteMode
define whether transactions target a single register, a block of registers, a block-read/write port o...
Definition: definitions.hpp:53
uhal::Info
InfoLevel Info
Definition: LogLevels.cpp:115
uhal::log
void log(FatalLevel &aFatal, const T0 &aArg0)
Function to add a log entry at Fatal level.
Definition: log.hxx:20
uhal::ClientInterface::read
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
Definition: ClientInterface.cpp:458
uhal::ClientInterface::CreateValHeader
std::pair< ValHeader, _ValHeader_ * > CreateValHeader()
Helper function to create a ValHeader object.
Definition: ClientInterface.cpp:391
log_inserters.integer.hpp
uhal::toString
std::string toString(const URI &aURI)
Definition: URI.cpp:61
uhal::Integer
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...
Definition: log_inserters.integer.hxx:43
uhal::ClientInterface::~ClientInterface
virtual ~ClientInterface()
Destructor.
Definition: ClientInterface.cpp:101
uhal::ClientInterface::mUriString
std::string mUriString
Definition: ClientInterface.hpp:426
uhal::ClientInterface::readBlock
ValVector< uint32_t > readBlock(const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Read a block of unsigned data from a block of registers or a block-read port.
Definition: ClientInterface.cpp:472
uhal::ClientInterface::mUserSideMutex
boost::mutex mUserSideMutex
A MutEx lock used to make sure the access functions are thread safe.
Definition: ClientInterface.hpp:393
uhal::ClientInterface::implementRead
virtual ValWord< uint32_t > implementRead(const uint32_t &aAddr, const uint32_t &aMask=defs::NOMASK)=0
Read a single, masked, unsigned word.
uhal::ClientInterface::rmw_bits
ValWord< uint32_t > rmw_bits(const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)
Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new val...
Definition: ClientInterface.cpp:481
uhal::ClientInterface::rmw_sum
ValWord< uint32_t > rmw_sum(const uint32_t &aAddr, const int32_t &aAddend)
Read the value of a register, add the addend, set the register to this new value and return a copy of...
Definition: ClientInterface.cpp:490
uhal::ClientInterface::implementReadBlock
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.
uhal::ClientInterface::getPreambleSize
virtual uint32_t getPreambleSize()
Return the size of the preamble.
Definition: ClientInterface.cpp:206
uhal::ClientInterface::mTimeoutPeriod
boost::posix_time::time_duration mTimeoutPeriod
Timeout period for transactions.
Definition: ClientInterface.hpp:413
uhal::Buffers
A class wrapping the send and recieve buffers that are to be filled and transported and the validated...
Definition: Buffers.hpp:56
uhal::ClientInterface::CreateValVector
std::pair< ValVector< uint32_t >, _ValVector_< uint32_t > * > CreateValVector(const uint32_t &aSize)
Helper function to create a ValVector object.
Definition: ClientInterface.cpp:405
uhal::Debug
DebugLevel Debug
Definition: LogLevels.cpp:133
uhal::ClientInterface::mUri
URI mUri
a struct containing the full URI of the target for this client
Definition: ClientInterface.hpp:424
uhal::ClientInterface::setTimeoutPeriod
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod=0)
A method to modify the timeout period for any pending or future transactions.
Definition: ClientInterface.cpp:498
uhal::ClientInterface::uri
const std::string & uri() const
Return the url of the target for this client.
Definition: ClientInterface.cpp:138
log.hpp
uhal::ValWord< uint32_t >
uhal::ClientInterface::getBoostTimeoutPeriod
const boost::posix_time::time_duration & getBoostTimeoutPeriod()
A method to retrieve the timeout period currently being used.
Definition: ClientInterface.cpp:520
bits.hpp
uhal::ClientInterface::returnBufferToPool
void returnBufferToPool(boost::shared_ptr< Buffers > &aBuffers)
Function to return a buffer to the buffer pool.
Definition: ClientInterface.cpp:221
uhal::utilities::TrailingRightBits
unsigned int TrailingRightBits(uint32_t aValue)
Helper function to calculate the number of zero-bits at the righthand end of a 32-bit number.
Definition: bits.cpp:44
uhal::_ValVector_
A Template helper struct wrapping a block of IPbus header, a register for storing a block of data and...
Definition: ValMem.hpp:127
LogLevels.hpp
uhal::ClientInterface::CreateValWord
std::pair< ValWord< uint32_t >, _ValWord_< uint32_t > * > CreateValWord(const uint32_t &aValue, const uint32_t &aMask=defs::NOMASK)
Helper function to create a ValWord object.
Definition: ClientInterface.cpp:398
uhal::ClientInterface::operator=
virtual ClientInterface & operator=(const ClientInterface &aClientInterface)
Assignment operator.
Definition: ClientInterface.cpp:90
uhal::_ValWord_
A Template helper struct wrapping an IPbus header, a register for storing a single word of data,...
Definition: ValMem.hpp:103
uhal::URI
Struct to store a URI when parsed by boost spirit.
Definition: URI.hpp:50
uhal::ClientInterface::implementWrite
virtual ValHeader implementWrite(const uint32_t &aAddr, const uint32_t &aValue)=0
Write a single, unmasked word to a register.
uhal::ClientInterface::mBufferMutex
boost::mutex mBufferMutex
A MutEx lock used to make sure the access to the buffers is thread safe.
Definition: ClientInterface.hpp:396
uhal::ClientInterface::validate
virtual exception::exception * validate(boost::shared_ptr< Buffers > aBuffers)
Function which dispatch calls when the reply is received to check that the headers are as expected.
Definition: ClientInterface.cpp:188
uhal::ValVector::mMembers
boost::shared_ptr< _ValVector_< T > > mMembers
A shared pointer to a ValVector struct, so that every copy of this ValVector points to the same under...
Definition: ValMem.hpp:399
uhal::ClientInterface::preamble
virtual void preamble(boost::shared_ptr< Buffers > aBuffers)
Add a preamble to an IPbus buffer.
Definition: ClientInterface.cpp:212
uhal::ClientInterface::implementRMWsum
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...
uhal::ClientInterface::getMaxReplySize
virtual uint32_t getMaxReplySize()=0
Return the maximum size of reply packet based on the buffer size in the target.
ClientInterface.hpp
Buffers.hpp
uhal::ClientInterface::mBuffers
std::deque< boost::shared_ptr< Buffers > > mBuffers
A memory pool of buffers which will be dispatched.
Definition: ClientInterface.hpp:399
uhal::ClientInterface::write
ValHeader write(const uint32_t &aAddr, const uint32_t &aValue)
Write a single, unmasked word to a register.
Definition: ClientInterface.cpp:413