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

📄 mac-sensor-timers.cc

📁 无线传感器网络中,基于ns2仿真平台,mannasim的源代码,研究ns2必不可少的
💻 CC
字号:
/******************************************************************
 * This code was developed as part of the MIT uAMPS project.      *
 ******************************************************************/

#include "mac-sensor.h"
#include "mac-sensor-timers.h"


/* ======================================================================
   Timers
   ====================================================================== */

void
MacSensorTimer::start(Packet *p, double time)
{
	Scheduler &s = Scheduler::instance();

	assert(busy_ == 0);

	busy_ = 1;
	paused_ = 0;
	stime = s.clock();
	rtime = time;
	assert(rtime >= 0.0);

	s.schedule(this, p, rtime);
}

void
MacSensorTimer::stop(Packet *p)
{
	Scheduler &s = Scheduler::instance();

	assert(busy_);

	if(paused_ == 0)
		s.cancel((Event *)p);

	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;
}

/* ======================================================================
   Defer Timer
   ====================================================================== */

void    
DeferSensorTimer::handle(Event *e)
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;

	mac->deferHandler(e);
}

/* ======================================================================
   Receive Timer
   ====================================================================== */

void    
RxSensorTimer::handle(Event *e)
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;

	mac->recvHandler(e);
}


/* ======================================================================
   Send Timer
   ====================================================================== */

void    
TxSensorTimer::handle(Event *e)
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;

	mac->sendHandler(e);
}

⌨️ 快捷键说明

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