#include <string.h>
#include <omnetpp.h>
class Txc2 : public cSimpleModule
{
private:
//添加模块坐标属性
const char *positionX;
const char *positionY;
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
Define_Module(Txc2);
void Txc2::initialize()
{
if (strcmp("tic", getName()) == 0)
{
// The `ev' object works like `cout' in C++.
EV << "Sending initial message\n";
cMessage *msg = new cMessage("tictocMsg");
send(msg, "out");
}
}
void Txc2::handleMessage(cMessage *msg)
{
EV <<"***********获取坐标*************************\n";
cDisplayString& dispStr = getDisplayString();
positionX = dispStr.getTagArg("p", 0);
positionY = dispStr.getTagArg("p", 1);
EV<<positionX<< "*************************\n";
EV<<positionY<< "*************************\n";
// msg->getName() is name of the msg object, here it will be "tictocMsg".
EV << "Received message `" << msg->getName() << "', sending it out again\n";
send(msg, "out");
}