📄 fading.c
字号:
/*************************************************************************** fading.c - Module for the net-server that makes a simple fading channel ------------------- begin : 2002 authors : Linus Gasser emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 02-12-16 - ineiti - begin **************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include <math.h>#include "system.h"#include "debugging.h"#include "server.h"#define DBG_LVL 0/** * @short a simple fading channel with no reflexions */double path_loss_fading[MAX_CLIENTS][MAX_CLIENTS];/** * @short initialises the channel */void fading_init() { path_loss_fading[0][0] = pow( 10.0, -4.0 ); path_loss_fading[0][1] = pow( 10.0, -4.0 ); path_loss_fading[0][2] = pow( 10.0, -4.0 ); path_loss_fading[1][1] = pow( 10.0, -10.0 ); path_loss_fading[1][0] = pow( 10.0, -4.0 ); path_loss_fading[1][2] = pow( 10.0, -4.0 ); path_loss_fading[2][2] = pow( 10.0, -10.0 ); path_loss_fading[2][0] = pow( 10.0, -4.0 ); path_loss_fading[2][1] = pow( 10.0, -4.0 );}/** * @short calculates the fading */void fading_calc( int nb_clients ) { int n,i,j; short *rx, *tx; double gain; for ( i = 0; i < MAX_CLIENTS; i++ ) { if ( client[i].id == -1 ) { continue; } rx = (short*)rx_signal_buffer[i][BLOCK_ACT_RX(tx_block)]; memset( rx, 0, DAQ_DMA_BLOCK_SIZE_BYTES ); PR_DBG( 4, "rx_gain0 = %e,tx_gain0 = %e\n", rx_gain[0], tx_gain[0] ); PR_DBG( 4, "rx_gain1 = %e,tx_gain1 = %e\n", rx_gain[1], tx_gain[1] ); for ( j = 0; j < MAX_CLIENTS; j++ ) { if ( client[j].id == -1 ) { continue; } gain = rx_gain[i] * tx_gain[j] * path_loss_fading[i][j]; tx = (short*)tx_signal_buffer[j][BLOCK_ACT_TX(tx_block)]; for ( n = 0; n < DAQ_DMA_BLOCK_SIZE_SAMPLES; n++ ) { rx[n] += sqrt( gain * tx[n] ); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -