μHAL (v2.7.9)
Part of the IPbus software repository
Classes | Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | List of all members
uhal::ControlHub< InnerProtocol > Class Template Reference

Transport protocol to transfer an IPbus buffer via ControlHub. More...

#include <uhal/ProtocolControlHub.hpp>

Inheritance diagram for uhal::ControlHub< InnerProtocol >:
[legend]
Collaboration diagram for uhal::ControlHub< InnerProtocol >:
[legend]

Classes

struct  tpreamble
 A struct representing the preamble which will be prepended to an IPbus buffer for the benefit of the Control Hub. More...
 

Public Member Functions

 ControlHub (const std::string &aId, const URI &aUri)
 Constructor. More...
 
virtual ~ControlHub ()
 Destructor. More...
 

Protected Member Functions

virtual void preamble (boost::shared_ptr< Buffers > aBuffers)
 Add a preamble to an IPbus buffer. More...
 
virtual uint32_t getPreambleSize ()
 Get the size of the preamble added by this protocol layer. More...
 
virtual void predispatch (boost::shared_ptr< Buffers > aBuffers)
 Finalize an IPbus buffer before it is transmitted. More...
 
virtual exception::exceptionvalidate (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)
 Function which the dispatch calls when the reply is received to check that the headers are as expected. More...
 
virtual uint32_t getMaxNumberOfBuffers ()
 Returns the maximum number of buffers that should be in-flight from the uHAL client at any given time. More...
 
virtual void dispatchExceptionHandler ()
 Function which tidies up this protocol layer in the event of an exception. More...
 

Static Private Member Functions

static void translateErrorCode (std::ostream &aStream, const uint16_t &aErrorCode)
 

Private Attributes

uint32_t mDeviceIPaddress
 The IP address of the target device that is connected to the Control Hub. More...
 
uint16_t mDevicePort
 The port number of the target device that is connected to the Control Hub. More...
 
std::deque< tpreamblemPreambles
 A queue of preample structs making the memory used by the preambles persistent during the dispatch. Must lock mPreamblesMutex when accessing this deque. More...
 
boost::mutex mPreamblesMutex
 Mutex to be used when accessing mPreambles. More...
 

Detailed Description

template<typename InnerProtocol>
class uhal::ControlHub< InnerProtocol >

Transport protocol to transfer an IPbus buffer via ControlHub.

Definition at line 85 of file ProtocolControlHub.hpp.

Constructor & Destructor Documentation

◆ ControlHub()

template<typename InnerProtocol >
uhal::ControlHub< InnerProtocol >::ControlHub ( const std::string &  aId,
const URI aUri 
)

Constructor.

Parameters
aIdthe uinique identifier that the client will be given.
aUria struct containing the full URI of the target.

Definition at line 146 of file ProtocolControlHub.cpp.

References uhal::ExtractTargetID(), uhal::ControlHub< InnerProtocol >::mDeviceIPaddress, and uhal::ControlHub< InnerProtocol >::mDevicePort.

◆ ~ControlHub()

template<typename InnerProtocol >
uhal::ControlHub< InnerProtocol >::~ControlHub
virtual

Destructor.

Definition at line 158 of file ProtocolControlHub.cpp.

Member Function Documentation

◆ dispatchExceptionHandler()

template<typename InnerProtocol >
void uhal::ControlHub< InnerProtocol >::dispatchExceptionHandler
protectedvirtual

Function which tidies up this protocol layer in the event of an exception.

Definition at line 288 of file ProtocolControlHub.cpp.

◆ getMaxNumberOfBuffers()

template<typename InnerProtocol >
uint32_t uhal::ControlHub< InnerProtocol >::getMaxNumberOfBuffers
protectedvirtual

Returns the maximum number of buffers that should be in-flight from the uHAL client at any given time.

Returns
the maximum number of buffers in-flight
Note
Currently set to 60 based on experience of performance measurements in building 904 IPbus test.
Since TCP allows the ControlHub to throttle incoming traffic, in the long term this "number in-flight" limit may not been needed.
But this limit is kept for the moment for safety (i.e. to prevent uHAL ever flooding ControlHub with data).

Definition at line 281 of file ProtocolControlHub.cpp.

◆ getPreambleSize()

template<typename InnerProtocol >
uint32_t uhal::ControlHub< InnerProtocol >::getPreambleSize
protectedvirtual

Get the size of the preamble added by this protocol layer.

Returns
the size of the preamble added by this protocol layer

Definition at line 198 of file ProtocolControlHub.cpp.

◆ preamble()

template<typename InnerProtocol >
void uhal::ControlHub< InnerProtocol >::preamble ( boost::shared_ptr< Buffers aBuffers)
protectedvirtual

◆ predispatch()

template<typename InnerProtocol >
void uhal::ControlHub< InnerProtocol >::predispatch ( boost::shared_ptr< Buffers aBuffers)
protectedvirtual

Finalize an IPbus buffer before it is transmitted.

Parameters
aBuffersa buffer on which to do the predispatch operation

Definition at line 205 of file ProtocolControlHub.cpp.

References uhal::ControlHub< InnerProtocol >::tpreamble::mSendWordCountPtr.

◆ translateErrorCode()

template<typename InnerProtocol >
void uhal::ControlHub< InnerProtocol >::translateErrorCode ( std::ostream &  aStream,
const uint16_t &  aErrorCode 
)
staticprivate

Definition at line 299 of file ProtocolControlHub.cpp.

◆ validate()

template<typename InnerProtocol >
exception::exception * uhal::ControlHub< InnerProtocol >::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 
)
protectedvirtual

Function which the dispatch calls when the reply is received to check that the headers are as expected.

Parameters
aSendBufferStarta pointer to the start of the first word of IPbus data which was sent (i.e. with no preamble)
aSendBufferEnda pointer to the end of the last word of IPbus data which was sent
aReplyStartItan iterator to the start of the list of memory locations in to which the reply was written
aReplyEndItan iterator to the end (one past last valid entry) of the list of memory locations in to which the reply was written
Returns
whether the returned IPbus packet is valid

Definition at line 216 of file ProtocolControlHub.cpp.

References uhal::Integer(), uhal::log(), uhal::Quote(), and uhal::tests::uri.

Member Data Documentation

◆ mDeviceIPaddress

template<typename InnerProtocol >
uint32_t uhal::ControlHub< InnerProtocol >::mDeviceIPaddress
private

The IP address of the target device that is connected to the Control Hub.

Definition at line 148 of file ProtocolControlHub.hpp.

Referenced by uhal::ControlHub< InnerProtocol >::ControlHub().

◆ mDevicePort

template<typename InnerProtocol >
uint16_t uhal::ControlHub< InnerProtocol >::mDevicePort
private

The port number of the target device that is connected to the Control Hub.

Definition at line 151 of file ProtocolControlHub.hpp.

Referenced by uhal::ControlHub< InnerProtocol >::ControlHub().

◆ mPreambles

template<typename InnerProtocol >
std::deque< tpreamble > uhal::ControlHub< InnerProtocol >::mPreambles
private

A queue of preample structs making the memory used by the preambles persistent during the dispatch. Must lock mPreamblesMutex when accessing this deque.

Definition at line 170 of file ProtocolControlHub.hpp.

◆ mPreamblesMutex

template<typename InnerProtocol >
boost::mutex uhal::ControlHub< InnerProtocol >::mPreamblesMutex
private

Mutex to be used when accessing mPreambles.

Definition at line 172 of file ProtocolControlHub.hpp.


The documentation for this class was generated from the following files: