Skip to content

Commit

Permalink
Merge pull request #504 from ourairquality/lli-defines
Browse files Browse the repository at this point in the history
Use LLI defines rather than baked in constants
  • Loading branch information
rtklibexplorer authored Nov 4, 2024
2 parents 7282f07 + 798b8a4 commit aa79681
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,11 @@ static void detslp_ll(rtk_t *rtk, const obsd_t *obs, int n)
trace(3,"detslp_ll: n=%d\n",n);

for (i=0;i<n&&i<MAXOBS;i++) for (j=0;j<rtk->opt.nf;j++) {
if (obs[i].L[j]==0.0||!(obs[i].LLI[j]&3)) continue;
if (obs[i].L[j]==0.0||!(obs[i].LLI[j]&(LLI_SLIP|LLI_HALFC))) continue;

trace(3,"detslp_ll: slip detected sat=%2d f=%d\n",obs[i].sat,j+1);

rtk->ssat[obs[i].sat-1].slip[j<nf?j:nf]=1;
rtk->ssat[obs[i].sat-1].slip[j<nf?j:nf]=LLI_SLIP;
}
}
/* detect cycle slip by geometry free phase jump -----------------------------*/
Expand All @@ -487,7 +487,7 @@ static void detslp_gf(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
trace(3,"detslip_gf: slip detected sat=%2d gf=%8.3f->%8.3f\n",
obs[i].sat,g0,g1);

for (j=0;j<rtk->opt.nf;j++) rtk->ssat[obs[i].sat-1].slip[j]|=1;
for (j=0;j<rtk->opt.nf;j++) rtk->ssat[obs[i].sat-1].slip[j]|=LLI_SLIP;
}
}
}
Expand All @@ -511,7 +511,7 @@ static void detslp_mw(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
trace(3,"detslip_mw: slip detected sat=%2d mw=%8.3f->%8.3f\n",
obs[i].sat,w0,w1);

for (j=0;j<rtk->opt.nf;j++) rtk->ssat[obs[i].sat-1].slip[j]|=1;
for (j=0;j<rtk->opt.nf;j++) rtk->ssat[obs[i].sat-1].slip[j]|=LLI_SLIP;
}
}
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ static void update_stat(rtk_t *rtk, const obsd_t *obs, int n, int stat)
rtk->ssat[obs[i].sat-1].snr_base[j] =0;
}
for (i=0;i<MAXSAT;i++) for (j=0;j<opt->nf;j++) {
if (rtk->ssat[i].slip[j]&3) rtk->ssat[i].slipc[j]++;
if (rtk->ssat[i].slip[j]&(LLI_SLIP|LLI_HALFC)) rtk->ssat[i].slipc[j]++;
if (rtk->ssat[i].fix[j]==2&&stat!=SOLQ_FIX) rtk->ssat[i].fix[j]=1;
}
}
Expand Down
33 changes: 17 additions & 16 deletions src/rtkpos.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ extern int rtkoutstat(rtk_t *rtk, int level, char *buff)
p+=sprintf(p,"$SAT,%d,%.3f,%s,%d,%.1f,%.1f,%.4f,%.4f,%d,%.0f,%d,%d,%d,%u,%u,%u,%.2f,%.6f,%.5f\n",
week,tow,id,j+1,ssat->azel[0]*R2D,ssat->azel[1]*R2D,
ssat->resp[j],ssat->resc[j],ssat->vsat[j],ssat->snr_rover[j]*SNR_UNIT,
ssat->fix[j],ssat->slip[j]&3,ssat->lock[j],ssat->outc[j],
ssat->fix[j],ssat->slip[j]&(LLI_SLIP|LLI_HALFC),ssat->lock[j],ssat->outc[j],
ssat->slipc[j],ssat->rejc[j],k<rtk->nx?rtk->x[k]:0,
k<rtk->nx?rtk->P[k+k*rtk->nx]:0,ssat->icbias[j]);
}
Expand Down Expand Up @@ -667,32 +667,33 @@ static void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv)

