DVBInterface.cc
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 
17 #include "DVBInterface.hh"
18 
19 // Custom includes
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 namespace {
25  using namespace senf::emu;
26 
27  struct DVBParam {
31  std::string coding;
32  short rssi;
33  unsigned rate;
34  };
35 
36  // rates calculated with http://www.saschateichmann.de/dvb-t-hf.html
37  // min RSSI values are guessed.
38  static DVBParam dvbParams[] = {
42  };
43 }
44 
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 // senf::emu::DVBModulationParameter / -Registry
47 
48 namespace {
49  boost::uint16_t calc_modulationId(DVBModulationParameter::fec_rate_t fec, DVBModulationParameter::modulation_t mod,
51  {
52  return (boost::uint16_t(fec) << 8) | (boost::uint16_t(mod) << 4) | (boost::uint16_t(gi));
53  }
54 }
55 
56 prefix_ senf::emu::DVBModulationParameter::DVBModulationParameter(std::string const & _label, short _minRssi, unsigned _rate,
57  fec_rate_t _fec, modulation_t mod, guard_interval_t gi)
58  : ModulationParameter(_label, _minRssi, _rate, 8000, /* we assume a fixed bandwidth of 8 MHz */ DVBInterface::linkTypeId),
59  fec(_fec), modulation(mod), guard_interval(gi)
60 {}
61 
62 
63 prefix_ boost::uint16_t senf::emu::DVBModulationParameter::v_modulationId()
64  const
65 {
66  return calc_modulationId(fec, modulation, guard_interval);
67 }
68 
69 prefix_ senf::emu::ModulationParameter * senf::emu::DVBModulationParameter::v_clone()
70  const
71 {
72  return new DVBModulationParameter(*this);
73 }
74 
75 prefix_ void senf::emu::DVBModulationParameter::v_dump(std::ostream & os)
76  const
77 {
78  os << "todo!" << std::endl;
79 }
80 
81 prefix_ void senf::emu::DVBModulationParameter::v_dumpTableHeader(std::ostream & os)
82  const
83 {
84  os << "todo!";
85 }
86 
87 prefix_ void senf::emu::DVBModulationParameter::v_dumpTableRow(std::ostream & os)
88  const
89 {
90  os << "todo!";
91 }
92 
93 prefix_ senf::emu::DVBModulationParameterRegistry::DVBModulationParameterRegistry()
94 {
95  for (DVBParam const & param : dvbParams) {
96  DVBModulationParameter p (param.coding, param.rssi, param.rate, param.fec, param.modulation, param.guard_interval);
97  registerModulation( p);
98  }
99 }
100 
101 prefix_ boost::uint32_t senf::emu::DVBModulationParameterRegistry::registerModulation(DVBModulationParameter & p)
102 {
104  modulations_.insert( std::make_pair(id, p));
105  idTranslateMap_.insert( std::make_pair(p.v_modulationId(), id));
106  return id;
107 }
108 
110  const
111 {
112  Modulations::const_iterator it (modulations_.find(id));
113  if (it == modulations_.end())
114  throw ModulationParameter::Error() << id << " (unknown id)";
115  return it->second;
116 }
117 
120  const
121 {
122  IdTranslateMap::const_iterator i (idTranslateMap_.find(calc_modulationId(fec, mod, gi)));
123  return (i != idTranslateMap_.end() ? i->second : 0);
124 }
125 
127  const
128 {
129  return senf::make_transform_range(modulations_, ::__gnu_cxx::select1st<Modulations::value_type>());
130 }
131 
132 //-/////////////////////////////////////////////////////////////////////////////////////////////////
133 // senf::emu::DVBInterface
134 
135 namespace senf { namespace emu {
137  (FEC_NONE)(FEC_1_2)(FEC_2_3)(FEC_3_4)(FEC_4_5)(FEC_5_6)(FEC_6_7)(FEC_7_8)(FEC_8_9)
138  (FEC_AUTO)(FEC_3_5)(FEC_9_10) );
140  (QPSK)(QAM_16)(QAM_32)(QAM_64)(QAM_128)(QAM_256)(QAM_AUTO)(VSB_8)(VSB_16)(PSK_8)
141  (APSK_16)(APSK_32)(DQPSK) );
143  (GUARD_INTERVAL_1_32)(GUARD_INTERVAL_1_16)(GUARD_INTERVAL_1_8)(GUARD_INTERVAL_1_4)
144  (GUARD_INTERVAL_AUTO)(GUARD_INTERVAL_1_128)(GUARD_INTERVAL_19_128)(GUARD_INTERVAL_19_256) );
145 }}
146 
148 {
150 
151  namespace fty = console::factory;
152  consoleDir().add("tune", fty::Command(&DVBInterface::tune, this) );
153 }
154 
155 prefix_ boost::uint8_t senf::emu::DVBInterface::v_linkTypeId()
156  const
157 {
158  return linkTypeId;
159 }
160 
163 {
164  v_tune( fec, mod, gi, freq);
165 }
166 
167 //-/////////////////////////////////////////////////////////////////////////////////////////////////
168 #undef prefix_
169 
170 
171 // Local Variables:
172 // mode: c++
173 // fill-column: 100
174 // comment-column: 40
175 // c-file-style: "senf"
176 // indent-tabs-mode: nil
177 // ispell-local-dictionary: "american"
178 // compile-command: "scons -u test"
179 // End:
unsigned registerModulation(ModulationParameter &parameter)
boost::iterator_range< ModulationParameterId_iterator > ModulationParameterIds
Definition: DVBInterface.hh:88
void tune(DVBModulationParameter::fec_rate_t fec, DVBModulationParameter::modulation_t mod, DVBModulationParameter::guard_interval_t gi, unsigned freq)
boost::uint8_t linkTypeId() const
Wireless modulation parameter.
SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBModulationParameter, fec_rate_t,(FEC_NONE)(FEC_1_2)(FEC_2_3)(FEC_3_4)(FEC_4_5)(FEC_5_6)(FEC_6_7)(FEC_7_8)(FEC_8_9)(FEC_AUTO)(FEC_3_5)(FEC_9_10))
#define prefix_
Definition: DVBInterface.cc:21
ModulationParameter::id_t parameterId(DVBModulationParameter::fec_rate_t fec, DVBModulationParameter::modulation_t mod, DVBModulationParameter::guard_interval_t gi) const
console::ScopedDirectory & consoleDir()
DVBModulationParameter const & findModulationById(ModulationParameter::id_t id) const
s8 rssi
static ModulationParameterRegistry & instance()
DVBInterface public header.
ModulationParameterIds parameterIds() const
__be16 freq