CARMA C++
DDSChannel.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_DDSCHANNEL_H
2 #define SZA_UTIL_DDSCHANNEL_H
3 
11 #include <string>
12 
13 namespace sza {
14  namespace util {
15 
16  class DDSChannel {
17  public:
18 
19  enum Id {
20  DDSNONE = 0x0,
21  DDS0 = 0x1, // Valid DDS channels -- these are numbered 0-23 in the firmware
22  DDS1 = 0x2,
23  DDS2 = 0x4,
24  DDS3 = 0x8,
25  DDS4 = 0x10,
26  DDS5 = 0x20,
27  DDS6 = 0x40,
28  DDS7 = 0x80,
29  DDS8 = 0x100,
30  DDS9 = 0x200,
31  DDS10 = 0x400,
32  DDS11 = 0x800,
33  DDS12 = 0x1000,
34  DDS13 = 0x2000,
35  DDS14 = 0x4000,
36  DDS15 = 0x8000,
37  DDS16 = 0x10000,
38  DDS17 = 0x20000,
39  DDS18 = 0x40000,
40  DDS19 = 0x80000,
41  DDS20 = 0x100000,
42  DDS21 = 0x200000,
43  DDS22 = 0x400000,
44  DDSMAX = DDS22,
45  DDSALL = DDS0|DDS1|DDS2|DDS3|DDS4|DDS5|DDS6|DDS7|DDS8|DDS9|DDS10|DDS11|DDS12|DDS13|DDS14|DDS15|DDS16|DDS17|DDS18|DDS19|DDS20|DDS21|DDS22
46  };
47 
48 
49  // Constructor
50 
51  DDSChannel(Id id) {
52  id_ = id;
53  }
54 
55  DDSChannel() {
56  id_ = DDSNONE;
57  }
58 
59  void setDDSId(Id id) {
60  id_ = id;
61  }
62 
63  // Convert from DDS Id to integer index expected by the lobe rotator
64 
65  static unsigned DDSToLRInt(Id id);
66  unsigned LRInt();
67 
68  // Convert from integer index expected by the lobe rotatorDDS Id to
69 
70  static Id LRIntToDDSId(unsigned intId);
71 
72  // Return true if this is a valid single DDS channel
73 
74  static bool isValidSingleChannel(Id id);
75  bool isValidSingleChannel();
76 
77  // Return true, if this is a valid channel set
78 
79  static bool isValidChannelSet(DDSChannel::Id channels);
80 
84  static Id intToId(unsigned int iant);
85 
89  static unsigned idToInt(DDSChannel::Id id);
90 
94  static unsigned int getIntId(Id id);
95  unsigned int getIntId();
96 
97  // Returna a string version of the DDS channels
98 
99  static std::string printChannels(Id id);
100  std::string printChannels();
101 
102  //------------------------------------------------------------
103  // Member operators
104  //------------------------------------------------------------
105 
109  const DDSChannel operator+(const DDSChannel& channel);
110 
114  bool operator<(const DDSChannel channel);
115 
119  bool operator<=(const DDSChannel channel);
120 
124  bool operator>(const DDSChannel channel);
125 
129  bool operator>=(const DDSChannel channel);
130 
134  bool operator==(const DDSChannel channel);
135 
139  const DDSChannel& operator++();
140 
144  const DDSChannel operator++(int);
145 
150  bool isSet(unsigned id);
151  bool isSet(DDSChannel::Id id);
152  bool isSet(DDSChannel& dds);
153 
157  Id getId();
158 
159  //------------------------------------------------------------
160  // Non-member operator methods
161  //------------------------------------------------------------
162 
166  friend std::ostream& operator<<(std::ostream& os, const DDSChannel& rx);
167 
171  friend DDSChannel::Id operator+(const DDSChannel::Id id1,
172  const DDSChannel::Id id2);
173 
177  friend DDSChannel::Id operator-(const DDSChannel::Id id1,
178  const DDSChannel::Id id2);
179 
183  void setId(Id id);
184 
185  private:
186 
187  Id id_;
188 
189  }; // End class DDSChannel
190 
194  std::ostream& operator<<(std::ostream& os, const DDSChannel& rx);
195 
199  DDSChannel::Id operator+(const DDSChannel::Id id1,
200  const DDSChannel::Id id2);
201 
205  DDSChannel::Id operator-(const DDSChannel::Id id1,
206  const DDSChannel::Id id2);
207 
208 
209  } // End namespace util
210 } // End namespace sza
211 
212 
213 
214 #endif // End #ifndef SZA_UTIL_DDSCHANNEL_H