// read observation data ---------------------------------------------------- void __fastcall TPlot::ReadObs(TStrings *files) { obs_t obs={0}; nav_t nav={0}; sta_t sta={0}; AnsiString s; char file[1024]; int i,nobs; trace(3,"ReadObs\n"); if (files->Count<=0) return; ReadWaitStart(); ShowLegend(NULL); if ((nobs=ReadObsRnx(files,&obs,&nav,&sta))<=0) { ReadWaitEnd(); return; } ClearObs(); Obs=obs; Nav=nav; Sta=sta; SimObs=0; UpdateObs(nobs); UpdateMp(); if (ObsFiles!=files) { ObsFiles->Assign(files); } NavFiles->Clear(); strcpy(file,U2A(files->Strings[0]).c_str()); Caption=s.sprintf("%s%s",file,files->Count>1?"...":""); BtnSol1->Down=true; time2gpst(Obs.data[0].time,&Week); SolIndex[0]=SolIndex[1]=ObsIndex=0; if (PlotType<PLOT_OBS||PLOT_DOP<PlotType) { UpdateType(PLOT_OBS); } else { UpdatePlotType(); } FitTime(); ReadWaitEnd(); UpdateObsType(); UpdateTime(); UpdatePlot(); }
// read solutions ----------------------------------------------------------- void __fastcall TPlot::ReadSol(TStrings *files, int sel) { solbuf_t sol={0}; AnsiString s; gtime_t ts,te; double tint; int i,n=0; char *paths[MAXNFILE]={""}; trace(3,"ReadSol: sel=%d\n",sel); if (files->Count<=0) return; ReadWaitStart(); for (i=0;i<files->Count&&n<MAXNFILE;i++) { paths[n++]=files->Strings[i].c_str(); } TimeSpan(&ts,&te,&tint); ShowMsg(s.sprintf("reading %s...",paths[0])); ShowLegend(NULL); if (!readsolt(paths,n,ts,te,tint,0,&sol)) { ShowMsg(s.sprintf("no solution data : %s...",paths[0])); ShowLegend(NULL); ReadWaitEnd(); return; } freesolbuf(SolData+sel); SolData[sel]=sol; if (SolFiles[sel]!=files) { SolFiles[sel]->Assign(files); } Caption=""; ReadSolStat(files,sel); for (i=0;i<2;i++) { if (SolFiles[i]->Count==0) continue; Caption=Caption+SolFiles[i]->Strings[0]+(SolFiles[i]->Count>1?"... ":" "); } BtnSol12->Down=False; if (sel==0) BtnSol1->Down=true; else BtnSol2->Down=true; if (sel==0||SolData[0].n<=0) { time2gpst(SolData[sel].data[0].time,&Week); UpdateOrigin(); } SolIndex[0]=SolIndex[1]=ObsIndex=0; if (PlotType>PLOT_NSAT) { UpdateType(PLOT_TRK); } else { UpdatePlotType(); } FitTime(); if (AutoScale&&PlotType<=PLOT_SOLA) { FitRange(1); } else { SetRange(1,YRange); } UpdateTime(); UpdatePlot(); ReadWaitEnd(); }
// generate visibility data ---------------------------------------------------- void __fastcall TPlot::GenVisData(void) { gtime_t time,ts,te; obsd_t data={{0}}; sta_t sta={0}; double tint,r,pos[3],rr[3],rs[6],e[3],azel[2]; int i,j,nobs=0; char name[16]; trace(3,"GenVisData\n"); ClearObs(); SimObs=1; ts=TimeStart; te=TimeEnd; tint=TimeInt; matcpy(pos,OOPos,3,1); pos2ecef(pos,rr); ReadWaitStart(); ShowLegend(NULL); ShowMsg("generating satellite visibility..."); Application->ProcessMessages(); for (time=ts;timediff(time,te)<=0.0;time=timeadd(time,tint)) { for (i=0;i<MAXSAT;i++) { satno2id(i+1,name); if (!tle_pos(time,name,"","",&TLEData,NULL,rs)) continue; if ((r=geodist(rs,rr,e))<=0.0) continue; if (satazel(pos,e,azel)<=0.0) continue; if (Obs.n>=Obs.nmax) { Obs.nmax=Obs.nmax<=0?4096:Obs.nmax*2; Obs.data=(obsd_t *)realloc(Obs.data,sizeof(obsd_t)*Obs.nmax); if (!Obs.data) { Obs.n=Obs.nmax=0; break; } } data.time=time; data.sat=i+1; for (j=0;j<NFREQ;j++) { data.P[j]=data.L[j]=0.0; data.code[j]=CODE_NONE; } data.code[0]=CODE_L1C; Obs.data[Obs.n++]=data; } if (++nobs>=MAX_SIMOBS) break; } if (Obs.n<=0) { ReadWaitEnd(); ShowMsg("no satellite visibility"); return; } UpdateObs(nobs); Caption="Satellite Visibility (Predicted)"; BtnSol1->Down=true; time2gpst(Obs.data[0].time,&Week); SolIndex[0]=SolIndex[1]=ObsIndex=0; if (PlotType<PLOT_OBS||PLOT_DOP<PlotType) { UpdateType(PLOT_OBS); } else { UpdatePlotType(); } FitTime(); ReadWaitEnd(); UpdateObsType(); UpdateTime(); UpdatePlot(); }