My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Tracker.h
Go to the documentation of this file.
1 #ifndef TRACKER_H
2 #define TRACKER_H
3 
11 #include <list>
12 
13 // Class includes
14 
15 #include "gcp/util/common/Atmosphere.h"
16 #include "gcp/util/common/PmacMode.h"
17 #include "gcp/util/common/Source.h"
18 #include "gcp/util/common/TrackingStatus.h"
19 
20 #include "gcp/util/common/TimeVal.h"
21 
22 #include "gcp/antenna/control/specific/Atmosphere.h"
23 #include "gcp/antenna/control/specific/EmlDebug.h"
24 #include "gcp/antenna/control/specific/Site.h"
25 #include "gcp/antenna/control/specific/SpecificTask.h"
26 #include "gcp/antenna/control/specific/Pointing.h"
27 #include "gcp/antenna/control/specific/PointingCorrections.h"
28 #include "gcp/antenna/control/specific/Position.h"
29 #include "gcp/antenna/control/specific/Scan.h"
30 #include "gcp/antenna/control/specific/TrackerBoard.h"
31 #include "gcp/antenna/control/specific/TrackerMsg.h"
32 #include "gcp/antenna/control/specific/TrackerOffset.h"
33 
34 // Needed for various gcp::control enumerators
35 
36 #include "gcp/control/code/unix/libunix_src/specific/specificregs.h"
37 
38 namespace gcp {
39  namespace antenna {
40  namespace control {
41 
42  class AntennaDrive;
43  class ServoCommsSa;
44 
49  class Tracker :
50  public SpecificTask,
51  public gcp::util::GenericTask<TrackerMsg> {
52 
53  //============================================================
54  // Public members
55  //============================================================
56 
57  public:
58 
59  //------------------------------------------------------------
60  // Protected members
61  //------------------------------------------------------------
62 
63  protected:
64 
65  bool simPmac_;
66  bool simGps_;
67 
73  IGNORE, // No further action needed (pmac halted)
74  HALT, // Tell the pmac to stop the telescope drives
75  SLEW, // Tell the pmac to slew
76  WAIT, // Waiting for the pmac to signal completion of a
77  // slew
78  TARGET, // Prepare to change source
79  SYNC, // Prepare the pmac to start a new track
80  SLAVE, // Send the next 1-second position of an ongoing
81  // track
82  REBOOT // Tell the pmac to reboot itself
83  };
84 
85  //------------------------------------------------------------
86  // Protected methods & members
87  //------------------------------------------------------------
88 
89  friend class AntennaDrive;
90 
95 
103  Tracker(AntennaDrive* parent);
104 
108  virtual ~Tracker();
109 
116  virtual void processMsg(TrackerMsg* msg);
117 
122 
123  // The current year - received from the control program.
124 
125  int year_;
126 
127  // The next PMAC action to perform.
128 
129  NextDriveState whatNext_;
130 
131  // The set of externally provided pointing parameters that
132  // have been recorded in the archive since their last
133  // change. This is a bit set of Pointing::Parameter values
134  // above
135 
136  unsigned archived_;
137 
138  // The set of externally provided pointing parameters which
139  // have not been received yet. This is a bitwise union of
140  // Pointing::Parameter values
141 
142  unsigned lacking_;
143 
144  // Calibration of encoders is pending;
145 
146  bool encoderCalPending_;
147 
148  // The sequence number of the last telescope positioning
149  // request received from the control program.
150 
151  volatile long lastReq_;
152 
153  // The last sequence number that was acknowledged to the
154  // control program on completion.
155 
156  volatile long lastAck_;
157 
158  // The tracking status at the previous 1-second tick.
159 
161 
162  // The current tracking status
163 
165 
166  // This should be set to non-zero whenever any parameters that
167  // could break the current track are changed.
168 
169  bool paramsUpdated_;
170 
171  // The last value of the "acquired" status of the drive
172 
173  int pmacTracking_;
174 
175  // The latest atmospheric refraction terms
176 
177  Atmosphere atmos_;
178 
179  // The telescope pointing model
180 
181  Model model_;
182 
183  // Registers of the servo box
184 
185  ServoCommsSa* servo_;
186 
187  // The position to request on the next 1-sec pulse
188 
189  Pointing nextTarget_;
190  Pointing nextTarget1_;
191  Pointing nextTarget2_;
192 
193  // The last three commanded mount positions
194 
195  Position lastCommanded_; // Position commanded on the last tick
196  Position prevCommanded_; // Position commanded two ticks ago
197  Position tertCommanded_; // Position commanded three ticks ago
198 
199  // The location of the telescope
200 
201  Site site_;
202 
203  // An object for handling atmospheric calculations
204 
205  gcp::util::Atmosphere refracCalculator_;
206 
207  // The current source
208 
209  gcp::util::Source src_;
210 
211  // The current scan
212 
213  Scan scan_;
214 
219 
220  // The time of the previous time-code-reader interrupt
221 
222  gcp::util::TimeVal lastTick_;
223 
228 
233 
234  //------------------------------------------------------------
235  // Protected Methods
236  //------------------------------------------------------------
237 
238  void resetMembers();
239 
246  void reset();
247 
253  virtual void initialize();
254 
259  void archiveStatus();
260 
261  void updatePmac(TimeVal& mjd, AxisPositions *current);
262 
269  void updateMountLimits();
270 
280  void sourcePosition(gcp::util::TimeVal& mjd, Pointing& thisTargetVal);
281  void sourcePositionTrack(gcp::util::TimeVal& mjd, double utc);
282  void sourcePositionTrack(gcp::util::TimeVal& mjd, double utc, Pointing& thisTargetVal);
283  void sourcePositionCenter(gcp::util::TimeVal& mjd);
284  void sourcePositionCenter(gcp::util::TimeVal& mjd, Pointing& thisTargetVal);
285 
292  virtual void pmacNewPosition(gcp::util::PmacMode::Mode mode,
293  AxisPositions *current, gcp::util::TimeVal& mjd);
294 
299  void finalizePointing(double pmra, double pmdec,
301  Pointing* p,
302  gcp::util::TimeVal& mjd);
303  void finalizePointing(double pmra, double pmdec,
305  Pointing* p,
306  gcp::util::TimeVal& mjd, Pointing& thisTargetVal);
307 
309  void finalizePointing(gcp::util::TimeVal& mjd, Pointing& thisTargetVal);
310 
320  void registerRequest(unsigned seq);
321 
322  //............................................................
323  // Methods which are called in response to messages from the
324  // Drive Task
325  //............................................................
326 
336  virtual void addTick(TrackerMsg* msg);
337  virtual void addTickOvro(TrackerMsg* msg);
338 
342  void calCollimation(TrackerMsg* msg);
343 
347  void calEncoders(TrackerMsg* msg);
348 
352  void calFlexure(TrackerMsg* msg);
353 
357  void calTilts(TrackerMsg* msg);
358 
366  void changeYear(TrackerMsg* msg);
367 
376  void extendEqnEqx(TrackerMsg* msg);
377 
384  void extendTrack(TrackerMsg* msg);
388  void extendScan(TrackerMsg* msg);
389 
398  void extendUt1Utc(TrackerMsg* msg);
399 
409  void haltTelescope(TrackerMsg* msg=0);
410 
417  void locateSite(TrackerMsg* msg);
418 
425  void locateAntenna(TrackerMsg* msg);
426 
436  void rebootDrive(TrackerMsg* msg);
437 
444  void recordEncoderLimits(TrackerMsg* msg);
445 
449  void selectModel(TrackerMsg* msg);
450 
457  void setEncoderZero(TrackerMsg* msg);
458 
466  void setOffset(TrackerMsg* msg);
467 
474  void setSlewRate(TrackerMsg* msg);
475 
482  void slewTelescope(TrackerMsg* msg);
483 
491  void updateRefraction(TrackerMsg* msg);
492  void updateRefraction();
493 
497  virtual void connectPmac();
498 
502  virtual void disconnectPmac();
503 
508  bool okToPoint();
509 
510  void setNextState(NextDriveState state);
511 
512  void strobeServo(TrackerMsg* msg);
513 
514  // acknowledges cmpletion of a motion command
515  bool acknowledgeCompletion();
516 
517  // executes a Servo Specific command
518  void executeServoCmd(TrackerMsg* msg);
519 
520  }; // End class Tracker
521 
522  }; // End namespace control
523  }; // End namespace antenna
524 } // End namespace gcp
525 
526 #endif
NextDriveState
Definition: Tracker.h:72
void resetMembers()
Definition: Tracker.cc:141
Definition: Site.h:33
void sourcePosition(gcp::util::TimeVal &mjd)
Definition: Tracker.cc:1595
Definition: Scan.h:21
Definition: Position.h:35
void calTilts(TrackerMsg *msg)
Definition: Tracker.cc:2643
virtual void pmacNewPosition(gcp::util::PmacMode::Mode mode, AxisPositions *current, gcp::util::TimeVal &mjd)
Definition: Tracker.cc:719
Definition: Source.h:31
Definition: TrackerOffset.h:28
Tracker(AntennaDrive *parent)
Definition: Tracker.cc:36
Definition: Tracker.h:49
void slewTelescope(TrackerMsg *msg)
Definition: Tracker.cc:999
void updatePmac(TimeVal &mjd, AxisPositions *current)
Definition: Tracker.cc:476
void calCollimation(TrackerMsg *msg)
Definition: Tracker.cc:2548
Definition: Atmosphere.h:23
void rebootDrive(TrackerMsg *msg)
Definition: Tracker.cc:2401
void calFlexure(TrackerMsg *msg)
Definition: Tracker.cc:2489
void extendTrack(TrackerMsg *msg)
Definition: Tracker.cc:1069
void updateMountLimits()
Definition: Tracker.cc:1572
virtual void initialize()
Definition: Tracker.cc:105
void updateRefraction()
Definition: Tracker.cc:1257
Definition: Pointing.h:35
Mode
Definition: PmacMode.h:24
void setOffset(TrackerMsg *msg)
Definition: Tracker.cc:1180
void changeYear(TrackerMsg *msg)
Definition: Tracker.cc:1459
void extendEqnEqx(TrackerMsg *msg)
Definition: Tracker.cc:1313
void reset()
Definition: Tracker.cc:162
Definition: Model.h:33
void haltTelescope(TrackerMsg *msg=0)
Definition: Tracker.cc:1036
void archiveStatus()
Definition: Tracker.cc:2195
virtual void processMsg(TrackerMsg *msg)
Definition: Tracker.cc:2218
Definition: SpecificTask.h:19
Definition: servoCommsSa.h:42
gcp::util::TimeVal currentTick_
Definition: Tracker.h:218
Definition: TimeVal.h:55
void recordEncoderLimits(TrackerMsg *msg)
Definition: Tracker.cc:1412
TrackerOffset offset_
Definition: Tracker.h:232
virtual void disconnectPmac()
Definition: Tracker.cc:2373
AntennaDrive * parent_
Definition: Tracker.h:94
virtual ~Tracker()
Definition: Tracker.cc:96
void locateAntenna(TrackerMsg *msg)
Definition: Tracker.cc:1516
bool shutdownPending_
Definition: Tracker.h:121
Definition: TrackerMsg.h:33
void setSlewRate(TrackerMsg *msg)
Definition: Tracker.cc:1340
Definition: AxisPositions.h:38
Definition: TrackerBoard.h:40
void registerRequest(unsigned seq)
Definition: Tracker.cc:2185
Definition: Atmosphere.h:30
void extendUt1Utc(TrackerMsg *msg)
Definition: Tracker.cc:1547
Definition: AntennaDrive.h:43
void calEncoders(TrackerMsg *msg)
Definition: Tracker.cc:1369
TrackerBoard * tracker_
Definition: Tracker.h:227
bool okToPoint()
Definition: Tracker.cc:2384
void finalizePointing(double pmra, double pmdec, PointingCorrections *f, Pointing *p, gcp::util::TimeVal &mjd)
Definition: Tracker.cc:1988
virtual void connectPmac()
Definition: Tracker.cc:2361
void selectModel(TrackerMsg *msg)
Definition: Tracker.cc:2421
void setEncoderZero(TrackerMsg *msg)
Definition: Tracker.cc:1198
Definition: PointingCorrections.h:22
Definition: GenericTask.h:33
void extendScan(TrackerMsg *msg)
Definition: Tracker.cc:1121
Status
Definition: TrackingStatus.h:20
virtual void addTick(TrackerMsg *msg)
Definition: Tracker.cc:215
virtual void addTickOvro(TrackerMsg *msg)
Definition: Tracker.cc:2918
void executeServoCmd(TrackerMsg *msg)
Definition: Tracker.cc:2753
void locateSite(TrackerMsg *msg)
Definition: Tracker.cc:1485