📄 calculations.h
字号:
#ifndef CAL_#define CAL_#include "CommonIncludes.h"#include "Gear_packet_m.h"#define ALPHA 1.0class Location:public cObject{ public: int x; int y; void operator= (Location loc) { x= loc.x; y = loc.y; } Location(int LocX,int LocY) { x=LocX; y=LocY; }};class Print{ public: Print(); void PrintHeader(Header* hdr);};class QuId: public cObject{ private: static int queryID; public: static int getNextQueryId() { queryID=++queryID; return queryID; } };//int QuId::queryID=0;class QueryObject: public cObject{ private: //int QueryId; char queryId[50]; unsigned int SrcId; unsigned int FinalSrc; unsigned int DestId; bool isAlive; public: QueryObject(); ~QueryObject(); QueryObject(char* id,unsigned int srcId,unsigned int destId, unsigned int nodeid); QueryObject(char* id); char* getQueryId(); unsigned int getSrcId(); unsigned int getDestId(); void setQueryId(char qid[50]); void setSrcId(unsigned int srcId); void setDestId(unsigned int destId); unsigned int getFinalSrc(); void setFinalSrc(unsigned int nodeid); void setIsAlive(bool flag); bool getIsAlive();}; class NeighbhorInfo: public cObject{ private: unsigned int NeighNodeId; Location* NeighPos; double Energy; public: NeighbhorInfo(); NeighbhorInfo(unsigned int nodeId, Location *loc,double energy); unsigned int getNodeId(); Location* getNeighPos(); double getEnergy(); Location* getLocation(unsigned int nodeId); void setNodeId(unsigned int NodeId); void setNeighPos(Location* loc); void setEnergy(double energy);};class Cost:public cObject{ private: unsigned int NodeId; double cost; public: Cost(unsigned int NodeId,double Nodecost); double getNodecost(); unsigned int getNodeId(); void setNodeId(unsigned int nodeId); void setNodecost(double nodecost); };class Region:public cObject{ private: cArray *RegionCost; Location *loc; char RegionName[255]; simtime_t LastUpdatedTime; cArray *SrcNodeList; cArray* QueryList; simtime_t DataUpdateTime; simtime_t ExploratoryTime; public: Region(); ~Region(); Region( Location * loc,int range); void addCost(Cost *cost); cArray* getRegionCost(); simtime_t getLastUpdateTime(){ return LastUpdatedTime; } void setLastUpdatedTime(simtime_t UpdatedTime) { LastUpdatedTime=UpdatedTime; } simtime_t getExploratoryTime(){return ExploratoryTime;} void setExploratoryTime(simtime_t expTime){ExploratoryTime = expTime;} cArray* getSrcNodeList(); char* getRegionName(); Location* getRegionLocation(); cArray* getQueryList(); cArray* addToQueryList(QueryObject* qryObject); void setDataUpdateTime(simtime_t dataUpdateTime); simtime_t getDataUpdateTime();}; class IdWrapper:public cObject{ public: unsigned int NodeId; IdWrapper(unsigned int nodeid); unsigned int getNodeId();};class queryEnforceTime:public cObject{ public: char strQry[50]; simtime_t sTime; queryEnforceTime(char strQry[50], simtime_t sTime); simtime_t getQueryEnforceTime();};class Heuristics :public cObject{ cArray* HeuristicTable; public: Heuristics(); double Distance(int xPos,int iPos, int destxPos,int destyPos); //Input :region of interest //output: NodId of least learned Cost void LearnedCostEntry(Region* reg,Cost* cost); //Input : NodeId,Location of load, energy //output: Updates the heuristic table with the new learned cost for region and called when the reply to beacon is got //Cost* EstimateCost(NeighbhorInfo* neigh,Location* RegionLoc); Cost* EstimateCost(NeighbhorInfo* neigh,Location* RegionLoc, double maxEnergy, double minEnergy, double maxDis, double minDis); double EnergyMinValue(cArray* a_neigh_list); double EnergyMaxValue(cArray* a_neigh_list); double DisMaxValue(cArray* a_neigh_list, int RegionX, int RegionY); double DisMinValue(cArray* a_neigh_list, int RegionX, int RegionY);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -