Beispiel #1
0
// get number of satellites, age and ratio from solutions -------------------
TIMEPOS * __fastcall TPlot::SolToNsat(solbuf_t *sol, int index, int qflag)
{
    TIMEPOS *ns;
    sol_t *data;
    int i;
    
    trace(3,"SolToNsat: n=%d\n",sol->n);
    
    ns=new TIMEPOS(index<0?sol->n:3,1);
    
    for (i=index<0?0:index;data=getsol(sol,i);i++) {
        
        if (qflag&&data->stat!=qflag) continue;
        
        ns->t[ns->n]=data->time;
        ns->x[ns->n]=data->ns;
        ns->y[ns->n]=data->age;
        ns->z[ns->n]=data->ratio;
        ns->q[ns->n]=data->stat;
        ns->n++;
        
        if (index>=0&&i>=2) break;
    }
    return ns;
}
Beispiel #2
0
// get current cursor position ----------------------------------------------
int __fastcall TPlot::GetCurrentPos(double *rr)
{
    sol_t *data;
    int i,sel=!BtnSol1->Down&&BtnSol2->Down?1:0;
    
    trace(3,"GetCurrentPos\n");
    
    if (PLOT_OBS<=PlotType&&PlotType<=PLOT_DOP) return 0;
    if (!(data=getsol(SolData+sel,SolIndex[sel]))) return 0;
    if (data->type) return 0;
    for (i=0;i<3;i++) rr[i]=data->rr[i];
    return 1;
}
Beispiel #3
0
// update time-information for solution plot --------------------------------
void __fastcall TPlot::UpdateTimeSol(void)
{
    const char *unit[]={"m","m/s","m/s2"},*u;
    const char *sol[]={"","FIX","FLOAT","SBAS","DGPS","Single","PPP"};
    AnsiString msg,msgs[8],s;
    sol_t *data;
    double xyz[3],pos[3],r,az,el;
    int sel=BtnSol1->Down||!BtnSol2->Down?0:1,ind=SolIndex[sel];
    char tstr[64];
    
    trace(3,"UpdateTimeSol\n");
    
    if ((BtnSol1->Down||BtnSol2->Down||BtnSol12->Down)&&
        (data=getsol(SolData+sel,ind))) {
        
        if (!ConnectState) msg.sprintf("[%d]",sel+1); else msg="[R]";
        
        TimeStr(data->time,2,1,tstr);
        msg+=tstr;
        msg+=" : ";
        
        if (PLOT_SOLP<=PlotType&&PlotType<=PLOT_SOLA) {
            PosToXyz(data->time,data->rr,data->type,xyz);
            u=unit[PlotType-PLOT_SOLP];
            msg+=s.sprintf("E=%7.4f%s N=%7.4f%s U=%7.4f%s Q=",
                           xyz[0],u,xyz[1],u,xyz[2],u);
        }
        else if (PlotType==PLOT_NSAT) {
            msg+=s.sprintf("NS=%d AGE=%.1f RATIO=%.1f Q=",data->ns,data->age,
                           data->ratio);
        }
        else if (!data->type) {
            ecef2pos(data->rr,pos);
            msg+=LatLonStr(pos,9)+s.sprintf(" %9.4fm  Q=",pos[2]);
        }
        else {
            r=norm(data->rr,3);
            az=norm(data->rr,2)<=1E-12?0.0:atan2(data->rr[0],data->rr[1])*R2D;
            el=r<=1E-12?0.0:asin(data->rr[2]/r)*R2D;
            msg+=s.sprintf("B=%.3fm D=%6.2f" CHARDEG " %5.2f" CHARDEG "  Q=",
                           r,az<0.0?az+360.0:az,el);
        }
        if (1<=data->stat&&data->stat<=6) {
            msgs[data->stat-1]=s.sprintf("%d:%s",data->stat,sol[data->stat]);
        }
    }
    ShowMsg(msg);
    ShowLegend(msgs);
}
Beispiel #4
0
// get position, velocity or accel from solutions ---------------------------
TIMEPOS * __fastcall TPlot::SolToPos(solbuf_t *sol, int index, int qflag, int type)
{
    TIMEPOS *pos,*vel,*acc;
    gtime_t ts={0};
    sol_t *data;
    double tint,xyz[3],xyzs[4];
    int i;
    
    trace(3,"SolToPos: n=%d\n",sol->n);
    
    pos=new TIMEPOS(index<0?sol->n:3,1);
    
    if (index>=0) {
        if (type==1&&index>sol->n-2) index=sol->n-2;
        if (type==2&&index>sol->n-3) index=sol->n-3;
    }
    for (i=index<0?0:index;data=getsol(sol,i);i++) {
        
        tint=TimeEna[2]?TimeInt:0.0;
        
        if (index<0&&!screent(data->time,ts,ts,tint)) continue;
        if (qflag&&data->stat!=qflag) continue;
        
        PosToXyz(data->time,data->rr,data->type,xyz);
        CovToXyz(data->rr,data->qr,data->type,xyzs);
        
        pos->t  [pos->n]=data->time;
        pos->x  [pos->n]=xyz [0];
        pos->y  [pos->n]=xyz [1];
        pos->z  [pos->n]=xyz [2];
        pos->xs [pos->n]=xyzs[0]; // var x^2
        pos->ys [pos->n]=xyzs[1]; // var y^2
        pos->zs [pos->n]=xyzs[2]; // var z^2
        pos->xys[pos->n]=xyzs[3]; // cov xy
        pos->q  [pos->n]=data->stat;
        pos->n++;
        
        if (index>=0&&pos->n>=3) break;
    }
    if (type!=1&&type!=2) return pos; // position
    
    vel=pos->tdiff();
    delete pos;
    if (type==1) return vel; // velocity
    
    acc=vel->tdiff();
    delete vel;
    return acc; // acceleration
}
Beispiel #5
0
// search solution by xy-position in plot -----------------------------------
int __fastcall TPlot::SearchPos(int x, int y)
{
    sol_t *data;
    TPoint p(x,y);
    double xp,yp,xs,ys,r,xyz[3];
    int i,sel=!BtnSol1->Down&&BtnSol2->Down?1:0;
    
    trace(3,"SearchPos: x=%d y=%d\n",x,y);
    
    if (!BtnShowTrack->Down||(!BtnSol1->Down&&!BtnSol2->Down)) return -1;
    
    GraphT->ToPos(p,xp,yp);
    GraphT->GetScale(xs,ys);
    r=(MarkSize/2+2)*xs;
    
    for (i=0;data=getsol(SolData+sel,i);i++) {
        if (QFlag->ItemIndex&&data->stat!=QFlag->ItemIndex) continue;
        
        PosToXyz(data->time,data->rr,data->type,xyz);
        
        if (SQR(xp-xyz[0])+SQR(yp-xyz[1])<=SQR(r)) return i;
    }
    return -1;
}
Beispiel #6
0
// update statistics-information for solution plot --------------------------
void __fastcall TPlot::UpdateInfoSol(void)
{
    AnsiString msg,msgs[8],s;
    TIMEPOS *pos=NULL,*pos1,*pos2;
    sol_t *data;
    gtime_t ts={0},te={0};
    double r[3],b,bl[2]={1E9,0.0};
    int i,j,n=0,nq[8]={0},sel=BtnSol1->Down||!BtnSol2->Down?0:1;
    char s1[64],s2[64];
    
    trace(3,"UpdateInfoSol:\n");
    
    if (BtnSol1->Down||BtnSol2->Down) {
        pos=SolToPos(SolData+sel,-1,0,0);
    }
    else if (BtnSol12->Down) {
        pos1=SolToPos(SolData  ,-1,0,0);
        pos2=SolToPos(SolData+1,-1,0,0);
        pos=pos1->diff(pos2,0);
        delete pos1;
        delete pos2;
    }
    if (pos) {
        for (i=0;i<pos->n;i++) {
            if (ts.time==0) ts=pos->t[i]; te=pos->t[i];
            nq[pos->q[i]]++;
            n++; 
        }
        delete pos;
    }
    for (i=0;data=getsol(SolData+sel,i);i++) {
        if (data->type) {
            b=norm(data->rr,3);
        }
        else if (norm(SolData[sel].rb,3)>0.0) {
            for (j=0;j<3;j++) r[j]=data->rr[j]-SolData[sel].rb[j];
            b=norm(r,3);
        }
        else b=0.0;
        if (b<bl[0]) bl[0]=b;
        if (b>bl[1]) bl[1]=b;
    }
    if (n>0) {
        if (!ConnectState) msg.sprintf("[%d]",sel+1); else msg="[R]";
        
        TimeStr(ts,0,0,s1);
        TimeStr(te,0,1,s2);
        msg+=s.sprintf("%s-%s : N=%d",s1,s2+(TimeLabel?5:0),n);
        
        if (bl[0]+100.0<bl[1]) {
            msg+=s.sprintf(" B=%.1f-%.1fkm",bl[0]/1E3,bl[1]/1E3);
        }
        else {
            msg+=s.sprintf(" B=%.1fkm",bl[0]/1E3);
        }
        msg+=" Q=";
        
        for (i=1;i<=6;i++) {
            if (nq[i]<=0) continue;
            msgs[i-1].sprintf("%d:%d(%.1f%%) ",i,nq[i],(double)nq[i]/n*100.0);
        }
    }
    ShowMsg(msg);
    ShowLegend(msgs);
}