資源簡(jiǎn)介
內(nèi)含三色算法的C++環(huán)境下的代碼和在C++環(huán)境下的仿真環(huán)境配置。

代碼片段和文件信息
//-------------------------------------------------------------------
//??file?name:?application.cpp
//?
//????-?contains?the?implementation?of?application?class
//
//-------------------------------------------------------------------
#include?“application.h“
//?some?constant?definitions
//?message?definitions
#define?SEND_BLACK_REQ_NEW { \
cMessage?*msg?=?new?cMessage(“BlackRequest“); \
msg->setKind(M_HIGHLOW); \
msg->addPar(“senderPX“)=this->parentModule()->par(“PX“);\
msg->addPar(“senderPY“)=this->parentModule()->par(“PY“);\
msg->addPar(“senderId“)=ID; \
msg->addPar(“nhops“)=0; \
msg->addPar(“preSenderId“)=ID; \
send(msg“l(fā)owergate_out“); \
}
#define?SEND_GREY_REQ_NEW { \
cMessage?*msg?=?new?cMessage(“GreyRequest“); \
msg->addPar(“senderPX“)=this->parentModule()->par(“PX“);\
msg->addPar(“senderPY“)=this->parentModule()->par(“PY“);\
msg->setKind(M_HIGHLOW); \
msg->addPar(“senderId“)=ID; \
msg->addPar(“nhops“)=nhops; \
msg->addPar(“preSenderId“)=preSenderId; \
send(msg“l(fā)owergate_out“); \
}?
/*
#define?SEND_GREY_REQ_DELAY???? { \
cMessage?*msg?=?new?cMessage(“GreyRequest“); \
msg->addPar(“senderPX“)=this->parentModule()->par(“PX“);\
msg->addPar(“senderPY“)=this->parentModule()->par(“PY“);\
msg->setKind(M_HIGHLOW); \
msg->addPar(“senderId“)=ID; \
msg->addPar(“nhops“)=nhops; \
msg->addPar(“preSenderId“)=preSenderId; \
sendDelayed(msgtime“l(fā)owergate_out“); \
}?
*/
void?application::initialize()
{
isreq=-1;
for(int?i=0;i neibor[i]=-1;
if?(ID==0) //?node?0?starts?the?algorithm
{
isreq=1;
parentModule()->par(“TYPE“)=1;
SEND_BLACK_REQ_NEW;
}
}
void?application::finish()
{
int?type=parentModule()->par(“TYPE“);
if(type==1)
{
for(int?i=0;i if(neibor[i]!=-1)
ev<<“node??“< }
}
void?application::handleMessage(cMessage?*msg)
{
nhops=msg->par(“nhops“);
preSenderId=msg->par(“preSenderId“);
msg->addPar(“senderPX“)=this->parentModule()->par(“PX“);
msg->addPar(“senderPY“)=this->parentModule()->par(“PY“);
switch(msg->kind())
{
case?M_LOWHIGH:
{
if(strcmp(msg->name()“BlackRequest“)==0)
{
processBlackRequest(msg);
break;
}
if(strcmp(msg->name()“GreyRequest“)==0)
{
processGreyRequest(msg);
break;
}
ev?<“unknown?message?received?from?another?node.\n“;
endSimulation();
}
default:
ev?<“unknown?message?received\n“;
endSimulation();
}
}
void?application::processBlackRequest(cMessage?*msg)
{
if(isreq==1||isreq==0)
{
if(nhops==1)
neibor[preSenderId]=msg->par(“senderId“);
delete?msg;
return;
}
else?if?(isreq==-1)
{
UPDATECOLOR(3);
isreq=0;
parentModule()->par(“TYPE“)=0;
double?time=(double)msg->par(“timeout“);
nhops=nhops+1;
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件?????818439??2009-02-20?13:30??WSN成簇仿真\[--VC配置第一彈--]?VC6環(huán)境下的OMNet工程配置?-?OMNeT++?-?NetForum仿真論壇?-?Powered?by?Discuz!.mht
?????文件???????3580??2007-06-06?18:53??WSN成簇仿真\three_color\application.cpp
?????文件???????1136??2007-06-05?11:19??WSN成簇仿真\three_color\application.h
?????文件???????3120??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\application.gif
?????文件???????6566??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\blackboard.gif
????..A.SHR?????????9??2007-03-12?14:25??WSN成簇仿真\three_color\bitmaps\Desktop_.ini
?????文件???????3243??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\energy.gif
?????文件???????3639??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\la
?????文件???????3240??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\sensor.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode.gif
?????文件????????936??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_0_0.gif
?????文件????????926??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_0_1.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_0_2.gif
?????文件????????923??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_0_3.gif
?????文件????????936??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_10_0.gif
?????文件????????926??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_10_1.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_10_2.gif
?????文件????????923??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_10_3.gif
?????文件????????936??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_11_0.gif
?????文件????????926??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_11_1.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_11_2.gif
?????文件????????923??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_11_3.gif
?????文件????????936??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_12_0.gif
?????文件????????926??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_12_1.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_12_2.gif
?????文件????????923??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_12_3.gif
?????文件????????936??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_13_0.gif
?????文件????????926??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_13_1.gif
?????文件????????919??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_13_2.gif
?????文件????????923??2004-03-25?06:22??WSN成簇仿真\three_color\bitmaps\snode_13_3.gif
............此處省略66個(gè)文件信息
評(píng)論
共有 條評(píng)論