CARMA C++
AntennaRxMsg.h
Go to the documentation of this file.
1 #ifndef SZA_ANTENNA_CONTROL_ANTENNARXMSG_H
2 #define SZA_ANTENNA_CONTROL_ANTENNARXMSG_H
3 
12 
13 // Needed for NetEnum
14 
15 #include "carma/szaarrayutils/netobj.h"
16 
17 // Needed for CalTertMsg
18 
19 #include "carma/szaarrayutils/rtcnetcoms.h"
20 
21 #include "carma/szautil/Amp.h"
22 #include "carma/szautil/CalPos.h"
25 #include "carma/szautil/Debug.h"
26 #include "carma/szautil/Directives.h"
27 #include "carma/szautil/IFAtten.h"
28 #include "carma/szautil/LoOsc.h"
29 #include "carma/szautil/LoStage.h"
30 #include "carma/szautil/Rx.h"
31 #include "carma/szautil/Thermal.h"
32 
33 namespace sza {
34  namespace antenna {
35  namespace control {
36 
40  class AntennaRxMsg :
42 
43  public:
44 
48  enum MsgType {
49  FLAG_BOARD,
50  FREQ,
51  LO,
52  OFFSET,
53  TOTALPOWER,
54  SET_INPUT_VOLTAGE,
55  SET_DRAIN_CURRENT,
56  TOGGLE_FAST_SAMPLING,
57  CALTERT,
58  INTMOD,
59  SET_BIAS,
60  IFMOD,
61  THERMAL,
62  TILTMETER,
63  SELECT_RX, // Select a receiver
64  RESET, // Reset a CAN module
65  EXECUTE_NEXT_CAN_INSTRUCTION
66  };
67 
72 
76  union {
77 
81  struct {
82  unsigned short board; // The register map index of the
83  // board to un/flag
84  bool flag; // True to flag, false to unflag
85  } flagBoard;
86 
90  struct {
91  sza::array::LoMsgId msgId;
92  sza::util::LoOsc::Osc oscs;
93  sza::util::LoStage::Stage stages;
94  sza::util::Rx::Id rxId;
95  bool on;
96  unsigned short dampGain;
97  unsigned short frequency;
98  unsigned short loopGain;
99  unsigned short voltage;
100  unsigned char id;
101  unsigned char day;
102  unsigned char month;
103  unsigned char year;
104  unsigned char npt;
105  float coeff;
106  int tunerPos;
107  int backshortPos;
108  int attenPos;
109  int position;
110  } lo;
111 
115  struct {
116  double az;
117  double el;
118  } offset;
119 
123  struct {
124  sza::util::Rx::Id rx;
125  sza::util::Amp::Type amp;
126  sza::util::Amp::Stage stage;
127  sza::util::Amp::Bias biasType;
128  short bias;
129  } inputVoltage;
130 
134  struct {
135  sza::util::Rx::Id rx;
136  sza::util::Amp::Type amp;
137  sza::util::Amp::Stage stage;
138  float current;
139  } drainCurrent;
140 
144  struct {
145  unsigned int channel;
146  bool start;
147  } fastSampling;
148 
152  struct {
153  sza::array::CalTertMsg msgId;
154  sza::util::Rx::Id rxId;
155  short tertPosition;
156  sza::util::CalPos::Pos calPosition;
157  bool enable;
158  sza::util::CalTertTypes::OwDevice owDevice;
159  sza::util::CalTertTypes::OwCommand owCommand;
160  unsigned long seq;
161  double tertPosDegrees;
162  } calTert;
163 
167  struct {
168  sza::array::IntModMsg msgId;
169  unsigned char atten;
170  } intMod;
171 
175  struct {
176  unsigned amp;
177  short bias;
178  sza::array::BiasType biasType;
179  sza::util::Rx::Id rxId;
180  unsigned seq;
181  bool isDefault;
182  } setBias;
183 
187  struct {
188  sza::array::IFModMsg msgId;
189  sza::util::Rx::Id band;
190  float level;
191  sza::util::IFAtten::Type attenSet;
192  float total;
193  float input;
194  float output;
195  unsigned seq;
196  sza::util::CalPos::Pos pos;
197  } IFMod;
198 
202  struct {
203  sza::array::ThermalMsg msgId;
204  sza::util::Thermal::Target target;
205  float value;
206  sza::util::Thermal::BoxMode mode;
207  bool eqState;
208  } thermal;
209 
213  struct {
214  sza::array::TiltmeterMsg msgId;
215  sza::array::TiltmeterMode mode;
216  float value;
217  float afZero;
218  float lrZero;
219  } tiltmeter;
220 
221  // CAN module commands
222 
223  struct {
224  sza::util::CanModule::Id modules;
225  bool hardwareReset;
226  } reset;
227 
228  // Select a receiver
229 
230  struct {
231  sza::util::Rx::Id rxBand;
232  unsigned seq;
233  } selectRx;
234 
235  struct {
236  MsgType type; // The network command this corresponds to
237  } canCommand;
238 
239  } body;
240 
241  //------------------------------------------------------------
242  // Methods for packing messages
243  //------------------------------------------------------------
244 
245  inline void packFlagBoardMsg(unsigned short board, bool flag)
246  {
247  genericMsgType_ =
248  sza::util::GenericTaskMsg::TASK_SPECIFIC;
249 
250  setCarmaSequenceNumber();
251  type = FLAG_BOARD;
252  body.flagBoard.board = board;
253  body.flagBoard.flag = flag;
254  }
255 
256  inline void packLoMsg(sza::array::LoMsgId msgId,
257  sza::util::LoOsc::Osc oscs,
258  sza::util::LoStage::Stage stages,
259  sza::util::Rx::Id rxId,
260  bool on,
261  unsigned short dampGain,
262  unsigned short frequency,
263  unsigned short loopGain,
264  unsigned short voltage,
265  unsigned char id,
266  unsigned char day,
267  unsigned char month,
268  unsigned char year,
269  unsigned char npt,
270  float coeff,
271  int tunerPos,
272  int backshortPos,
273  int attenPos,
274  int position)
275  {
276  genericMsgType_ =
277  sza::util::GenericTaskMsg::TASK_SPECIFIC;
278 
279  type = LO;
280 
281  body.lo.msgId = msgId;
282  body.lo.oscs = oscs;
283  body.lo.stages = stages;
284  body.lo.rxId = rxId;
285  body.lo.on = on;
286  body.lo.dampGain = dampGain;
287  body.lo.frequency = frequency;
288  body.lo.loopGain = loopGain;
289  body.lo.voltage = voltage;
290  body.lo.id = id;
291  body.lo.day = day;
292  body.lo.month = month;
293  body.lo.year = year;
294  body.lo.npt = npt;
295  body.lo.coeff = coeff;
296  body.lo.tunerPos = tunerPos;
297  body.lo.backshortPos = backshortPos;
298  body.lo.attenPos = attenPos;
299  body.lo.position = position;
300  }
301 
302  inline void packOffsetMsg(double az, double el)
303  {
304  genericMsgType_ =
305  sza::util::GenericTaskMsg::TASK_SPECIFIC;
306 
307  setCarmaSequenceNumber();
308  type = OFFSET;
309  body.offset.az = az;
310  body.offset.el = el;
311  }
312 
313  inline void packSetDrainCurrentMsg(sza::util::Rx::Id rx,
314  sza::util::Amp::Type amp,
315  sza::util::Amp::Stage stage,
316  float current)
317  {
318  genericMsgType_ =
319  sza::util::GenericTaskMsg::TASK_SPECIFIC;
320 
321  setCarmaSequenceNumber();
322  type = SET_DRAIN_CURRENT;
323 
324  body.drainCurrent.rx = rx;
325  body.drainCurrent.amp = amp;
326  body.drainCurrent.stage = stage;
327  body.drainCurrent.current = current;
328  }
329 
330  inline void packSetInputVoltageMsg(sza::util::Rx::Id rx,
331  sza::util::Amp::Type amp,
332  sza::util::Amp::Stage stage,
333  sza::util::Amp::Bias biasType,
334  short bias)
335  {
336  genericMsgType_ =
337  sza::util::GenericTaskMsg::TASK_SPECIFIC;
338 
339  setCarmaSequenceNumber();
340  type = SET_INPUT_VOLTAGE;
341 
342  body.inputVoltage.rx = rx;
343  body.inputVoltage.amp = amp;
344  body.inputVoltage.stage = stage;
345  body.inputVoltage.biasType = biasType;
346  body.inputVoltage.bias = bias;
347  }
348 
349  inline void packToggleFastSamplingMsg(unsigned int channel,
350  bool start)
351  {
352  genericMsgType_ =
353  sza::util::GenericTaskMsg::TASK_SPECIFIC;
354 
355  setCarmaSequenceNumber();
356  type = TOGGLE_FAST_SAMPLING;
357 
358  body.fastSampling.channel = channel;
359  body.fastSampling.start = start;
360  }
361 
362  inline void packSetBiasMsg(unsigned amp, short bias,
363  sza::array::BiasType biasType,
364  sza::util::Rx::Id rxId,
365  unsigned seq, bool isDefault)
366  {
367  genericMsgType_ =
368  sza::util::GenericTaskMsg::TASK_SPECIFIC;
369 
370  setCarmaSequenceNumber();
371  type = SET_BIAS;
372 
373  body.setBias.amp = amp;
374  body.setBias.bias = bias;
375  body.setBias.biasType = biasType;
376  body.setBias.rxId = rxId;
377  body.setBias.seq = seq;
378  body.setBias.isDefault = isDefault;
379  }
380 
381  inline void packIntModMsg(sza::array::IntModMsg msgId,
382  unsigned char atten=0)
383  {
384  genericMsgType_ =
385  sza::util::GenericTaskMsg::TASK_SPECIFIC;
386 
387  setCarmaSequenceNumber();
388  type = INTMOD;
389 
390  body.intMod.msgId = msgId;
391  body.intMod.atten = atten;
392  }
393 
394  inline void packCalTertMsg(sza::array::CalTertMsg msgId,
395  sza::util::Rx::Id rxId,
396  short tertPosition,
397  sza::util::CalPos::Pos calPosition,
398  bool enable,
399  sza::util::CalTertTypes::OwDevice device,
400  sza::util::CalTertTypes::OwCommand command,
401  unsigned long seq)
402  {
403  genericMsgType_ =
404  sza::util::GenericTaskMsg::TASK_SPECIFIC;
405 
406  DBPRINT(true, sza::util::Debug::DEBUG5, "Seq = " << seq);
407 
408  setCarmaSequenceNumber();
409  type = CALTERT;
410 
411  body.calTert.msgId = msgId;
412  body.calTert.rxId = rxId;
413  body.calTert.tertPosition = tertPosition;
414  body.calTert.calPosition = calPosition;
415  body.calTert.enable = enable;
416  body.calTert.owDevice = device;
417  body.calTert.owCommand = command;
418  body.calTert.seq = seq;
419  }
420 
421  inline void packNewCalTertMsg(sza::array::CalTertMsg msgId,
422  sza::util::CalPos::Pos calPosition,
423  sza::util::Rx::Id rxId,
424  double tertPosDegrees,
425  unsigned long seq)
426  {
427  genericMsgType_ =
428  sza::util::GenericTaskMsg::TASK_SPECIFIC;
429 
430  DBPRINT(true, sza::util::Debug::DEBUG5, "Seq = " << seq);
431 
432  setCarmaSequenceNumber();
433  type = CALTERT;
434 
435  body.calTert.msgId = msgId;
436  body.calTert.calPosition = calPosition;
437  body.calTert.rxId = rxId;
438  body.calTert.tertPosDegrees = tertPosDegrees;
439  body.calTert.seq = seq;
440  }
441 
442  // Pack an antenna IF message
443 
444  inline void packIFModMsg(sza::array::IFModMsg msgId,
445  sza::util::Rx::Id band,
446  float level,
447  sza::util::IFAtten::Type attenSet,
448  float total,
449  float input,
450  float output,
451  unsigned seq,
452  sza::util::CalPos::Pos pos)
453  {
454  genericMsgType_ =
455  sza::util::GenericTaskMsg::TASK_SPECIFIC;
456 
457  setCarmaSequenceNumber();
458  type = IFMOD;
459 
460  body.IFMod.msgId = msgId;
461  body.IFMod.band = band;
462  body.IFMod.level = level;
463  body.IFMod.attenSet = attenSet;
464  body.IFMod.total = total;
465  body.IFMod.input = input;
466  body.IFMod.output = output;
467  body.IFMod.seq = seq;
468  body.IFMod.pos = pos;
469  }
470 
471  inline void packThermalMsg(sza::array::ThermalMsg msgId,
472  sza::util::Thermal::Target target,
473  float value,
474  sza::util::Thermal::BoxMode mode,
475  bool eqState)
476  {
477  genericMsgType_ =
478  sza::util::GenericTaskMsg::TASK_SPECIFIC;
479 
480  setCarmaSequenceNumber();
481  type = THERMAL;
482 
483  body.thermal.msgId = msgId;
484  body.thermal.target = target;
485  body.thermal.value = value;
486  body.thermal.mode = mode;
487  body.thermal.eqState = eqState;
488  }
489 
490  inline void packTiltmeterMsg(sza::array::TiltmeterMsg msgId,
491  sza::array::TiltmeterMode mode,
492  float value,
493  float afZero=0.0,
494  float lrZero=0.0)
495 
496  {
497  genericMsgType_ =
498  sza::util::GenericTaskMsg::TASK_SPECIFIC;
499 
500  setCarmaSequenceNumber();
501  type = TILTMETER;
502 
503  body.tiltmeter.msgId = msgId;
504  body.tiltmeter.mode = mode;
505  body.tiltmeter.value = value;
506  body.tiltmeter.afZero = afZero;
507  body.tiltmeter.lrZero = lrZero;
508  }
509 
510  // Generic message to reset a CAN module.
511 
512  inline void packResetMsg(sza::util::CanModule::Id modules, bool hard)
513  {
514  genericMsgType_ =
515  sza::util::GenericTaskMsg::TASK_SPECIFIC;
516 
517  setCarmaSequenceNumber();
518  type = RESET;
519 
520  body.reset.modules = modules;
521  body.reset.hardwareReset = hard;
522  }
523 
524  // Generic message to reset a CAN module.
525 
526  inline void packSelectRxMsg(sza::util::Rx::Id rxBand, unsigned seq)
527  {
528  genericMsgType_ =
529  sza::util::GenericTaskMsg::TASK_SPECIFIC;
530 
531  setCarmaSequenceNumber();
532  type = SELECT_RX;
533 
534  body.selectRx.rxBand = rxBand;
535  body.selectRx.seq = seq;
536 
537  COUT("packSelectRxMsg seq = " << seq);
538 
539  }
540 
541  inline void packExecuteNextCanInstructionMsg(MsgType commandType)
542  {
543  genericMsgType_ =
544  sza::util::GenericTaskMsg::TASK_SPECIFIC;
545 
546  setCarmaSequenceNumber();
547  type = EXECUTE_NEXT_CAN_INSTRUCTION;
548 
549  body.canCommand.type = commandType;
550  }
551 
555  friend std::ostream& operator<<(std::ostream& os, AntennaRxMsg* msg);
556 
557  }; // End class AntennaRxMsg
558 
559  }; // End namespace control
560  }; // End namespace antenna
561 }; // End namespace sza
562 
563 #endif // End #ifndef
struct sza::antenna::control::AntennaRxMsg::@18::@26 intMod
Control the Berkeley interface module
Tagged: Tue Aug 24 08:51:16 PDT 2004.
struct sza::antenna::control::AntennaRxMsg::@18::@27 setBias
Set a bias
struct sza::antenna::control::AntennaRxMsg::@18::@30 tiltmeter
Control the Tiltmeter Module
Started: Wed Jan 14 11:00:24 PST 2004.
MsgType
Enumerate supported AntennaRx messages.
Definition: AntennaRxMsg.h:48
friend std::ostream & operator<<(std::ostream &os, AntennaRxMsg *msg)
Allows cout &lt;&lt; AntennaRxMsg.
Tagged: Wed Aug 25 21:23:12 PDT 2004.
Class to encapsulate messages send to the Rx task.
Definition: AntennaRxMsg.h:40
struct sza::antenna::control::AntennaRxMsg::@18::@20 lo
Control the LO chain
union sza::antenna::control::AntennaRxMsg::@18 body
Define a Message container.
MsgType type
The type of this message.
Definition: AntennaRxMsg.h:71
struct sza::antenna::control::AntennaRxMsg::@18::@28 IFMod
Control the Antenna IF module
struct sza::antenna::control::AntennaRxMsg::@18::@19 flagBoard
Flag a board.
struct sza::antenna::control::AntennaRxMsg::@18::@22 inputVoltage
Set a input voltage
Started: Wed Dec 10 23:48:07 UTC 2003.
Tagged: Thu Jun 17 21:05:13 UTC 2004.
Tagged: Tue Mar 30 08:46:08 PST 2004.
Tagged: Fri Nov 14 12:39:34 UTC 2003.
struct sza::antenna::control::AntennaRxMsg::@18::@21 offset
Install offsets needed to bring this receiver on-axis
GenericMsgType genericMsgType_
A type for this message.
struct sza::antenna::control::AntennaRxMsg::@18::@29 thermal
Control the Thermal Module
struct sza::antenna::control::AntennaRxMsg::@18::@25 calTert
Control the Calibrator/Tertiary CAN module
Started: Tue Jan 13 18:57:18 PST 2004.
Tagged: Wed Aug 18 06:20:23 PDT 2004.
A class to encapsulate message types for a generic task.
struct sza::antenna::control::AntennaRxMsg::@18::@24 fastSampling
Toggle fast sampling
struct sza::antenna::control::AntennaRxMsg::@18::@23 drainCurrent
Set a drain current