📄 autoobs.c
字号:
scanf("%d %d %d %d %d", &month1,&mday1,&hh1,&mm1,&ss1); md2ddd(year1,&ddd1,month1,mday1); secnow=hh1*3600+mm1*60+ss1; dtime1=(double)ddd1+secnow/86400.0; printf("Enter Stop Time (month mday hour min sec)\n"); scanf("%d %d %d %d %d", &month2,&mday2,&hh2,&mm2,&ss2); md2ddd(year1,&ddd2,month2,mday2); secnow=hh2*3600+mm2*60+ss2; dtime2=(double)ddd2+secnow/86400.0; printf("dtime1 dtime2 %f %f\n)",dtime1,dtime2); } /* station select if Station is not yet selected */ if (argc<=2) { printf(" ****** STATION ID TABLE *********\n"); for (i=0; i<skd.nstation ; i++) { printf(" %s --- %s\n",skd.statid[i],skd.statnam[i]); } printf(" *********************************\n"); printf(" Enter Station ID ----> "); scanf("%s",&stat_id); printf(" Selected station_id is %s\n",stat_id); } /* Set Up my station Name */ strcpy(mystation,"\0"); for (i=0; i<skd.nstation ; i++) { if (strncmp(skd.statid[i],stat_id,1)==0) { //strncpy(mystation,skd.statnam[i],strlen(skd.statnam[i])); strcpy(mystation,skd.statnam[i]); printf(" %s --- %s\n",stat_id,mystation); } } /* Board Time and System Time Check and offset get */ iofset=0; tofset=0.0; fd_in = open("/dev/tds0", O_RDONLY); //僨僶僀僗偺僆乕僾儞 if (fd_in == -1) { perror("device open() error "); return -1; } //僨僶僀僗偐傜帪崗忣曬偺庢摼 and display while secold=100000; counter=0; do{ rv = ioctl(fd_in, TDSIO_GET_TIME, &time); if (rv == -1) { perror("ioctl() time get failed "); return -1; } day=TDS_GET_DAYS(time); sec=TDS_GET_SEC(time); if (sec!=secold) // to catch exact second tic { sec2hms(sec,&h,&m,&s); printf("%03d %02d:%02d:%02d\n",day,h,m,s); if (counter >=1 ) { goto exith1 ;} counter++; } secold=sec; }while(counter <=10); exith1: //iofset=0; //tofset=0.0; //getsystime(&year, &month, &mday, &hh, &mm, &ss, &iofset); getsystimef(&year, &month, &mday, &hh, &mm, &ss, &fsec, &tofset); tofset=(float)sec-((float)(hh*3600+mm*60+ss)+fsec); //iofset=sec-(hh*3600+mm*60+ss); printf("System Time : %04d/%02d/%02d %02d:%02d:%02d\n",year,month,mday,hh,mm,ss); printf("Offset %f\n",tofset); yearPC=year; // year info get from PC save //printf("Offset %d\n",iofset); close(fd_in); // 俬俹亅倁俴俛俬儃乕僪僋儘乕僘 /* Schedule Time Check */ /* wait till next obs */ nobs=0; obsloop: secold=90000; printf("\033[2J"); // Erase the screen ( move the cursor to home ) for VT100 printf("\033[H"); // move the cursor to home printf("*****************************************************************\n"); printf("* *\n"); printf("* AUTOOBS (Automatic observation program for IP-VLBI board) *\n"); printf("* (Ver 2.21 2002-07-22 T.Kondo/CRL) *\n"); printf("* *\n"); if(time_mode==1){ printf("* Time for scheduling Get from IP-Board *\n"); } else { printf("* Time for scheduling Get from PC *\n"); } printf("*****************************************************************\n"); printf("\n"); printf(" Schedule File : %s\n",skdname); /* printf(" Experiment Code : %s Sampling Frequency :%s\n",skd.expcode,afreq); */ printf(" Experiment Code : %s\n",skd.expcode); printf(" Sampling Frequency: %s, AD bits: %d, # of CH: %d\n",afreq, adbit, numch); printf(" Stations Included : %s",skd.statnam[0]); for (i=1; i<skd.nstation; i++){ printf(" %s",skd.statnam[i]); } printf("\n"); printf(" My Station Name : %s (My Station ID : %s)\n",mystation,stat_id); printf(" Total Scan Number : %d\n",skd.nobs); printf(" 1st Scan : %04d/%02d/%02d %02d:%02d:%02d (%3dsec) %s\n", yearf,monthf,mdayf,hhf,mmf,ssf,skd.dura[0],skd.obsstar[0]); printf(" Last Scan : %04d/%02d/%02d %02d:%02d:%02d (%3dsec) %s\n", yearl,monthl,mdayl,hhl,mml,ssl,skd.dura[skd.nobs-1],skd.obsstar[skd.nobs-1]); printf(" Obs Range (start) : %04d/%02d/%02d %02d:%02d:%02d\n", year1,month1,mday1,hh1,mm1,ss1); printf(" Obs Range (end) : %04d/%02d/%02d %02d:%02d:%02d\n", year2,month2,mday2,hh2,mm2,ss2); printf("\n"); printf("\033[2B"); // 僇乕僜儖傪壓偵俀峴摦偐偡 if(time_mode == 1) { if(ip_board_time(&day, &secnow, &hh, &mm, &ss)==-1) return -1 ; ddd=day; year=yearPC; ddd2md(year, ddd, &month, &mday); } else { getsystimef(&year, &month, &mday, &hh, &mm, &ss, &fsec, &tofset); secnow=hh*3600+mm*60+ss; md2ddd(year, &ddd, month, mday); } dtimenow=ddd+secnow/86400.0; printf(" Time Now (UTC) : %04d/%02d/%02d %02d:%02d:%02d\n\033[A", year,month,mday,hh,mm,ss); printf("\033[2A"); // 僇乕僜儖傪忋偵俀峴摦偐偡 //fixspan=10; // compulsory fix span length (sec) //nobs=0; //flagobs=0; while(1) { // observation routine /* next observation start time get */ yearn=skd.start[nobs][0]+2000; dddn=skd.start[nobs][1]; hhn=skd.start[nobs][2]; mmn=skd.start[nobs][3]; ssn=skd.start[nobs][4]; secnext=hhn*3600+mmn*60+ssn; daynext=dddn; //printf("daynext %d\n",daynext); dtimenext=daynext+secnext/86400.0; ddd2md(yearn,dddn,&monthn,&mdayn); obsspan=skd.dura[nobs]; dtimenext2=dtimenext+(double)obsspan/86400.0; if(fixspan > obsspan || fixspan==0) { printf("\033[2K Next Scan (No.%03d): %04d/%02d/%02d %02d:%02d:%02d (%3dsec) %s\n", nobs+1,yearn,monthn,mdayn,hhn,mmn,ssn,obsspan,skd.obsstar[nobs]); // \033[2K means erases the entire current line } else { printf("\033[2K Next Scan (No.%03d): %04d/%02d/%02d %02d:%02d:%02d (%3dsec ==>%3dsec) %s\n", nobs+1,yearn,monthn,mdayn,hhn,mmn,ssn,obsspan,fixspan,skd.obsstar[nobs]); } printf("\n"); /* if (dtimenow > dtimenext2 ) // next observation set { nobs++; printf("\033[2A"); // 僇乕僜儖傪忋偵俀峴摦偐偡 goto pass2; } */ loop1: /* compare system time */ usleep(SLEEP_USEC); //getsystime(&year, &month, &mday, &hh, &mm, &ss, &iofset); if(time_mode == 1) { if(ip_board_time(&day, &secnow, &hh, &mm, &ss)==-1) return -1 ; ddd=day; year=yearPC; ddd2md(year, ddd, &month, &mday); } else { getsystimef(&year, &month, &mday, &hh, &mm, &ss, &fsec, &tofset); secnow=hh*3600+mm*60+ss; md2ddd(year, &ddd, month, mday); } dtimenow=ddd+secnow/86400.0; //printf("Total Day %d %f\n", ddd, dtimenow); if (dtime1 > dtimenext2 ) // next observation set { nobs++; if(nobs > skd.nobs) { goto exitend; } // add on 2002/7/22 printf("\033[2A"); // 僇乕僜儖傪忋偵俀峴摦偐偡 goto pass2; } if (dtimenow < dtime1) { goto pass1; } if (dtimenow < dtime1st) { goto pass1; } if (dtimenow > dtime2) { goto exitend; } if (dtimenow > dtimelast) { goto exitend; } if (dtimenow >= dtimenext && dtimenow < dtimenext2 ) { /* sampling start */ /* out file name creation */ /* Xdddnnn.dat X-- satation id ddd -- total day, nnn -- obs number */ sprintf(fname,"%1s%03d%03d.dat\0",stat_id,dddf,nobs+1); strcpy(outfile,outdir); strcat(outfile,fname); //printf("%s\n",outfile); /* obsspan re-calc */ //printf("obsspan %d\n",obsspan); dwork=(dtimenext2 - dtimenow)*86400.0; obsspan=(int)dwork ; //printf("obsspan(after) %d\n",obsspan); if (fixspan > obsspan | fixspan==0) { span=obsspan; } else { span=fixspan; } printf("\033[B"); // 僇乕僜儖傪壓偵侾峴摦偐偡 printf("OUT file name ==> %s\n",outfile); rv=sampleget(outfile, span, sfreq, adbit, numch); nobs++; //printf("\033[A\033[A"); // 僇乕僜儖傪忋偵俀峴摦偐偡 //goto pass2; goto obsloop; } if (dtimenow > dtimenext2 ) // next observation set { nobs++; printf("\033[2A"); // 僇乕僜儖傪忋偵俀峴摦偐偡 goto pass2; } pass1: if (secnow != secold) { printf(" Time Now (UTC) : %04d/%02d/%02d %02d:%02d:%02d\n\033[A", year,month,mday,hh,mm,ss); } secold=secnow; goto loop1; pass2: } exitend: printf("\n\n"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -