Inheritance diagram for Txc5:

We leave out the counter, to keep the source code small.
Public Member Functions | |
| Module_Class_Members (Txc5, cSimpleModule, 0) | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
Protected Attributes | |
| cMessage * | event |
| cMessage * | tictocMsg |
|
|
Reimplemented from cSimpleModule. 00062 {
00063 // There are several ways of distinguishing messages, for example by message
00064 // kind (an int attribute of cMessage) or by class using dynamic_cast
00065 // (provided you subclass from cMessage). In this code we just check if we
00066 // recognize the pointer, which (if feasible) is the easiest and fastest
00067 // method.
00068 if (msg==event)
00069 {
00070 // The self-message arrived, so we can send out tictocMsg and NULL out
00071 // its pointer so that it doesn't confuse us later.
00072 ev << "Wait period is over, sending back message\n";
00073 send(tictocMsg, "out");
00074 tictocMsg = NULL;
00075 }
00076 else
00077 {
00078 // If the message we received is not our self-message, then it must
00079 // be the tic-toc message arriving from our partner. We remember its
00080 // pointer in the tictocMsg variable, then schedule our self-message
00081 // to come back to us in 1s simulated time.
00082 ev << "Message arrived, starting to wait 1 sec...\n";
00083 tictocMsg = msg;
00084 scheduleAt(simTime()+1.0, event);
00085 }
00086 }
|
|
|
Reimplemented from cModule. 00043 {
00044 // Create the event object we'll use for timing -- just any ordinary message.
00045 event = new cMessage("event");
00046
00047 // No tictoc message yet.
00048 tictocMsg = NULL;
00049
00050 if (strcmp("tic", name()) == 0)
00051 {
00052 // We don't start right away, but instead send an message to ourselves
00053 // (a "self-message") -- we'll do the first sending when it arrives
00054 // back to us, at t=5.0s simulated time.
00055 ev << "Scheduling first send to t=5.0s\n";
00056 tictocMsg = new cMessage("tictocMsg");
00057 scheduleAt(5.0, event);
00058 }
00059 }
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
1.3.9.1