11 #ifndef CARMA_ANTENNA_BIMA_DRIVES_H
12 #define CARMA_ANTENNA_BIMA_DRIVES_H
27 #include "carma/util/Program.h"
29 #include "carma/util/QuadraticInterpolatorNormal.h"
34 #include "carma/util/Logger.h"
45 #define TILTSAMPLES 100
53 class Drives :
public TelemetryClient
57 Drives( Configuration& config,
bool checkTelemHost =
true );
59 typedef enum { UP, DOWN } ElDir;
60 typedef enum { CLOCKWISE, COUNTERCLOCKWISE } AzDir;
63 TRACK, CLOSE, SLEW, STOW, SNOW, STOP, DISABLE, HWLIMIT, SWLIMIT, ERROR
65 typedef enum { AZEL, EQUAT, STOWMODE, SNOWMODE, STOPMODE }
ModeType;
67 typedef enum { OPTICAL, RADIO } RefractModel;
68 typedef enum { KEYENABLE, KEYDISABLE } KeySwitch;
69 typedef enum { COMPUTER, MANUAL } ControlSwitch;
74 void pegAz(
bool peggit );
75 void pegEl(
bool peggit );
80 void pegVelocities(
int limit );
81 void markAzVel(
int vel );
82 void markElVel(
int vel );
86 WrapLogic getWrapLogic();
87 void setWrapLogic( WrapLogic logic);
88 void setOverTheTop(
bool overTop );
92 void setState( StateType state);
93 StateType getActiveState();
94 void setActiveState( StateType state);
97 void setMode( ModeType mode );
99 RefractModel getModel();
100 void setModel( RefractModel model );
102 void setRefract(
float refract);
104 double getConstantChange();
106 double getOneSecRateAz();
107 double getOneSecRateEl();
108 void markOneSecAzRate(
double rate );
109 void markOneSecElRate(
double rate );
113 void markAzStallMJD();
114 void markAzStalls(
int stalls );
116 void markElStalls(
int stalls );
118 void markElStallMJD();
120 double getAzStallMJD();
121 double getElStallMJD();
122 void setStallRetries(
int cnt );
123 int getStallRetries();
132 void setStowPosition( DriveCommand::PositionType );
133 DriveCommand::PositionType getStowPosition();
141 double getTargetAz(
double mjd = 0);
142 double getRawTargetAz();
143 double getTargetEl(
double mjd = 0);
144 double getRawTargetEl();
146 void setTargetAz(
int whence,
double mjd,
double az,
bool discontinuity );
147 void setRawTargetAz(
double az );
148 void setTargetEl(
double mjd,
double el,
bool discontinuity );
149 void setRawTargetEl(
double el );
151 int getInstantAzResolver();
152 int getSmoothedAzResolver();
154 int getAzDigVeFilter();
155 int getAzDigVeFilterWriteOut();
156 int getInstantAzCosEnc();
157 int getSmoothAzCosEnc();
158 int getInstantAzSinEnc();
159 int getSmoothAzSinEnc();
160 void setAzCheckDrivePower(
bool status );
161 bool getAzCheckDrivePower();
163 int getInstantElResolver();
164 int getSmoothedElResolver();
166 int getElDigVeFilter();
167 int getElDigVeFilterWriteOut();
168 int getInstantElCosEnc();
169 int getSmoothElCosEnc();
170 int getInstantElSinEnc();
171 int getSmoothElSinEnc();
172 void setElCheckDrivePower(
bool status );
173 bool getElCheckDrivePower();
175 double getAzRequested();
176 double getElRequested();
177 void setAzRequested(
double az );
178 void setElRequested(
double el );
186 double getAzErrSky();
191 std::string* getSource();
192 void setSource( std::string *name );
195 void setRA(
double angle );
197 void setDec(
double angle );
202 double getOffsetAz();
203 void setOffsetAz(
double angle );
204 double getOffsetEl();
205 void setOffsetEl(
double angle );
207 double getMountOffsetAz();
208 void setMountOffsetAz(
double angle );
209 double getMountOffsetEl();
210 void setMountOffsetEl(
double angle );
212 void setAperture( DriveCommand::ApertureType ap );
213 DriveCommand::ApertureType getAperture();
214 double getApertureOffsetAz( DriveCommand::ApertureType ap );
215 void setApertureOffsetAz( DriveCommand::ApertureType ap,
double angle );
216 double getApertureOffsetEl( DriveCommand::ApertureType ap );
217 void setApertureOffsetEl( DriveCommand::ApertureType ap,
double angle );
218 double getApertureOffsetSag( DriveCommand::ApertureType ap );
219 void setApertureOffsetSag( DriveCommand::ApertureType ap,
double angle );
221 float getAzRateAdjust();
222 float getElRateAdjust();
223 void setAzRateAdjust();
224 void setElRateAdjust();
226 float getMaxAzRate();
227 void setMaxAzRate(
float rate );
228 float getMaxElRate();
229 void setMaxElRate(
float rate );
232 void setWindDir(
float dir );
237 double getTilt1Arcmin();
238 double getTilt2Arcmin();
240 void setTiltOutliers(
const char *name,
int outliers );
241 void setTilt1Outliers(
int outliers );
242 int getTilt1Outliers();
243 void setTilt2Outliers(
int outliers );
244 int getTilt2Outliers();
246 int getTilt1Counts();
247 int getTilt2Counts();
248 int getTiltCounts(
const char *name,
int &outliers,
int &rms1 );
249 void getAveRms(
int *samples,
int size,
int &ave,
int &rms );
251 int computeAzCoarseOffset(
int degrees );
252 int computeElCoarseOffset(
int degrees );
254 void setPointingModelCoefs(
255 double * dazCoefs,
unsigned int dazCoefCount,
256 double * delCoefs,
unsigned int delCoefCount);
258 void setTolerance(
double beamWidth );
259 double getTolerance();
261 void setNextSequenceNo(
unsigned long seq );
262 unsigned long getNextSequenceNo();
263 void setCurSequenceNo(
unsigned long seq );
264 unsigned long getCurSequenceNo();
266 void setCoefChange(
double mjd );
267 double getCoefChange();
269 int limitAxisAccel(
int &stalls,
int curcounts,
int lastcounts,
int &accelLim,
int origLim,
270 int &maxSlew,
int origMax,
float slewMod,
struct timeval &tv1 );
276 double getAzSansPointing();
277 double getElSansPointing();
282 void setLatitude(
double lat );
283 double getLatitude();
284 void setLongitude(
double longi );
285 double getLongitude();
286 void setAltitude(
double alt );
287 double getAltitude();
290 int getAzMaxSlew() {
return _azMaxSlew; }
291 int getElMaxSlew() {
return _elMaxSlew; }
292 double getAzRampDown() {
return _azRampDown; }
293 double getElRampDown() {
return _elRampDown; }
294 int getAzRampStartSpeed() {
return _azRampStartSpeed; }
295 int getElRampStartSpeed() {
return _elRampStartSpeed; }
296 int getAzCoarseOffset() {
return _azCoarseOffset; }
297 int getElCoarseOffset() {
return _elCoarseOffset; }
298 double getswAzHiLim() {
return _swAzHiLim; }
299 double getswElHiLim() {
return _swElHiLim; }
300 double getswAzLoLim() {
return _swAzLoLim; }
301 double getswElLoLim() {
return _swElLoLim; }
302 bool getswSlewLim() {
return _limitAccel; }
303 int getAzAccelLim() {
return _azAccelLim; }
304 int getElAccelLim() {
return _elAccelLim; }
305 float getAzSlewMod() {
return _azSlewMod; }
306 float getElSlewMod() {
return _elSlewMod; }
307 float getGain() {
return _gain; }
308 unsigned int getWaitInUSec() {
return _waitInUsec; }
310 void setAmbWeatherTemp(
float temp );
311 float getAmbWeatherTemp();
313 void setSafeCalled(
int safe )
315 putData(
"SAFECALLED", &safe );
321 getData(
"SAFECALLED", &safeCalled );
322 return ( safeCalled != 0 );
325 void setSafeRange(
float azLow,
float azHigh,
326 float elLow,
float elHigh )
330 _azSafeLow = azLow; _azSafeHigh = azHigh;
331 _elSafeLow = elLow; _elSafeHigh = elHigh;
333 putData(
"AZSAFELO", &_azSafeLow );
334 putData(
"AZSAFEHI", &_azSafeHigh );
335 putData(
"ELSAFELO", &_elSafeLow );
336 putData(
"ELSAFEHI", &_elSafeHigh );
339 void getSafeRange(
float &azLow,
float &azHigh,
340 float &elLow,
float &elHigh )
342 getData(
"AZSAFELO", &azLow );
343 getData(
"AZSAFEHI", &azHigh );
344 getData(
"ELSAFELO", &elLow );
345 getData(
"ELSAFEHI", &elHigh );
348 void setSoftLimits(
float &azlo,
float &azhi,
float &ello,
float &elhi )
357 putData(
"SOFTLIM", sl, 4 );
360 void getSoftLimits(
float &azlo,
float &azhi,
float &ello,
float &elhi )
364 getData(
"SOFTLIM", sl, 4 );
372 void setHardLimits(
float azlo,
float azhi,
float ello,
float elhi )
381 putData(
"HARDLIM", hl, 4 );
384 void getHardLimits(
float &azlo,
float &azhi,
float &ello,
float &elhi )
388 getData(
"HARDLIM", hl, 4 );
396 void getSafeTarget(
float &az,
float &el )
406 az = _azSafeLow + ((_azSafeHigh - _azSafeLow) / 2.0);
407 el = _elSafeLow + ((_elSafeHigh - _elSafeLow) / 2.0);
421 double getFastPacketRxMJD();
426 void loadDrivesConfig();
435 int _azMaxSlew, _azOrigMaxSlew, _elMaxSlew, _elOrigMaxSlew;
436 int _lastiAzVel, _lastiElVel;
437 int _azDigWOMismatch, _elDigWOMismatch;
438 float _gain, _mjdGainLookAhead, _gainConst;
439 unsigned int _waitInUsec;
440 float _azSlewMod, _elSlewMod;
441 float _azSafeLow, _azSafeHigh, _elSafeLow, _elSafeHigh;
442 float _azHardLow, _azHardHigh, _elHardLow, _elHardHigh;
443 double _azMaxRate, _elMazRate;
444 double _azRate, _elRate, _lastAzRate, _lastElRate;
445 double _azRampDown, _elRampDown;
446 int _azRampStartSpeed, _elRampStartSpeed;
447 int _azCoarseOffset, _elCoarseOffset;
448 int _azVel, _elVel, _forceVelLimit;
449 int _azAccelLim, _azOrigAccelLim;
450 int _elAccelLim, _elOrigAccelLim;
451 struct timeval _lastLimChkAz;
452 struct timeval _lastLimChkEl;
454 int _toggle, _lastToggle;
455 time_t _lastToggleUpdate;
463 double _hardLoLimitAz, _hardHiLimitAz;
464 double _hardLoLimitEl, _hardHiLimitEl;
466 float _swAzLoLim, _swAzHiLim;
467 float _swElLoLim, _swElHiLim;
474 void dataInvert(
int &value )
476 if ( ( value & 0x8000 ) != 0 )
477 value = ~( value & 0x7fff ) + 1;
480 static const double DR = 0.01745329251994;
481 static const double RD = 57.2957795130823;
483 int _azStalls, _azStallCnt, _azRetries;
484 int _elStalls, _elStallCnt, _elRetries;
485 double _azLastStallChk, _elLastStallChk;
488 time_t _stallsStarted;
490 Configuration &_config;
491 log4cpp::Category &_logger;
498 ::std::ostream&
operator<<( ::std::ostream& os,
499 ::carma::antenna::bima::Drives& drives );
501 #endif // CARMA_ANTENNA_BIMA_DRIVES_H
std::ostream & operator<<(::std::ostream &os, const carma::dbms::Table &table)
modeType getMode(idType id)
Extract the address mode from a 29 bit can id.
Class definition for DriveCommand on the BIMA antennas.
ModeType
Correlator operational modes.
Class definition for Stepper Motors for BIMA systems.
Don't add or subtract.
Class definition for TelemetryClient on the BIMA antennas.
Class definition for Stepper Motors for BIMA systems.