一个简单的基于静态路由表的最佳路由过程
源代码在线查看: application.cpp
//-------------------------------------------------------------------
// file name: application.cpp
//
// - contains the implementation of application class
//
//-------------------------------------------------------------------
#include "application.h"
// some constant definitions
// message definitions
void application::initialize()
{
}
void application::finish()
{
}
void application::handleMessage(cMessage *msg)
{
//msg->addPar("senderPX")=this->parentModule()->par("PX");
//msg->addPar("senderPY")=this->parentModule()->par("PY");
//msg->addPar("senderId")=ID;
//msg->addPar("destination")=msg->par("IPd");
int IPd=(int)msg->par("IPd");
//int px=(int)this->parentModule()->par("PX");
//int py=(int)this->parentModule()->par("PY");
switch(msg->kind())
{
/*case M_LOWHIGH:
{
//this->parentModule()->par("mark")=1;
UPDATECOLOR(3);
//ev
send(msg,"lowergate_out");
//delete msg;
break;
//}
}*/
case M_SELF:
{
if(strcmp(msg->name(),"Start")==0)
{
//this->parentModule()->par("mark")=1;
UPDATECOLOR(3);
cMessage *msg = new cMessage("linknode");
msg->setKind(M_HIGHLOW);
msg->addPar("senderPX")=this->parentModule()->par("PX");
msg->addPar("senderPY")=this->parentModule()->par("PY");
//msg->addPar("senderGX")=this->parentModule()->par("GX");
//msg->addPar("senderGY")=this->parentModule()->par("GY");
msg->addPar("IPd")=IPd;
send(msg,"lowergate_out");
//delete msg;
}
break;
}
//break;
default:
{
ev endSimulation();
delete msg;
}
}
}