CARMA C++
DriveEngine.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_ANTENNA_OVRO_DRIVEENGINE_H
11 #define CARMA_ANTENNA_OVRO_DRIVEENGINE_H
12 
13 #include <memory>
14 #include <pthread.h>
15 #include <string>
16 #include <vector>
17 
18 namespace carma {
19 
20 namespace monitor {
21  class OvroSubsystem;
22 } // namespace monitor
23 
24 namespace services {
25  class Angle;
26  class Location;
27 } // namespace services
28 
29 namespace antenna {
30 namespace ovro {
31 
32  class Drive;
33  class Encoder;
34  class Tiltmeter;
35 
36  struct RaDecEpoch {
37  double mjd;
38  double raRadians;
39  double decRadians;
40  };
41 
42  typedef ::std::vector< RaDecEpoch > RaDecTriplet;
43  typedef RaDecTriplet::iterator RaDecTripletIter;
44  typedef RaDecTriplet::const_iterator RaDecTripletConstIter;
45 
51  class DriveEngine {
52  public:
53 
54  explicit DriveEngine( Drive & drive,
55  const Encoder & azEncoder,
56  const Encoder & elEncoder,
57  const Tiltmeter & tiltmeter,
58  carma::monitor::OvroSubsystem & mon );
59 
60  /* virtual */ ~DriveEngine( );
61 
67  void setAzEl( const carma::services::Angle & angle,
68  const carma::services::Angle & elevation );
69 
74  void setAz( const carma::services::Angle & azimuth );
75 
80  void setEl( const carma::services::Angle & elevation );
81 
89  void setRawDriveVoltages( float azVoltage, float elVoltage );
90 
97  void setRawDriveRates( float azRateInDegPerMin,
98  float elRateInDegPerMin );
99 
105  void setEngineeringMode( bool enable );
106 
110  void setAzOffset( const carma::services::Angle & offset );
111 
115  void setElOffset( const carma::services::Angle & offset );
116 
120  void setOffset( const carma::services::Angle & azOffset,
121  const carma::services::Angle & elOffset );
122 
127  void setSource( std::string source );
128 
133  void setAzMaxRate( double azMaxRateInDegPerSec );
134 
139  void setElMaxRate( double elMaxRateInDegPerSec );
140 
144  enum WrapType {
145  NO_TURN, /*< Add Nothing to requested AZ EL */
146  ADD_TURN, /*< Add 360 degrees to requested AZ EL */
147  SUBTRACT_TURN /*< Subtract 360 degrees from requested AZ EL */
148  };
149 
155  void setRaDec( const RaDecTriplet & raDecTriplet,
156  WrapType wrap = NO_TURN );
157 
163  void updateRaDec( const RaDecEpoch & raDecEpoch,
164  WrapType wrap = NO_TURN );
165 
178  void setWeather( double ambientTemp,
179  double barometricPressure,
180  double relativeHumidity,
181  double dewpointTemp,
182  double windSpeed,
183  double windDirection );
184 
189  void setLocation( const carma::services::Location & location );
190 
191  enum ApertureType {
192  OPTICAL,
193  RADIO1MM,
194  RADIO3MM,
195  RADIO1CM,
196  APERTURE_COUNT
197  };
198 
207  void selectAperture( ApertureType aperture );
208 
216  ApertureType aperture,
217  const carma::services::Angle & azOffset,
218  const carma::services::Angle & elOffset,
219  const carma::services::Angle & sag );
220 
225  const carma::services::Angle & azEncoderZero,
226  const carma::services::Angle & elEncoderZero,
227  const carma::services::Angle & nonOrthogonalityOfAxes,
228  const carma::services::Angle & azimuthVerticalityNorthSouth,
229  const carma::services::Angle & azimuthVerticalityEastWest );
230 
234  void setTiltmeterZeros(
235  const carma::services::Angle & aftForwardZero,
236  const carma::services::Angle & leftRightZero );
237 
242  void setAzEncoderZero( const carma::services::Angle & azEncoderZero );
243 
248  void setElEncoderZero( const carma::services::Angle & azEncoderZero );
249 
253  void setMountOffsets( const carma::services::Angle & azMountOffset,
254  const carma::services::Angle & elMountOffset );
255 
259  void setAzMountOffset( const carma::services::Angle & azMountOffset );
260 
264  void setElMountOffset( const carma::services::Angle & elMountOffset );
265 
271  void snow( );
272 
276  void stop( );
277 
281  void stowZenith( );
282 
292  void setSafeRange( const carma::services::Angle & azLow,
293  const carma::services::Angle & azHigh,
294  const carma::services::Angle & elLow,
295  const carma::services::Angle & elHigh );
296 
304  void stowSafe( );
305 
311  void setSequenceNumber( unsigned long seqNo );
312 
316  void setTolerance( const carma::services::Angle & tolerance );
317 
321  void updateConfigurationData( );
322 
326  void freezeTilt( );
327 
331  void thawTilt( );
332 
336  void toggleBacklashCorrection( bool enable );
337 
338  protected:
339 
340  // Nothing
341 
342  private:
343 
344  void writeMonitorData( );
345 
346  void driveLoopThread( );
347 
348  static void driveLoopThreadEntry( DriveEngine & This );
349 
350  class Acquisition;
351  class DriveState;
352  class Limits;
353  class Pointing;
354  class Servo;
355  class SourcePosition;
356  class Timing;
357  class Tracking;
358 
359  struct EngineeringInfo;
360 
361  Drive & drive_;
362  ::std::auto_ptr< Acquisition > acquisition_;
363  ::std::auto_ptr< DriveState > driveState_;
364  ::std::auto_ptr< EngineeringInfo > engineering_;
365  ::std::auto_ptr< Limits > limits_;
366  ::std::auto_ptr< Pointing > pointing_;
367  ::std::auto_ptr< Servo > azServo_;
368  ::std::auto_ptr< Servo > elServo_;
369  ::std::auto_ptr< SourcePosition > sourcePosition_;
370  ::std::auto_ptr< Timing > timing_;
371  ::std::auto_ptr< Tracking > tracking_;
372  ::pthread_t driveLoopThreadId_;
373  ::pthread_mutex_t mutex_;
374 
375  }; // class DriveEngine
376 
377 }}} // namespace carma::antenna::ovro
378 #endif
void setOffset(const carma::services::Angle &azOffset, const carma::services::Angle &elOffset)
Set offset.
void stowSafe()
Stow antenna to a safe position.
void toggleBacklashCorrection(bool enable)
Toggle backlash correction.
void setAzEl(const carma::services::Angle &angle, const carma::services::Angle &elevation)
Set azimuth and elevation.
Tiltmeter device class.
Definition: Tiltmeter.h:34
void setEl(const carma::services::Angle &elevation)
Set elevation.
10-m Antenna Encoder Module CAN Implementation (API No.
Definition: Encoder.h:36
void setElOffset(const carma::services::Angle &offset)
Set elevation offset.
void setElEncoderZero(const carma::services::Angle &azEncoderZero)
Set El Encoder Zero.
void setRaDec(const RaDecTriplet &raDecTriplet, WrapType wrap=NO_TURN)
Set new Ra and Dec triplet.
void thawTilt()
Thaw tilt ( debug )
void setAzEncoderZero(const carma::services::Angle &azEncoderZero)
Set Az Encoder Zero.
void setRawDriveRates(float azRateInDegPerMin, float elRateInDegPerMin)
Engineering command to set raw drive slew rates.
void setTolerance(const carma::services::Angle &tolerance)
Set acquisition tolerance.
void setAz(const carma::services::Angle &azimuth)
Set azimuth.
void setAzMaxRate(double azMaxRateInDegPerSec)
Set azimuth maz rate on the sky.
void setSequenceNumber(unsigned long seqNo)
Set sequence number.
void snow()
Track a position 60 degrees into the wind in order to minimize snow buildup on the backing structure ...
void setAzOffset(const carma::services::Angle &offset)
Set azimuth offset.
void setAzMountOffset(const carma::services::Angle &azMountOffset)
Set Az Mount Offset.
Location specifies a location (observatory if you wish) on planet earth, as longitude, latitude, and altitude above sea-level.
Definition: Location.h:32
void setElMaxRate(double elMaxRateInDegPerSec)
Set elevation max rate.
The Angle class can represent any angle in any units.
Definition: Angle.h:38
void setSafeRange(const carma::services::Angle &azLow, const carma::services::Angle &azHigh, const carma::services::Angle &elLow, const carma::services::Angle &elHigh)
Set anti-collision safe ranges.
void updateConfigurationData()
Update Drive module configuration data from file.
void setSource(std::string source)
Set source name.
void updateRaDec(const RaDecEpoch &raDecEpoch, WrapType wrap=NO_TURN)
Update current Ra/Dec position with a new epoch.
void stowZenith()
Stow antenna close to zenith.
void setLocation(const carma::services::Location &location)
Set antenna location.
10-m Antenna Drive Module CAN Implementation (API No.
Definition: Drive.h:33
void setMountPointingConstants(const carma::services::Angle &azEncoderZero, const carma::services::Angle &elEncoderZero, const carma::services::Angle &nonOrthogonalityOfAxes, const carma::services::Angle &azimuthVerticalityNorthSouth, const carma::services::Angle &azimuthVerticalityEastWest)
Set mount pointing constants.
void setElMountOffset(const carma::services::Angle &elMountOffset)
Set El Mount Offset.
void setTiltmeterZeros(const carma::services::Angle &aftForwardZero, const carma::services::Angle &leftRightZero)
Set Tiltmeter Zeros.
void setRawDriveVoltages(float azVoltage, float elVoltage)
Engineering command to set raw drive motor control voltages.
void setEngineeringMode(bool enable)
Set engineering mode.
void freezeTilt()
Freeze tilt ( debug )
void setMountOffsets(const carma::services::Angle &azMountOffset, const carma::services::Angle &elMountOffset)
Set both az and el mount offsets simultaneously.
Responsible for storing and maintaining drive parameters, calculating drive rate updates and regularl...
Definition: DriveEngine.h:51
void setAperturePointingConstants(ApertureType aperture, const carma::services::Angle &azOffset, const carma::services::Angle &elOffset, const carma::services::Angle &sag)
Set aperture pointing constants These constants represent on the sky collimation errors for a particu...
void selectAperture(ApertureType aperture)
Select aperture.
void setWeather(double ambientTemp, double barometricPressure, double relativeHumidity, double dewpointTemp, double windSpeed, double windDirection)
Set weather parameters needed for refraction corrections, snow track and wind track.