Classes | Public Member Functions | Protected Attributes | Friends

RadioStateAnalogueModel Class Reference
[phyLayer - physical layer modules]

This special AnalogueModel provides filtering of a Signal according to the actual RadioStates the Radio were in during the Signal's time interval. More...

#include <PhyUtils.h>

Inherits AnalogueModel.

Collaboration diagram for RadioStateAnalogueModel:
Collaboration graph
[legend]

List of all members.

Classes

class  ListEntry
 Data structure for the list elements. More...

Public Member Functions

 RadioStateAnalogueModel (double initValue, bool currentlyTracking=false, simtime_t initTime=0)
 Standard constructor for a RadioStateAnalogueModel instance.
virtual void filterSignal (Signal &s)
 Filters the Signal according to the RadioState (passively), i.e. adding an appropriate instance of RSAMMapping to the Signal.
void setTrackingModeTo (bool b)
 sets tracking mode
void cleanUpUntil (simtime_t t)
 Cleans up all stored information strictly before the given time-point, i.e. all elements with their time-point strictly smaller than given key. That means multiple entries with same time are preserved.
void writeRecvEntry (simtime_t time, double value)
 Stores an entry of the form "time-point/attenuation (from now on)".

Protected Attributes

bool currentlyTracking
 Indicator variable whether we are currently tracking changes.
std::list< ListEntryradioStateAttenuation
 Data structure to track the Radios attenuation over time.

Friends

class RSAMMapping
class RSAMConstMappingIterator

Detailed Description

This special AnalogueModel provides filtering of a Signal according to the actual RadioStates the Radio were in during the Signal's time interval.

This AnalogueModel models the effects of the radio state on the received signal. This effects are for example total attenuation during the time the radio is not in receiving state. And no attenuation at all if it is in receiving state.

This way it is assured that the received power calculated for a Signal by use of the AnalogueModels really is the power received, means if the radio is not in receiving state then this is reflected by the received power of the signal. Therefore the Decider which evaluates the receiving power doesn't have to care about if the radio was in correct state to actually receive a signal. It just has to check if the receiving power was/is high enough.

A state-machine-diagram for Radio, RadioStateAnalogueModel and ChannelInfo showing how they work together under control of BasePhyLayer as well as some documentation on how RadioStateAnalogueModel works is available in phyLayer - physical layer modules.

Definition at line 40 of file PhyUtils.h.


Constructor & Destructor Documentation

RadioStateAnalogueModel::RadioStateAnalogueModel ( double  initValue,
bool  currentlyTracking = false,
simtime_t  initTime = 0 
) [inline]

Standard constructor for a RadioStateAnalogueModel instance.

Default setting is: tracking off

Definition at line 120 of file PhyUtils.h.

References radioStateAttenuation.

    : currentlyTracking(currentlyTracking)
  {
    // put the initial time-stamp to the list
    radioStateAttenuation.push_back(ListEntry(initTime, initValue));
  }


Member Function Documentation

void RadioStateAnalogueModel::cleanUpUntil ( simtime_t  t  ) 

Cleans up all stored information strictly before the given time-point, i.e. all elements with their time-point strictly smaller than given key. That means multiple entries with same time are preserved.

Intended to be used by the PhyLayer

THIS SHOULD BE THE ONLY WAY TO DELETE ENTRIES IN THE RECEIVING LIST

Definition at line 14 of file PhyUtils.cc.

References radioStateAttenuation.

Referenced by Radio::cleanAnalogueModelUntil(), and writeRecvEntry().

{
  // assert that list is not empty
  assert(!radioStateAttenuation.empty());

  /* the list contains at least one element */

  // CASE: t is smaller or equal the timepoint of the first element ==> nothing to do, return
  if ( t <= radioStateAttenuation.front().getTime() )
  {
    return;
  }


  // CASE: t is greater than the timepoint of the last element
  // ==> clear complete list except the last element, return
  if ( t > radioStateAttenuation.back().getTime() )
  {
    ListEntry lastEntry = radioStateAttenuation.back();
    radioStateAttenuation.clear();
    radioStateAttenuation.push_back(lastEntry);
    return;
  }

  /*
   * preconditions from now on:
   * 1. list contains at least two elements, since 2. + 3.
   * 2. t > first_timepoint
   * 3. t <= last_timepoint
   */

  // get an iterator and set it to the first timepoint >= t
  std::list<ListEntry>::iterator it;
  it = lower_bound(radioStateAttenuation.begin(), radioStateAttenuation.end(), t);


  // CASE: list contains an element with exactly the given key
  if ( it->getTime() == t )
  {
    radioStateAttenuation.erase(radioStateAttenuation.begin(), it);
    return;
  }

  // CASE: t is "in between two elements"
  // ==> set the iterators predecessors time to t, it becomes the first element
  it--; // go back one element, possible since this one has not been the first one

  it->setTime(t); // set this elements time to t
  radioStateAttenuation.erase(radioStateAttenuation.begin(), it); // and erase all previous elements

}

void RadioStateAnalogueModel::filterSignal ( Signal s  )  [virtual]

Filters the Signal according to the RadioState (passively), i.e. adding an appropriate instance of RSAMMapping to the Signal.

The Signal is added a new RSAMMapping that has a pointer to this instance RadioStateAnalogueModel, hence the pointer is valid as long as the Radio instance exists that has this RSAM as a member.

Implements AnalogueModel.

Definition at line 5 of file PhyUtils.cc.

References Signal::addAttenuation(), Signal::getSignalLength(), and Signal::getSignalStart().

{
  simtime_t start = s.getSignalStart();
  simtime_t end = start + s.getSignalLength();

  RSAMMapping* attMapping = new RSAMMapping(this, start, end);
  s.addAttenuation(attMapping);
}

void RadioStateAnalogueModel::writeRecvEntry ( simtime_t  time,
double  value 
)

Stores an entry of the form "time-point/attenuation (from now on)".

Intended to be used by the Radio

Definition at line 66 of file PhyUtils.cc.

References cleanUpUntil(), currentlyTracking, and radioStateAttenuation.

Referenced by Radio::makeRSAMEntry().

{
  // bugfixed on 08.04.2008
  assert( (radioStateAttenuation.empty()) || (time >= radioStateAttenuation.back().getTime()) );

  radioStateAttenuation.push_back(ListEntry(time, value));

  if (!currentlyTracking)
  {
    cleanUpUntil(time);

    assert(radioStateAttenuation.back().getTime() == time);
  }
}


The documentation for this class was generated from the following files: