CARMA C++
Tracker.h
Go to the documentation of this file.
1 #ifndef TRACKER_H
2 #define TRACKER_H
3 
11 #include <list>
12 #include <map>
13 
14 // SZA class includes
15 
16 #include "carma/szautil/Atmosphere.h"
17 #include "carma/szautil/PmacMode.h"
18 #include "carma/szautil/QuadPath.h"
19 #include "carma/szautil/Source.h"
21 
22 #include "carma/szautil/TimeVal.h"
23 
24 #include "carma/antenna/sza/antenna/control/Atmosphere.h"
26 #include "carma/antenna/sza/antenna/control/Site.h"
36 
37 // Needed for various sza::array enumerators
38 
39 #include "carma/szaarrayutils/szaregs.h"
40 
41 namespace sza {
42  namespace antenna {
43  namespace control {
44 
45  class AntennaDrive;
46 
51  class Tracker :
52  public SzaTask,
53  public sza::util::GenericTask<TrackerMsg> {
54 
55  //============================================================
56  // Public members
57  //============================================================
58 
59  public:
60 
64  enum BoardType {
65  CAMERA,
66  TRACKER,
67  PMAC
68  };
69 
73  std::list<Board*> listBoards();
74 
75  //============================================================
76  // Private members
77  //============================================================
78 
79  private:
80 
81  // The receiver we're currently using
82 
83  sza::util::Rx::Id rxId_;
84 
85  bool simPmac_;
86  bool ignoreWrapLogic_;
87 
92  enum NextPmacState {
93  IGNORE, // No further action needed (pmac halted)
94  HALT, // Tell the pmac to stop the telescope drives
95  SLEW, // Tell the pmac to slew
96  WAIT, // Waiting for the pmac to signal completion of a
97  // slew
98  TARGET, // Prepare to change source
99  SYNC, // Prepare the pmac to start a new track
100  SLAVE, // Send the next 1-second position of an ongoing
101  // track
102  REBOOT // Tell the pmac to reboot itself
103  };
104 
105  //------------------------------------------------------------
106  // Private methods & members
107  //------------------------------------------------------------
108 
109  friend class AntennaDrive;
110 
114  AntennaDrive* parent_;
115 
123  Tracker(AntennaDrive* parent, bool simPmac=false, bool ignoreWrapLogic=true);
124 
128  ~Tracker();
129 
136  void processMsg(TrackerMsg* msg);
137 
138  //------------------------------------------------------------
139  // Private member declarations
140  //------------------------------------------------------------
141 
145  bool shutdownPending_;
146 
150  int year_;
151 
155  NextPmacState whatNext_;
156 
163  unsigned archived_;
164 
170  unsigned lacking_;
171 
176  long lastReq_;
177 
182  long lastAck_;
183 
184  std::map<sza::util::GenericTaskMsg::CarmaSeqNoType, unsigned long> lastReqCarmaSeqNo_;
185  std::map<sza::util::GenericTaskMsg::CarmaSeqNoType, unsigned long> lastAckCarmaSeqNo_;
186  sza::util::GenericTaskMsg::CarmaSeqNoType carmaSeqNoType_;
187 
192 
197 
202  bool paramsUpdated_;
208  int pmacTracking_;
212  Atmosphere atmos_;
213 
217  CameraBoard* camera_;
218 
222  Model model_;
223 
228  PmacBoard* pmac_;
229 
233  Pointing nextTarget_;
234 
238  Position lastCommanded_; // Position commanded on the last tick
239  Position prevCommanded_; // Position commanded two ticks ago
240 
244  Site site_;
245 
246  // An object for handling atmospheric calculations
247 
248  sza::util::Atmosphere refracCalculator_;
249 
253  sza::util::Source src_;
254 
258  sza::util::TimeVal lastTick_;
259 
263  TrackerBoard* tracker_;
264 
268  TrackerOffset offset_;
269 
270  //------------------------------------------------------------
271  // Private Methods
272  //------------------------------------------------------------
273 
274  void resetMembers();
275 
282  void reset();
283 
289  void initialize();
290 
302  void updatePmac(sza::util::TimeVal& mjd,
303  AxisPositions* current);
304 
309  void archiveStatus();
310 
317  void updateMountLimits();
318 
327  void sourcePosition(sza::util::TimeVal& mjd);
328 
329  // Version for fixed sources
330 
331  void sourcePositionTrack(sza::util::TimeVal& mjd);
332 
344  void pmacNewPosition(sza::util::PmacMode::Mode mode,
345  AxisPositions *current);
346 
351  void finalizePointing(double pmra, double pmdec,
352  PointingCorrections *f);
353 
354  // Version for fixed sources
355 
356  void finalizePointing();
357 
367  void registerRequest(unsigned seq);
368 
369  void registerCarmaRequest(TrackerMsg* msg);
370  void sendCarmaSeqNoMsg(bool success);
371 
376  void sendPmacDoneMessage(unsigned seq);
380  void sendSourceSetMessage(unsigned seq);
381 
382  //............................................................
383  // Methods which are called in response to messages from the
384  // Drive Task
385  //............................................................
386 
396  void addTick(TrackerMsg* msg);
397 
403  void calCollimation(TrackerMsg* msg);
404 
411  void calEncoders(TrackerMsg* msg);
412 
419  void calFlexure(TrackerMsg* msg);
420 
427  void calTilts(TrackerMsg* msg);
428 
436  void changeYear(TrackerMsg* msg);
437 
446  void extendEqnEqx(TrackerMsg* msg);
447 
454  void extendTrack(TrackerMsg* msg);
455 
464  void extendUt1Utc(TrackerMsg* msg);
465 
475  void haltTelescope(TrackerMsg* msg);
476 
483  void locateSite(TrackerMsg* msg);
484 
491  void locateAntenna(TrackerMsg* msg);
492 
502  void rebootPmac(TrackerMsg* msg);
503 
510  void recordEncoderLimits(TrackerMsg* msg);
511 
522  void setTvAngle(TrackerMsg* msg);
523 
530  void selectModel(TrackerMsg* msg);
531 
538  void setEncoderZero(TrackerMsg* msg);
539 
547  void setOffset(TrackerMsg* msg);
548 
555  void setSlewRate(TrackerMsg* msg);
556 
563  void slewTelescope(TrackerMsg* msg);
564 
573  void unflagBoard(TrackerMsg* msg);
574 
582  void updateRefraction(TrackerMsg* msg);
583  void updateRefraction();
584 
588  void strobePmac();
589 
593  void connectPmac();
594 
598  void disconnectPmac();
599 
604  bool okToPoint();
605 
606  void setWrapMode(WrapMode::Mode wrapMode);
607 
608  }; // End class Tracker
609 
610  }; // End namespace control
611  }; // End namespace antenna
612 }; // End namespace sza
613 
614 #endif
A class for managing timeval/timespec structs.
Definition: TimeVal.h:53
Tagged: Thu Nov 13 16:53:43 UTC 2003.
std::list< Board * > listBoards()
Return a list of boards controlled by this task.
Tagged: Fri Nov 14 12:39:38 UTC 2003.
Tagged: Thu Nov 13 16:53:49 UTC 2003.
Tagged: Fri Apr 6 10:52:00 PDT 2012.
All tasks will have the following functionality:
Definition: GenericTask.h:32
BoardType
Enumerate the boards controlled by this task.
Definition: Tracker.h:64
Started: Wed Dec 17 19:50:04 UTC 2003.
Tagged: Thu Nov 13 16:53:56 UTC 2003.
Mode
Enumerate the pmac control modes.
Definition: PmacMode.h:24
Tagged: Thu Nov 13 16:53:47 UTC 2003.
The following class is used to record details about the current source trajectory.
Definition: Source.h:31
Tagged: Thu Nov 13 16:53:56 UTC 2003.
Tagged: Thu Nov 13 16:53:57 UTC 2003.
Tagged: Thu Nov 13 16:53:45 UTC 2003.
Tagged: Thu Nov 13 16:53:35 UTC 2003.
Tagged: Thu Nov 13 16:53:54 UTC 2003.
Define a class that will handle pointing and tracking for this antenna.
Definition: Tracker.h:51
Tagged: Thu Nov 13 16:53:49 UTC 2003.
Tagged: Thu Nov 13 16:53:46 UTC 2003.