application.h
来自「OMNET++仿真三色算法的源码,三色算法是无线传感器中一个典型的分簇算法」· C头文件 代码 · 共 113 行
H
113 行
#ifndef APPLICATION_H#define APPLICATION_H#include "omnetpp.h"#include "costants.h"#include "physic.h"
#include "log.h"
class Application : public cSimpleModule{ Module_Class_Members(Application,cSimpleModule,0); private: //number of packet to send in a request burst int pktNum; //the destinatary node of a pkt burst int dest; int pktSize; int numHost; int rate; // pkt per second simtime_t burstInterval, ST1,ST2,ST3; //an unique id of the message int msgId; bool active; //does this app generate traffic?
//new add
int status; // idle , cand, c_head, i_bank, o_band
int role; // head,
int head; // the cluster ID
int LID;
int MAXD;
int posX;
int posY;
bool blClustered; //pointer to the module that hold //the vector with all possible destination Physic* physic;
/*各种事件消息的定义 */
cMessage * CandEvent;
cMessage * HeadEvent;
cMessage * ConflictEvent;
cMessage * JoinEvent;
cMessage * HelloEvent;
cMessage * DataEvent;
cMessage * StartEvent;
cMessage * EndEvent;
public:
int id;
cArray chList, cmList;/*簇首候选列表, 簇成员列表 */
int cmCount;
int nbCount;
bool blFoundNB;
private: /*如果节点是簇头,则在一段时间内会发送Hello信息,普通节点也会接收这条信息,并处理*/
/*接收到某个节点德竞选信息节点发布*/
void handleCand(cMessage* msg);
void handleHead(cMessage* msg);
void handleJoin(cMessage* msg);
void handleConflict(cMessage* msg);
void handleHello(cMessage* msg);
void handleStart(cMessage* msg);
void handleData(cMessage* msg);
void handleEnd(cMessage* msg);
void printNB();
// void Log(char* logdata);
cMessage* genCandMsg();
cMessage* genHeadMsg();
cMessage* genJoinMsg();
cMessage* genConflictMsg();
cMessage* genHelloMsg();
cMessage* genDataMsg();
cMessage* genStartMsg();
cMessage* genEndMsg();
//cMessage*
public: virtual void initialize(); virtual void handleMessage(cMessage* msg); virtual void finish();};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?