TTimer Class Reference

Simu5G: TTimer Class Reference
Simu5G

#include <TTimer.h>

Public Member Functions

 TTimer (cSimpleModule *module)
void start (simtime_t t)
void stop ()
void handle ()
unsigned int getTimerId () const
void setTimerId (unsigned int timerId_)
bool busy ()
bool idle ()
simtime_t elapsed ()
simtime_t remaining ()

Protected Attributes

unsigned int timerId_ = 0
 Timer identifier - will be inserted in each timer-generated message.
opp_component_ptr< cSimpleModule > module_
 Object for handling the event.
TTimerMsg * intr_ = nullptr
 Used for scheduling an event into the Omnet++ event scheduler.
bool busy_ = false
 True if the timer has already been started.
simtime_t start_
 Last time the timer was started.
simtime_t expire_
 Expire time.

Detailed Description

Generic timer interface.

Constructor & Destructor Documentation

◆ TTimer()

TTimer ( cSimpleModule * module)
inlineexplicit

Build an idle timer.

Parameters
module- the connected module
Returns
the idle timer

References expire_, module_, and start_.

Member Function Documentation

◆ start()

void start ( simtime_t t)

Start the timer. The timer is now busy. If the timer has already been started, then there is probably a programming error. Thus, we abort execution immediately.

Parameters
tinterval before timer is triggered

◆ stop()

void stop ( )

Stop the timer, if busy. The timer is now idle.

◆ handle()

void handle ( )

Call-back to signal the timer event handled by connected simpleModule

◆ getTimerId()

unsigned int getTimerId ( ) const
inline

Gets the timer identifier which is inserted into each timer message

Returns
The timer identifier

References timerId_.

◆ setTimerId()

void setTimerId ( unsigned int timerId_)
inline

Sets the timer identifier which is inserted into each timer message

Parameters
timerId_The timer identifier

References timerId_.

◆ busy()

bool busy ( )
inline

Return true if the timer is busy.

Returns
whether the timer is busy or not

References busy_.

◆ idle()

bool idle ( )
inline

Return true if the timer is idle.

Returns
whether the timer is idle or not

References busy_.

◆ elapsed()

simtime_t elapsed ( )
inline

Return the elapsed time from timer start.

Returns
the elapsed time

References start_.

◆ remaining()

simtime_t remaining ( )
inline

Return the remaining time before expiration.

Returns
the remaining time

References expire_.

Member Data Documentation

◆ timerId_

unsigned int timerId_ = 0
protected

Timer identifier - will be inserted in each timer-generated message.

Referenced by getTimerId(), and setTimerId().

◆ module_

opp_component_ptr<cSimpleModule> module_
protected

Object for handling the event.

Referenced by TTimer().

◆ intr_

TTimerMsg* intr_ = nullptr
protected

Used for scheduling an event into the Omnet++ event scheduler.

◆ busy_

bool busy_ = false
protected

True if the timer has already been started.

Referenced by busy(), and idle().

◆ start_

simtime_t start_
protected

Last time the timer was started.

Referenced by elapsed(), and TTimer().

◆ expire_

simtime_t expire_
protected

Expire time.

Referenced by remaining(), and TTimer().