Changeset 6329 in ntrip


Ignore:
Timestamp:
Nov 20, 2014, 2:07:01 PM (9 years ago)
Author:
stoecker
Message:

support type 1043 sbas ephemeris

Location:
trunk/rtcm3torinex/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/rtcm3torinex/lib/rtcm3torinex.c

    r5660 r6329  
    446446        ge->TOW = 0.9999E9;
    447447        ret = 1019;
     448      }
     449      break;
     450    case 1043:
     451      if(handle->GPSWeek)
     452      {
     453        struct sbasephemeris *gs;
     454        int sv, i, time, tod, day;
     455        gs = &handle->ephemerisSBAS;
     456        memset(gs, 0, sizeof(*gs));
     457
     458        GETBITS(sv, 6)
     459        gs->satellite = PRN_SBAS_START+sv;
     460        GETBITS(gs->IODN, 8)
     461        GETBITS(time, 13)
     462        time <<= 4;
     463        gs->GPSweek_TOE = handle->GPSWeek;
     464        GETBITS(gs->URA, 4)
     465        GETFLOATSIGN(gs->x_pos, 30, 0.08)
     466        GETFLOATSIGN(gs->y_pos, 30, 0.08)
     467        GETFLOATSIGN(gs->z_pos, 25, 0.4)
     468        GETFLOATSIGN(gs->x_velocity, 17, 0.000625)
     469        GETFLOATSIGN(gs->y_velocity, 17, 0.000625)
     470        GETFLOATSIGN(gs->z_velocity, 18, 0.004)
     471        GETFLOATSIGN(gs->x_acceleration, 10, 0.0000125)
     472        GETFLOATSIGN(gs->y_acceleration, 10, 0.0000125)
     473        GETFLOATSIGN(gs->z_acceleration, 10, 0.0000625)
     474        GETFLOATSIGN(gs->agf0, 12, 1.0/(1<<30)/(1<<1))
     475        GETFLOATSIGN(gs->agf1, 8, 1.0/(1<<30)/(1<<10))
     476
     477        /* calculate time */
     478        tod = handle->GPSTOW%(24*60*60);
     479        day = handle->GPSTOW/(24*60*60);
     480        if(time > 19*60*60 && tod < 5*60*60)
     481          --day;
     482        else if(time < 5*60*60 && tod > 19*60*60)
     483          ++day;
     484        time += day*24*60*60;
     485        if(time > 7*24*60*60)
     486          ++gs->GPSweek_TOE;
     487        else if(time < 0)
     488          --gs->GPSweek_TOE;
     489        gs->TOE = time;
     490
     491        i = (gs->GPSweek_TOE - handle->GPSWeek)*7*24*60*60
     492        + (gs->TOE - handle->GPSTOW) - 2*60*60;
     493        if(i > 5*60*60 && i < 8*60*60)
     494        {
     495          handle->GPSTOW = gs->TOE;
     496          handle->GPSWeek = gs->GPSweek_TOE;
     497        }
     498        gs->TOW = 0.9999E9;
     499        ret = 1043;
    448500      }
    449501      break;
     
    24892541    while((r = RTCM3Parser(Parser)))
    24902542    {
    2491       if(r == 1020 || r == 1019 || r == 1044)
     2543      if(r == 1020 || r == 1019 || r == 1044 || r == 1043)
    24922544      {
    24932545        FILE *file = 0;
     
    25142566            Parser->gpsephemeris = 0;
    25152567            Parser->glonassephemeris = 0;
     2568            Parser->sbasephemeris = 0;
    25162569            file = Parser->gpsfile;
    25172570          }
     
    25592612            file = Parser->gpsfile;
    25602613          }
     2614          else if(r == 1043)
     2615          {
     2616            if(Parser->sbasephemeris)
     2617            {
     2618              if(!(Parser->sbasfile = fopen(Parser->sbasephemeris, "w")))
     2619              {
     2620                RTCM3Error("Could not open SBAS ephemeris output file.\n");
     2621              }
     2622              else
     2623              {
     2624                char buffer[100];
     2625                fprintf(Parser->sbasfile,
     2626                "%9.2f%11sN: SBAS NAV DATA%24sRINEX VERSION / TYPE\n", 2.1, "", "");
     2627                HandleRunBy(buffer, sizeof(buffer), 0, Parser->rinex3);
     2628                fprintf(Parser->sbasfile, "%s\n%60sEND OF HEADER\n", buffer, "");
     2629              }
     2630              Parser->sbasephemeris = 0;
     2631            }
     2632            file = Parser->sbasfile;
     2633          }
    25612634          else if(r == 1044)
    25622635          {
     
    25822655        if(file)
    25832656        {
     2657          const char *sep = "   ";
    25842658          if(r == 1020)
    25852659          {
     
    25942668
    25952669            if(Parser->rinex3)
     2670            {
    25962671              ConvLine(file, "R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
    25972672              e->almanac_number, cti.year, cti.month, cti.day, cti.hour, cti.minute,
    25982673              cti.second, -e->tau, e->gamma, (double) i);
     2674              sep = "    ";
     2675            }
    25992676            else
     2677            {
    26002678              ConvLine(file, "%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
    26012679              e->almanac_number, cti.year%100, cti.month, cti.day, cti.hour, cti.minute,
    26022680              (double) cti.second, -e->tau, e->gamma, (double) i);
    2603             ConvLine(file, "   %19.12e%19.12e%19.12e%19.12e\n", e->x_pos,
     2681            }
     2682            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->x_pos,
    26042683            e->x_velocity, e->x_acceleration, (e->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
    2605             ConvLine(file, "   %19.12e%19.12e%19.12e%19.12e\n", e->y_pos,
     2684            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->y_pos,
    26062685            e->y_velocity, e->y_acceleration, (double) e->frequency_number);
    2607             ConvLine(file, "   %19.12e%19.12e%19.12e%19.12e\n", e->z_pos,
     2686            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->z_pos,
    26082687            e->z_velocity, e->z_acceleration, (double) e->E);
     2688          }
     2689          else if(r == 1043)
     2690          {
     2691            struct sbasephemeris *e = &Parser->ephemerisSBAS;
     2692            struct converttimeinfo cti;
     2693            converttime(&cti, e->GPSweek_TOE, e->TOE);
     2694            if(Parser->rinex3)
     2695            {
     2696              ConvLine(file, "S%02d %04d %2d %2d %2d %2d %2d%19.12e%19.12e%19.12e\n",
     2697              e->satellite-100, cti.year, cti.month, cti.day, cti.hour, cti.minute,
     2698              cti.second, e->agf0, e->agf1, (double)e->TOW);
     2699              sep = "    ";
     2700            }
     2701            else
     2702            {
     2703              ConvLine(file, "%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
     2704              e->satellite-100, cti.year%100, cti.month, cti.day, cti.hour, cti.minute,
     2705              (double)cti.second, e->agf0, e->agf1, (double)e->TOW);
     2706            }
     2707            /* X, health */
     2708            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->x_pos,
     2709            e->x_velocity, e->x_acceleration, e->URA == 15 ? 1.0 : 0.0);
     2710            /* Y, accuracy */
     2711            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->y_pos,
     2712            e->y_velocity, e->y_acceleration, (double)e->URA);
     2713            /* Z */
     2714            ConvLine(file, "%s%19.12e%19.12e%19.12e%19.12e\n", sep, e->z_pos,
     2715            e->z_velocity, e->z_acceleration, (double)e->IODN);
    26092716          }
    26102717          else /* if(r == 1019 || r == 1044) */
     
    26152722            struct converttimeinfo cti;
    26162723            converttime(&cti, e->GPSweek, e->TOC);
    2617             const char *sep = "   ";
    26182724            int qzss = 0;
    26192725            int num = e->satellite;
     
    32593365  const char *data;
    32603366  const char *headerfile;
     3367  const char *sbasephemeris;
    32613368  const char *gpsephemeris;
    32623369  const char *qzssephemeris;
     
    32803387{ "qzssephemeris",    required_argument, 0, 'Q'},
    32813388{ "glonassephemeris", required_argument, 0, 'G'},
     3389{ "sbasephemeris",    required_argument, 0, 'B'},
    32823390{ "rinex3",           no_argument,       0, '3'},
    32833391{ "changeobs",        no_argument,       0, 'O'},
     
    32893397{0,0,0,0}};
    32903398#endif
    3291 #define ARGOPT "-d:s:p:r:t:f:u:E:G:Q:M:S:R:n:h3O"
     3399#define ARGOPT "-d:s:p:r:t:f:u:E:G:B:Q:M:S:R:n:h3O"
    32923400
    32933401enum MODE { HTTP = 1, RTSP = 2, NTRIP1 = 3, AUTO = 4, END };
     
    34203528  args->gpsephemeris = 0;
    34213529  args->qzssephemeris = 0;
     3530  args->sbasephemeris = 0;
    34223531  args->glonassephemeris = 0;
    34233532  args->rinex3 = 0;
     
    34443553    case 'f': args->headerfile = optarg; break;
    34453554    case 'E': args->gpsephemeris = optarg; break;
     3555    case 'B': args->sbasephemeris = optarg; break;
    34463556    case 'G': args->glonassephemeris = optarg; break;
    34473557    case 'Q': args->qzssephemeris = optarg; break;
     
    35213631    " -G " LONG_OPT("--glonassephemeris ") "output file for GLONASS ephemeris data\n"
    35223632    " -Q " LONG_OPT("--qzssephemeris    ") "output file for QZSS ephemeris data\n"
     3633    " -B " LONG_OPT("--sbasephemeris    ") "output file for SBAS ephemeris data\n"
    35233634    " -3 " LONG_OPT("--rinex3           ") "output RINEX type 3 data\n"
    35243635    " -S " LONG_OPT("--proxyhost        ") "proxy name or address\n"
     
    36263737    Parser.gpsephemeris = args.gpsephemeris;
    36273738    Parser.qzssephemeris = args.qzssephemeris;
     3739    Parser.sbasephemeris = args.sbasephemeris;
    36283740    Parser.rinex3 = args.rinex3;
    36293741    Parser.changeobs = args.changeobs;
  • trunk/rtcm3torinex/lib/rtcm3torinex.h

    r5674 r6329  
    401401};
    402402
     403struct sbasephemeris {
     404  int    satellite;
     405  int    IODN;             /*          [bits  14- 21] */
     406  int    GPSweek_TOE;
     407  int    TOW;
     408  int    TOE;              /*  [s]     [bits  22- 34] */
     409  double agf0;             /*  [s]     [bits 206-217] */
     410  double agf1;             /*  [s/s]   [bits 218-225] */
     411  double x_pos;            /*  [km]    [bits  39- 68] */
     412  double x_velocity;       /*  [km/s]  [bits 124-140] */
     413  double x_acceleration;   /*  [km/s^2][bits 176-185] */
     414  double y_pos;            /*  [km]    [bits  69- 98] */
     415  double y_velocity;       /*  [km/s]  [bits 141-157] */
     416  double y_acceleration;   /*  [km/s^2][bits 186-195] */
     417  double z_pos;            /*  [km]    [bits  99-123] */
     418  double z_velocity;       /*  [km/s]  [bits 158-175] */
     419  double z_acceleration;   /*  [km/s^2][bits 196-205] */
     420  int    URA;              /*          [bits  35- 38] */
     421};
     422
    403423struct galileoephemeris {
    404424  int    flags;            /* GALEPHF_xxx */
     
    451471  struct galileoephemeris ephemerisGALILEO;
    452472  struct glonassephemeris ephemerisGLONASS;
     473  struct sbasephemeris ephemerisSBAS;
    453474  struct gnssdata DataNew;
    454475  int    GLOFreq[PRN_GLONASS_NUM]; /* frequency numbers of GLONASS + 100 */
     
    493514  const char * gpsephemeris;
    494515  const char * qzssephemeris;
     516  const char * sbasephemeris;
    495517  FILE *       glonassfile;
    496518  FILE *       gpsfile;
    497519  FILE *       qzssfile;
     520  FILE *       sbasfile;
    498521};
    499522
Note: See TracChangeset for help on using the changeset viewer.