CARMA C++
AntNum.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_ANTNUM_H
2 #define SZA_UTIL_ANTNUM_H
3 
11 #include <iostream>
12 #include <sstream>
13 #include <string>
14 
15 namespace sza {
16  namespace util {
17 
21  class AntNum {
22 
23  //------------------------------------------------------------
24  // Public members
25  //------------------------------------------------------------
26 
27  public:
28 
29  static const unsigned int NANT = 8;
30  static const unsigned int NBASE = (NANT*(NANT-1))/2;
31 
35  enum Id {
36  ANTNONE = 0, // Make these orthogonal bits, so we can OR them
37  // together, as below.
38  ANT0 = 1,
39  ANT1 = 2,
40  ANT2 = 4,
41  ANT3 = 8,
42  ANT4 = 16,
43  ANT5 = 32,
44  ANT6 = 64,
45  ANT7 = 128,
46  ANTMAX = ANT7, // This should always be set to the last valid antenna
47  SPARE = 256,
48  ANTALL = ANT0 | ANT1 | ANT2 | ANT3 | ANT4 | ANT5 | ANT6 | ANT7
49  } id_;
50 
54  AntNum(Id id);
55 
61  AntNum(unsigned int);
62 
66  AntNum();
67 
73  AntNum(const AntNum& antNum);
74 
80  AntNum(AntNum* antNum);
81 
85  bool isValidSingleAnt();
86 
87  static bool isValidSingleAnt(Id antId);
88 
93  std::string getObjectName();
94 
99  std::string getEventChannelName();
100 
105  std::string getAntennaName();
106 
110  std::string getString();
111 
115  std::string getLoggerPrefix();
116 
124  unsigned int getDelayEngineIntId();
125 
133  unsigned int getIntId();
134 
139  Id getId();
140 
148  unsigned short getDcAntennaIndex();
149  unsigned short getDcNodeIndex();
150  unsigned short getCarmaAntennaIndex();
151 
155  unsigned int getAntMax();
156 
160  void set(AntNum::Id id);
161 
166  bool isSet(unsigned id);
167 
172  bool isSet(AntNum::Id id);
173 
178  bool isSet(AntNum& antNum);
179 
184  bool isSet(AntNum* antNum);
185 
189  void setId(AntNum::Id);
190 
194  void setId(unsigned int id);
195 
199  void setId(const AntNum& antNum);
200 
205  void setIdFromHost();
206 
210  static AntNum::Id intToId(unsigned int iant);
211 
215  static unsigned idToInt(AntNum::Id id);
216 
220  std::string printAntennaSet();
221  std::string printAntennaSet(AntNum::Id id);
222 
223  //------------------------------------------------------------
224  // Member operators
225  //------------------------------------------------------------
226 
230  const AntNum operator+(const AntNum& rx);
231 
235  bool operator<(const AntNum rx);
236 
240  bool operator<=(const AntNum rx);
241 
245  bool operator>(const AntNum rx);
246 
250  bool operator>=(const AntNum rx);
251 
255  bool operator==(const AntNum rx);
256 
260  const AntNum& operator++();
261 
265  const AntNum operator++(int);
266 
267  //------------------------------------------------------------
268  // Non-member operator methods
269  //------------------------------------------------------------
270 
274  friend std::ostream& operator<<(std::ostream& os, const AntNum& rx);
275 
279  friend AntNum::Id operator+(const AntNum::Id id1,
280  const AntNum::Id id2);
281 
285  friend AntNum::Id operator-(const AntNum::Id id1,
286  const AntNum::Id id2);
287 
291  friend bool isValidAnt(unsigned int ant);
292 
296  friend bool isValidAntennaSet(AntNum::Id antennas);
297 
301  friend std::string printAntennaSet(AntNum::Id antennas);
302 
306  friend AntNum::Id intToId(unsigned int iant);
307 
311  friend unsigned idToInt(AntNum::Id id);
312 
313  //------------------------------------------------------------
314  // Private members
315  //------------------------------------------------------------
316 
317  private:
318 
322  void checkMaxAnt();
323 
324  }; // End class AntNum
325 
326  bool isValidAnt(unsigned int ant);
327 
331  std::ostream& operator<<(std::ostream& os, const AntNum& rx);
332 
336  AntNum::Id operator+(const AntNum::Id id1,
337  const AntNum::Id id2);
338 
342  AntNum::Id operator-(const AntNum::Id id1,
343  const AntNum::Id id2);
344 
348  bool isValidAnt(unsigned int ant);
349 
353  bool isValidAntennaSet(AntNum::Id antennas);
354 
358  std::string printAntennaSet(AntNum::Id antennas);
359 
363  AntNum::Id intToId(unsigned int iant);
364 
368  unsigned idToInt(AntNum::Id id);
369 
370  }; // End namespace util
371 }; // End namespace sza
372 
373 #endif
bool operator>(const AntNum rx)
Define &gt; for two antenna enumerators.
A class to enumerate a single Antenna, or a set of Antennas.
Definition: AntNum.h:21
std::string getLoggerPrefix()
Return a prefix suitable for use in logging.
std::string getAntennaName()
Return a board name in the register database constructed from this Antenna enumerator.
bool operator<=(const AntNum rx)
Define &lt;= for two antenna enumerators.
const AntNum operator+(const AntNum &rx)
Add two antenna enumerators.
static AntNum::Id intToId(unsigned int iant)
Convert from integer index to enumerator.
std::string getObjectName()
Return a CORBA object name constructed from this Antenna enumerator.
bool operator>=(const AntNum rx)
Define &gt;= for two antenna enumerators.
friend bool isValidAntennaSet(AntNum::Id antennas)
Return true if the passed index specifies a valid antenna set.
bool isValidSingleAnt()
Check if this object specifies a valid single receiver.
void set(AntNum::Id id)
Set the antennas represented by this object.
friend AntNum::Id operator-(const AntNum::Id id1, const AntNum::Id id2)
Allows expressions like ANTALL-ANT1.
Id getId()
Return the antenna id associated with this enumerator.
bool operator==(const AntNum rx)
Define equality for two antenna enumerators.
void setId(AntNum::Id)
Set the id of this antenna enumerator.
unsigned int getDelayEngineIntId()
Return an integer antenna index associated with this enumerator, as expected by the delay engine...
std::string getEventChannelName()
Return a CORBA object name constructed from this Antenna enumerator.
static unsigned idToInt(AntNum::Id id)
Convert from integer index to enumerator.
void setIdFromHost()
Set the id of this antenna enumerator from the name of the host machine.
bool isSet(unsigned id)
Return true if the passed id is part of this object&#39;s antenna set.
AntNum()
Constructor with uninitialized antenna.
std::string getString()
Return a string representation of this antenna set.
friend bool isValidAnt(unsigned int ant)
Return true if the passed index specifies a valid receiver.
bool operator<(const AntNum rx)
Define &lt; for two antenna enumerators.
unsigned short getDcAntennaIndex()
Return an integer antenna index suitable for passing to downconverter API methods.
Id
Enumerate known receivers.
Definition: AntNum.h:35
unsigned int getAntMax()
Return the maximum number of antennas we know about.
friend std::ostream & operator<<(std::ostream &os, const AntNum &rx)
Allows cout &lt;&lt; ant.
unsigned int getIntId()
Return an integer antenna index associated with this enumerator.
std::string printAntennaSet()
Return a string representing an antenna set.
const AntNum & operator++()
Prefix increment.