Changeset 3255 in ntrip
- Timestamp:
- Apr 3, 2011, 1:18:26 PM (14 years ago)
- Location:
- trunk/BNC
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM3/RTCM3Decoder.cpp
r3008 r3255 446 446 double weekold = 0.0; 447 447 double weeknew = gpseph.GPSweek() + gpseph.GPSweeks() / secPerWeek; 448 if ( _ephList.find(gpseph.prn()) != _ephList.end() ) { 449 weekold = _ephList.find(gpseph.prn())->second.GPSweek() 450 + _ephList.find(gpseph.prn())->second.GPSweeks() / secPerWeek; 448 string prn = gpseph.prn().toAscii().data(); 449 if ( _ephList.find(prn) != _ephList.end() ) { 450 weekold = _ephList.find(prn)->second.GPSweek() 451 + _ephList.find(prn)->second.GPSweeks() / secPerWeek; 451 452 } 452 453 453 454 if ( weeknew - weekold > 1.0/secPerWeek ) { 454 _ephList[ gpseph.prn()] = gpseph;455 _ephList[prn] = gpseph; 455 456 456 457 return true; -
trunk/BNC/RTCM3/ephemeris.cpp
r2771 r3255 14 14 using namespace std; 15 15 16 #define PI 3.1415926535898 17 // Returns nearest integer value 18 //////////////////////////////////////////////////////////////////////////// 19 static double NearestInt(double fl, double * remain) 20 { 21 bool isneg = fl < 0.0; 22 double intval; 23 if(isneg) fl *= -1.0; 24 intval = (double)((unsigned long)(fl+0.5)); 25 if(isneg) {fl *= -1.0; intval *= -1.0;} 26 if(remain) 27 *remain = fl-intval; 28 return intval; 29 } /* NearestInt() */ 30 31 // Returns CRC24 32 //////////////////////////////////////////////////////////////////////////// 33 static unsigned long CRC24(long size, const unsigned char *buf) 34 { 35 unsigned long crc = 0; 36 int i; 37 38 while(size--) 39 { 40 crc ^= (*buf++) << (16); 41 for(i = 0; i < 8; i++) 42 { 43 crc <<= 1; 44 if(crc & 0x1000000) 45 crc ^= 0x01864cfb; 46 } 47 } 48 return crc; 49 } /* CRC24 */ 50 16 51 // 17 52 //////////////////////////////////////////////////////////////////////////// … … 29 64 //////////////////////////////////////////////////////////////////////////// 30 65 void t_ephGPS::set(const gpsephemeris* ee) { 31 ostringstream prn; 32 prn << 'G' << setfill('0') << setw(2) << ee->satellite; 33 34 _prn = prn.str(); 66 67 _prn = QString("G%1").arg(ee->satellite, 2, 10, QChar('0')); 35 68 36 69 // TODO: check if following two lines are correct … … 154 187 } 155 188 189 // build up RTCM3 for GPS 190 //////////////////////////////////////////////////////////////////////////// 191 #define GPSTOINT(type, value) static_cast<type>(NearestInt(value,0)) 192 193 #define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \ 194 |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \ 195 numbits += (a); \ 196 while(numbits >= 8) { \ 197 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}} 198 #define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \ 199 GPSADDBITS(a,i)}; 200 201 int t_ephGPS::RTCM3(unsigned char *buffer) 202 { 203 204 unsigned char *startbuffer = buffer; 205 buffer= buffer+3; 206 int size = 0; 207 int numbits = 0; 208 unsigned long long bitbuffer = 0; 209 if (_ura <= 2.40){ 210 _ura = 0; 211 } 212 else if (_ura <= 3.40){ 213 _ura = 1; 214 } 215 else if (_ura <= 6.85){ 216 _ura = 2; 217 } 218 else if (_ura <= 9.65){ 219 _ura = 3; 220 } 221 else if (_ura <= 13.65){ 222 _ura = 4; 223 } 224 else if (_ura <= 24.00){ 225 _ura = 5; 226 } 227 else if (_ura <= 48.00){ 228 _ura = 6; 229 } 230 else if (_ura <= 96.00){ 231 _ura = 7; 232 } 233 else if (_ura <= 192.00){ 234 _ura = 8; 235 } 236 else if (_ura <= 384.00){ 237 _ura = 9; 238 } 239 else if (_ura <= 768.00){ 240 _ura = 10; 241 } 242 else if (_ura <= 1536.00){ 243 _ura = 11; 244 } 245 else if (_ura <= 1536.00){ 246 _ura = 12; 247 } 248 else if (_ura <= 2072.00){ 249 _ura = 13; 250 } 251 else if (_ura <= 6144.00){ 252 _ura = 14; 253 } 254 else{ 255 _ura = 15; 256 } 257 258 GPSADDBITS(12, 1019) 259 GPSADDBITS(6,_prn.right((_prn.length()-1)).toInt()) 260 GPSADDBITS(10, _GPSweek) 261 GPSADDBITS(4, _ura) 262 GPSADDBITS(2,_L2Codes) 263 GPSADDBITSFLOAT(14, _IDOT, PI/static_cast<double>(1<<30) 264 /static_cast<double>(1<<13)) 265 GPSADDBITS(8, _IODE) 266 GPSADDBITS(16, static_cast<int>(_TOC)>>4) 267 GPSADDBITSFLOAT(8, _clock_driftrate, 1.0/static_cast<double>(1<<30) 268 /static_cast<double>(1<<25)) 269 GPSADDBITSFLOAT(16, _clock_drift, 1.0/static_cast<double>(1<<30) 270 /static_cast<double>(1<<13)) 271 GPSADDBITSFLOAT(22, _clock_bias, 1.0/static_cast<double>(1<<30) 272 /static_cast<double>(1<<1)) 273 GPSADDBITS(10, _IODC) 274 GPSADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5)) 275 GPSADDBITSFLOAT(16, _Delta_n, PI/static_cast<double>(1<<30) 276 /static_cast<double>(1<<13)) 277 GPSADDBITSFLOAT(32, _M0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 278 GPSADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29)) 279 GPSADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3)) 280 GPSADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29)) 281 GPSADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19)) 282 GPSADDBITS(16, static_cast<int>(_TOE)>>4) 283 GPSADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29)) 284 GPSADDBITSFLOAT(32, _OMEGA0, PI/static_cast<double>(1<<30) 285 /static_cast<double>(1<<1)) 286 GPSADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29)) 287 GPSADDBITSFLOAT(32, _i0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 288 GPSADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5)) 289 GPSADDBITSFLOAT(32, _omega, PI/static_cast<double>(1<<30) 290 /static_cast<double>(1<<1)) 291 GPSADDBITSFLOAT(24, _OMEGADOT, PI/static_cast<double>(1<<30) 292 /static_cast<double>(1<<13)) 293 GPSADDBITSFLOAT(8, _TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 294 GPSADDBITS(6, _health) 295 GPSADDBITS(1, _L2PFlag) 296 GPSADDBITS(1, 0) /* GPS fit interval */ 297 298 startbuffer[0]=0xD3; 299 startbuffer[1]=(size >> 8); 300 startbuffer[2]=size; 301 unsigned long i = CRC24(size+3, startbuffer); 302 buffer[size++] = i >> 16; 303 buffer[size++] = i >> 8; 304 buffer[size++] = i; 305 size += 3; 306 return size; 307 } 156 308 157 309 // Derivative of the state vector using a simple force model (static) … … 268 420 void t_ephGlo::set(const glonassephemeris* ee) { 269 421 270 ostringstream prn; 271 prn << 'R' << setfill('0') << setw(2) << ee->almanac_number; 272 _prn = prn.str(); 422 _prn = QString("R%1").arg(ee->almanac_number, 2, 10, QChar('0')); 273 423 274 424 int ww = ee->GPSWeek; 275 425 int tow = ee->GPSTOW; 276 426 updatetime(&ww, &tow, ee->tb*1000, 0); // Moscow -> GPS 427 428 bncTime hlpTime(ee->GPSWeek, ee->GPSTOW); 429 unsigned year, month, day; 430 hlpTime.civil_date(year, month, day); 431 _gps_utc = gnumleap(year, month, day); 277 432 278 433 _GPSweek = ww; … … 306 461 } 307 462 463 // build up RTCM3 for GLONASS 464 //////////////////////////////////////////////////////////////////////////// 465 #define GLONASSTOINT(type, value) static_cast<type>(NearestInt(value,0)) 466 467 #define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \ 468 |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \ 469 numbits += (a); \ 470 while(numbits >= 8) { \ 471 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}} 472 #define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \ 473 if(b < 0.0) \ 474 { \ 475 s = 1; \ 476 i = GLONASSTOINT(long long,(-b)/(c)); \ 477 if(!i) s = 0; \ 478 } \ 479 else \ 480 { \ 481 s = 0; \ 482 i = GLONASSTOINT(long long,(b)/(c)); \ 483 } \ 484 GLONASSADDBITS(1,s) \ 485 GLONASSADDBITS(a-1,i)} 486 487 int t_ephGlo::RTCM3(unsigned char *buffer) 488 { 489 490 int size = 0; 491 int numbits = 0; 492 long long bitbuffer = 0; 493 unsigned char *startbuffer = buffer; 494 buffer= buffer+3; 495 496 GLONASSADDBITS(12, 1020) 497 GLONASSADDBITS(6, _prn.right((_prn.length()-1)).toInt()) 498 GLONASSADDBITS(5, 7+_frequency_number) 499 GLONASSADDBITS(1, 0) 500 GLONASSADDBITS(1, 0) 501 GLONASSADDBITS(2, 0) 502 _tki=_tki+3*60*60; 503 GLONASSADDBITS(5, static_cast<int>(_tki)/(60*60)) 504 GLONASSADDBITS(6, (static_cast<int>(_tki)/60)%60) 505 GLONASSADDBITS(1, (static_cast<int>(_tki)/30)%30) 506 GLONASSADDBITS(1, _health) 507 GLONASSADDBITS(1, 0) 508 unsigned long long timeofday = (static_cast<int>(_tt+3*60*60-_gps_utc)%86400); 509 GLONASSADDBITS(7, timeofday/60/15) 510 GLONASSADDBITSFLOATM(24, _x_velocity*1000, 1000.0/static_cast<double>(1<<20)) 511 GLONASSADDBITSFLOATM(27, _x_pos*1000, 1000.0/static_cast<double>(1<<11)) 512 GLONASSADDBITSFLOATM(5, _x_acceleration*1000, 1000.0/static_cast<double>(1<<30)) 513 GLONASSADDBITSFLOATM(24, _y_velocity*1000, 1000.0/static_cast<double>(1<<20)) 514 GLONASSADDBITSFLOATM(27, _y_pos*1000, 1000.0/static_cast<double>(1<<11)) 515 GLONASSADDBITSFLOATM(5, _y_acceleration*1000, 1000.0/static_cast<double>(1<<30)) 516 GLONASSADDBITSFLOATM(24, _z_velocity*1000, 1000.0/static_cast<double>(1<<20)) 517 GLONASSADDBITSFLOATM(27,_z_pos*1000, 1000.0/static_cast<double>(1<<11)) 518 GLONASSADDBITSFLOATM(5, _z_acceleration*1000, 1000.0/static_cast<double>(1<<30)) 519 GLONASSADDBITS(1, 0) 520 GLONASSADDBITSFLOATM(11, _gamma, 1.0/static_cast<double>(1<<30) 521 /static_cast<double>(1<<10)) 522 GLONASSADDBITS(2, 0) /* GLONASS-M P */ 523 GLONASSADDBITS(1, 0) /* GLONASS-M ln(3) */ 524 GLONASSADDBITSFLOATM(22, _tau, 1.0/static_cast<double>(1<<30)) 525 GLONASSADDBITS(5, 0) /* GLONASS-M delta tau */ 526 GLONASSADDBITS(5, _E) 527 GLONASSADDBITS(1, 0) /* GLONASS-M P4 */ 528 GLONASSADDBITS(4, 0) /* GLONASS-M FT */ 529 GLONASSADDBITS(11, 0) /* GLONASS-M NT */ 530 GLONASSADDBITS(2, 0) /* GLONASS-M active? */ 531 GLONASSADDBITS(1, 0) /* GLONASS additional data */ 532 GLONASSADDBITS(11, 0) /* GLONASS NA */ 533 GLONASSADDBITS(32, 0) /* GLONASS tau C */ 534 GLONASSADDBITS(5, 0) /* GLONASS-M N4 */ 535 GLONASSADDBITS(22, 0) /* GLONASS-M tau GPS */ 536 GLONASSADDBITS(1, 0) /* GLONASS-M ln(5) */ 537 GLONASSADDBITS(7, 0) /* Reserved */ 538 539 startbuffer[0]=0xD3; 540 startbuffer[1]=(size >> 8); 541 startbuffer[2]=size; 542 unsigned long i = CRC24(size+3, startbuffer); 543 buffer[size++] = i >> 16; 544 buffer[size++] = i >> 8; 545 buffer[size++] = i; 546 size += 3; 547 return size; 548 } 549 308 550 // Set Galileo Satellite Position 309 551 //////////////////////////////////////////////////////////////////////////// 310 552 void t_ephGal::set(const galileoephemeris* ee) { 311 ostringstream prn; 312 prn << 'E' << setfill('0') << setw(2) << ee->satellite; 313 314 _prn = prn.str(); 553 554 _prn = QString("E%1").arg(ee->satellite, 2, 10, QChar('0')); 315 555 316 556 _GPSweek = ee->Week; … … 429 669 } 430 670 671 // build up RTCM3 for Galileo 672 //////////////////////////////////////////////////////////////////////////// 673 int t_ephGal::RTCM3(unsigned char *buffer) { 674 675 return 0; 676 } -
trunk/BNC/RTCM3/ephemeris.h
r3174 r3255 14 14 virtual ~t_eph() {}; 15 15 16 bool 17 std::stringprn() const {return _prn;}16 bool isNewerThan(const t_eph* eph) const; 17 QString prn() const {return _prn;} 18 18 void setReceptDateTime(const QDateTime& dateTime) { 19 19 _receptDateTime = dateTime; … … 41 41 42 42 virtual int IOD() const = 0; 43 44 virtual int RTCM3(unsigned char *) = 0; 43 45 44 46 protected: 45 std::string_prn;46 int 47 double 48 QDateTime 47 QString _prn; 48 int _GPSweek; 49 double _GPSweeks; 50 QDateTime _receptDateTime; 49 51 }; 50 52 … … 63 65 64 66 virtual int IOD() const { return static_cast<int>(_IODC); } 67 68 virtual int RTCM3(unsigned char *); 65 69 66 70 private: … … 92 96 93 97 double _TGD; // [s] 98 double _health; // SV health 99 double _ura; // SV accuracy 100 double _L2PFlag; // L2 P data flag 101 double _L2Codes; // Codes on L2 channel 94 102 }; 95 103 … … 106 114 virtual int IOD() const; 107 115 116 virtual int RTCM3(unsigned char *); 117 108 118 void set(const glonassephemeris* ee); 109 119 … … 115 125 mutable ColumnVector _xv; // status vector (position, velocity) at time _tt 116 126 127 double _gps_utc; 117 128 double _E; // [days] 118 129 double _tau; // [s] … … 146 157 virtual int IOD() const { return static_cast<int>(_IODnav); } 147 158 159 virtual int RTCM3(unsigned char *); 160 148 161 private: 149 162 double _IODnav; … … 169 182 double _IDOT; // [rad/s] 170 183 double _BGD_1_5A; // group delay [s] 184 double _BGD_1_5B; // group delay [s] 171 185 int _SISA; // Signal In Space Accuracy 172 186 int _E5aHS; // E5a Health Status -
trunk/BNC/upload/bncephuploadcaster.cpp
r3254 r3255 27 27 28 28 QString mountpoint = settings.value("uploadEphMountpoint").toString(); 29 QString outHost = settings.value("uploadEphHost").toString(); 30 int outPort = settings.value("uploadEphPort").toInt(); 31 QString password = settings.value("uploadEphPassword").toString(); 29 if (mountpoint.isEmpty()) { 30 _ephUploadCaster = 0; 31 } 32 else { 33 QString outHost = settings.value("uploadEphHost").toString(); 34 int outPort = settings.value("uploadEphPort").toInt(); 35 QString password = settings.value("uploadEphPassword").toString(); 32 36 33 _ephUploadCaster = new bncUploadCaster(mountpoint, outHost, outPort,37 _ephUploadCaster = new bncUploadCaster(mountpoint, outHost, outPort, 34 38 password, -1); 35 39 36 connect(_ephUploadCaster, SIGNAL(newBytes(QByteArray,double)),40 connect(_ephUploadCaster, SIGNAL(newBytes(QByteArray,double)), 37 41 this, SIGNAL(newBytes(QByteArray,double))); 38 42 39 _ephUploadCaster->start(); 43 _ephUploadCaster->start(); 44 } 40 45 } 41 46 … … 43 48 //////////////////////////////////////////////////////////////////////////// 44 49 bncEphUploadCaster::~bncEphUploadCaster() { 45 _ephUploadCaster->deleteSafely(); 50 if (_ephUploadCaster) { 51 _ephUploadCaster->deleteSafely(); 52 } 46 53 } 47 54 … … 49 56 //////////////////////////////////////////////////////////////////////////// 50 57 void bncEphUploadCaster::ephBufferChanged() { 51 58 if (_ephUploadCaster) { 59 QByteArray dummy = "from bncEphUploadCaster"; 60 _ephUploadCaster->setOutBuffer(dummy); 61 } 52 62 } -
trunk/BNC/upload/bncrtnetuploadcaster.cpp
r3233 r3255 444 444 445 445 outLine.sprintf("%d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n", 446 GPSweek, GPSweeks, eph->prn(). c_str(),446 GPSweek, GPSweeks, eph->prn().toAscii().data(), 447 447 eph->IOD(), dClk, rsw(1), rsw(2), rsw(3)); 448 448
Note:
See TracChangeset
for help on using the changeset viewer.