INET Framework for OMNeT++/OMNEST
inet::physicallayer::DimensionalTransmitterBase Class Reference

#include <DimensionalTransmitterBase.h>

Inheritance diagram for inet::physicallayer::DimensionalTransmitterBase:
inet::physicallayer::IPrintableObject inet::physicallayer::APSKDimensionalTransmitter inet::physicallayer::Ieee80211DimensionalTransmitter

Classes

class  FrequencyGainEntry
 
class  TimeGainEntry
 

Public Member Functions

 DimensionalTransmitterBase ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
- Public Member Functions inherited from inet::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Protected Member Functions

virtual void initialize (int stage)
 
virtual ConstMappingcreatePowerMapping (const simtime_t startTime, const simtime_t endTime, Hz carrierFrequency, Hz bandwidth, W power) const
 

Protected Attributes

DimensionSet dimensions
 
Mapping::InterpolationMethod interpolationMode
 
std::vector< TimeGainEntrytimeGains
 
std::vector< FrequencyGainEntryfrequencyGains
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 

Constructor & Destructor Documentation

inet::physicallayer::DimensionalTransmitterBase::DimensionalTransmitterBase ( )
27  :
29 {
30 }
InterpolationMethod
Types of interpolation methods for mappings.
Definition: MappingBase.h:1249
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalTransmitterBase.h:61

Member Function Documentation

ConstMapping * inet::physicallayer::DimensionalTransmitterBase::createPowerMapping ( const simtime_t  startTime,
const simtime_t  endTime,
Hz  carrierFrequency,
Hz  bandwidth,
W  power 
) const
protectedvirtual

Referenced by inet::physicallayer::APSKDimensionalTransmitter::createTransmission(), and inet::physicallayer::Ieee80211DimensionalTransmitter::createTransmission().

