This is Unofficial EPICS BASE Doxygen Site
searchTimer Class Reference

#include "searchTimer.h"

+ Inheritance diagram for searchTimer:
+ Collaboration diagram for searchTimer:

Public Member Functions

 searchTimer (class searchTimerNotify &, epicsTimerQueue &, const unsigned index, epicsMutex &, bool boostPossible)
 
virtual ~searchTimer ()
 
void start (epicsGuard< epicsMutex > &)
 
void shutdown (epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void moveChannels (epicsGuard< epicsMutex > &, searchTimer &dest)
 
void installChannel (epicsGuard< epicsMutex > &, nciu &)
 
void uninstallChan (epicsGuard< epicsMutex > &, nciu &)
 
void uninstallChanDueToSuccessfulSearchResponse (epicsGuard< epicsMutex > &, nciu &, ca_uint32_t respDatagramSeqNo, bool seqNumberIsValid, const epicsTime &currentTime)
 
void show (unsigned level) const
 

Detailed Description

Definition at line 52 of file searchTimer.h.

Constructor & Destructor Documentation

searchTimer::searchTimer ( class searchTimerNotify iiuIn,
epicsTimerQueue &  queueIn,
const unsigned  index,
epicsMutex &  mutexIn,
bool  boostPossible 
)

Definition at line 38 of file searchTimer.cpp.

43  :
44  timeAtLastSend ( epicsTime::getCurrent () ),
45  timer ( queueIn.createTimer () ),
46  iiu ( iiuIn ),
47  mutex ( mutexIn ),
48  framesPerTry ( initialTriesPerFrame ),
49  framesPerTryCongestThresh ( DBL_MAX ),
50  retry ( 0 ),
51  searchAttempts ( 0u ),
52  searchResponses ( 0u ),
53  index ( indexIn ),
54  dgSeqNoAtTimerExpireBegin ( 0u ),
55  dgSeqNoAtTimerExpireEnd ( 0u ),
56  boostPossible ( boostPossibleIn ),
57  stopped ( false )
58 {
59 }
searchTimer::~searchTimer ( )
virtual

Definition at line 67 of file searchTimer.cpp.

68 {
69  assert ( this->chanListReqPending.count() == 0 );
70  assert ( this->chanListRespPending.count() == 0 );
71  this->timer.destroy ();
72 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
void destroy()
Definition: timer.cpp:47
unsigned count() const
Definition: tsDLList.h:181

Member Function Documentation

void searchTimer::installChannel ( epicsGuard< epicsMutex > &  guard,
nciu chan 
)

Definition at line 99 of file searchTimer.cpp.

101 {
102  this->chanListReqPending.add ( chan );
103  chan.channelNode::setReqPendingState ( guard, this->index );
104 }
void add(T &item)
Definition: tsDLList.h:313
void searchTimer::moveChannels ( epicsGuard< epicsMutex > &  guard,
searchTimer dest 
)

Definition at line 106 of file searchTimer.cpp.

108 {
109  while ( nciu * pChan = this->chanListRespPending.get () ) {
110  if ( this->searchAttempts > 0 ) {
111  this->searchAttempts--;
112  }
113  dest.installChannel ( guard, *pChan );
114  }
115  while ( nciu * pChan = this->chanListReqPending.get () ) {
116  dest.installChannel ( guard, *pChan );
117  }
118 }
void installChannel(epicsGuard< epicsMutex > &, nciu &)
Definition: searchTimer.cpp:99
T * get()
Definition: tsDLList.h:261
Definition: nciu.h:127
void searchTimer::show ( unsigned  level) const

Definition at line 289 of file searchTimer.cpp.

290 {
291  epicsGuard < epicsMutex > guard ( this->mutex );
292  ::printf ( "searchTimer with period %f\n", this->period ( guard ) );
293  if ( level > 0 ) {
294  ::printf ( "channels with search request pending = %u\n",
295  this->chanListReqPending.count () );
296  if ( level > 1u ) {
297  tsDLIterConst < nciu > pChan =
298  this->chanListReqPending.firstIter ();
299  while ( pChan.valid () ) {
300  pChan->show ( level - 2u );
301  pChan++;
302  }
303  }
304  ::printf ( "channels with search response pending = %u\n",
305  this->chanListRespPending.count () );
306  if ( level > 1u ) {
307  tsDLIterConst < nciu > pChan =
308  this->chanListRespPending.firstIter ();
309  while ( pChan.valid () ) {
310  pChan->show ( level - 2u );
311  pChan++;
312  }
313  }
314  }
315 }
tsDLIterConst< T > firstIter() const
Definition: tsDLList.h:459
#define printf
Definition: epicsStdio.h:41
unsigned count() const
Definition: tsDLList.h:181
bool valid() const
Definition: tsDLList.h:506
void show(unsigned level) const
Definition: nciu.cpp:472
void searchTimer::shutdown ( epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 74 of file searchTimer.cpp.

77 {
78  this->stopped = true;
79  {
80  epicsGuardRelease < epicsMutex > unguard ( guard );
81  {
82  epicsGuardRelease < epicsMutex > cbUnguard ( cbGuard );
83  this->timer.cancel ();
84  }
85  }
86 
87  while ( nciu * pChan = this->chanListReqPending.get () ) {
88  pChan->channelNode::listMember =
89  channelNode::cs_none;
90  pChan->serviceShutdownNotify ( cbGuard, guard );
91  }
92  while ( nciu * pChan = this->chanListRespPending.get () ) {
93  pChan->channelNode::listMember =
94  channelNode::cs_none;
95  pChan->serviceShutdownNotify ( cbGuard, guard );
96  }
97 }
T * get()
Definition: tsDLList.h:261
void cancel()
Definition: timer.cpp:135
Definition: nciu.h:127
void searchTimer::start ( epicsGuard< epicsMutex > &  guard)

Definition at line 61 of file searchTimer.cpp.

62 {
63  guard.assertIdenticalMutex ( this->mutex );
64  this->timer.start ( *this, this->period ( guard ) );
65 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
void searchTimer::uninstallChan ( epicsGuard< epicsMutex > &  cacGuard,
nciu chan 
)

Definition at line 363 of file searchTimer.cpp.

365 {
366  cacGuard.assertIdenticalMutex ( this->mutex );
367  unsigned ulistmem =
368  static_cast <unsigned> ( chan.channelNode::listMember );
369  unsigned uReqBase =
370  static_cast <unsigned> ( channelNode::cs_searchReqPending0 );
371  if ( ulistmem == this->index + uReqBase ) {
372  this->chanListReqPending.remove ( chan );
373  }
374  else {
375  unsigned uRespBase =
376  static_cast <unsigned > (
377  channelNode::cs_searchRespPending0 );
378  if ( ulistmem == this->index + uRespBase ) {
379  this->chanListRespPending.remove ( chan );
380  }
381  else {
382  throw std::runtime_error (
383  "uninstalling channel search timer, but channel "
384  "state is wrong" );
385  }
386  }
387  chan.channelNode::listMember = channelNode::cs_none;
388 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
void remove(T &item)
Definition: tsDLList.h:219
void searchTimer::uninstallChanDueToSuccessfulSearchResponse ( epicsGuard< epicsMutex > &  guard,
nciu chan,
ca_uint32_t  respDatagramSeqNo,
bool  seqNumberIsValid,
const epicsTime &  currentTime 
)

Definition at line 322 of file searchTimer.cpp.

326 {
327  guard.assertIdenticalMutex ( this->mutex );
328  this->uninstallChan ( guard, chan );
329 
330  if ( this->stopped ) {
331  return;
332  }
333 
334  bool validResponse = true;
335  if ( seqNumberIsValid ) {
336  validResponse =
337  this->dgSeqNoAtTimerExpireBegin <= respDatagramSeqNo &&
338  this->dgSeqNoAtTimerExpireEnd >= respDatagramSeqNo;
339  }
340 
341  // if we receive a successful response then reset to a
342  // reasonable timer period
343  if ( validResponse ) {
344  double measured = currentTime - this->timeAtLastSend;
345  this->iiu.updateRTTE ( guard, measured );
346 
347  if ( this->searchResponses < UINT_MAX ) {
348  this->searchResponses++;
349  if ( this->searchResponses == this->searchAttempts ) {
350  if ( this->chanListReqPending.count () ) {
351  //
352  // when we get 100% success immediately
353  // send another search request
354  //
355  debugPrintf ( ( "All requests succesful, set timer delay to zero\n" ) );
356  this->timer.start ( *this, currentTime );
357  }
358  }
359  }
360  }
361 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
unsigned count() const
Definition: tsDLList.h:181
void uninstallChan(epicsGuard< epicsMutex > &, nciu &)
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
virtual void updateRTTE(epicsGuard< epicsMutex > &, double rtte)=0

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