📄 callgenerator.cpp
字号:
//////////////////////////////////////////////////////////////////////
// Title: A Cooperative Negotiation Approach for Cellular Coverage Control
//
// Description: Using cooperative negotiation to dynamically control the cell size and
// shapes according to different call traffic distributions.
//
// Copyright: Copyright (c) 2002
// Company: Elec. Eng., Queen Mary, University of London
// @author Lin Du
// @version 1.0
//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Simple call generator, only used for snapshot simulation.
//////////////////////////////////////////////////////////////////////
// allGenerator.cpp: implementation of the CallGenerator class.
//
//////////////////////////////////////////////////////////////////////
#include "CallGenerator.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CallGenerator::CallGenerator() {
prevTime = 0;
isTalking = false;
lambda = CALL_ARRIVAL_RATE;
arrivalTime = this->getRnd();
lambda = 1.0 / CALL_HOLDING_TIME;
holdingTime = this->getRnd();
while ( holdingTime < MIN_HOLDING_TIME )
holdingTime = this->getRnd();
}
CallGenerator::~CallGenerator() {
}
//////////////////////////////////////////////////////////////////////
// decide if this MS want to talk or not.
//////////////////////////////////////////////////////////////////////
bool CallGenerator::talking(double currentTime) {
// Check if this MS on talking
if( isTalking ) {
// on talking, check if it want to stop.
if( currentTime - prevTime > holdingTime ) {
// stop talking
prevTime = currentTime;
isTalking = false;
// set arrival time for the next call
lambda = CALL_ARRIVAL_RATE;
arrivalTime = this->getRnd();
}
}else {
// not talking, check if it want to talk now
if( currentTime - prevTime > ( arrivalTime - holdingTime ) ) {
// start to talk
prevTime = currentTime;
isTalking = true;
// set arrival time for the next call
lambda = 1.0 / CALL_HOLDING_TIME;
holdingTime = this->getRnd();
}
}
return isTalking;
}
//////////////////////////////////////////////////////////////////////
// Return the state of this object
//////////////////////////////////////////////////////////////////////
void CallGenerator::getState(bool *isTalking, double *prevTime, double *arrivalTime, double *holdingTime) {
*isTalking = this->isTalking;
*prevTime = this->prevTime;
*arrivalTime = this->arrivalTime;
*holdingTime = this->holdingTime;
}
//////////////////////////////////////////////////////////////////////
// Reset the state of this object
//////////////////////////////////////////////////////////////////////
void CallGenerator::reset(bool isTalking, double prevTime, double arrivalTime, double holdingTime) {
this->isTalking = isTalking;
this->prevTime = prevTime;
this->arrivalTime = arrivalTime;
this->holdingTime = holdingTime;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -