CARMA C++
LOchain.h
Go to the documentation of this file.
1 #ifndef CARMA_CONTROL_LOCHAIN_H
2 #define CARMA_CONTROL_LOCHAIN_H
3 
17 #include <vector>
18 #include <string>
19 
20 
21 namespace carma {
22 namespace control {
23 
24 
31 class Freq
32 {
33 public:
37  enum UNITS {
38  uHz, // microHz
39  mHz, // milliHz
40  Hz,
41  KHz,
42  MHz,
43  GHz
44  } ;
48  Freq();
54  Freq(double val, UNITS units);
55 
56  Freq operator+(const Freq& rhs) const;
57  Freq operator-(const Freq& rhs) const;
58  Freq operator*(const Freq& rhs) const;
59  Freq operator*(const double& rhs) const;
60  Freq operator/(double div) const;
61 
67  double div(const Freq& div) const;
68 
72  double microhertz() const;
73 
77  double millihertz() const;
78 
82  double hertz() const;
83 
87  double kilohertz() const;
88 
92  double megahertz() const;
93 
97  double gigahertz() const;
98 private:
99  double value_; // in Hz
100 };
101 
102 
107 class Harmonic
108 {
109 public:
113  Harmonic();
114 
115  virtual ~Harmonic();
116 
120  Freq getYigFreq() const;
121 
126  void setYigFreq(const Freq& yig);
127 
131  Freq getRefFreq() const;
132 
137  void setRefFreq(const Freq& ref);
138 
142  int getYigHarmonicNumber() const;
143 
148  void setYigHarmonicNumber(int harm);
149 
153  int getRefHarmonicNumber() const;
154 
159  void setRefHarmonicNumber(int harm);
160 
164  double getTuningRange() const;
165 
170  void setTuningRange(double range);
171 
175  double getTuningScore() const;
176 
181  void setTuningScore(double score);
182 
186  int getRank() const;
187 
192  void setRank(int rank);
193 
194 
195 private:
196  Freq yig_;
197  Freq ref_;
198  int yigHarmonicNo_; // Yig * harm
199  int refHarmonicNo_; // ref * harm
200  // Minimum absolute fractional tuning range of yig or ref
201  double tuningRange_;
202  double tuningScore_; // Score of this tuning; range=[0,10]
203  int rank_; // Rank among odd harms (even harms rank=0)
204 };
205 
206 
230 class LOchain
231 {
232 
233 public:
241  LOchain(int mode);
242 
251  explicit LOchain(const Freq& freq, int mode=0);
252 
253  virtual ~LOchain();
254 
261  void setOscillatorFreq(const Freq& freq);
262 
269  void setOscillatorMultiplier(int multiplier);
270 
277 
281  Freq getOscillatorFreq() const;
282 
286  Freq getLOfreq() const;
287 
296  void updateFreq(const Freq& freq);
297 
305 
315  Harmonic getHarmonic(int rank) const;
316 
326  int getNumberHarmonics() const;
327 
332  ::std::string toString( const Harmonic& h ) const;
333 
338  ::std::string toString( const ::std::vector< Harmonic >& h ) const;
339 
343  ::std::string toString() const;
344 
348  ::std::string toStringAll() const;
349 
354  ::std::string toStringPreferred() const;
355 
356 private:
357  LOchain(); // Default private constructor
358  typedef ::std::vector<Harmonic> HarmonicVec;
359 
364  HarmonicVec getHarmonics() const;
365 
369  HarmonicVec getAllHarmonics() const;
370 
371  static HarmonicVec
372  computeHarmonics( const Freq& oscFreq,
373  const Freq& oscOffsetLock,
374  const Freq& yigOffsetLock,
375  const Freq& refLow,
376  const Freq& refHigh,
377  const Freq& yigLow,
378  const Freq& yigHigh);
379 
380  static size_t
381  findPreferredHarmonic(const HarmonicVec& harmonics,
382  const Freq& oscFreq,
383  bool allowEven,
384  int mode);
385 
386  Freq oscfreq_;
387  Freq oscOffsetLock_;
388  Freq yigOffsetLock_;
389  Freq refLow_;
390  Freq refHigh_;
391  Freq yigLow_;
392  Freq yigHigh_;
393 
394  size_t preferredHarmonicIndex_; // index to the preferred harmonic
395  HarmonicVec harmonics_;
396  int multiplier_;
397  int mode_;
398  int nOdd_; // Number of odd yig harmonics
399 };
400 
401 
402 } // namespace carma::control
403 } // namespace carma
404 
405 
406 #endif // End of conditional include guard
void setTuningRange(double range)
Set the tuning range.
double megahertz() const
Accessor, megaHertz.
double getTuningScore() const
Get the score for this harmonic (range is [0,10)
::std::string toString() const
Dump LOchain parameters for the odd YIG harmonics to a string.
Handles all parameters and calculations for the CARMA LO chain.
Definition: LOchain.h:230
double microhertz() const
Accessor, microHertz.
void setYigHarmonicNumber(int harm)
Set the yig harmonic number.
double gigahertz() const
Accessor, gigaHertz.
int getYigHarmonicNumber() const
Get the yig harmonic number.
int getRank() const
Get the rank for this harmonic (1 is best, 2 is second best, etc)
UNITS
Enumeration for units.
Definition: LOchain.h:37
void setRefHarmonicNumber(int harm)
Set the harmonic number.
Freq()
Default constructor.
double kilohertz() const
Accessor, kiloHertz.
void setYigFreq(const Freq &yig)
Set the yig frequency.
Frequency class.
Definition: LOchain.h:31
int getOscillatorMultiplier()
Get the oscillator multiplier.
::std::string toStringPreferred() const
Dump the LOchain parameters for the preferred harmonics to a string.
Freq getOscillatorFreq() const
Get the oscillator (Gunn) frequency.
void setOscillatorMultiplier(int multiplier)
Set the oscillator multiplier to get the LOfreq.
double getTuningRange() const
Get the fractional tuning range.
int getRefHarmonicNumber() const
Get the ref harmonic number.
int getNumberHarmonics() const
Gets the number of available harmonics.
void setOscillatorFreq(const Freq &freq)
Set the oscillator (Gunn) frequency and computes LO chain.
double millihertz() const
Accessor, milliHertz.
Freq getYigFreq() const
Get the yig frequency.
void setRefFreq(const Freq &ref)
Set the ref frequency.
void setRank(int rank)
Set the rank.
Harmonic getPreferredHarmonic() const
Gets the preferred harmonic.
::std::string toStringAll() const
Dump the LOchain parameters for all harmonics to a string.
void setTuningScore(double score)
Set the tuning score.
An LOchain harmonic; has self consistent ref and yig frequencies and harmonics.
Definition: LOchain.h:107
double div(const Freq &div) const
Division operation.
Freq getRefFreq() const
Get the ref frequency.
Harmonic()
Constructor.
Harmonic getHarmonic(int rank) const
Gets the specified harmonic.
Freq getLOfreq() const
Get the LO frequency.
double hertz() const
Accessor, Hertz.
void updateFreq(const Freq &freq)
Update the LO frequency.