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

📄 dsss_ad_hoc.h

📁 博弈论自适应功率控制中的实现
💻 H
字号:
#ifndef _DSSS_ad_hoc_h_
#define _DSSS_ad_hoc_h_

#include <fstream.h>

#include "DSSS_radio.h"

class DSSS_ad_hoc : public generic_radio
{
protected:
	DSSS_transmit my_xmt;
	DSSS_receive my_rcv;

public:
	DSSS_ad_hoc()
	{
		static int num_ad_hoc = 0;
		node_id = num_ad_hoc;
		num_ad_hoc++;
	}; // constructor
	
	void hook_radio(generic_radio *g)
	{
		my_rcv.add_radio(g);
	};

	generic_radio* get_xmt_pointer(void)
	{
		return &my_xmt;	
	};

	void update_decision(void)
	{
		if(node_of_interest!=this)
			my_xmt.update_decision(); //otherwise do nothing
	};

	void update_incident_power(void)
	{
		my_rcv.update_incident_power();
		incident_power = my_rcv.get_incident_power();
	};

	void set_power(double power)
	{
		my_xmt.set_power(power); 
	};
	
	double get_power(void)
	{
		return my_xmt.get_power();
	};

	virtual void set_pos(double d1, double d2)
	{
		//internal
		x = d1;
		y = d2;
		//components
		my_xmt.set_pos(d1,d2);
		my_rcv.set_pos(d1,d2);
	};

	virtual void update_stats(void)
	{
		my_xmt.update_stats();	
	};

	virtual void set_node_of_interest(generic_radio *gr)
	{
		node_of_interest = gr;
		my_xmt.set_node_of_interest(gr);
		my_rcv.set_node_of_interest(gr);
	};

	virtual int allocate_space(int N)
	{
		my_xmt.allocate_space(N);	
		my_rcv.allocate_space(N);
		return 0;
	};

	void set_noise(double d)
	{
		my_rcv.set_noise(d);
	};

	double get_noise(void)
	{
		return my_rcv.get_noise();
	};


	friend ifstream& operator>> (ifstream &fin, DSSS_ad_hoc &d)
	{
		double temp_noise;;
		double temp_x, temp_y;
		double garbage;


		fin >> d.node_id;
		fin >> temp_x;
		fin >> temp_y;
		d.set_pos(temp_x,temp_y);

		fin >> garbage;
		
		fin >>garbage;
		d.node_of_interest_id = (int) garbage;
		
		fin >> d.my_xmt;

		fin >> temp_noise;
		d.set_noise(dB2lin(temp_noise));
		
		return fin;
	};

	friend ofstream& operator<< (ofstream &fout, DSSS_ad_hoc &d)
	{
		fout << d.my_xmt;
		return fout;
	};
};
#endif

⌨️ 快捷键说明

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