Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
SocCamera::tcPendingAckWatchdog< IdType > Class Template Reference

#include <tcPendingAckWatchdog.h>

Inheritance diagram for SocCamera::tcPendingAckWatchdog< IdType >:
Collaboration diagram for SocCamera::tcPendingAckWatchdog< IdType >:

Public Member Functions

 tcPendingAckWatchdog ()
 
virtual ~tcPendingAckWatchdog ()
 
void setTimeoutPeriod (std::chrono::microseconds duration)
 
void addWatcher (tcPendingAckWatcher *apWatcher)
 
void removeWatcher (tcPendingAckWatcher *apWatcher)
 
void newMessage (IdType id)
 
void messageDone (IdType id)
 
virtual void timerTicked (tcTimer *)
 

Protected Member Functions

void timerTick ()
 
void notifyWatchers (const void *apPtr)
 

Detailed Description

template<class IdType>
class SocCamera::tcPendingAckWatchdog< IdType >

The tcPendingAckWatchdog class provides a utility to allow transport message handlers to be notified if a message handling/response thread is taking too long. Many transport protocols used by cameras are request/response based, where a response is required within some defined about of time or a timeout condition is required. Such protocols typically provide a provision for sending a "pending acknowledgment" message back to the requested essentially requesting for more time.

This class allows transport message handlers to implement a callback via the tcPendingAckWatcher interface and start a timer when beginning a message handling cycle. If the timer expires before the message handler is complete, the pendingAckNeeded() interface method is called, which allows the message handler to transmit an appropriate pending-ack message and continue processing the message.

The goal of this framework is to support decoupling the transport handler from the Sensor / Camera message handling implementations. The transport handler doesn't need to know how long a specific message will take to process, and the sensor board doesn't have to know or care about how long it takes to handle a message and provide hints back to the transport for pending acks.

The implementation does support multiple message timers, though in practice it is unlikely that more than one timer would ever be running at any given time.

Message Handler Flow:

class tcHandler : public tcPendingAckWatcher()
tcHandler::tcHandler()
{
mpWatchDog = new tcPendingAckWatchdog<int>(); // create a tcPendingAckWatchdog object
mpWatchDog->setTimeoutPeriod(std::chrono::microseconds{timeout});
mpWatchDog->addWatcher(this);
}
tcHandler::HandleMessage(message* msg)
{
mpWatchDog->newMessage(msg->id);
response = HandleMessage();
SendResponse();
mpWatchDog->messageDone(msg->id);
}
tcHandler::pendingAckNeeded(void * id)
{
SendPendingAck(*id);
}

Constructor & Destructor Documentation

◆ tcPendingAckWatchdog()

template<class IdType >
SocCamera::tcPendingAckWatchdog< IdType >::tcPendingAckWatchdog ( )
inline

◆ ~tcPendingAckWatchdog()

template<class IdType >
virtual SocCamera::tcPendingAckWatchdog< IdType >::~tcPendingAckWatchdog ( )
inlinevirtual

Member Function Documentation

◆ addWatcher()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::addWatcher ( tcPendingAckWatcher apWatcher)
inline

Register an object for callback notifications

Parameters
apWatcherthe object to receive callbacks

◆ messageDone()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::messageDone ( IdType  id)
inline

Cancel an ongoing timer for the given id.

Parameters
idthe unique ID that should be cancelled

◆ newMessage()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::newMessage ( IdType  id)
inline

Start a timer for for a given message id.

Parameters
idthe unique ID for this timer.

◆ notifyWatchers()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::notifyWatchers ( const void *  apPtr)
inlineprotected

Execute the callbacks of all the watchers for the even.

◆ removeWatcher()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::removeWatcher ( tcPendingAckWatcher apWatcher)
inline

Remove an object for callback notifications

Parameters
apWatcherthe object to be removed

◆ setTimeoutPeriod()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::setTimeoutPeriod ( std::chrono::microseconds  duration)
inline

Set the timeout period for the callback.

Note
the timeout period is scaled by 0.85 to account for slop in the timer notification and callback latency.
Parameters
durationthe timeout period

◆ timerTick()

template<class IdType >
void SocCamera::tcPendingAckWatchdog< IdType >::timerTick ( )
inlineprotected

Handle a tcTimer timeout notification. Call any watcher registered for a message ID that has been marked to expire.

◆ timerTicked()

template<class IdType >
virtual void SocCamera::tcPendingAckWatchdog< IdType >::timerTicked ( tcTimer )
inlinevirtual

tcTimedObject callback interface.

Called by underlying tcTimer class when a timer interval has expired.

Implements tcTimedObject.


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