From 74daf5722aae93ec72c289efc5a024ec55debbb2 Mon Sep 17 00:00:00 2001 From: TimEverett <tim.everett3@gmail.com> Date: Wed, 10 Oct 2018 18:12:35 -0600 Subject: [PATCH] Generate output log of event positions. This check-in and the previous one for logging events are ported from the Emlid code base and expanded to include Swiftnav receivers as well as u-blox. --- app/rtkrcv/rtkrcv.c | 18 +++-- src/convrnx.c | 2 +- src/pntpos.c | 2 + src/postpos.c | 161 +++++++++++++++++++++++++++++++++++++------- src/rcv/swiftnav.c | 14 ++-- src/rcv/ublox.c | 4 +- src/rinex.c | 74 +++++++++++++------- src/rtklib.h | 12 ++-- 8 files changed, 223 insertions(+), 64 deletions(-) diff --git a/app/rtkrcv/rtkrcv.c b/app/rtkrcv/rtkrcv.c index 6d78916..114b539 100644 --- a/app/rtkrcv/rtkrcv.c +++ b/app/rtkrcv/rtkrcv.c @@ -632,11 +632,12 @@ static void prstatus(vt_t *vt) "single","DGPS","kinematic","static","static-start","moving-base","fixed", "PPP-kinema","PPP-static" }; - const char *freq[]={"-","L1","L1+L2","L1+L2+L5","","",""}; + gtime_t eventime={0}; + const char *freq[]={"-","L1","L1+L2","L1+L2+E5b","L1+L2+E5b+L5","",""}; rtcm_t rtcm[3]; - int i,j,n,thread,cycle,state,rtkstat,nsat0,nsat1,prcout,nave; + int i,j,n,thread,cycle,state,rtkstat,nsat0,nsat1,prcout,rcvcount,tmcount,timevalid,nave; int cputime,nb[3]={0},nmsg[3][10]={{0}}; - char tstr[64],s[1024],*p; + char tstr[64],tmstr[64],s[1024],*p; double runtime,rt[3]={0},dop[4]={0},rr[3],bl1=0.0,bl2=0.0; double azel[MAXSAT*2],pos[3],vel[3],*del; @@ -650,6 +651,8 @@ static void prstatus(vt_t *vt) rtkstat=svr.rtk.sol.stat; nsat0=svr.obs[0][0].n; nsat1=svr.obs[1][0].n; + rcvcount = svr.raw[0].obs.rcvcount; + tmcount = svr.raw[0].obs.tmcount; cputime=svr.cputime; prcout=svr.prcout; nave=svr.nave; @@ -663,6 +666,11 @@ static void prstatus(vt_t *vt) rt[1]=floor(runtime/60.0); rt[2]=runtime-rt[1]*60.0; } for (i=0;i<3;i++) rtcm[i]=svr.rtcm[i]; + if (svr.raw[0].obs.data != NULL) { + timevalid = svr.raw[0].obs.data[0].timevalid; + eventime = svr.raw[0].obs.data[0].eventime; + } + time2str(eventime,tmstr,9); rtksvrunlock(&svr); for (i=n=0;i<MAXSAT;i++) { @@ -763,7 +771,9 @@ static void prstatus(vt_t *vt) } vt_printf(vt,"%-28s: %.3f\n","baseline length float (m)",bl1); vt_printf(vt,"%-28s: %.3f\n","baseline length fixed (m)",bl2); - vt_printf(vt,"%-28s: %d\n","monitor port",moniport); + vt_printf(vt,"%-28s: %s\n","last time mark",tmcount ? tmstr : "-"); + vt_printf(vt,"%-28s: %d\n","receiver time mark count",rcvcount); + vt_printf(vt,"%-28s: %d\n","rtklib time mark count",tmcount); } /* print satellite -----------------------------------------------------------*/ static void prsatellite(vt_t *vt, int nf) diff --git a/src/convrnx.c b/src/convrnx.c index 4cf6816..04cc73d 100644 --- a/src/convrnx.c +++ b/src/convrnx.c @@ -1004,7 +1004,7 @@ static void convobs(FILE **ofp, rnxopt_t *opt, strfile_t *str, int *staid, } } /* output rinex obs */ - outrnxobsb(ofp[0],opt,str->obs); + outrnxobsb(ofp[0],opt,str->obs->data,str->obs->n,str->obs->flag); /* n[NOUTFILE+1] - count of events converted to rinex */ if (str->obs->flag == 5) n[NOUTFILE+1]++; diff --git a/src/pntpos.c b/src/pntpos.c index 9892c6a..fdfbe13 100644 --- a/src/pntpos.c +++ b/src/pntpos.c @@ -431,6 +431,7 @@ static int raim_fde(const obsd_t *obs, int n, const double *rs, resp[j]=resp_e[k++]; } stat=1; + sol_e.eventime = sol->eventime; *sol=sol_e; sat=obs[i].sat; rms=rms_e; @@ -550,6 +551,7 @@ extern int pntpos(const obsd_t *obs, int n, const nav_t *nav, trace(3,"pntpos : tobs=%s n=%d\n",time_str(obs[0].time,3),n); sol->time=obs[0].time; msg[0]='\0'; + sol->eventime = obs[0].eventime; rs=mat(6,n); dts=mat(2,n); var=mat(1,n); azel_=zeros(2,n); resp=mat(1,n); diff --git a/src/postpos.c b/src/postpos.c index 3b29d1f..38fdbff 100644 --- a/src/postpos.c +++ b/src/postpos.c @@ -31,7 +31,7 @@ * add function to read satellite fcb * add function to read stec and troposphere file * add keyword replacement in dcb, erp and ionos file -* 2015/11/13 1.17 add support of L5 antenna phase center paramters +* 2015/11/13 1.17 add support of L5 antenna phase center parameters * add *.stec and *.trp file for ppp correction * 2015/11/26 1.18 support opt->freqopt(disable L2) * 2016/01/12 1.19 add carrier-phase bias correction by ssr @@ -56,12 +56,14 @@ static obs_t obss={0}; /* observation data */ static nav_t navs={0}; /* navigation data */ static sbs_t sbss={0}; /* sbas messages */ static lex_t lexs={0}; /* lex messages */ -static sta_t stas[MAXRCV]; /* station infomation */ +static sta_t stas[MAXRCV]; /* station information */ static int nepoch=0; /* number of observation epochs */ +static int nitm =0; /* number of invalid time marks */ static int iobsu =0; /* current rover observation data index */ static int iobsr =0; /* current reference observation data index */ static int isbs =0; /* current sbas message index */ static int ilex =0; /* current lex message index */ +static int iitm =0; /* current invalid time mark index */ static int revs =0; /* analysis direction (0:forward,1:backward) */ static int aborts=0; /* abort status */ static sol_t *solf; /* forward solutions */ @@ -74,6 +76,7 @@ static char proc_rov [64]=""; /* rover for current processing */ static char proc_base[64]=""; /* base station for current processing */ static char rtcm_file[1024]=""; /* rtcm data file */ static char rtcm_path[1024]=""; /* rtcm data path */ +static gtime_t invalidtm[100]={{0}};/* invalid time marks */ static rtcm_t rtcm; /* rtcm control struct */ static FILE *fp_rtcm=NULL; /* rtcm data file pointer */ @@ -256,7 +259,7 @@ static int inputobs(obsd_t *obs, int solq, const prcopt_t *popt) if (timediff(obss.data[i].time,obss.data[iobsu].time)>DTTOL) break; } nr=nextobsf(&obss,&iobsr,2); - if (nr<=0) { + if (nr<=0) { /* remove this for event logging??? */ nr=nextobsf(&obss,&iobsr,2); } for (i=0;i<nu&&n<MAXOBS*2;i++) obs[n++]=obss.data[iobsu+i]; @@ -320,6 +323,59 @@ static int inputobs(obsd_t *obs, int solq, const prcopt_t *popt) } return n; } +/* output to file message of invalid time mark -------------------------------*/ +static void outinvalidtm(FILE *fptm, const solopt_t *opt, const gtime_t tm) +{ + gtime_t time = tm; + double gpst; + int week,timeu; + char s[100]; + + timeu=opt->timeu<0?0:(opt->timeu>20?20:opt->timeu); + + if (opt->times>=TIMES_UTC) time=gpst2utc(time); + if (opt->times==TIMES_JST) time=timeadd(time,9*3600.0); + + if (opt->timef) time2str(time,s,timeu); + else { + gpst=time2gpst(time,&week); + if (86400*7-gpst<0.5/pow(10.0,timeu)) { + week++; + gpst=0.0; + } + sprintf(s,"%4d %*.*f",week,6+(timeu<=0?0:timeu+1),timeu,gpst); + } + strcat(s, " Q=0, Time mark is not valid\n"); + + fwrite(s,strlen(s),1,fptm); +} +/* fill structure sol_t for time mark ----------------------------------------*/ +static sol_t fillsoltm(const sol_t solold, const sol_t solnew, const gtime_t tm) +{ + gtime_t t1={0},t2={0}; + sol_t sol=solold; + int i=0; + + if (solold.stat == 0 || solnew.stat == 0) { + sol.stat = 0; + } else { + sol.stat = (solold.stat > solnew.stat) ? solold.stat : solnew.stat; + } + sol.ns = (solold.ns < solnew.ns) ? solold.ns : solnew.ns; + sol.ratio = (solold.ratio < solnew.ratio) ? solold.ratio : solnew.ratio; + + /* interpolation position and speed of time mark */ + t1 = solold.time; + t2 = solnew.time; + sol.time = tm; + + for (i=0;i<6;i++) + { + sol.rr[i] = solold.rr[i] + timediff(tm,t1) / timediff(t2,t1) * (solnew.rr[i] - solold.rr[i]); + } + + return sol; +} /* carrier-phase bias correction by fcb --------------------------------------*/ static void corr_phase_bias_fcb(obsd_t *obs, int n, const nav_t *nav) { @@ -353,14 +409,14 @@ static void corr_phase_bias_ssr(obsd_t *obs, int n, const nav_t *nav) } } /* process positioning -------------------------------------------------------*/ -static void procpos(FILE *fp, const prcopt_t *popt, const solopt_t *sopt, rtk_t *rtk, - int mode) +static void procpos(FILE *fp, FILE *fptm, const prcopt_t *popt, const solopt_t *sopt, + rtk_t *rtk, int mode) { gtime_t time={0}; - sol_t sol={{0}}; + sol_t sol={{0}},oldsol={{0}},newsol={{0}}; obsd_t obs[MAXOBS*2]; /* for rover and base */ double rb[3]={0}; - int i,nobs,n,solstatic,pri[]={0,1,2,3,4,5,1,6}; + int i,nobs,n,solstatic,num=0,pri[]={0,1,2,3,4,5,1,6}; trace(3,"procpos : mode=%d\n",mode); @@ -395,7 +451,16 @@ static void procpos(FILE *fp, const prcopt_t *popt, const solopt_t *sopt, rtk_t for (i=0;i<n;i++) obs[i].L[1]=obs[i].P[1]=0.0; } #endif - if (!rtkpos(rtk,obs,n,&navs)) continue; + if (!rtkpos(rtk,obs,n,&navs)) { + if (rtk->sol.eventime.time != 0) { + if (mode == 0) { + outinvalidtm(fptm, sopt, rtk->sol.eventime); + } else if (!revs) { + invalidtm[nitm++] = rtk->sol.eventime; + } + } + continue; + } if (mode==0) { /* forward/backward */ if (!solstatic) { @@ -408,6 +473,16 @@ static void procpos(FILE *fp, const prcopt_t *popt, const solopt_t *sopt, rtk_t time=rtk->sol.time; } } + /* check time mark */ + if (rtk->sol.eventime.time != 0) + { + newsol = fillsoltm(oldsol,rtk->sol,rtk->sol.eventime); + num++; + if (!solstatic && mode == 0) { + outsol(fptm,&newsol,rb,sopt); + } + } + oldsol = rtk->sol; } else if (!revs) { /* combined-forward */ if (isolf>=nepoch) return; @@ -452,12 +527,12 @@ static int valcomb(const sol_t *solf, const sol_t *solb) return 1; } /* combine forward/backward solutions and output results ---------------------*/ -static void combres(FILE *fp, const prcopt_t *popt, const solopt_t *sopt) +static void combres(FILE *fp, FILE *fptm, const prcopt_t *popt, const solopt_t *sopt) { gtime_t time={0}; - sol_t sols={{0}},sol={{0}}; + sol_t sols={{0}},sol={{0}},oldsol={{0}},newsol={{0}}; double tt,Qf[9],Qb[9],Qs[9],rbs[3]={0},rb[3]={0},rr_f[3],rr_b[3],rr_s[3]; - int i,j,k,solstatic,pri[]={0,1,2,3,4,5,1,6}; + int i,j,k,solstatic,num=0,pri[]={0,1,2,3,4,5,1,6}; trace(3,"combres : isolf=%d isolb=%d\n",isolf,isolb); @@ -552,6 +627,20 @@ static void combres(FILE *fp, const prcopt_t *popt, const solopt_t *sopt) time=sols.time; } } + if (iitm < nitm && timediff(invalidtm[iitm],sols.time)<0.0) + { + outinvalidtm(fptm,sopt,invalidtm[iitm]); + iitm++; + } + if (sols.eventime.time != 0) + { + newsol = fillsoltm(oldsol,sols,sols.eventime); + num++; + if (!solstatic) { + outsol(fptm,&newsol,rb,sopt); + } + } + oldsol = sols; } if (solstatic&&time.time!=0.0) { sol.time=time; @@ -974,15 +1063,33 @@ static FILE *openfile(const char *outfile) return !*outfile?stdout:fopen(outfile,"a"); } +/* Name time marks file ------------------------------------------------------*/ +static void namefiletm(char *outfiletm, const char *outfile) +{ + int i; + + for (i=strlen(outfile);i>0;i--) { + if (outfile[i] == '.') { + break; + } + } + /* if no file extension, then name time marks file as name of outfile + _events.pos */ + if (i == 0) { + i = strlen(outfile); + } + strncpy(outfiletm, outfile, i); + strcat(outfiletm, "_events.pos"); +} /* execute processing session ------------------------------------------------*/ static int execses(gtime_t ts, gtime_t te, double ti, const prcopt_t *popt, const solopt_t *sopt, const filopt_t *fopt, int flag, char **infile, const int *index, int n, char *outfile) { - FILE *fp; + FILE *fp,*fptm; rtk_t rtk; prcopt_t popt_=*popt; - char tracefile[1024],statfile[1024],path[1024],*ext; + solopt_t tmsopt = *sopt; + char tracefile[1024],statfile[1024],path[1024],*ext,outfiletm[1024]={0}; trace(3,"execses : n=%d outfile=%s\n",n,outfile); @@ -1023,7 +1130,7 @@ static int execses(gtime_t ts, gtime_t te, double ti, const prcopt_t *popt, reppath(fopt->dcb,path,ts,"",""); readdcb(path,&navs,stas); } - /* set antenna paramters */ + /* set antenna parameters */ if (popt_.mode!=PMODE_SINGLE) { setpcv(obss.n>0?obss.data[0].time:timeget(),&popt_,&navs,&pcvss,&pcvsr, stas); @@ -1061,19 +1168,26 @@ static int execses(gtime_t ts, gtime_t te, double ti, const prcopt_t *popt, freeobsnav(&obss,&navs); return 0; } + /* name time events file */ + namefiletm(outfiletm,outfile); + /* write header to file with time marks */ + outhead(outfiletm,infile,n,&popt_,&tmsopt); + iobsu=iobsr=isbs=ilex=revs=aborts=0; if (popt_.mode==PMODE_SINGLE||popt_.soltype==0) { - if ((fp=openfile(outfile))) { - procpos(fp,&popt_,sopt,&rtk,0); /* forward */ + if ((fp=openfile(outfile)) && (fptm=openfile(outfiletm))) { + procpos(fp,fptm,&popt_,sopt,&rtk,0); /* forward */ fclose(fp); + fclose(fptm); } } else if (popt_.soltype==1) { - if ((fp=openfile(outfile))) { + if ((fp=openfile(outfile)) && (fptm=openfile(outfiletm))) { revs=1; iobsu=iobsr=obss.n-1; isbs=sbss.n-1; ilex=lexs.n-1; - procpos(fp,&popt_,sopt,&rtk,0); /* backward */ + procpos(fp,fptm,&popt_,sopt,&rtk,0); /* backward */ fclose(fp); + fclose(fptm); } } else { /* combined */ @@ -1084,14 +1198,15 @@ static int execses(gtime_t ts, gtime_t te, double ti, const prcopt_t *popt, if (solf&&solb) { isolf=isolb=0; - procpos(NULL,&popt_,sopt,&rtk,1); /* forward */ + procpos(NULL,NULL,&popt_,sopt,&rtk,1); /* forward */ revs=1; iobsu=iobsr=obss.n-1; isbs=sbss.n-1; ilex=lexs.n-1; - procpos(NULL,&popt_,sopt,&rtk,1); /* backward */ + procpos(NULL,NULL,&popt_,sopt,&rtk,1); /* backward */ /* combine forward/backward solutions */ - if (!aborts&&(fp=openfile(outfile))) { - combres(fp,&popt_,sopt); + if (!aborts&&(fp=openfile(outfile)) && (fptm=openfile(outfiletm))) { + combres(fp,fptm,&popt_,sopt); fclose(fp); + fclose(fptm); } } else showmsg("error : memory allocation"); @@ -1235,7 +1350,7 @@ static int execses_b(gtime_t ts, gtime_t te, double ti, const prcopt_t *popt, * observation data file in the input files is recognized as the rover * data. * -* the type of an input file is recognized by the file extention as ] +* the type of an input file is recognized by the file extension as ] * follows: * .sp3,.SP3,.eph*,.EPH*: precise ephemeris (sp3c) * .sbs,.SBS,.ems,.EMS : sbas message log files (rtklib or ems) diff --git a/src/rcv/swiftnav.c b/src/rcv/swiftnav.c index 07fd6b5..04bae7b 100644 --- a/src/rcv/swiftnav.c +++ b/src/rcv/swiftnav.c @@ -296,9 +296,9 @@ static int flushobuf(raw_t *raw) { trace(3, "flushobuf: n=%d\n", raw->obuf.n); /* copy events from data buffer */ - if (raw->obuf.eventime.time>0) { - raw->obs.eventime = raw->obuf.eventime; - raw->obs.timevalid = raw->obuf.timevalid; + if (raw->obuf.data[0].eventime.time>0) { + raw->obs.data[0].eventime = raw->obuf.data[0].eventime; + raw->obs.data[0].timevalid = raw->obuf.data[0].timevalid; raw->obs.flag = raw->obuf.flag; raw->obs.rcvcount = raw->obuf.rcvcount; raw->obs.tmcount=raw->obuf.tmcount; @@ -315,8 +315,8 @@ static int flushobuf(raw_t *raw) { raw->obs.n = n; /* clear events from data buffer */ - raw->obuf.eventime = time0; - raw->obuf.flag = raw->obuf.timevalid=0; + raw->obuf.data[0].eventime = time0; + raw->obuf.flag = raw->obuf.data[0].timevalid=0; raw->obuf.rcvcount = raw->obuf.tmcount=0; /* clear observation data buffer */ @@ -1173,9 +1173,9 @@ static int decode_event(raw_t *raw) { /* write to event variables */ eventime = gpst2time(wn,tow*1E-3+ns_residual*1E-9); raw->obuf.flag = 5; /* event flag */ - raw->obuf.eventime = eventime; + raw->obuf.data[0].eventime = eventime; raw->obuf.tmcount++; - raw->obuf.timevalid = (flags & 0x02)>>1; + raw->obuf.data[0].timevalid = (flags & 0x02)>>1; return 0; } diff --git a/src/rcv/ublox.c b/src/rcv/ublox.c index c1b329c..7575527 100644 --- a/src/rcv/ublox.c +++ b/src/rcv/ublox.c @@ -1108,10 +1108,10 @@ static int decode_timtm2(raw_t *raw) { eventime = gpst2time(wnF,towMsF*1E-3+towSubMsF*1E-9); raw->obs.flag = 5; /* Event flag */ - raw->obs.eventime = eventime; + raw->obs.data[0].eventime = eventime; raw->obs.rcvcount = count; raw->obs.tmcount++; - raw->obs.timevalid = time; + raw->obs.data[0].timevalid = time; } else { raw->obs.flag = 0; } diff --git a/src/rinex.c b/src/rinex.c index a04c8e0..7cca82c 100644 --- a/src/rinex.c +++ b/src/rinex.c @@ -645,11 +645,17 @@ static int decode_obsepoch(FILE *fp, char *buff, double ver, gtime_t *time, trace(4,"decode_obsepoch: ver=%.2f\n",ver); if (ver<=2.99) { /* ver.2 */ - if ((n=(int)str2num(buff,29,3))<=0) return 0; + /* if ((n=(int)str2num(buff,29,3))<=0) return 0; */ /* epoch flag: 3:new site,4:header info,5:external event */ *flag=(int)str2num(buff,28,1); + if (*flag == 5) { + str2time(buff,0,26,time); + } + + if ((n=(int)str2num(buff,29,3))<=0) return 0; + if (3<=*flag&&*flag<=5) return n; if (str2time(buff,0,26,time)) { @@ -668,10 +674,16 @@ static int decode_obsepoch(FILE *fp, char *buff, double ver, gtime_t *time, } } else { /* ver.3 */ - if ((n=(int)str2num(buff,32,3))<=0) return 0; + /* if ((n=(int)str2num(buff,32,3))<=0) return 0; */ *flag=(int)str2num(buff,31,1); + if (*flag == 5) { + str2time(buff,1,28,time); + } + + if ((n=(int)str2num(buff,32,3))<=0) return 0; + if (3<=*flag&&*flag<=5) return n; if (buff[0]!='>'||str2time(buff,1,28,time)) { @@ -956,9 +968,13 @@ static int readrnxobsb(FILE *fp, const char *opt, double ver, int *tsys, /* decode obs epoch */ if (i==0) { - if ((nsat=decode_obsepoch(fp,buff,ver,&time,flag,sats))<=0) { + if ((nsat=decode_obsepoch(fp,buff,ver,&time,flag,sats))<=0 && (*flag != 5)) { continue; } + if (*flag == 5) { + data[0].eventime = time; + return 0; + } } else if (*flag<=2||*flag==6) { @@ -982,6 +998,7 @@ static int readrnxobs(FILE *fp, gtime_t ts, gtime_t te, double tint, const char *opt, int rcv, double ver, int *tsys, char tobs[][MAXOBSTYPE][4], obs_t *obs, sta_t *sta) { + gtime_t eventime={0}; obsd_t *data; unsigned char slips[MAXSAT][NFREQ]={{0}}; int i,n,flag=0,stat=0; @@ -994,6 +1011,16 @@ static int readrnxobs(FILE *fp, gtime_t ts, gtime_t te, double tint, /* read rinex obs data body */ while ((n=readrnxobsb(fp,opt,ver,tsys,tobs,&flag,data,sta))>=0&&stat>=0) { + + if (flag == 5) { + eventime = data[0].eventime; + n = readrnxobsb(fp,opt,ver,tsys,tobs,&flag,data,sta); + } + + for (i=0;i<n;i++) data[i].eventime = eventime; + /* set to zero eventime for the next iteration */ + eventime.time = 0; + eventime.sec = 0; for (i=0;i<n;i++) { @@ -1710,7 +1737,7 @@ extern void free_rnxctr(rnxctr_t *rnx) free(rnx->nav.seph); rnx->nav.seph=NULL; rnx->nav.ns=0; } /* open rinex data ------------------------------------------------------------- -* fetch next rinex message and input a messsage from file +* fetch next rinex message and input a message from file * args : rnxctr_t *rnx IO rinex control struct * FILE *fp I file pointer * return : status (-2: end of file, 0: no message, 1: input observation data, @@ -1876,7 +1903,7 @@ extern int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav) else { /* ver.3 */ if (opt->navsys==SYS_GPS) sys="G: GPS"; else if (opt->navsys==SYS_GLO) sys="R: GLONASS"; - else if (opt->navsys==SYS_GAL) sys="E: Galileo"; + else if (opt->navsys==SYS_GAL) sys="E: Galielo"; else if (opt->navsys==SYS_QZS) sys="J: QZSS"; /* ver.3.02 */ else if (opt->navsys==SYS_CMP) sys="C: BeiDou"; /* ver.3.02 */ else if (opt->navsys==SYS_IRN) sys="I: IRNSS"; /* ver.3.03 */ @@ -2039,13 +2066,13 @@ static int obsindex(double ver, int sys, const unsigned char *code, return -1; } /* output rinex event time ---------------------------------------------------*/ -static void outrinexevent(FILE *fp, const rnxopt_t *opt, const obs_t *obs, +static void outrinexevent(FILE *fp, const rnxopt_t *opt, const obsd_t *obs, const double epdiff) { int n; double epe[6]; - time2epoch(obs->eventime,epe); + time2epoch(obs[0].eventime,epe); n = obs->timevalid ? 0 : 1; if (opt->rnxver<=2.99) { /* ver.2 */ @@ -2068,21 +2095,22 @@ static void outrinexevent(FILE *fp, const rnxopt_t *opt, const obs_t *obs, * int flag I epoch flag (0:ok,1:power failure,>1:event flag) * return : status (1:ok, 0:output error) *-----------------------------------------------------------------------------*/ -extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs) +extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obsd_t *obs, int n, + int flag) { const char *mask; double epdiff,ep[6]; char sats[MAXOBS][4]={""}; int i,j,k,m,ns,sys,ind[MAXOBS],s[MAXOBS]={0}; - trace(3,"outrnxobsb: n=%d\n",obs->n); + trace(3,"outrnxobsb: n=%d\n",n); - time2epoch(obs->data[0].time,ep); + time2epoch(obs[0].time,ep); - for (i=ns=0;i<obs->n&&ns<MAXOBS;i++) { - sys=satsys(obs->data[i].sat,NULL); - if (!(sys&opt->navsys)||opt->exsats[obs->data[i].sat-1]) continue; - if (!sat2code(obs->data[i].sat,sats[ns])) continue; + for (i=ns=0;i<n&&ns<MAXOBS;i++) { + sys=satsys(obs[i].sat,NULL); + if (!(sys&opt->navsys)||opt->exsats[obs[i].sat-1]) continue; + if (!sat2code(obs[i].sat,sats[ns])) continue; switch (sys) { case SYS_GPS: s[ns]=0; break; case SYS_GLO: s[ns]=1; break; @@ -2098,8 +2126,8 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs) /* if epoch of event less than epoch of observation, then first output time mark, else first output observation record */ - epdiff = timediff(obs->data[0].time,obs->eventime); - if (obs->flag == 5 && epdiff >= 0) { + epdiff = timediff(obs[0].time,obs[0].eventime); + if (flag == 5 && epdiff >= 0) { outrinexevent(fp, opt, obs, epdiff); } @@ -2116,7 +2144,7 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs) ep[0],ep[1],ep[2],ep[3],ep[4],ep[5],0,ns,""); } for (i=0;i<ns;i++) { - sys=satsys(obs->data[ind[i]].sat,NULL); + sys=satsys(obs[ind[i]].sat,NULL); if (opt->rnxver<=2.99) { /* ver.2 */ m=0; @@ -2133,7 +2161,7 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs) if (j%5==0) fprintf(fp,"\n"); } /* search obs data index */ - if ((k=obsindex(opt->rnxver,sys,obs->data[ind[i]].code,opt->tobs[m][j], + if ((k=obsindex(opt->rnxver,sys,obs[ind[i]].code,opt->tobs[m][j], mask))<0) { outrnxobsf(fp,0.0,-1,-1); continue; @@ -2141,16 +2169,16 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs) /* output field */ switch (opt->tobs[m][j][0]) { case 'C': - case 'P': outrnxobsf(fp,obs->data[ind[i]].P[k],-1,obs->data[ind[i]].qualP[k]); break; - case 'L': outrnxobsf(fp,obs->data[ind[i]].L[k],obs->data[ind[i]].LLI[k],obs->data[ind[i]].qualL[k]); break; - case 'D': outrnxobsf(fp,obs->data[ind[i]].D[k],-1,-1); break; - case 'S': outrnxobsf(fp,obs->data[ind[i]].SNR[k]*0.25,-1,-1); break; + case 'P': outrnxobsf(fp,obs[ind[i]].P[k],-1,obs[ind[i]].qualP[k]); break; + case 'L': outrnxobsf(fp,obs[ind[i]].L[k],obs[ind[i]].LLI[k],obs[ind[i]].qualL[k]); break; + case 'D': outrnxobsf(fp,obs[ind[i]].D[k],-1,-1); break; + case 'S': outrnxobsf(fp,obs[ind[i]].SNR[k]*0.25,-1,-1); break; } } if (opt->rnxver>2.99&&fprintf(fp,"\n")==EOF) return 0; } - if (obs->flag == 5 && epdiff < 0) { + if (flag == 5 && epdiff < 0) { outrinexevent(fp, opt, obs, epdiff); } diff --git a/src/rtklib.h b/src/rtklib.h index f2307fb..6d0f261 100644 --- a/src/rtklib.h +++ b/src/rtklib.h @@ -349,6 +349,9 @@ extern "C" { #define PMODE_PPP_STATIC 8 /* positioning mode: PPP-static */ #define PMODE_PPP_FIXED 9 /* positioning mode: PPP-fixed */ +#define SOLT_XYZ 0 /* solution type: x/y/z-ecef */ +#define SOLT_ENU 1 /* solution type: e/n/u-baseline */ + #define SOLF_LLH 0 /* solution format: lat/lon/height */ #define SOLF_XYZ 1 /* solution format: x/y/z-ecef */ #define SOLF_ENU 2 /* solution format: e/n/u-baseline */ @@ -545,6 +548,8 @@ typedef struct { /* time struct */ typedef struct { /* observation data record */ gtime_t time; /* receiver sampling time (GPST) */ + gtime_t eventime; /* time of event (GPST) */ + int timevalid; /* time is valid (Valid GNSS fix) for time mark */ unsigned char sat,rcv; /* satellite/receiver number */ unsigned char SNR [NFREQ+NEXOBS]; /* signal strength (0.25 dBHz) */ unsigned char LLI [NFREQ+NEXOBS]; /* loss of lock indicator */ @@ -557,12 +562,10 @@ typedef struct { /* observation data record */ } obsd_t; typedef struct { /* observation data */ - gtime_t eventime; /* time of event (GPST) */ - int timevalid; /* time is valid (Valid GNSS fix) for time mark */ + int n,nmax; /* number of obervation data/allocated */ int flag; /* epoch flag (0:ok,1:power failure,>1:event flag) */ int rcvcount; /* count of rcv event */ int tmcount; /* time mark count */ - int n,nmax; /* number of obervation data/allocated */ obsd_t *data; /* observation data records */ } obs_t; @@ -931,6 +934,7 @@ typedef struct { /* station parameter type */ typedef struct { /* solution type */ gtime_t time; /* time (GPST) */ + gtime_t eventime; /* time of event (GPST) */ double rr[6]; /* position/velocity (m|m/s) */ /* {x,y,z,vx,vy,vz} or {e,n,u,ve,vn,vu} */ float qr[6]; /* position variance/covariance (m^2) */ @@ -1613,7 +1617,7 @@ EXPORT int readrnxt(const char *file, int rcv, gtime_t ts, gtime_t te, sta_t *sta); EXPORT int readrnxc(const char *file, nav_t *nav); EXPORT int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav); -EXPORT int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obs_t *obs); +EXPORT int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obsd_t *obsd, int n, int flag); EXPORT int outrnxnavh (FILE *fp, const rnxopt_t *opt, const nav_t *nav); EXPORT int outrnxgnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav); EXPORT int outrnxhnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav); -- GitLab