Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convrnx: reinitialize the raw state between passes #454

Open
wants to merge 1 commit into
base: demo5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 61 additions & 19 deletions src/convrnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,23 +697,24 @@ static void resolve_halfc(const strfile_t *str, obsd_t *data, int n)
halfc_t *p;
int i,j,sat;

for (i=0;i<n;i++) for (j=0;j<NFREQ+NEXOBS;j++) {
for (i=0;i<n;i++) {
sat=data[i].sat;

for (p=str->halfc[sat-1][j];p;p=p->next) {
if (p->stat<=1) continue; /* unresolved half cycle */
if (timediff(data[i].time,p->ts)<-DTTOL||
timediff(data[i].time,p->te)> DTTOL) continue;
for (j=0;j<NFREQ+NEXOBS;j++) {
for (p=str->halfc[sat-1][j];p;p=p->next) {
if (p->stat<=1) continue; /* unresolved half cycle */
if (timediff(data[i].time,p->ts)<-DTTOL||
timediff(data[i].time,p->te)> DTTOL) continue;

if (p->stat==2) { /* add half cycle */
data[i].L[j]+=0.5;
}
else if (p->stat==3) { /* subtract half cycle */
data[i].L[j]-=0.5;
if (p->stat==2) { /* add half cycle */
data[i].L[j]+=0.5;
}
else if (p->stat==3) { /* subtract half cycle */
data[i].L[j]-=0.5;
}
data[i].LLI[j]&=~LLI_HALFC;
}
data[i].LLI[j]&=~LLI_HALFC;
data[i].LLI[j]&=~(LLI_HALFA|LLI_HALFS);
}
data[i].LLI[j]&=~(LLI_HALFA|LLI_HALFS);
}
}
/* scan input files ----------------------------------------------------------*/
Expand Down Expand Up @@ -1019,15 +1020,17 @@ static void convobs(FILE **ofp, rnxopt_t *opt, strfile_t *str, int *n,

if (*staid>=0) { /* output RINEX event */
outrnxevent(ofp[0],opt,str->time,EVENT_NEWSITE,str->stas,str->staid);
/* Set cycle slips */
for (i=0;i<str->obs->n;i++) {
for (j=0;j<NFREQ+NEXOBS;j++) {
if (str->obs->data[i].L[j]!=0.0) {
str->obs->data[i].LLI[j]|=LLI_SLIP;
}
}
}
}
*staid=str->staid;

/* set cycle slips */
for (i=0;i<str->obs->n;i++) for (j=0;j<NFREQ+NEXOBS;j++) {
if (str->obs->data[i].L[j]!=0.0) {
str->obs->data[i].LLI[j]|=LLI_SLIP;
}
}
}
/* resolve half-cycle ambiguity */
if (opt->halfcyc) {
Expand Down Expand Up @@ -1306,6 +1309,45 @@ static int convrnx_s(int sess, int format, rnxopt_t *opt, const char *file,
}
str->time=str->tstart;

// Reinitialize the input state. Don't want decoding state from the
// end of the scanning pass to affect the start of the next pass.
if (str->format == STRFMT_RTCM2 || str->format == STRFMT_RTCM3) {
free_rtcm(&str->rtcm);
if (!init_rtcm(&str->rtcm)) {
showmsg("init rtcm error");
for (int i = 0; i < MAXEXFILE; i++) free(epath[i]);
free_strfile(str);
return 0;
}
strcpy(str->rtcm.opt, opt->rcvopt);
} else if (str->format <= MAXRCVFMT) {
free_raw(&str->raw);
if (!init_raw(&str->raw, str->format)) {
showmsg("reinit raw error");
for (int i = 0; i < MAXEXFILE; i++) free(epath[i]);
free_strfile(str);
return 0;
}
strcpy(str->raw.opt, opt->rcvopt);
} else if (format == STRFMT_RINEX) {
free_rnxctr(&str->rnx);
if (!init_rnxctr(&str->rnx)) {
showmsg("reinit rnx error");
for (int i = 0; i < MAXEXFILE; i++) free(epath[i]);
free_strfile(str);
return 0;
}
strcpy(str->rnx.opt, opt->rcvopt);
}

// Don't want saved slips from the scanning pass to be flagged at
// the start of the next pass. But do want to retain the halfc data.
for (int i = 0; i < MAXSAT; i++) {
for (int j = 0; j < NFREQ + NEXOBS; j++) {
str->slips[i][j] = 0;
}
}

for (i=0;i<nf&&!abort;i++) {
if (!mask[i]) continue;

Expand Down
1 change: 1 addition & 0 deletions src/rcvraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ extern int init_raw(raw_t *raw, int format)
raw->tobs [i][j]=time0;
raw->lockt[i][j]=0.0;
raw->halfc[i][j]=0;
raw->lockflag[i][j]=0;
}
raw->icpp[i]=raw->off[i]=raw->prCA[i]=raw->dpCA[i]=0.0;
}
Expand Down