/* gpst2time(), time2gpst() */ void utest4(void) { gtime_t t; double ep[6]; int w,week; double time,tt; t=gpst2time(0,0.0); time2epoch(t,ep); assert(ep[0]==1980&&ep[1]==1&&ep[2]==6&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2time(1400,86400.0); time2epoch(t,ep); assert(ep[0]==2006&&ep[1]==11&&ep[2]==6&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2time(1400,86400.0*7-1.0); time2epoch(t,ep); assert(ep[0]==2006&&ep[1]==11&&ep[2]==11&&ep[3]==23&&ep[4]==59&&ep[5]==59.0); t=gpst2time(1400,86400.0*7); time2epoch(t,ep); assert(ep[0]==2006&&ep[1]==11&&ep[2]==12&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2time(1401,0.0); time2epoch(t,ep); assert(ep[0]==2006&&ep[1]==11&&ep[2]==12&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); for (w=1000;w<1100;w++) { for (time=0.0;time<86400.0*7;time+=3600.0) { t=gpst2time(w,time); tt=time2gpst(t,&week); assert(tt==time&&week==w); } } printf("%s utset4 : OK\n",__FILE__); }
/* main ----------------------------------------------------------------------*/ int main(int argc, char **argv) { gtime_t time; double ep[6]= {0}; int i,page=1; time2epoch(utc2gpst(timeget()),ep); ep[4]=ep[5]=0.0; for (i=1; i<argc; i++) { if (!strcmp(argv[i],"-t")&&i+2<argc) { sscanf(argv[++i],"%lf/%lf/%lf",ep ,ep+1,ep+2); sscanf(argv[++i],"%lf:%lf:%lf",ep+3,ep+4,ep+5); } else if (!strcmp(argv[i],"-p")&&i+1<argc) page=atoi(argv[++i]); } time=epoch2time(ep); switch (page) { case 1: gen_page1(time,TEMP1,PAGE1); break; case 2: gen_page2(time,TEMP2,PAGE2); break; case 3: gen_page3(time,TEMP3,PAGE3); break; } return 0; }
static void statesend(hcnraw_t *hcnraw){ state_t state = { { 0 } }; gtime_t utc; double timer[6]; utc=gpst2utc(hcnraw->time); time2epoch(utc,timer); #if 0 if((timer=gmtime(&utc.time))){ sprintf(state.utctime,"%d-%d-%d-%d-%d-%d",timer->tm_year, timer->tm_mon,timer->tm_mday,timer->tm_hour,timer->tm_min, timer->tm_sec); } #endif sprintf(state.utctime,"%.0f-%.0f-%.0f-%.0f-%.0f-%.0f", timer[0],timer[1],timer[2],timer[3],timer[4],timer[5]); state.antn.mainantnworksta = hcnraw->board.mainantnworksta; state.antn.mainantnrfsta = hcnraw->board.mainantnrfsta; state.antn.aantnworksta = hcnraw->board.aantnworksta; state.antn.aantnrfsta = hcnraw->board.aantnrfsta; state.cpu.acpuload = hcnraw->board.acpuload; state.cpu.dcpuload = hcnraw->board.dcpuload; state.cpu.astatus = hcnraw->board.astatus; state.cpu.dstatus = hcnraw->board.dstatus; #if 1 state.cpu.fstatus = hcnraw->board.fstatus; #endif pthread_mutex_lock(&lock); cmd_response_massage( sock,&msg_head[0],&state,sizeof(state_t)); pthread_mutex_unlock(&lock); }
/* gpst2utc() */ void utest7(void) { double ep0[]={1980, 1, 6, 0, 0, 0.000000}; double ep1[]={1992, 7, 1, 0, 0, 6.999999}; double ep2[]={1992, 7, 1, 0, 0, 7.000000}; double ep3[]={1992, 7, 1, 0, 0, 8.000000}; double ep4[]={2004,12,31,23,59,59.999999}; double ep5[]={2006, 1, 1, 0, 0, 0.000000}; double ep6[]={2038, 1, 1, 0, 0, 0.000000}; gtime_t t; double ep[6]; t=gpst2utc(epoch2time(ep0)); time2epoch(t,ep); assert(ep[0]==1980&&ep[1]==1&&ep[2]==6&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2utc(epoch2time(ep1)); time2epoch(t,ep); assert(ep[0]==1992&&ep[1]==6&&ep[2]==30&&ep[3]==23&&ep[4]==59&&fabs(ep[5]-59.999999)<1E-14); t=gpst2utc(epoch2time(ep2)); time2epoch(t,ep); assert(ep[0]==1992&&ep[1]==7&&ep[2]==1&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2utc(epoch2time(ep3)); time2epoch(t,ep); assert(ep[0]==1992&&ep[1]==7&&ep[2]==1&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=gpst2utc(epoch2time(ep4)); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==12&&ep[2]==31&&ep[3]==23&&ep[4]==59&&fabs(ep[5]-46.999999)<1E-14); t=gpst2utc(epoch2time(ep5)); time2epoch(t,ep); assert(ep[0]==2005&&ep[1]==12&&ep[2]==31&&ep[3]==23&&ep[4]==59&&ep[5]==47.0); t=gpst2utc(epoch2time(ep6)); time2epoch(t,ep); assert(ep[0]==2037&&ep[1]==12&&ep[2]==31&&ep[3]==23&&ep[4]==59&&ep[5]==44.0); printf("%s utset7 : OK\n",__FILE__); }
/* decode nmea gpgga: fix information ----------------------------------------*/ static int decode_nmeagga(char **val, int n, sol_t *sol) { gtime_t time; double tod=0.0,lat=0.0,lon=0.0,hdop=0.0,alt=0.0,msl=0.0,ep[6],tt; double pos[3]={0}; char ns='N',ew='E',ua=' ',um=' '; int i,solq=0,nrcv=0; trace(4,"decode_nmeagga: n=%d\n",n); for (i=0;i<n;i++) { switch (i) { case 0: tod =atof(val[i]); break; /* time in utc (hhmmss) */ case 1: lat =atof(val[i]); break; /* latitude (ddmm.mmm) */ case 2: ns =*val[i]; break; /* N=north,S=south */ case 3: lon =atof(val[i]); break; /* longitude (dddmm.mmm) */ case 4: ew =*val[i]; break; /* E=east,W=west */ case 5: solq=atoi(val[i]); break; /* fix quality */ case 6: nrcv=atoi(val[i]); break; /* # of satellite tracked */ case 7: hdop=atof(val[i]); break; /* hdop */ case 8: alt =atof(val[i]); break; /* altitude in msl */ case 9: ua =*val[i]; break; /* unit (M) */ case 10: msl =atof(val[i]); break; /* height of geoid */ case 11: um =*val[i]; break; /* unit (M) */ } } if ((ns!='N'&&ns!='S')||(ew!='E'&&ew!='W')) { trace(2,"invalid nmea gpgga format\n"); return 0; } if (sol->time.time==0.0) { trace(2,"no date info for nmea gpgga\n"); return 0; } pos[0]=(ns=='N'?1.0:-1.0)*dmm2deg(lat)*D2R; pos[1]=(ew=='E'?1.0:-1.0)*dmm2deg(lon)*D2R; pos[2]=alt+msl; time2epoch(sol->time,ep); septime(tod,ep+3,ep+4,ep+5); time=utc2gpst(epoch2time(ep)); tt=timediff(time,sol->time); if (tt<-43200.0) sol->time=timeadd(time, 86400.0); else if (tt> 43200.0) sol->time=timeadd(time,-86400.0); else sol->time=time; pos2ecef(pos,sol->rr); sol->stat=0<=solq&&solq<=8?solq_nmea[solq]:SOLQ_NONE; sol->ns=nrcv; sol->type=0; /* postion type = xyz */ trace(5,"decode_nmeagga: %s rr=%.3f %.3f %.3f stat=%d ns=%d hdop=%.1f ua=%c um=%c\n", time_str(sol->time,0),sol->rr[0],sol->rr[1],sol->rr[2],sol->stat,sol->ns, hdop,ua,um); return 1; }
/* tidal displacement ---------------------------------------------------------- * displacements by earth tides * args : gtime_t tutc I time in utc * double *rr I site position (ecef) (m) * int opt I options (or of the followings) * 1: solid earth tide * 2: ocean tide loading * 4: pole tide * 8: elimate permanent deformation * double *erp I earth rotation parameters (NULL: not used) * double *odisp I ocean loading parameters (NULL: not used) * odisp[0+i*6]: consituent i amplitude radial(m) * odisp[1+i*6]: consituent i amplitude west (m) * odisp[2+i*6]: consituent i amplitude south (m) * odisp[3+i*6]: consituent i phase radial (deg) * odisp[4+i*6]: consituent i phase west (deg) * odisp[5+i*6]: consituent i phase south (deg) * (i=0:M2,1:S2,2:N2,3:K2,4:K1,5:O1,6:P1,7:Q1, * 8:Mf,9:Mm,10:Ssa) * double *dr O displacement by earth tides (ecef) (m) * return : none * notes : see ref [1], [2] chap 7 * see ref [4] 5.2.1, 5.2.2, 5.2.3 * ver.2.4.0 does not use ocean loading and pole tide corrections *-----------------------------------------------------------------------------*/ extern void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, const double *odisp, double *dr) { gtime_t tut; double pos[2],E[9],drt[3],denu[3],rs[3],rm[3],gmst,erpv[5]={0}; int i; #ifdef IERS_MODEL double ep[6],fhr; int year,mon,day; #endif trace(3,"tidedisp: tutc=%s\n",time_str(tutc,0)); if (erp) geterp(erp,tutc,erpv); tut=timeadd(tutc,erpv[2]); dr[0]=dr[1]=dr[2]=0.0; if (norm(rr,3)<=0.0) return; pos[0]=asin(rr[2]/norm(rr,3)); pos[1]=atan2(rr[1],rr[0]); xyz2enu(pos,E); if (opt&1) { /* solid earth tides */ /* sun and moon position in ecef */ sunmoonpos(tutc,erpv,rs,rm,&gmst); #ifdef IERS_MODEL time2epoch(tutc,ep); year=(int)ep[0]; mon =(int)ep[1]; day =(int)ep[2]; fhr =ep[3]+ep[4]/60.0+ep[5]/3600.0; /* call DEHANTTIDEINEL */ dehanttideinel_((double *)rr,&year,&mon,&day,&fhr,rs,rm,drt); #else tide_solid(rs,rm,pos,E,gmst,opt,drt); #endif for (i=0;i<3;i++) dr[i]+=drt[i]; } if ((opt&2)&&odisp) { /* ocean tide loading */ tide_oload(tut,odisp,denu); matmul("TN",3,1,3,1.0,E,denu,0.0,drt); for (i=0;i<3;i++) dr[i]+=drt[i]; } if ((opt&4)&&erp) { /* pole tide */ tide_pole(pos,erpv,denu); matmul("TN",3,1,3,1.0,E,denu,0.0,drt); for (i=0;i<3;i++) dr[i]+=drt[i]; } trace(5,"tidedisp: dr=%.3f %.3f %.3f\n",dr[0],dr[1],dr[2]); }
/* adjust daily rollover of time ---------------------------------------------*/ static gtime_t adjday(gtime_t time, double tod) { double ep[6],tod_p; time2epoch(time,ep); tod_p=ep[3]*3600.0+ep[4]*60.0+ep[5]; if (tod<tod_p-43200.0) tod+=86400.0; else if (tod>tod_p+43200.0) tod-=86400.0; ep[3]=ep[4]=ep[5]=0.0; return timeadd(epoch2time(ep),tod); }
/* timeadd() */ void utest5(void) { double ep0[]={2003,12,31,23,59,59.000000}; double ep1[]={2004, 1, 1, 0, 0, 1.000000}; double ep2[]={2004, 2,28, 0, 0, 0.000000}; double ep3[]={2004, 2,29, 0, 0, 0.000000}; gtime_t t; double ep[6]; t=timeadd(epoch2time(ep0),3.0); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==1&&ep[2]==1&&ep[3]==0&&ep[4]==0&&ep[5]==2.0); t=timeadd(epoch2time(ep1),-3.0); time2epoch(t,ep); assert(ep[0]==2003&&ep[1]==12&&ep[2]==31&&ep[3]==23&&ep[4]==59&&ep[5]==58.0); t=timeadd(epoch2time(ep2),86400.0); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==2&&ep[2]==29&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=timeadd(epoch2time(ep2),86400.0*2); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==3&&ep[2]==1&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=timeadd(epoch2time(ep3),86400.0*2); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==3&&ep[2]==2&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); printf("%s utset5 : OK\n",__FILE__); }
/* str2time() */ void utest2(void) { char s1[30]="....2004 1 1 0 1 2.345........"; char s2[30]=".... 00 2 3 23 59 59.999....."; char s3[30]=".... 80 10 30 6 58 9........."; char s4[30]=".... 37 12 31 1 2 3 ........."; int s; gtime_t t; double ep[6]; s=str2time(s1,0,0,&t); assert(s<0); s=str2time(s1,30,10,&t); assert(s<0); s=str2time(s1,10,0,&t); assert(s<0); s=str2time(s1,-1,10,&t); assert(s<0); s=str2time(s1,4,17,&t); time2epoch(t,ep); assert(!s&&ep[0]==2004&&ep[1]==1&&ep[2]==1&&ep[3]==0&&ep[4]==1&&fabs(ep[5]-2.34)<1E-15); s=str2time(s2,4,21,&t); time2epoch(t,ep); assert(!s&&ep[0]==2000&&ep[1]==2&&ep[2]==3&&ep[3]==23&&ep[4]==59&&fabs(ep[5]-59.999)<1E-14); s=str2time(s3,4,20,&t); time2epoch(t,ep); assert(!s&&ep[0]==1980&&ep[1]==10&&ep[2]==30&&ep[3]==6&&ep[4]==58&&ep[5]==9); s=str2time(s4,4,20,&t); time2epoch(t,ep); assert(!s&&ep[0]==2037&&ep[1]==12&&ep[2]==31&&ep[3]==1&&ep[4]==2&&ep[5]==3); printf("%s utset2 : OK\n",__FILE__); }
/* displacement by ocean tide loading (ref [2] 7) ----------------------------*/ static void tide_oload(gtime_t tut, const double *odisp, double *denu) { const double args[][5]={ {1.40519E-4, 2.0,-2.0, 0.0, 0.00}, /* M2 */ {1.45444E-4, 0.0, 0.0, 0.0, 0.00}, /* S2 */ {1.37880E-4, 2.0,-3.0, 1.0, 0.00}, /* N2 */ {1.45842E-4, 2.0, 0.0, 0.0, 0.00}, /* K2 */ {0.72921E-4, 1.0, 0.0, 0.0, 0.25}, /* K1 */ {0.67598E-4, 1.0,-2.0, 0.0,-0.25}, /* O1 */ {0.72523E-4,-1.0, 0.0, 0.0,-0.25}, /* P1 */ {0.64959E-4, 1.0,-3.0, 1.0,-0.25}, /* Q1 */ {0.53234E-5, 0.0, 2.0, 0.0, 0.00}, /* Mf */ {0.26392E-5, 0.0, 1.0,-1.0, 0.00}, /* Mm */ {0.03982E-5, 2.0, 0.0, 0.0, 0.00} /* Ssa */ }; const double ep1975[]={1975,1,1,0,0,0}; double ep[6],fday,days,t,t2,t3,a[5],ang,dp[3]={0}; int i,j; trace(3,"tide_oload:\n"); /* angular argument: see subroutine arg.f for reference [1] */ time2epoch(tut,ep); fday=ep[3]*3600.0+ep[4]*60.0+ep[5]; ep[3]=ep[4]=ep[5]=0.0; days=timediff(epoch2time(ep),epoch2time(ep1975))/86400.0; t=(27392.500528+1.000000035*days)/36525.0; t2=t*t; t3=t2*t; a[0]=fday; a[1]=(279.69668+36000.768930485*t+3.03E-4*t2)*D2R; /* H0 */ a[2]=(270.434358+481267.88314137*t-0.001133*t2+1.9E-6*t3)*D2R; /* S0 */ a[3]=(334.329653+4069.0340329577*t+0.010325*t2-1.2E-5*t3)*D2R; /* P0 */ a[4]=2.0*PI; /* displacements by 11 constituents */ for (i=0;i<11;i++) { ang=0.0; for (j=0;j<5;j++) ang+=a[j]*args[i][j]; for (j=0;j<3;j++) dp[j]+=odisp[j+i*6]*cos(ang-odisp[j+3+i*6]*D2R); } denu[0]=-dp[1]; denu[1]=-dp[2]; denu[2]= dp[0]; trace(5,"tide_oload: denu=%.3f %.3f %.3f\n",denu[0],denu[1],denu[2]); }
//--------------------------------------------------------------------------- void __fastcall TConvDialog::TimeY2UDChangingEx(TObject *Sender, bool &AllowChange, short NewValue, TUpDownDirection Direction) { AnsiString s; double ep[]={2000,1,1,0,0,0}; int p=TimeY2->SelStart,ud=Direction==updUp?1:-1; sscanf(TimeY2->Text.c_str(),"%lf/%lf/%lf",ep,ep+1,ep+2); if (4<p&&p<8) { ep[1]+=ud; if (ep[1]<=0) {ep[0]--; ep[1]+=12;} else if (ep[1]>12) {ep[0]++; ep[1]-=12;} } else if (p>7||p==0) ep[2]+=ud; else ep[0]+=ud; time2epoch(epoch2time(ep),ep); TimeY2->Text=s.sprintf("%04.0f/%02.0f/%02.0f",ep[0],ep[1],ep[2]); TimeY2->SelStart=p>7||p==0?10:(p>4?7:4); }
static jboolean open_solution_status_file(JNIEnv* env, int level, gtime_t timestamp) { double ep[6]; char filename[1024]; if (level <= 0) return JNI_FALSE; time2epoch(utc2gpst(timestamp),ep); sprintf(filename,"rtkgps_%04.0f%02.0f%02.0f%02.0f%02.0f%02.0f.stat", ep[0],ep[1],ep[2],ep[3],ep[4],ep[5]); if (!get_path_in_storage_dir(env, filename, sizeof(filename))) return JNI_FALSE; LOGV("open_solution_status_file() %s", filename); rtkopenstat(filename, level); return JNI_TRUE; }
/* output reference ----------------------------------------------------------*/ static int out_ref(FILE *ofp, gtime_t ts) { double ep[6]; char file[1024]; int i; fprintf(ofp," <TR>\n"); fprintf(ofp," <TD><FONT size=\"-1\"><B>Report</B></FONT></TD>\n"); for (i=0; i<24; i++) { time2epoch(timeadd(ts,i*3600.0),ep); sprintf(file,REP_FILE,ep[0],ep[1],ep[2],ep[3]); fprintf(ofp," <TD align=\"right\"><FONT size=\"-1\"><A href=\"../%s\">%02.0fh</A></FONT></TD>\n", file,ep[3]); } fprintf(ofp," </TR>\n"); return 1; }
/* convert pvt message -------------------------------------------------------*/ static void convpvt(FILE **ofp, rnxopt_t *opt, strfile_t *str, int *n) { gtime_t time,current; static gtime_t firsttime={0,0}; double ep[6]; trace(3,"convpvt :\n"); if (!ofp[7]) return; time=str->pvt->time; if (!screent(time,opt->ts,opt->te,opt->tint)) return; if(n[7]==0) { current=timeget(); if(timediff(time,current)>86400) return; firsttime=time; time2epoch(time,ep); fprintf(ofp[7], "%04.0f %02.0f %02.0f %02.0f %02.0f %02.6f\n", ep[0],ep[1],ep[2],ep[3],ep[4],ep[5]); } fprintf(ofp[7], "%15.7f %14.3lf %14.3lf %14.3lf %11.3lf %11.3lf %11.3lf", timediff(time,firsttime), str->pvt->pos[0], str->pvt->pos[1], str->pvt->pos[2], str->pvt->vel[0], str->pvt->vel[1], str->pvt->vel[2]); fprintf(ofp[7],"\n"); if (opt->tstart.time==0) opt->tstart=time; opt->tend=time; n[7]++; }
/* epoch2time(),time2epoch() */ void utest3(void) { double ep0[]={1980, 1, 6, 0, 0, 0.000000}; double ep1[]={2004, 2,28, 2, 0,59.999999}; double ep2[]={2004, 2,29, 2, 0,30.000000}; double ep3[]={2004,12,31,23,59,59.999999}; double ep4[]={2037,10, 1, 0, 0, 0.000000}; int year,month,day,mday[]={31,28,31,30,31,30,31,31,30,31,30,31}; gtime_t t; double ep[6]; t=epoch2time(ep0); time2epoch(t,ep); assert(ep[0]==1980&&ep[1]==1&&ep[2]==6&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); t=epoch2time(ep1); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==2&&ep[2]==28&&ep[3]==2&&ep[4]==0&&fabs(ep[5]-59.999999)<1E-14); t=epoch2time(ep2); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==2&&ep[2]==29&&ep[3]==2&&ep[4]==0&&ep[5]==30.0); t=epoch2time(ep3); time2epoch(t,ep); assert(ep[0]==2004&&ep[1]==12&&ep[2]==31&&ep[3]==23&&ep[4]==59&&fabs(ep[5]-59.999999)<1E-14); t=epoch2time(ep4); time2epoch(t,ep); assert(ep[0]==2037&&ep[1]==10&&ep[2]==1&&ep[3]==0&&ep[4]==0&&ep[5]==0.0); for (year=1970;year<=2037;year++) { mday[1]=year%4==0?29:28; for (month=1;month<=12;month++) { for (day=1;day<=mday[month-1];day++) { if (year==1970&&month==1&&day==1) continue; ep0[0]=year; ep0[1]=month; ep0[2]=day; t=epoch2time(ep0); time2epoch(t,ep); /* fprintf(stderr,"ep=%.0f %2.0f %2.0f : %.0f %2.0f %2.0f\n", ep0[0],ep0[1],ep0[2],ep[0],ep[1],ep[2]); */ assert(ep[0]==ep0[0]&&ep[1]==ep0[1]&&ep[2]==ep0[2]); assert(ep[3]==0.0&&ep[4]==0.0&&ep[5]==0.0); } } } printf("%s utset3 : OK\n",__FILE__); }
/* single-point positioning ---------------------------------------------------- * compute receiver position, velocity, clock bias by single-point positioning * with pseudorange and doppler observables * args : obsd_t *obs I observation data * int n I number of observation data * nav_t *nav I navigation data * prcopt_t *opt I processing options * sol_t *sol IO solution * double *azel IO azimuth/elevation angle (rad) (NULL: no output) * ssat_t *ssat IO satellite status (NULL: no output) * char *msg O error message for error exit * return : status(1:ok,0:error) * notes : assuming sbas-gps, galileo-gps, qzss-gps, compass-gps time offset and * receiver bias are negligible (only involving glonass-gps time offset * and receiver bias) *-----------------------------------------------------------------------------*/ extern int pntpos(const obsd_t *obs, int n, const nav_t *nav, const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, char *msg) { prcopt_t opt_=*opt; double *rs,*dts,*var,*azel_,*resp; int i,stat,vsat[MAXOBS]={0},svh[MAXOBS]; double ep[6], ep2[6]; output = fopen("solution_log.txt", "a"); fprintf(output, "\nBegin solution in single point positioning mode\n"); fprintf(output, " Input observaton data:\n"); for(i = 0; i < n; i++) { time2epoch(obs[i].time, ep); fprintf(output, " %i) time: %4.0f/%2.0f/%2.0f %2.0f:%2.0f:%6.4f, sat: %i, code: %i, P1: %f, L1: %f, D1: %f, S1: %f, P2: %f, L2: %f, D2: %f, S2: %f\n", i+1, ep[0], ep[1], ep[2], ep[3], ep[4], ep[5], obs[i].sat, obs[i].code, obs[i].P[0], obs[i].L[0], obs[i].D[0], obs[i].SNR[0], obs[i].P[1], obs[i].L[1], obs[i].D[1], obs[i].SNR[1]); } fprintf(output, " Input GPS ephemeris:\n"); for(i = 0; i < nav->n; i++) { time2epoch(nav->eph[i].toe, ep); time2epoch(nav->eph[i].toc, ep2); fprintf(output, " %i) sat: %i, IODE: %i, sva: %i, svh: %i, week: %i, toe: %4.0f/%2.0f/%2.0f %2.0f:%2.0f:%6.4f, toc: %4.0f/%2.0f/%2.0f %2.0f:%2.0f:%6.4f, sqrt(A): %f, E: %f, i0: %f, OMG0: %f, omega: %f, M0: %f, delta_n: %f, OMGdot: %f, Idot: %f, Crc: %f, Crs: %f, Cuc: %f, Cus: %f, Cic: %f, Cis: %f, af0: %f, af1: %f, af2: %f, Tgd: %f\n", i + 1, nav->eph[i].sat, nav->eph[i].iode, nav->eph[i].sva, nav->eph[i].svh, nav->eph[i].week, ep[0], ep[1], ep[2], ep[3], ep[4], ep[5], ep2[0], ep2[1], ep2[2], ep2[3], ep2[4], ep2[5], sqrt(nav->eph[i].A), nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd, nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc, nav->eph[i].cus, nav->eph[i].cic, nav->eph[i].cis, nav->eph[i].f0, nav->eph[i].f0, nav->eph[i].f1, nav->eph[i].f2, nav->eph[i].tgd[0]); } fprintf(output, " Input GLONASS ephemeris:\n"); for(i = 0; i < nav->ng; i++) { time2epoch(nav->geph[i].toe, ep); fprintf(output, " %i) sat: %i, sva: %i, svh: %i, toe: %4.0f/%2.0f/%2.0f %2.0f:%2.0f:%6.4f, X: %f, Y: %f, Z: %f, VX: %f, VY: %f, VZ: %f, tau_n: %f, gamma_n: %f\n", i + 1, nav->geph[i].sat, nav->geph[i].sva, nav->geph[i].svh, ep[0], ep[1], ep[2], ep[3], ep[4], ep[5], nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2], nav->geph[i].taun, nav->geph[i].gamn); } sol->stat=SOLQ_NONE; if (n<=0) {strcpy(msg,"no observation data"); return 0;} trace(3,"pntpos : tobs=%s n=%d\n",time_str(obs[0].time,3),n); sol->time=obs[0].time; msg[0]='\0'; rs=mat(6,n); dts=mat(2,n); var=mat(1,n); azel_=zeros(2,n); resp=mat(1,n); if (opt_.mode!=PMODE_SINGLE) { /* for precise positioning */ #if 0 opt_.sateph =EPHOPT_BRDC; #endif opt_.ionoopt=IONOOPT_BRDC; opt_.tropopt=TROPOPT_SAAS; } /* satellite positons, velocities and clocks */ satposs(sol->time,obs,n,nav,opt_.sateph,rs,dts,var,svh); fprintf(output, " Satellite positions, velocities and clocks:\n"); for(i = 0; i < n; i++) { fprintf(output, " sat %i: X = %f, Y = %f, Z = %f, VX = %f, VY = %f, VZ = %f, dt = %f, dt_dot = %f\n", obs[i].sat, rs[i*6], rs[i*6 + 1], rs[i*6 + 2], rs[i*6 + 3], rs[i*6 + 4], rs[i*6 + 5], dts[i*2], dts[i*2 + 1]); } /* estimate receiver position with pseudorange */ stat=estpos(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); /* raim fde */ if (!stat&&n>=6&&opt->posopt[4]) { stat=raim_fde(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); } /* estimate receiver velocity with doppler */ if (stat) estvel(obs,n,rs,dts,nav,&opt_,sol,azel_,vsat); if (azel) { for (i=0;i<n*2;i++) azel[i]=azel_[i]; } if (ssat) { for (i=0;i<MAXSAT;i++) { ssat[i].vs=0; ssat[i].azel[0]=ssat[i].azel[1]=0.0; ssat[i].resp[0]=ssat[i].resc[0]=0.0; ssat[i].snr[0]=0; } for (i=0;i<n;i++) { ssat[obs[i].sat-1].azel[0]=azel_[ i*2]; ssat[obs[i].sat-1].azel[1]=azel_[1+i*2]; ssat[obs[i].sat-1].snr[0]=obs[i].SNR[0]; if (!vsat[i]) continue; ssat[obs[i].sat-1].vs=1; ssat[obs[i].sat-1].resp[0]=resp[i]; } } free(rs); free(dts); free(var); free(azel_); free(resp); fprintf(output, "End calculations in single point positioning mode\n"); fclose(output); output = fopen("cov_matr_single.txt", "a"); time2epoch(sol->time, ep); fprintf(output, "%4.0f/%2.0f/%2.0f %2.0f:%2.0f:%2.4f coords: %f %f %f %f %f %f velocities: %f %f %f %f %f %f\n", ep[0], ep[1], ep[2], ep[3], ep[4], ep[5], sol->qr[0], sol->qr[3], sol->qr[5], sol->qr[1], sol->qr[4], sol->qr[2], sol->qvr[0], sol->qvr[3], sol->qvr[5], sol->qvr[1], sol->qvr[4], sol->qvr[2]); fclose(output); return stat; }
/* generate data qc page -----------------------------------------------------*/ static int gen_page3(gtime_t time, const char *temp, const char *page) { FILE *ifp,*ofp; gtime_t ts,te; double ep[6],hour[24],mp1[MAXSTA][24]= {{0}},mp2[MAXSTA][24]= {{0}}; double slip[MAXSTA][24]= {{0}},val1[MAXSTA],val2[MAXSTA],val3[MAXSTA]; char buff[1024],file[1024],*sta[MAXSTA],str[MAXSTA][32]; int i,j,n,nsta=0,sec=0; ts=timeadd(time,-90000.0); te=timeadd(time, -3600.0); for (i=0; i<MAXSTA; i++) sta[i]=str[i]; for (i=0; i<24; i++) { time2epoch(timeadd(ts,i*3600.0),ep); sprintf(file,QC_FILE,ep[0],ep[1],ep[2],ep[3]); if (!(n=read_qc(file,sta,val1,val2,val3))) continue; for (j=0; j<n; j++) { mp1 [j][i]=val1[j]; mp2 [j][i]=val2[j]; slip[j][i]=val3[j]; } hour[i]=ep[3]; nsta=n; } if (!(ifp=fopen(temp,"r"))) { fprintf(stderr,"file open error: %s\n",temp); return 0; } if (!(ofp=fopen(page,"w"))) { fprintf(stderr,"file open error: %s\n",page); fclose(ifp); return 0; } while (fgets(buff,sizeof(buff),ifp)) { if (strstr(buff,"@DATE START" )) sec=1; else if (strstr(buff,"@TABLE0 START")) sec=2; else if (strstr(buff,"@TABLE1 START")) sec=3; else if (strstr(buff,"@TABLE2 START")) sec=4; else if (strstr(buff,"@DATE END" )) sec=0; else if (strstr(buff,"@TABLE0 END" )) sec=0; else if (strstr(buff,"@TABLE1 END" )) sec=0; else if (strstr(buff,"@TABLE2 END" )) sec=0; switch (sec) { case 0: fputs(buff,ofp); break; case 1: out_date(ofp,ts,te); break; case 2: out_table1(ofp,sta,nsta,hour,mp1 ,3); break; case 3: out_table1(ofp,sta,nsta,hour,mp2 ,3); break; case 4: out_table1(ofp,sta,nsta,hour,slip,0); break; } } fclose(ifp); fclose(ofp); return 1; }