OpenASIP
2.0
src
applibs
Explorer
FrequencySweep.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2009 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file FrequencySweep.cc
26
*
27
* Implementation of the FrequencySweep class.
28
*
29
* @author Jari Mäntyneva 2007 (jari.mantyneva-no.spam-tut.fi)
30
* @note rating: red
31
*/
32
33
#include "
FrequencySweep.hh
"
34
35
/**
36
* Constructor of the FrequencySweep.
37
*
38
* @param startMHz Start frequency in MHz.
39
* @param endMHz End frequency in MHz.
40
* @param stepMHz Stepping frequency in MHz.
41
* @exception IllegalParameters Throws if the frequencies are smaller than one.
42
*/
43
FrequencySweep::FrequencySweep
(
int
startMHz,
int
endMHz,
int
stepMHz)
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
}
59
60
/**
61
* The destructor.
62
*/
63
FrequencySweep::~FrequencySweep
() {
64
}
65
66
/**
67
* Returns the next frequency or zero if all steps have been returned and steps
68
* forward.
69
*
70
* @return Next frequency of zero if all steps have been returned.
71
*/
72
int
73
FrequencySweep::nextFrequency
() {
74
75
if
(
hasNext_
==
false
) {
76
return
0;
77
}
78
int
current =
nextFrequency_
;
79
nextFrequency_
= current +
stepMHz_
;
80
if
(
nextFrequency_
>
endMHz_
) {
81
nextFrequency_
=
endMHz_
;
82
if
(current ==
nextFrequency_
) {
83
hasNext_
=
false
;
84
}
85
}
86
return
current;
87
}
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
FrequencySweep::FrequencySweep
FrequencySweep(int startMHz, int endMHz, int stepMHz)
Definition:
FrequencySweep.cc:43
IllegalParameters
Definition:
Exception.hh:113
__func__
#define __func__
Definition:
Application.hh:67
FrequencySweep::~FrequencySweep
virtual ~FrequencySweep()
Definition:
FrequencySweep.cc:63
FrequencySweep.hh
FrequencySweep::nextFrequency
int nextFrequency()
Definition:
FrequencySweep.cc:73
FrequencySweep::endMHz_
int endMHz_
End frequency.
Definition:
FrequencySweep.hh:59
FrequencySweep::stepMHz_
int stepMHz_
Step frequency.
Definition:
FrequencySweep.hh:61
Generated by
1.8.17