/* detect slip by cycle slip flag in LLI */
if (rtk->tt>=0.0) { /* forward */
if (obs[i].LLI[f]&1) {
if (obs[i].LLI[f]&LLI_SLIP) {
errmsg(rtk,"slip detected forward (sat=%2d rcv=%d F=%d LLI=%x)\n",
sat,rcv,f+1,obs[i].LLI[f]);
}
slip=obs[i].LLI[f];
}
else { /* backward */
if (LLI&1) {
if (LLI&LLI_SLIP) {
errmsg(rtk,"slip detected backward (sat=%2d rcv=%d F=%d LLI=%x)\n",
sat,rcv,f+1,LLI);
}
slip=LLI;
}
/* detect slip by parity unknown flag transition in LLI */
if (((LLI&2)&&!(obs[i].LLI[f]&2))||(!(LLI&2)&&(obs[i].LLI[f]&2))) {
if (((LLI&LLI_HALFC)&&!(obs[i].LLI[f]&LLI_HALFC))||
(!(LLI&LLI_HALFC)&&(obs[i].LLI[f]&LLI_HALFC))) {
errmsg(rtk,"slip detected half-cyc (sat=%2d rcv=%d F=%d LLI=%x->%x)\n",
sat,rcv,f+1,LLI,obs[i].LLI[f]);
slip|=1;
slip|=LLI_SLIP;
}
/* save current LLI */
if (rcv==1) setbitu(&rtk->ssat[sat-1].slip[f],0,2,obs[i].LLI[f]);
else setbitu(&rtk->ssat[sat-1].slip[f],2,2,obs[i].LLI[f]);

/* save slip and half-cycle valid flag */
rtk->ssat[sat-1].slip[f]|=(uint8_t)slip;
rtk->ssat[sat-1].half[f]=(obs[i].LLI[f]&2)?0:1;
rtk->ssat[sat-1].half[f]=(obs[i].LLI[f]&LLI_HALFC)?0:1;
}
}
/* detect cycle slip by geometry free phase jump -----------------------------*/
Expand All @@ -707,7 +708,7 @@ static void detslp_gf(rtk_t *rtk, const obsd_t *obs, int i, int j,
/* skip check if slip already detected or check disabled*/
if (rtk->opt.thresslip==0) return;
for (k=0;k<rtk->opt.nf;k++)
if (rtk->ssat[sat-1].slip[k]&1) return;
if (rtk->ssat[sat-1].slip[k]&LLI_SLIP) return;

for (k=1;k<rtk->opt.nf;k++) {
/* calc SD geomotry free LC of phase between freq0 and freqk */
Expand All @@ -717,8 +718,8 @@ static void detslp_gf(rtk_t *rtk, const obsd_t *obs, int i, int j,
rtk->ssat[sat-1].gf[k-1]=gf1; /* save current gf for next epoch */

if (gf0!=0.0&&fabs(gf1-gf0)>rtk->opt.thresslip) {
rtk->ssat[sat-1].slip[0]|=1;
rtk->ssat[sat-1].slip[k]|=1;
rtk->ssat[sat-1].slip[0]|=LLI_SLIP;
rtk->ssat[sat-1].slip[k]|=LLI_SLIP;
errmsg(rtk,"slip detected GF jump (sat=%2d L1-L%d dGF=%.3f)\n",
sat,k+1,gf0-gf1);
}
Expand Down Expand Up @@ -768,7 +769,7 @@ static void detslp_dop(rtk_t *rtk, const obsd_t *obs, const int *ix, int ns,
for (f=0;f<nf;f++) {
if (dopdif[i][f]==0.00) continue;
if (fabs(dopdif[i][f]-mean_dop)>rtk->opt.thresdop) {
rtk->ssat[sat-1].slip[f]|=1;
rtk->ssat[sat-1].slip[f]|=LLI_SLIP;
errmsg(rtk,"slip detected doppler (sat=%2d rcv=%d dL%d=%.3f off=%.3f tt=%.2f)\n",
sat,rcv,f+1,dopdif[i][f]-mean_dop,mean_dop,tt[i][f]);
}
Expand Down Expand Up @@ -804,7 +805,7 @@ static void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat,
/* update half-cycle valid flag */
for (k=0;k<nf;k++) {
rtk->ssat[sat[i]-1].half[k]=
!((obs[iu[i]].LLI[k]&2)||(obs[ir[i]].LLI[k]&2));
!((obs[iu[i]].LLI[k]&LLI_HALFC)||(obs[ir[i]].LLI[k]&LLI_HALFC));
}
}
for (k=0;k<nf;k++) {
Expand Down Expand Up @@ -836,7 +837,7 @@ static void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat,
f2=seliflc(rtk->opt.nf,rtk->ssat[sat[i]-1].sys);
slip|=rtk->ssat[sat[i]-1].slip[f2];
}
if (rtk->opt.modear==ARMODE_INST||(!(slip&1)&&rejc<2)) continue;
if (rtk->opt.modear==ARMODE_INST||(!(slip&LLI_SLIP)&&rejc<2)) continue;
/* reset phase-bias state if detecting cycle slip or outlier */
rtk->x[j]=0.0;
rtk->ssat[sat[i]-1].rejc[k]=0;
Expand Down Expand Up @@ -1481,7 +1482,7 @@ static int ddidx(rtk_t *rtk, int *ix, int gps, int glo, int sbs)
continue;
}
/* set sat to use for fixing ambiguity if meets criteria */
if (rtk->ssat[i-k].lock[f]>=0&&!(rtk->ssat[i-k].slip[f]&2)&&
if (rtk->ssat[i-k].lock[f]>=0&&!(rtk->ssat[i-k].slip[f]&LLI_HALFC)&&
rtk->ssat[i-k].azel[1]>=rtk->opt.elmaskar&&!nofix) {
rtk->ssat[i-k].fix[f]=2; /* fix */
break;/* break out of loop if find good sat */
Expand All @@ -1497,7 +1498,7 @@ static int ddidx(rtk_t *rtk, int *ix, int gps, int glo, int sbs)
continue;
}
if (sbs==0 && satsys(j-k+1,NULL)==SYS_SBS) continue;
if (rtk->ssat[j-k].lock[f]>=0&&!(rtk->ssat[j-k].slip[f]&2)&&
if (rtk->ssat[j-k].lock[f]>=0&&!(rtk->ssat[j-k].slip[f]&LLI_HALFC)&&
rtk->ssat[j-k].vsat[f]&&
rtk->ssat[j-k].azel[1]>=rtk->opt.elmaskar&&!nofix) {
/* set D coeffs to subtract sat j from sat i */
Expand Down Expand Up @@ -2147,8 +2148,8 @@ static int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr,
for (i=0;i<MAXSAT;i++) for (j=0;j<nf;j++) {
/* Don't lose track of which sats were used to try and resolve the ambiguities */
/* if (rtk->ssat[i].fix[j]==2&&stat!=SOLQ_FIX) rtk->ssat[i].fix[j]=1; */
if (rtk->ssat[i].slip[j]&1) rtk->ssat[i].slipc[j]++;
/* inc lock count if this sat used for good fix */
if (rtk->ssat[i].slip[j]&LLI_SLIP) rtk->ssat[i].slipc[j]++;
/* Inc lock count if this sat used for good fix */
if (!rtk->ssat[i].vsat[j]) continue;
if (rtk->ssat[i].lock[j]<0||(rtk->nfix>0&&rtk->ssat[i].fix[j]>=2))
rtk->ssat[i].lock[j]++;
Expand Down

0 comments on commit aa79681

Please sign in to comment.