📄 physic.h
字号:
//AODV protocol//#ifndef PH_H#define PH_H#include "omnetpp.h"#include "costants.h"
#include "log.h"//in order to avoid the scan of evry module,//I keep the ids of evry mobile host in an array//object that stores the neighbours data. It is a subclass of//cObject in order ot use a cArray to store and handle it//// FIXME it is definately a bad idea to subclass for cObject and use// cArray for storage. Should be changed to a plain struct, and// stored in std::vector. --Andras//class cNeighbour : public cObject{ public: int ph; int mobHost; int gateIndex;
bool blClustered;
int status;
int degree; cNeighbour(); ~cNeighbour();};class Physic : public cSimpleModule{ private: //position of the host itself in the hosts array int myI;
int posX, posY;
/*****above was private var ********************/
//check whether the modules passed //are within the eachother range of trasmission bool isReachable(int, int, int&); //create the gates and the connections //returns the gate index of the physic gate int connectModules(int,int,bool); //disconnect the gates: //physic->mobile, mobile->mobile, mobile->physic //deleting the gates bool disconnectFrom(int, int); //returns the index of the gates that connect //the two modules passed by parameter bool getGateIndex(cModule*,cModule*,int&,int&,int&,int&); //adds a gate to the module passe by parameter. //it try to "recycle" empty slots within the gate vector //before create a new istance of a gate int addNewGate(cModule *mod, char* name, char type); //send a copy of the input message to each neighbour void broadcast(cMessage*); public:
//number of hosts in the map
int numHost ;
//array to achive a faster acces to the other modules
cArray hosts ;
//array of pointers to hosts that are within the range of
//trasmission
cArray nbList ;
//neighbour counter
int nbCount;
//Macro that contains the costructor,destructor //and other Omnett++ stuff Module_Class_Members(Physic, cSimpleModule,0 ) //check whether the other hosts are still //reachable void updateConnections(bool,int); bool checkConnection(int i, bool,int); //device trasmission power,it affect directly the tx range double power; //threshold that part the noise form an actual message double rxThreshold; //channel parameters cPar* delay; cPar* error; cPar* dataRate; //Trasmission range of the module double range; //gives the i-th element of the hosts array void getVect(int,int&,int&); //gates counter int gatesNum ; //set up a cannection between the physic module and //sthe compuntd module, then returns the index of //the external gate (by the referece variable) void setUpConn(char,int&,int&); //delete the link between two modules bool putDownConn(int,int,int,int);
//fulfill the above vector , the private fun, I moved it here
void detectNeighbours();
void detectNB();
//OMNeT++ methods virtual void handleMessage(cMessage*); virtual void initialize(); virtual void finish(); //set and return the host actual position void getPos(int &x, int &y); void setPos(int x, int y); //statistical variable: erroneus message received int msgWithErr;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -