#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, alt, az, rotation; double lat = 19.8261; int jumpnum; int goflag = 1; 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); do { do_measure(); } while (goflag); fclose(outfd); } void do_measure() { double pos[8], newpos; double altitude, azimuth; int posflag, i; printf("Waiting for Slew. Press On Completion, or 'q' to quit."); if(getc(stdin) == 'q') goflag = 0; 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)); }