126 {
128  Argument position(dimensions);
129  bool hasTimeDimension = dimensions.hasDimension(Dimension::time);
130  bool hasFrequencyDimension = dimensions.hasDimension(Dimension::frequency);
131  if (hasTimeDimension && hasFrequencyDimension) {
132  double startFrequency = (carrierFrequency - bandwidth / 2).get();
133  double endFrequency = (carrierFrequency + bandwidth / 2).get();
134  // must be 0 before the start
135  position.setTime(0);
136  position.setArgValue(Dimension::frequency, 0);
137  powerMapping->setValue(position, 0);
138  position.setTime(startTime);
139  powerMapping->setValue(position, 0);
140  position.setTime(endTime);
141  powerMapping->setValue(position, 0);
142  position.setTime(0);
143  position.setArgValue(Dimension::frequency, startFrequency);
144  powerMapping->setValue(position, 0);
145  position.setArgValue(Dimension::frequency, endFrequency);
146  powerMapping->setValue(position, 0);
147  // iterate over timeGains and frequencyGains
148  for (const auto & timeGainEntry : timeGains) {
149 
150  switch (timeGainEntry.timeUnit) {
151  case 's':
152  position.setTime(timeGainEntry.time >= 0 ? startTime + timeGainEntry.time : endTime - timeGainEntry.time);
153  break;
154  case '%':
155  position.setTime((1 - timeGainEntry.time) * startTime + timeGainEntry.time * endTime);
156  break;
157  default:
158  throw cRuntimeError("Unknown time unit");
159  }
160  for (const auto & frequencyGainEntry : frequencyGains) {
161 
162  switch (frequencyGainEntry.frequencyUnit) {
163  case 's':
164  position.setArgValue(Dimension::frequency, frequencyGainEntry.frequency >= 0 ? startFrequency + frequencyGainEntry.frequency : endFrequency - frequencyGainEntry.frequency);
165  break;
166  case '%':
167  position.setArgValue(Dimension::frequency, (1 - frequencyGainEntry.frequency) * startFrequency + frequencyGainEntry.frequency * endFrequency);
168  break;
169  default:
170  throw cRuntimeError("Unknown frequency unit");
171  }
172  powerMapping->setValue(position, timeGainEntry.gain * frequencyGainEntry.gain * power.get());
173  }
174  }
175  // must be 0 after the end
176  position.setTime(startTime);
177  position.setArgValue(Dimension::frequency, endFrequency);
178  powerMapping->setValue(position, 0);
179  position.setTime(endTime);
180  position.setArgValue(Dimension::frequency, startFrequency);
181  powerMapping->setValue(position, 0);
182  position.setTime(endTime);
183  position.setArgValue(Dimension::frequency, endFrequency);
184  powerMapping->setValue(position, 0);
185  }
186  else if (hasTimeDimension) {
187  // must be 0 before the start
188  position.setTime(0);
189  powerMapping->setValue(position, 0);
190  // iterate over timeGains
191  for (const auto & timeGainEntry : timeGains) {
192 
193  switch (timeGainEntry.timeUnit) {
194  case 's':
195  position.setTime(timeGainEntry.time >= 0 ? startTime + timeGainEntry.time : endTime - timeGainEntry.time);
196  break;
197  case '%':
198  position.setTime((1 - timeGainEntry.time) * startTime + timeGainEntry.time * endTime);
199  break;
200  default:
201  throw cRuntimeError("Unknown time unit");
202  }
203  powerMapping->setValue(position, timeGainEntry.gain * power.get());
204  }
205  // must be 0 after the end
206  position.setTime(endTime);
207  powerMapping->setValue(position, 0);
208  }
209  else if (hasFrequencyDimension) {
210  double startFrequency = (carrierFrequency - bandwidth / 2).get();
211  double endFrequency = (carrierFrequency + bandwidth / 2).get();
212  // must be 0 before the start
213  position.setArgValue(Dimension::frequency, 0);
214  powerMapping->setValue(position, 0);
215  // iterate over frequencyGains
216  for (const auto & frequencyGainEntry : frequencyGains) {
217 
218  switch (frequencyGainEntry.frequencyUnit) {
219  case 's':
220  position.setArgValue(Dimension::frequency, frequencyGainEntry.frequency >= 0 ? startFrequency + frequencyGainEntry.frequency : endFrequency - frequencyGainEntry.frequency);
221  break;
222  case '%':
223  position.setArgValue(Dimension::frequency, (1 - frequencyGainEntry.frequency) * startFrequency + frequencyGainEntry.frequency * endFrequency);
224  break;
225  default:
226  throw cRuntimeError("Unknown frequency unit");
227  }
228  powerMapping->setValue(position, frequencyGainEntry.gain * power.get());
229  }
230  // must be 0 after the end
231  position.setArgValue(Dimension::frequency, endFrequency);
232  powerMapping->setValue(position, 0);
233  }
234  else
235  throw cRuntimeError("Unknown dimensions");
236  return powerMapping;
237 }
static const mapped_type MappedZero
Zero value of a Argument value.
Definition: MappingBase.h:427
bool hasDimension(const DimensionSet::value_type &d) const
Returns true if the passed Dimension is inside this DimensionSet.
Definition: MappingBase.h:282
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
std::vector< TimeGainEntry > timeGains
Definition: DimensionalTransmitterBase.h:62
static Mapping * createMapping(const DimensionSet &domain=DimensionSet(Dimension::time), Mapping::InterpolationMethod intpl=Mapping::LINEAR)
Returns an appropriate changeable Mapping with the specified domain and the specified interpolation m...
Definition: MappingUtils.cc:103
DimensionSet dimensions
Definition: DimensionalTransmitterBase.h:60
static const Dimension frequency
Shortcut to the frequency Dimension, same as &#39;Dimension("frequency")&#39;, but spares the parsing of a st...
Definition: MappingBase.h:68
std::vector< FrequencyGainEntry > frequencyGains
Definition: DimensionalTransmitterBase.h:63
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalTransmitterBase.h:61
void inet::physicallayer::DimensionalTransmitterBase::initialize ( int  stage)
protectedvirtual

Reimplemented in inet::physicallayer::Ieee80211DimensionalTransmitter, and inet::physicallayer::APSKDimensionalTransmitter.

Referenced by inet::physicallayer::APSKDimensionalTransmitter::initialize(), and inet::physicallayer::Ieee80211DimensionalTransmitter::initialize().

