Skip to content

Commit

Permalink
Enhanced error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
hjd1964 committed Oct 20, 2019
1 parent 618f671 commit ce3f180
Show file tree
Hide file tree
Showing 24 changed files with 1,050 additions and 810 deletions.
13 changes: 7 additions & 6 deletions Align.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TGeoAlignH
void readCoe();
void writeCoe();
bool isReady();
bool addStar(int I, int N, double RA, double Dec);
CommandErrors addStar(int I, int N, double RA, double Dec);
void horToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide);
void instrToHor(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide);
void autoModel(int n);
Expand Down Expand Up @@ -101,7 +101,7 @@ class TGeoAlign
void readCoe();
void writeCoe();
bool isReady();
bool addStar(int I, int N, double RA, double Dec);
CommandErrors addStar(int I, int N, double RA, double Dec);
void equToInstr(double HA, double Dec, double *HA1, double *Dec1, int PierSide);
void instrToEqu(double HA, double Dec, double *HA1, double *Dec1, int PierSide);
void autoModel(int n);
Expand Down Expand Up @@ -141,13 +141,14 @@ boolean alignActive() {
}

// adds an alignment star, returns true on success
boolean alignStar() {
CommandErrors alignStar() {
// after last star turn meridian flips off when align is done
if ((alignNumStars == alignThisStar) && (meridianFlip == MeridianFlipAlign)) meridianFlip=MeridianFlipNever;

if (alignThisStar <= alignNumStars) {
if (Align.addStar(alignThisStar,alignNumStars,newTargetRA,newTargetDec)) alignThisStar++; else return false;
} else return false;
CommandErrors e=Align.addStar(alignThisStar,alignNumStars,newTargetRA,newTargetDec);
if (e == CE_NONE) alignThisStar++; else return e;
} else return CE_PARAM_RANGE;

return true;
return CE_NONE;
}
9 changes: 6 additions & 3 deletions AlignEq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ bool TGeoAlign::isReady() {
// I=1 for 1st star, I=2 for 2nd star, I=3 for 3rd star
// N=total number of stars for this align (1 to 9)
// RA, Dec (all in degrees)
bool TGeoAlign::addStar(int I, int N, double RA, double Dec) {
CommandErrors TGeoAlign::addStar(int I, int N, double RA, double Dec) {

// First star, just sync
if (I == 1) { if (syncEqu(RA,Dec) != GOTO_ERR_NONE) return false; }
if (I == 1) {
CommandErrors e=syncEqu(RA,Dec);
if (e != CE_NONE) return e;
}

mount[I-1].ha=getInstrAxis1()/Rad;
mount[I-1].dec=getInstrAxis2()/Rad;
Expand All @@ -74,7 +77,7 @@ bool TGeoAlign::addStar(int I, int N, double RA, double Dec) {
// two or more stars and finished
if ((I >= 2) && (I == N)) model(N);

return true;
return CE_NONE;
}

// kick off modeling
Expand Down
9 changes: 6 additions & 3 deletions AlignHor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ bool TGeoAlignH::isReady() {
// I=1 for 1st star, I=2 for 2nd star, I=3 for 3rd star
// N=total number of stars for this align (1 to 9)
// RA, Dec (all in degrees)
bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) {
CommandErrors TGeoAlignH::addStar(int I, int N, double RA, double Dec) {
double a,z;
equToHor(haRange(LST()*15.0-RA),Dec,&a,&z);

// First star, just sync
if (I == 1) { if (syncEqu(RA,Dec) != GOTO_ERR_NONE) return false; }
if (I == 1) {
CommandErrors e=syncEqu(RA,Dec);
if (e != GOTO_ERR_NONE) return e;
}

mount[I-1].azm=getInstrAxis1();
mount[I-1].alt=getInstrAxis2();
Expand All @@ -88,7 +91,7 @@ bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) {
// two or more stars and finished
if ((I >= 2) && (I == N)) model(N);

return true;
return GOTO_ERR_NONE;
}

// kick off modeling
Expand Down
15 changes: 4 additions & 11 deletions Astro.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ boolean hmsToDouble(double *f, char *hms) {
}

// convert double to string in a variety of formats (as above)
boolean doubleToHms(char *reply, double *f, boolean hp) {
void doubleToHms(char *reply, double *f, boolean hp) {
double h1,m1,f1,s1;

f1=fabs(*f)+0.000139; // round to 0.5 sec
Expand All @@ -69,12 +69,10 @@ boolean doubleToHms(char *reply, double *f, boolean hp) {
char sign[2]="";
if (((s1 != 0) || (m1 != 0) || (h1 != 0)) && (*f < 0.0)) strcpy(sign,"-");
sprintf(reply,s,sign,(int)h1,(int)m1,(int)s1);

return true;
}

// convert double to string in format HH:MM:SS.SSSS
boolean doubleToHmsd(char *reply, double *f) {
void doubleToHmsd(char *reply, double *f) {
double h1,m1,f1,s1,sd;

f1=fabs(*f)+0.0000000139; // round to 0.00005 sec
Expand All @@ -87,8 +85,6 @@ boolean doubleToHmsd(char *reply, double *f) {
char sign[2]="";
if (((sd != 0) || (s1 != 0) || (m1 != 0) || (h1 != 0)) && (*f < 0.0)) strcpy(sign,"-");
sprintf(reply,s,sign,(int)h1,(int)m1,(int)s1,(int)sd);

return true;
}

// convert string in format sDD:MM:SS to double
Expand Down Expand Up @@ -153,7 +149,7 @@ boolean dmsToDouble(double *f, char *dms, boolean sign_present) {
}

// convert double to string in a variety of formats (as above)
boolean doubleToDms(char *reply, double *f, boolean fullRange, boolean signPresent) {
void doubleToDms(char *reply, double *f, boolean fullRange, boolean signPresent) {
char sign[]="+";
int o=0,d1,s1=0;
double m1,f1;
Expand Down Expand Up @@ -182,11 +178,10 @@ boolean doubleToDms(char *reply, double *f, boolean fullRange, boolean signPrese
s[9+o]=0;
sprintf(reply,s,d1,(int)m1);
}
return true;
}

// convert double to string in format sDD:MM:SS.SSS
boolean doubleToDmsd(char *reply, double *f) {
void doubleToDmsd(char *reply, double *f) {
char sign[]="+";
double d1,m1,s1,s2,f1;
f1=*f;
Expand All @@ -203,8 +198,6 @@ boolean doubleToDmsd(char *reply, double *f) {
char s[]="+%02d*%02d:%02d.%03d";
if (sign[0] == '-') { s[0]='-'; }
sprintf(reply,s,(int)d1,(int)m1,(int)s1,(int)s2);

return true;
}

// convert timezone to string in format sHHH:MM[:SS]
Expand Down
Loading

0 comments on commit ce3f180

Please sign in to comment.