⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newnetlayer.cc

📁 基于Oment++的无线传感器网络仿真
💻 CC
字号:
#include "NewNetLayer.h"Define_Module_Like ( NewNetLayer , NewNetLayerModule );NewNetLayer::NewNetLayer(const char *name, cModule *parentModule, unsigned stacksize) :	NetLayerBase(name, parentModule, stacksize){//	printf("\n\t In constructor for NewNetLayer");}void NewNetLayer::initialize(){//	printf("\n\t In NetLayerSimple::initialize()");//	ev << "\n\t In NetLayerSimple::initialize()";//	printf("\n\t NetLayerModule: Name of current module: %s", fullName());	cModule *pNode = parentModule();	pCoOrdinator = pNode->submodule("CoOrdinator");	return;}void NewNetLayer::handleMessage(cMessage *msg){//	printf("\n\t In NetLayerSimple::handleMessage");//	ev <<  "\n\t In NetLayerSimple::handleMessage";	if (TARGET == msg->kind())	{		cModule *pNode = parentModule();		int iNodeId = pNode->par("NodeId");		printf("\n\t NetLayerSimple::handleMessage for Node: %d, Message Received from TopNetLayer", iNodeId);		msg->par("xPos") = pNode->par("xPos");		msg->par("yPos") = pNode->par("yPos");		if (-1 == msg->findPar("RadioPower"))			msg->addPar("RadioPower") = 5;		//send(msg, "toBottomLayer");	}	else if(DATA == msg->kind())	{		cModule *pNode = parentModule();		int iNodeId = pNode->par("NodeId");//		printf("\n\t NetLayerSimple::handleMessage for Node: %d, Message Received of type DATA from BottomNetLayer", iNodeId);		cGate *pTopGate = gate("toTopLayer");		if (true == pTopGate->isConnected())			send(msg, "toTopLayer");	}	else		printf("\n\t NetLayerSimple::handleMessage, Message Received but NOT of type TARGET");}void NewNetLayer :: finish (){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -