WirelessInterfaceAPI.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief WirelessInterfaceAPI inline non-template implementation */
16 
17 // Custom includes
18 
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 // senf::emu::WirelessInterface::Frequency
24 
25 prefix_ senf::emu::WirelessInterface::Frequency::Frequency(unsigned frequencyLower_,
26  unsigned frequencyUpper_,
27  unsigned bandwidthLower_,
28  unsigned bandwidthUpper_)
29  : frequencyLower(frequencyLower_), frequencyUpper(frequencyUpper_), bandwidthLower(bandwidthLower_),
30  bandwidthUpper(bandwidthUpper_)
31 {}
32 
33 prefix_ senf::emu::WirelessInterface::Frequency::Frequency(unsigned frequency_,
34  unsigned bandwidth_)
35  : frequencyLower(frequency_), frequencyUpper(frequency_), bandwidthLower(bandwidth_),
36  bandwidthUpper(bandwidth_)
37 {}
38 
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
40 // senf::emu::WirelessInterface
41 
42 prefix_ unsigned senf::emu::WirelessInterface::frequency()
43  const
44 {
45  return v_frequency();
46 }
47 
48 prefix_ unsigned senf::emu::WirelessInterface::bandwidth()
49  const
50 {
51  return v_bandwidth();
52 }
53 
54 prefix_ void senf::emu::WirelessInterface::frequency(unsigned freq)
55 {
56  unsigned bw (bandwidth());
57  lookupFrequency(freq, bw);
58  v_frequency(freq, bw);
59 }
60 
61 prefix_ void senf::emu::WirelessInterface::frequency(unsigned freq, unsigned bw)
62 {
63  lookupFrequency(freq, bw);
64  v_frequency(freq, bw);
65 }
66 
67 prefix_ senf::emu::WirelessInterface::FrequenciesRange
68 senf::emu::WirelessInterface::frequencies()
69  const
70 {
71  frequency_is_whitelisted predicate (whitelistedFrequencies_);
72  return boost::make_iterator_range(
73  boost::make_filter_iterator( predicate, frequencies_.begin(), frequencies_.end()),
74  boost::make_filter_iterator( predicate, frequencies_.end(), frequencies_.end()) );
75 }
76 
77 prefix_ senf::emu::WirelessInterface::WirelessInterface()
78 {}
79 
80 prefix_ void senf::emu::WirelessInterface::coverageRange(unsigned distance)
81 {
82  v_coverageRange(distance);
83 }
84 
85 prefix_ void senf::emu::WirelessInterface::clearRegisteredFrequencies()
86 {
87  frequencies_.clear();
88 }
89 
90 prefix_ void senf::emu::WirelessInterface::clearRegisteredModulations()
91 {
92  modulationIds_.clear();
93 }
94 
95 prefix_ void senf::emu::WirelessInterface::registerFrequency(unsigned frequency,
96  unsigned bandwidth)
97 {
98  frequencies_.insert(Frequency(frequency, bandwidth));
99 }
100 
101 prefix_ void senf::emu::WirelessInterface::registerFrequency(unsigned frequencyLower,
102  unsigned frequencyUpper,
103  unsigned bandwidthLower,
104  unsigned bandwidthUpper)
105 {
106  SENF_ASSERT( frequencyLower <= frequencyUpper,
107  "Reversed frequency parameters in "
108  "senf::emu::WirelessInterface::registerFrequency()");
109  SENF_ASSERT( bandwidthLower <= bandwidthUpper,
110  "Reversed frequency parameters in "
111  "senf::emu::WirelessInterface::registerFrequency()");
112  frequencies_.insert(Frequency(frequencyLower, frequencyUpper, bandwidthLower, bandwidthUpper));
113 }
114 
115 prefix_ senf::emu::WirelessInterface::ModulationParameterIds const &
116 senf::emu::WirelessInterface::modulationParameterIds()
117  const
118 {
119  return modulationIds_;
120 }
121 
122 prefix_ void senf::emu::WirelessInterface::registerModulation(ModulationParameter::id_t id)
123 {
124  ModulationParameterRegistry::instance().findModulationById(id); // throws if id is not registered
125  modulationIds_.insert(id);
126 }
127 
128 //-/////////////////////////////////////////////////////////////////////////////////////////////////
129 // senf::emu::WirelessReceiver
130 
131 prefix_
132 senf::emu::WirelessReceiver::WirelessReceiver(ppi::connector::ActiveOutput<> & output)
133  : Receiver (output)
134 {}
135 
136 prefix_ senf::emu::WirelessReceiver::
137 WirelessReceiver(ppi::connector::ActiveOutput<EthernetPacket> & output)
138  : Receiver (output)
139 {}
140 
141 prefix_ senf::emu::WirelessReceiver::
142 WirelessReceiver(ppi::connector::ActiveOutputJack<> & output)
143  : Receiver (output)
144 {}
145 
146 prefix_ senf::emu::WirelessReceiver::
147 WirelessReceiver(ppi::connector::ActiveOutputJack<EthernetPacket> & output)
148  : Receiver (output)
149 {}
150 
151 prefix_ void senf::emu::WirelessReceiver::init()
152 {
153  Receiver::init();
154 }
155 
156 //-/////////////////////////////////////////////////////////////////////////////////////////////////
157 // senf::emu::WirelessTransmitter::TxPower
158 
159 prefix_ senf::emu::WirelessTransmitter::TxPower::TxPower(int _lower, int _upper)
160  : lower(_lower), upper(_upper)
161 {}
162 
163 //-/////////////////////////////////////////////////////////////////////////////////////////////////
164 // senf::emu::WirelessTransmitter
165 
166 prefix_ int senf::emu::WirelessTransmitter::txPower()
167  const
168 {
169  return v_txPower();
170 }
171 
172 prefix_ void senf::emu::WirelessTransmitter::txPower(int power)
173 {
174  TxPowers::const_iterator i (txPowers_.lower_bound(power));
175  if (i == txPowers_.end() || i->lower > power)
176  throw InvalidArgumentException("invalid txPower ") << power;
177  v_txPower(power);
178 }
179 
180 prefix_ senf::emu::WirelessTransmitter::TxPowersRange senf::emu::WirelessTransmitter::txPowers()
181  const
182 {
183  return boost::make_iterator_range(txPowers_.begin(), txPowers_.end());
184 }
185 
186 prefix_ senf::emu::WirelessTransmitter::
187 WirelessTransmitter(ppi::connector::PassiveInput<> & input)
188  : Transmitter (input)
189 {}
190 
191 prefix_ senf::emu::WirelessTransmitter::
192 WirelessTransmitter(ppi::connector::PassiveInput<EthernetPacket> & input)
193  : Transmitter (input)
194 {}
195 
196 prefix_ senf::emu::WirelessTransmitter::
197 WirelessTransmitter(ppi::connector::PassiveInputJack<> & input)
198  : Transmitter (input)
199 {}
200 
201 prefix_ senf::emu::WirelessTransmitter::
202 WirelessTransmitter(ppi::connector::PassiveInputJack<EthernetPacket> & input)
203  : Transmitter (input)
204 {}
205 
206 //-/////////////////////////////////////////////////////////////////////////////////////////////////
207 #undef prefix_
208 
209 
210 // Local Variables:
211 // mode: c++
212 // fill-column: 100
213 // comment-column: 40
214 // c-file-style: "senf"
215 // indent-tabs-mode: nil
216 // ispell-local-dictionary: "american"
217 // compile-command: "scons -u test"
218 // End: