#include #include #include #include #include #include "mirror.h" #include "tcs.h" time_t tloc, oldtloc; struct tm *hst; char outname[256]; float jumpsize, ha, dec, sensitivity, rotation; double alt, az; double lat = 19.8261; int jumpnum; FILE *outfd; void do_measure(void); void main(int argc, char *argv[]) { int i; printf("Enter File Name for Output: "); scanf("%s",outname); if ((outfd=fopen(outname,"w")) == NULL) { perror(outname); exit(1); } printf("Enter Step Size in Degrees: "); scanf("%f",&jumpsize); printf("Enter Number of Steps: "); scanf("%d",&jumpnum); printf("Enter Rotation in Degrees: "); scanf("%f",&rotation); printf("Enter Sensitivity for Mirror Settling: "); scanf("%f",&sensitivity); getc(stdin); oldtloc = tloc = time(0); /* Do Zenith */ alt = 90.; az = 90. + rotation; do_measure(); /* Go down East */ az = 270. + rotation; for (i=0; i 30.) do_measure(); } /* Go South to Zenith */ for (i=0; i 30.) do_measure(); } fclose(outfd); } void do_measure() { double pos[8], newpos; double altitude, azimuth; int posflag, i; if (az == 180. || az == 0.) ha = 0.; else ha = 12./M_PI*atan2(sin(az*M_PI/(double)180.),(cos(az*M_PI/(double)180.)+tan(alt*M_PI/(double)180.))*cos(lat*M_PI/(double)180.)); dec = (double)180./M_PI*asin(sin(lat*M_PI/(double)180.)*sin(alt*M_PI/(double)180.)-cos(lat*M_PI/(double)180.)*cos(alt*M_PI/(double)180.)*cos(az*M_PI/(double)180.)); #ifndef DEBUG set_tcshaslew(ha,dec); printf("TCS Slewing to HA: %.4f hrs, Dec: %.4f deg.(az=%.1f,el=%.1f) Press On Completion",ha,dec, az, alt); #else printf("Alt: %8.4f Az: %8.4f = HA: %8.4f Dec: %8.4f",alt,az,ha,dec); #endif getc(stdin); #ifndef DEBUG get_tcsaltaz(&altitude, &azimuth); /* Wait for mirror to stabilize */ oldtloc = time(0); mropen("/dev/ttyS0"); do { tloc = time(0); hst = localtime(&tloc); printf("%2d %02d %02d %2d %02d %02d ",hst->tm_year,hst->tm_mon,hst->tm_mday,hst->tm_hour,hst->tm_min,hst->tm_sec); printf("%6.3lf %7.3lf ",altitude,azimuth); posflag = 0; for (i=0; i<5; i++) { newpos = mrpos(i); if (fabs(pos[i]-newpos) > sensitivity) posflag = 1; pos[i] = newpos; printf("%8.3lf ",pos[i]); } printf("\r"); fflush(stdout); } while (posflag); printf("\n"); mrclose(); fprintf(outfd,"%2d,%02d,%02d,%2d,%02d,%02d,",hst->tm_year,hst->tm_mon,hst->tm_mday,hst->tm_hour,hst->tm_min,hst->tm_sec); fprintf(outfd,"%4.1lf,%5.1lf,",altitude,azimuth); for (i=0; i<5; i++) { fprintf(outfd,"%10.5lf,",pos[i]); } fprintf(outfd,"%5d\n",(int)(tloc-oldtloc)); #endif }