#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 Sensitivity for Mirror Settling: "); scanf("%f",&sensitivity); getc(stdin); oldtloc = tloc = time(0); /* get_tcspos(&ra,&dec); printf("%lf %lf\n",ra,dec); */ do { printf("Altitude Azimuth: "); scanf("%f %f",&alt,&az); if (alt >= 0. && az >= 0.) do_measure(); } while (alt >= 0. && az >= 0.); fclose(outfd); } void do_measure() { double pos[8], newpos; double altitude, azimuth; int posflag, i; ha = 12./M_PI*atan2(sin(az*M_PI/(double)180.),(cos(az*M_PI/(double)180.)*cos(lat*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.)); set_tcshaslew(ha,dec); printf("TCS Slewing to HA: %8.4f hrs, Dec: %8.4f deg. Press On Completion",ha,dec); getc(stdin); 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,"%6.3lf,%7.3lf,",altitude,azimuth); for (i=0; i<5; i++) { fprintf(outfd,"%10.5lf,",pos[i]); } fprintf(outfd,"%5d\n",(int)(tloc-oldtloc)); }