33 {
34  if (stage == INITSTAGE_LOCAL)
35  {
36  cModule *module = check_and_cast<cModule *>(this);
37  // TODO: factor parsing?
38  // dimensions
39  const char *dimensionsString = module->par("dimensions");
40  cStringTokenizer tokenizer(dimensionsString);
41  while (tokenizer.hasMoreTokens()) {
42  const char *dimensionString = tokenizer.nextToken();
43  if (!strcmp("time", dimensionString))
45  else if (!strcmp("frequency", dimensionString))
47  else
48  throw cRuntimeError("Unknown dimension");
49  }
50  // interpolation mode
51  const char *interpolationModeString = module->par("interpolationMode");
52  if (!strcmp("linear", interpolationModeString))
54  else if (!strcmp("sample-hold", interpolationModeString))
56  else
57  throw cRuntimeError("Unknown interpolation mode: '%s'", interpolationModeString);
58  // time gains
59  cStringTokenizer timeGainsTokenizer(module->par("timeGains"));
60  while (timeGainsTokenizer.hasMoreTokens()) {
61  char *end;
62  const char *timeString = timeGainsTokenizer.nextToken();
63  double time = strtod(timeString, &end);
64  char timeUnit;
65  if (!end)
66  timeUnit = 's';
67  else if (*end == '%') {
68  timeUnit = '%';
69  time /= 100;
70  if (time < 0 || time > 1)
71  throw cRuntimeError("Invalid percentage in timeGains parameter");
72  }
73  else {
74  timeUnit = 's';
75  time = cNEDValue::parseQuantity(timeString, "s");
76  }
77  const char *gainString = timeGainsTokenizer.nextToken();
78  double gain = strtod(gainString, &end);
79  if (end && !strcmp(end, "dB"))
80  gain = math::dB2fraction(gain);
81  if (gain < 0 || gain > 1)
82  throw cRuntimeError("Invalid gain in timeGains parameter");
83  timeGains.push_back(TimeGainEntry(timeUnit, time, gain));
84  }
85  // frequency gains
86  cStringTokenizer frequencyGainsTokenizer(module->par("frequencyGains"));
87  while (frequencyGainsTokenizer.hasMoreTokens()) {
88  char *end;
89  const char *frequencyString = frequencyGainsTokenizer.nextToken();
90  double frequency = strtod(frequencyString, &end);
91  char frequencyUnit;
92  if (!end)
93  frequencyUnit = 'H';
94  else if (*end == '%') {
95  frequencyUnit = '%';
96  frequency /= 100;
97  if (frequency < 0 || frequency > 1)
98  throw cRuntimeError("Invalid percentage in frequencyGains parameter");
99  }
100  else {
101  frequencyUnit = 'H';
102  frequency = cNEDValue::parseQuantity(frequencyString, "Hz");
103  }
104  const char *gainString = frequencyGainsTokenizer.nextToken();
105  double gain = strtod(gainString, &end);
106  if (end && !strcmp(end, "dB"))
107  gain = math::dB2fraction(gain);
108  if (gain < 0 || gain > 1)
109  throw cRuntimeError("Invalid gain in frequencyGains parameter");
110  frequencyGains.push_back(FrequencyGainEntry(frequencyUnit, frequency, gain));
111  }
112  }
113 }
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
std::vector< TimeGainEntry > timeGains
Definition: DimensionalTransmitterBase.h:62
DimensionSet dimensions
Definition: DimensionalTransmitterBase.h:60
interpolates with next lower entry
Definition: MappingBase.h:1251
double dB2fraction(double dB)
Converts a dB value to fraction.
Definition: INETMath.h:166
Local initializations.
Definition: InitStages.h:35
interpolates linear with next lower and next upper entry constant before the first and after the last...
Definition: MappingBase.h:1256
void addDimension(const DimensionSet::value_type &d)
Adds the passed dimension to the DimensionSet.
Definition: MappingBase.h:274
static const Dimension frequency
Shortcut to the frequency Dimension, same as &#39;Dimension("frequency")&#39;, but spares the parsing of a st...
Definition: MappingBase.h:68
std::vector< FrequencyGainEntry > frequencyGains
Definition: DimensionalTransmitterBase.h:63
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalTransmitterBase.h:61
std::ostream & inet::physicallayer::DimensionalTransmitterBase::printToStream ( std::ostream &  stream,
int  level 
) const
overridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

Reimplemented in inet::physicallayer::Ieee80211DimensionalTransmitter, and inet::physicallayer::APSKDimensionalTransmitter.

Referenced by inet::physicallayer::APSKDimensionalTransmitter::printToStream(), and inet::physicallayer::Ieee80211DimensionalTransmitter::printToStream().

116 {
117  if (level <= PRINT_LEVEL_TRACE)
118  stream << ", interpolationMode = " << interpolationMode
119  << ", dimensions = " << dimensions ;
120  // TODO: << "timeGains = " << timeGains
121  // TODO: << "frequencyGains = " << frequencyGains ;
122  return stream;
123 }
DimensionSet dimensions
Definition: DimensionalTransmitterBase.h:60
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalTransmitterBase.h:61

Member Data Documentation

DimensionSet inet::physicallayer::DimensionalTransmitterBase::dimensions
protected
std::vector<FrequencyGainEntry> inet::physicallayer::DimensionalTransmitterBase::frequencyGains
protected

Referenced by createPowerMapping(), and initialize().

Mapping::InterpolationMethod inet::physicallayer::DimensionalTransmitterBase::interpolationMode
protected
std::vector<TimeGainEntry> inet::physicallayer::DimensionalTransmitterBase::timeGains
protected

Referenced by createPowerMapping(), and initialize().


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