Changeset 3226 in ntrip for trunk/BNC/upload/bncrtnetuploadcaster.cpp
- Timestamp:
- Mar 31, 2011, 6:10:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/upload/bncrtnetuploadcaster.cpp
r3224 r3226 35 35 bncUploadCaster(mountpoint, outHost, outPort, password) { 36 36 37 bncSettings settings;38 37 _crdTrafo = crdTrafo; 39 38 _CoM = CoM; … … 158 157 } 159 158 else if (_crdTrafo == "Custom") { 159 bncSettings settings; 160 160 _dx = settings.value("trafo_dx").toDouble(); 161 161 _dy = settings.value("trafo_dy").toDouble(); … … 188 188 } 189 189 190 // Endless Loop191 ////////////////////////////////////////////////////////////////////////////192 void bncRtnetUploadCaster::run() {193 while (true) {194 if (_isToBeDeleted) {195 QThread::quit();196 deleteLater();197 return;198 }199 open();200 uploadClockOrbitBias();201 msleep(10);202 }203 }204 205 190 // 206 191 //////////////////////////////////////////////////////////////////////////// … … 211 196 // Append to buffer 212 197 // ---------------- 213 const int MAXBUFFSIZE = 100000;214 198 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen)); 215 if (_rtnetStreamBuffer.size() > MAXBUFFSIZE) { 216 _rtnetStreamBuffer = _rtnetStreamBuffer.right(MAXBUFFSIZE); 217 } 218 } 219 220 // Function called in separate thread 221 //////////////////////////////////////////////////////////////////////// 222 void bncRtnetUploadCaster::uploadClockOrbitBias() { 223 224 QMutexLocker locker(&_mutex); 199 int iLastAsterix = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch 200 if (iLastAsterix == -1) { 201 _rtnetStreamBuffer.clear(); 202 return; 203 } 204 else { 205 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastAsterix); 206 } 225 207 226 208 // Prepare list of lines with satellite positions in SP3-like format 227 209 // ----------------------------------------------------------------- 228 QStringList lines; 229 int iLast = _rtnetStreamBuffer.lastIndexOf('\n'); 230 if (iLast != -1) { 231 QStringList hlpLines = _rtnetStreamBuffer.split('\n', QString::SkipEmptyParts); 232 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLast+1); 233 for (int ii = 0; ii < hlpLines.size(); ii++) { 234 if (hlpLines[ii].indexOf('*') != -1) { 235 lines.clear(); 236 QTextStream in(hlpLines[ii].toAscii()); 237 QString hlp; 238 int year, month, day, hour, min; 239 double sec; 240 in >> hlp >> year >> month >> day >> hour >> min >> sec; 241 _epoTime.set( year, month, day, hour, min, sec); 242 } 243 else if (_epoTime.valid()) { 244 lines << hlpLines[ii]; 245 } 246 } 247 } 248 249 if (lines.size() == 0) { 210 QStringList lines = _rtnetStreamBuffer.split('\n', QString::SkipEmptyParts); 211 212 if (lines.size() < 2) { 250 213 return; 251 214 } 252 215 253 unsigned year, month, day; 254 _epoTime.civil_date(year, month, day); 255 216 // Keep the last unfinished line in buffer 217 // --------------------------------------- 218 int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n'); 219 if (iLastEOL != -1) { 220 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1); 221 } 222 223 // Read first line (with epoch time) 224 // --------------------------------- 225 QTextStream in(lines[0].toAscii()); 226 QString hlp; 227 int year, month, day, hour, min; 228 double sec; 229 in >> hlp >> year >> month >> day >> hour >> min >> sec; 230 bncTime epoTime; epoTime.set( year, month, day, hour, min, sec); 231 256 232 struct ClockOrbit co; 257 233 memset(&co, 0, sizeof(co)); 258 co.GPSEpochTime = static_cast<int>( _epoTime.gpssec());259 co.GLONASSEpochTime = static_cast<int>(fmod( _epoTime.gpssec(), 86400.0))234 co.GPSEpochTime = static_cast<int>(epoTime.gpssec()); 235 co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0)) 260 236 + 3 * 3600 - gnumleap(year, month, day); 261 237 co.ClockDataSupplied = 1; … … 265 241 struct Bias bias; 266 242 memset(&bias, 0, sizeof(bias)); 267 bias.GPSEpochTime 268 bias.GLONASSEpochTime 269 270 for (int ii = 0; ii < lines.size(); ii++) {271 243 bias.GPSEpochTime = co.GPSEpochTime; 244 bias.GLONASSEpochTime = co.GLONASSEpochTime; 245 246 for (int ii = 1; ii < lines.size(); ii++) { 247 272 248 QString prn; 273 249 ColumnVector xx(14); xx = 0.0; … … 315 291 if (sd) { 316 292 QString outLine; 317 processSatellite(eph, _epoTime.gpsw(), _epoTime.gpssec(), prn,293 processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn, 318 294 xx, sd, outLine); 319 295 if (_outFile) { 320 _outFile->write( _epoTime.gpsw(), _epoTime.gpssec(), outLine);296 _outFile->write(epoTime.gpsw(), epoTime.gpssec(), outLine); 321 297 } 322 298 } … … 367 343 int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer)); 368 344 if (len > 0) { 369 this->write(obuffer, len);345 _outBuffer.append(QByteArray(obuffer, len)); 370 346 } 371 347 } … … 375 351 int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer)); 376 352 if (len > 0) { 377 this->write(obuffer, len);353 _outBuffer.append(QByteArray(obuffer, len)); 378 354 } 379 355 }
Note:
See TracChangeset
for help on using the changeset viewer.