CARMA C++
TrackerMsg.h
Go to the documentation of this file.
1 #ifndef TRACKERMSG_H
2 #define TRACKERMSG_H
3 
11 #include "carma/szaarrayutils/szaregs.h" // SRC_LEN
12 
15 
16 #include "carma/szautil/Axis.h"
18 #include "carma/szautil/PointingMode.h"
19 #include "carma/szautil/Rx.h"
20 
24 
25 namespace sza {
26  namespace antenna {
27  namespace control {
28 
29  class TrackerMsg :
31 
32  public:
33 
37  enum MsgType {
38  COLLIMATION,
39  CONNECT_PMAC, // Attempt to connect to the pmac.
40  DISCONNECT_PMAC, // Disconnect from the pmac.
41  ENCODER_CALS,
42  ENCODER_LIMITS,
43  ENCODER_ZEROS,
44  EXTEND_EQNEQX,
45  EXTEND_UT1UTC,
46  FLAG_BOARD,
47  FLEXURE,
48  HALT,
49  LOCATION,
50  SITE,
51  OFFSET,
52  REBOOT_PMAC,
53  REFRACTION,
54  RESTART,
55  SELECT_MODEL,
56  SLEW,
57  SLEWRATE,
58  START_TIMER, // Start 1pps timer
59  STOP_TIMER, // Stop 1pps timer
60  STROBE_PMAC,
61  TICK, // 1-pps tick has arrived
62  TILTS,
63  TRACK,
64  TV_ANGLE,
65  YEAR,
66  WEATHER,
67  RX,
68  WRAPMODE
69  };
70 
74  MsgType type;
75 
79  union {
80 
84  struct {
85  unsigned long seq;
86  } rebootPmac;
87 
91  struct {
92  unsigned long seq;
94  char source[SRC_LEN];
95  double az;
96  double el;
97  double pa;
98  } slew;
99 
103  struct {
104  unsigned long seq;
105  } halt;
106 
110  unsigned long tick;
111 
115  struct {
116  signed int seq;
117  char source[SRC_LEN];
118  double mjd; // The Terrestrial Time at which ra,dec are
119  // valid, expressed as a Modified Julian Day
120  // number
121  double ra; // The desired apparent Right Ascension
122  // (0...360 degrees in radians)
123  double dec; // The desired apparent Declination
124  // (-180..180 degrees in radians)
125  double dist; // The distance to the source if it is near
126  // enough for parallax to be
127  // significant. Specify the distance in
128  // AU. Send 0 for distant sources.
129  WrapMode::Mode wrapMode;
130  } track;
131 
135  struct {
136  unsigned long seq; // The sequence number of this request
137  sza::util::OffsetMsg offset; // A message containg the
138  // offset (see OffsetMsg.h)
139  } offset;
140 
146  struct {
147  double angle; // The PA angle at which the camera image is
148  // upright (radians)
149  } tvAngle;
150 
155  struct {
156  sza::util::PointingMode::Type mode; // Which refraction mode are we
157  // updating? (radio | optical)
158  double a; // The A term of the refraction correction
159  double b; // The B term of the refraction correction
160  } refraction;
161 
189  struct {
190  double mjd; // The UTC to which this command refers as
191  // a Modified Julian Day number
192  double ut1utc; // The value of ut1 - utc (seconds)
193  } extendUt1Utc;
194 
198  struct {
199  double mjd; // The Terrestrial Time to which this
200  // command refers, as a Modified Julian
201  // day
202  double eqneqx; // The equation of the equinoxes (radians)
203  } extendEqnEqx;
204 
210  struct {
211  unsigned long seq; // The tracker sequence number of this command
212  sza::util::Axis::Type axes; // A bitwise union of
213  // Axis::Type enumerated
214  // bits, used to specify
215  // which of the following
216  // axis rates are to be
217  // applied.
218  long az; // Azimuth slew rate (0-100)
219  long el; // Elevation slew rate (0-100)
220  long dk; // Deck slew rate (0-100)
221  } slewRate;
222 
226  struct {
227  unsigned long seq; // The tracker sequence number of this command
228  double ha; // The hour-angle component of the
229  // azimuth-axis tilt (mas)
230  double lat; // The latitude component of the azimuth-axis
231  // tilt (mas)
232  double el; // The tilt of the elevation axis
233  // perpendicular to the azimuth ring,
234  // measured clockwise around the direction of
235  // the azimuth std::vector (mas)
236  } tilts;
237 
241  struct {
242  unsigned long seq; // The tracker sequence number of this
243  // command
244  sza::util::PointingMode::Type mode; // A PointingMode
245  // enumeration
246  // (optical|radio)
247 
248  double sFlexure; // Gravitational flexure (radians per
249  // sine elevation)
250  double cFlexure; // Gravitational flexure (radians per
251  // cosine elevation)
252  } flexure;
253 
257  struct {
258  unsigned long seq; // The tracker sequence number of this
259  // command
260  sza::util::PointingMode::Type mode; // Which collimation?
261  // (optical|radio)
262  double x; // The magnitude of the horizonatl
263  // collimation offset
264  double y; // The magnitude of the vertical
265  // collimation offset
266  sza::util::OffsetMsg::Mode addMode; // ADD or SET?
267 
268  } collimation;
269 
273  struct {
274  unsigned long seq; // The sequence number of this command
275  long az;
276  long el;
277  long dk;
278  } encoderCountsPerTurn;
279 
284  struct {
285  unsigned long seq; // The tracker sequence number of this command
286  long az_min; // The lower azimuth limit (encoder counts)
287  long az_max; // The upper azimuth limit (encoder counts)
288  long el_min; // The lower elevation limit (encoder counts)
289  long el_max; // The upper elevation limit (encoder counts)
290  long pa_min; // The lower deck limit (encoder counts)
291  long pa_max; // The upper deck limit (encoder counts)
292  } encoderLimits;
293 
299  struct {
300  unsigned long seq; // The sequence number of this command
301  double az; // Azimuth encoder angle at zero azimuth,
302  // measured in the direction of increasing
303  // azimuth (radians)
304  double el; // Elevation encoder angle at zero elevation,
305  // measured in the direction of increasing
306  // elevation (radians)
307  double dk; // Deck encoder angle at the deck reference
308  // position, measured clockwise when looking
309  // towards the sky (radians)
310  } encoderZeros;
311 
315  struct {
316  unsigned long seq; // The tracker sequence number of this
317  // command
318  sza::util::PointingMode::Type mode; // A PointingMode enumeration
319  } selectModel;
320 
326  struct {
327  short year; // The current Gregorian year
328  } year;
329 
334  struct {
335  double lon; // The SZA longitude (east +ve) [-pi..pi] (radians)
336  double lat; // The SZA latitude [-pi/2..pi/2] (radians)
337  double alt; // The SZA altitude (meters)
338  } site;
339 
344  struct {
345  double north; // The antenna offset N (meters)
346  double east; // The antenna offset E (meters)
347  double up; // The antenna offset Up (meters)
348  } location;
349 
353  struct {
354  unsigned short board; // The register map index of the
355  // board to un/flag
356  bool flag; // True to flag, false to unflag
357  } flagBoard;
358 
359  struct {
360  double airTemperatureInK;
361  double relativeHumidity;
362  double pressureInMbar;
363  } weather;
364 
365  struct {
366  sza::util::Rx::Id id;
367  } rx;
368 
369  struct {
370  WrapMode::Mode wrapMode;
371  } wrapMode;
372 
373  } body;
374 
375  //------------------------------------------------------------
376  // Methods for packing message to the tracker task.
377  //
378  // We explicitly initialize genericMsgType_ in each method,
379  // since we cannot do this in a constructor, since objects
380  // with explicit constructors apparently can't be union
381  // members.
382  //------------------------------------------------------------
383 
387  inline void packConnectPmacMsg() {
388  genericMsgType_ =
389  sza::util::GenericTaskMsg::TASK_SPECIFIC;
390 
391  setCarmaSequenceNumber();
392  type = CONNECT_PMAC;
393  }
394 
398  inline void packStrobePmacMsg() {
399  genericMsgType_ =
400  sza::util::GenericTaskMsg::TASK_SPECIFIC;
401 
402  setCarmaSequenceNumber();
403  type = STROBE_PMAC;
404  }
405 
409  inline void packDisconnectPmacMsg() {
410  genericMsgType_ =
411  sza::util::GenericTaskMsg::TASK_SPECIFIC;
412 
413  setCarmaSequenceNumber();
414  type = DISCONNECT_PMAC;
415  }
416 
417  inline void packRebootPmacMsg(unsigned long seq)
418  {
419  genericMsgType_ =
420  sza::util::GenericTaskMsg::TASK_SPECIFIC;
421 
422  setCarmaSequenceNumber();
423  type = REBOOT_PMAC;
424  body.rebootPmac.seq = seq;
425  }
426 
427  inline void packSlewMsg(unsigned long seq,
428  std::string source,
429  sza::util::Axis::Type axes,
430  double az, double el, double pa)
431  {
432  genericMsgType_ =
433  sza::util::GenericTaskMsg::TASK_SPECIFIC;
434 
435  type = SLEW;
436  body.slew.seq = seq;
437  body.slew.axes = axes;
438 
439  if(source.size() > SRC_LEN)
440  ThrowError("source name is too long.\n");
441 
442  strncpy(body.slew.source, source.c_str(), SRC_LEN);
443 
444  body.slew.az = az;
445  body.slew.el = el;
446  body.slew.pa = pa;
447 
448  setCarmaSequenceNumber();
449  }
450 
451  inline void packHaltMsg(unsigned long seq)
452  {
453  genericMsgType_ =
454  sza::util::GenericTaskMsg::TASK_SPECIFIC;
455 
456  type = HALT;
457  body.halt.seq = seq;
458 
459  setCarmaSequenceNumber();
460  }
461 
462  inline void packTrackMsg(signed long seq,
463  std::string source,
464  double mjd, double ra,
465  double dec, double dist,
466  WrapMode::Mode wrapMode)
467  {
468  genericMsgType_ =
469  sza::util::GenericTaskMsg::TASK_SPECIFIC;
470 
471  setCarmaSequenceNumber();
472  type = TRACK;
473  body.track.seq = seq;
474 
475  if(source.size() > SRC_LEN)
476  ThrowError("source name is too long.\n");
477 
478  strncpy(body.track.source, source.c_str(), SRC_LEN);
479 
480  body.track.mjd = mjd;
481  body.track.ra = ra;
482  body.track.dec = dec;
483  body.track.dist = dist;
484  body.track.wrapMode = wrapMode;
485  }
486 
487  inline void packOffsetMsg(unsigned long seq,
488  sza::util::OffsetMsg offset)
489  {
490  genericMsgType_ =
491  sza::util::GenericTaskMsg::TASK_SPECIFIC;
492 
493  setCarmaSequenceNumber();
494  type = OFFSET;
495  body.offset.seq = seq;
496  body.offset.offset = offset;
497  }
498 
499  inline void packTvAngleMsg(double angle)
500  {
501  genericMsgType_ =
502  sza::util::GenericTaskMsg::TASK_SPECIFIC;
503 
504  setCarmaSequenceNumber();
505  type = TV_ANGLE;
506  body.tvAngle.angle = angle;
507  }
508 
509  inline void packEncoderZerosMsg(unsigned long seq,
510  double az, double el, double dk)
511  {
512  genericMsgType_ =
513  sza::util::GenericTaskMsg::TASK_SPECIFIC;
514 
515  setCarmaSequenceNumber();
516  type = ENCODER_ZEROS;
517 
518  body.encoderZeros.seq = seq;
519  body.encoderZeros.az = az;
520  body.encoderZeros.el = el;
521  body.encoderZeros.dk = dk;
522  }
523 
524  inline void packEncoderCountsPerTurnMsg(unsigned long seq,
525  long az, long el, long dk)
526  {
527  genericMsgType_ =
528  sza::util::GenericTaskMsg::TASK_SPECIFIC;
529 
530  setCarmaSequenceNumber();
531  type = ENCODER_CALS;
532  body.encoderCountsPerTurn.seq = seq;
533  body.encoderCountsPerTurn.az = az;
534  body.encoderCountsPerTurn.el = el;
535  body.encoderCountsPerTurn.dk = dk;
536  }
537 
538  inline void packRefractionMsg(sza::util::PointingMode::Type mode, double a,
539  double b)
540  {
541  genericMsgType_ =
542  sza::util::GenericTaskMsg::TASK_SPECIFIC;
543 
544  setCarmaSequenceNumber();
545  type = REFRACTION;
546  body.refraction.mode = mode;
547  body.refraction.a = a;
548  body.refraction.b = b;
549  }
550 
551  inline void packRestartMsg()
552  {
553  genericMsgType_ =
554  sza::util::GenericTaskMsg::TASK_SPECIFIC;
555 
556  setCarmaSequenceNumber();
557  type = RESTART;
558  }
559 
560  inline void packExtendUt1UtcMsg(double mjd, double ut1utc)
561  {
562  genericMsgType_ =
563  sza::util::GenericTaskMsg::TASK_SPECIFIC;
564 
565  setCarmaSequenceNumber();
566  type = EXTEND_UT1UTC;
567  body.extendUt1Utc.mjd = mjd;
568  body.extendUt1Utc.ut1utc = ut1utc;
569  }
570 
571  inline void packExtendEqnEqxMsg(double mjd, double eqneqx)
572  {
573  genericMsgType_ =
574  sza::util::GenericTaskMsg::TASK_SPECIFIC;
575 
576  setCarmaSequenceNumber();
577  type = EXTEND_EQNEQX;
578  body.extendEqnEqx.mjd = mjd;
579  body.extendEqnEqx.eqneqx = eqneqx;
580  }
581 
582  inline void packSlewRateMsg(unsigned long seq,
583  sza::util::Axis::Type axes,
584  long az, long el, long dk)
585  {
586  genericMsgType_ =
587  sza::util::GenericTaskMsg::TASK_SPECIFIC;
588 
589  setCarmaSequenceNumber();
590  type = SLEWRATE;
591  body.slewRate.seq = seq;
592  body.slewRate.axes = axes;
593  body.slewRate.az = az;
594  body.slewRate.el = el;
595  body.slewRate.dk = dk;
596  }
597 
598  inline void packTickMsg(unsigned long tick)
599  {
600  genericMsgType_ =
601  sza::util::GenericTaskMsg::TASK_SPECIFIC;
602 
603  setCarmaSequenceNumber();
604  type = TICK;
605  body.tick = tick;
606  }
607 
608  inline void packTiltsMsg(unsigned long seq, double ha, double lat,
609  double el)
610  {
611  genericMsgType_ =
612  sza::util::GenericTaskMsg::TASK_SPECIFIC;
613 
614  setCarmaSequenceNumber();
615  type = TILTS;
616  body.tilts.seq = seq;
617  body.tilts.ha = ha;
618  body.tilts.lat = lat;
619  body.tilts.el = el;
620  }
621 
622  inline void packFlexureMsg(unsigned long seq,
624  double sFlexure,
625  double cFlexure)
626  {
627  genericMsgType_ =
628  sza::util::GenericTaskMsg::TASK_SPECIFIC;
629 
630  setCarmaSequenceNumber();
631  type = FLEXURE;
632  body.flexure.seq = seq;
633  body.flexure.mode = mode;
634  body.flexure.sFlexure = sFlexure;
635  body.flexure.cFlexure = cFlexure;
636  }
637 
638  inline void packCollimationMsg(unsigned long seq,
640  double x, double y,
641  sza::util::OffsetMsg::Mode addMode)
642 
643  {
644  genericMsgType_ =
645  sza::util::GenericTaskMsg::TASK_SPECIFIC;
646 
647  setCarmaSequenceNumber();
648  type = COLLIMATION;
649  body.collimation.seq = seq;
650  body.collimation.mode = mode;
651  body.collimation.x = x;
652  body.collimation.y = y;
653  body.collimation.addMode = addMode;
654  }
655 
656  inline void packEncoderLimitsMsg(unsigned long seq,
657  long az_min, long az_max,
658  long el_min, long el_max,
659  long pa_min, long pa_max)
660  {
661  genericMsgType_ =
662  sza::util::GenericTaskMsg::TASK_SPECIFIC;
663 
664  setCarmaSequenceNumber();
665  type = ENCODER_LIMITS;
666  body.encoderLimits.seq = seq;
667  body.encoderLimits.az_min = az_min;
668  body.encoderLimits.az_max = az_max;
669  body.encoderLimits.el_min = el_min;
670  body.encoderLimits.el_max = el_max;
671  body.encoderLimits.pa_min = pa_min;
672  body.encoderLimits.pa_max = pa_max;
673  }
674 
675  inline void packSelectModelMsg(unsigned long seq,
677  {
678  genericMsgType_ =
679  sza::util::GenericTaskMsg::TASK_SPECIFIC;
680 
681  setCarmaSequenceNumber();
682  type = SELECT_MODEL;
683  body.selectModel.seq = seq;
684  body.selectModel.mode = mode;
685  }
686 
687  inline void packYearMsg(short year)
688  {
689  genericMsgType_ =
690  sza::util::GenericTaskMsg::TASK_SPECIFIC;
691 
692  setCarmaSequenceNumber();
693  type = YEAR;
694  body.year.year = year;
695  }
696 
697  inline void packSiteMsg(double lon, double lat, double alt)
698  {
699  genericMsgType_ =
700  sza::util::GenericTaskMsg::TASK_SPECIFIC;
701 
702  setCarmaSequenceNumber();
703  type = SITE;
704  body.site.lon = lon;
705  body.site.lat = lat;
706  body.site.alt = alt;
707  }
708 
709  inline void packLocationMsg(double north, double east, double up)
710  {
711  genericMsgType_ =
712  sza::util::GenericTaskMsg::TASK_SPECIFIC;
713 
714  setCarmaSequenceNumber();
715  type = LOCATION;
716  body.location.north = north;
717  body.location.east = east;
718  body.location.up = up;
719  }
720 
721  inline void packFlagBoardMsg(unsigned short board, bool flag)
722  {
723  genericMsgType_ =
724  sza::util::GenericTaskMsg::TASK_SPECIFIC;
725 
726  setCarmaSequenceNumber();
727  type = FLAG_BOARD;
728  body.flagBoard.board = board;
729  body.flagBoard.flag = flag;
730  }
731 
736  inline void packWeatherMsg(double airTempInK, double relHumidity, double pressureInMbar)
737  {
738  genericMsgType_ =
739  sza::util::GenericTaskMsg::TASK_SPECIFIC;
740 
741  setCarmaSequenceNumber();
742  type = WEATHER;
743 
744  body.weather.airTemperatureInK = airTempInK;
745  body.weather.relativeHumidity = relHumidity;
746  body.weather.pressureInMbar = pressureInMbar;
747  }
748 
753  inline void packRxMsg(sza::util::Rx::Id rxId)
754  {
755  genericMsgType_ =
756  sza::util::GenericTaskMsg::TASK_SPECIFIC;
757 
758  setCarmaSequenceNumber();
759  type = RX;
760 
761  body.rx.id = rxId;
762  }
763 
764  inline void packWrapModeMsg(WrapMode::Mode wrapMode)
765  {
766  genericMsgType_ =
767  sza::util::GenericTaskMsg::TASK_SPECIFIC;
768 
769  setCarmaSequenceNumber();
770  type = WRAPMODE;
771 
772  body.wrapMode.wrapMode = wrapMode;
773  }
774 
778  friend std::ostream& operator<<(std::ostream& os, TrackerMsg* msg);
779 
780  }; // End class TrackerMsg
781 
782  }; // End namespace control
783  }; // End namespace antenna
784 }; // End namespace sza
785 
786 #endif // End #ifndef
Tagged: Thu Nov 13 16:53:35 UTC 2003.
Type
Enumerate possible pointing modes.
Definition: PointingMode.h:25
Tagged: Fri Apr 6 10:52:00 PDT 2012.
Type
An enumerator to identify a valid axis.
Definition: Axis.h:24
Tagged: Fri Nov 14 12:39:34 UTC 2003.
GenericMsgType genericMsgType_
A type for this message.
Tagged: Thu Nov 13 16:53:50 UTC 2003.
Tagged: Thu Mar 11 16:38:48 PST 2004.
A class to encapsulate message types for a generic task.
Tagged: Fri Nov 14 12:39:33 UTC 2003.