TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TTEthernetModel::DummySync Class Reference

Dummy sync module. More...

#include <DummySync.h>

Inheritance diagram for TTEthernetModel::DummySync:
TTEthernetModel::SyncBase

Protected Member Functions

virtual void initialize (int stage)
 Initializes the dummy synchronization module. More...
 
virtual int numInitStages () const
 Returns the numer of initializaiton stages this module needs. More...
 
virtual void handleMessage (cMessage *msg)
 dummy synchronization function. More...
 
- Protected Member Functions inherited from TTEthernetModel::SyncBase
void notify (SyncNotificationKind kind)
 

Detailed Description

Dummy sync module.

This module corrects the time of a node by using the simulation time

Warning
Currently only dummy

Definition at line 31 of file DummySync.h.

Member Function Documentation

void DummySync::handleMessage ( cMessage *  msg)
protectedvirtual

dummy synchronization function.

Parameters
msgEvent of the scheduler that triggers the synchronization

Definition at line 47 of file DummySync.cc.

48 {
49  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
50  if(msg->arrivedOn("schedulerIn")){
51  if(tteScheduler->getCycles()>1){
52  uint32_t cycleTicks = tteScheduler->par("cycle_ticks").longValue();
53  simtime_t tick = tteScheduler->par("tick").doubleValue();
54 
55  int64_t modticks = ((int64_t)(simTime()/tick)-par("action_time").longValue())%cycleTicks;
56  if(modticks>((int64_t)cycleTicks/2))
57  modticks=modticks-cycleTicks;
58  modticks+=uniform(-par("precission").doubleValue()/2, par("precission").doubleValue()/2)/tick;
59 
60  tteScheduler->clockCorrection(-modticks);
61  }
62 
64  tteScheduler->registerEvent(event);
65  }
66 }
void DummySync::initialize ( int  stage)
protectedvirtual

Initializes the dummy synchronization module.

registers an event in the scheduler to trigger the synchronization

Parameters
stagethe stages. Module registers events when stage==1

Definition at line 30 of file DummySync.cc.

31 {
32  if(stage==1)
33  {
34  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
36  event->setAction_time(par("action_time").longValue());
37  event->setDestinationGate(gate("schedulerIn"));
38  tteScheduler->registerEvent(event);
39  }
40  if(stage==2)
41  {
42  notify(SYNC);
43  getDisplayString().setTagArg("i", 1, "green");
44  }
45 }
int DummySync::numInitStages ( ) const
protectedvirtual

Returns the numer of initializaiton stages this module needs.

Returns
always returns 2

Definition at line 25 of file DummySync.cc.

26 {
27  return 3;
28 }

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