OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
FrequencySweep Class Reference

#include <FrequencySweep.hh>

Collaboration diagram for FrequencySweep:
Collaboration graph

Public Member Functions

 FrequencySweep (int startMHz, int endMHz, int stepMHz)
 
virtual ~FrequencySweep ()
 
int nextFrequency ()
 

Private Attributes

int nextFrequency_
 Next frequency to be returned. More...
 
bool hasNext_
 Flag indicating is there next frequency to return. More...
 
int endMHz_
 End frequency. More...
 
int stepMHz_
 Step frequency. More...
 

Detailed Description

Sweeps through the frequencies from lowest frequency towards the highest frequency and returns all step frequencies including the start and end frequency.

FrequencySweep takes start and and frequencies and a step frequency that tells how big frequency steps are taken between the start and end point.

Definition at line 47 of file FrequencySweep.hh.

Constructor & Destructor Documentation

◆ FrequencySweep()

FrequencySweep::FrequencySweep ( int  startMHz,
int  endMHz,
int  stepMHz 
)

Constructor of the FrequencySweep.

Parameters
startMHzStart frequency in MHz.
endMHzEnd frequency in MHz.
stepMHzStepping frequency in MHz.
Exceptions
IllegalParametersThrows if the frequencies are smaller than one.

Definition at line 43 of file FrequencySweep.cc.

44  : hasNext_(true), endMHz_(endMHz), stepMHz_(stepMHz) {
45  // Sweep is always done from the lowest frequency towards the highest
46  // frequency.
47  if (startMHz > endMHz) {
48  int tempMHz = startMHz;
49  startMHz = endMHz;
50  endMHz = tempMHz;
51  }
52 
53  if (startMHz < 1 || stepMHz < 1) {
54  std::string message = "Parameter value lower than one.";
55  throw IllegalParameters(__FILE__, __LINE__, __func__, message);
56  }
57  nextFrequency_ = startMHz;
58 }

References __func__, and nextFrequency_.

◆ ~FrequencySweep()

FrequencySweep::~FrequencySweep ( )
virtual

The destructor.

Definition at line 63 of file FrequencySweep.cc.

63  {
64 }

Member Function Documentation

◆ nextFrequency()

int FrequencySweep::nextFrequency ( )

Returns the next frequency or zero if all steps have been returned and steps forward.

Returns
Next frequency of zero if all steps have been returned.

Definition at line 73 of file FrequencySweep.cc.

73  {
74 
75  if (hasNext_ == false) {
76  return 0;
77  }
78  int current = nextFrequency_;
79  nextFrequency_ = current + stepMHz_;
80  if (nextFrequency_ > endMHz_) {
82  if (current == nextFrequency_) {
83  hasNext_ = false;
84  }
85  }
86  return current;
87 }

References endMHz_, hasNext_, nextFrequency_, and stepMHz_.

Referenced by FrequencySweepExplorer::explore().

Member Data Documentation

◆ endMHz_

int FrequencySweep::endMHz_
private

End frequency.

Definition at line 59 of file FrequencySweep.hh.

Referenced by nextFrequency().

◆ hasNext_

bool FrequencySweep::hasNext_
private

Flag indicating is there next frequency to return.

Definition at line 57 of file FrequencySweep.hh.

Referenced by nextFrequency().

◆ nextFrequency_

int FrequencySweep::nextFrequency_
private

Next frequency to be returned.

Definition at line 55 of file FrequencySweep.hh.

Referenced by FrequencySweep(), and nextFrequency().

◆ stepMHz_

int FrequencySweep::stepMHz_
private

Step frequency.

Definition at line 61 of file FrequencySweep.hh.

Referenced by nextFrequency().


The documentation for this class was generated from the following files:
FrequencySweep::nextFrequency_
int nextFrequency_
Next frequency to be returned.
Definition: FrequencySweep.hh:55
FrequencySweep::hasNext_
bool hasNext_
Flag indicating is there next frequency to return.
Definition: FrequencySweep.hh:57
IllegalParameters
Definition: Exception.hh:113
__func__
#define __func__
Definition: Application.hh:67
FrequencySweep::endMHz_
int endMHz_
End frequency.
Definition: FrequencySweep.hh:59
FrequencySweep::stepMHz_
int stepMHz_
Step frequency.
Definition: FrequencySweep.hh:61