Inheritance diagram for Txc5:

We leave out the counter, to keep the source code small.
Public Member Functions | |
| Txc5 () | |
| virtual | ~Txc5 () |
Protected Member Functions | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
Private Attributes | |
| cMessage * | event |
| cMessage * | tictocMsg |
|
|
00045 {
00046 // Set the pointer to NULL, so that the destructor won't crash
00047 // even if initialize() doesn't get called because of a runtime
00048 // error or user cancellation during the startup process.
00049 event = tictocMsg = NULL;
00050 }
|
|
|
00053 {
00054 // Dispose of dynamically allocated the objects
00055 cancelAndDelete(event);
00056 delete tictocMsg;
00057 }
|
|
|
Reimplemented from cSimpleModule. 00079 {
00080 // There are several ways of distinguishing messages, for example by message
00081 // kind (an int attribute of cMessage) or by class using dynamic_cast
00082 // (provided you subclass from cMessage). In this code we just check if we
00083 // recognize the pointer, which (if feasible) is the easiest and fastest
00084 // method.
00085 if (msg==event)
00086 {
00087 // The self-message arrived, so we can send out tictocMsg and NULL out
00088 // its pointer so that it doesn't confuse us later.
00089 ev << "Wait period is over, sending back message\n";
00090 send(tictocMsg, "out");
00091 tictocMsg = NULL;
00092 }
00093 else
00094 {
00095 // If the message we received is not our self-message, then it must
00096 // be the tic-toc message arriving from our partner. We remember its
00097 // pointer in the tictocMsg variable, then schedule our self-message
00098 // to come back to us in 1s simulated time.
00099 ev << "Message arrived, starting to wait 1 sec...\n";
00100 tictocMsg = msg;
00101 scheduleAt(simTime()+1.0, event);
00102 }
00103 }
|
|
|
Reimplemented from cModule. 00060 {
00061 // Create the event object we'll use for timing -- just any ordinary message.
00062 event = new cMessage("event");
00063
00064 // No tictoc message yet.
00065 tictocMsg = NULL;
00066
00067 if (strcmp("tic", name()) == 0)
00068 {
00069 // We don't start right away, but instead send an message to ourselves
00070 // (a "self-message") -- we'll do the first sending when it arrives
00071 // back to us, at t=5.0s simulated time.
00072 ev << "Scheduling first send to t=5.0s\n";
00073 tictocMsg = new cMessage("tictocMsg");
00074 scheduleAt(5.0, event);
00075 }
00076 }
|
|
|
|
|
|
|
1.4.1