Changeset 3224 in ntrip for trunk/BNC/upload/bncrtnetuploadcaster.cpp
- Timestamp:
- Mar 31, 2011, 5:15:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/upload/bncrtnetuploadcaster.cpp
r3222 r3224 3 3 * ------------------------------------------------------------------------- 4 4 * 5 * Class: bnc UploadCaster5 * Class: bncRtnetUploadCaster 6 6 * 7 7 * Purpose: Connection to NTRIP Caster … … 16 16 17 17 #include <math.h> 18 #include "bnc uploadcaster.h"18 #include "bncrtnetuploadcaster.h" 19 19 #include "bncsettings.h" 20 #include "bncversion.h" 21 #include "bncapp.h" 20 #include "bncephuser.h" 22 21 #include "bncclockrinex.h" 23 22 #include "bncsp3.h" … … 27 26 // Constructor 28 27 //////////////////////////////////////////////////////////////////////////// 29 bnc UploadCaster::bncUploadCaster(const QString& mountpoint,28 bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint, 30 29 const QString& outHost, int outPort, 31 30 const QString& password, … … 33 32 const QString& sp3FileName, 34 33 const QString& rnxFileName, 35 const QString& outFileName) { 34 const QString& outFileName) : 35 bncUploadCaster(mountpoint, outHost, outPort, password) { 36 36 37 bncSettings settings; 37 38 connect(this, SIGNAL(newMessage(QByteArray,bool)),39 ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));40 41 _mountpoint = mountpoint;42 _outHost = outHost;43 _outPort = outPort;44 _password = password;45 38 _crdTrafo = crdTrafo; 46 39 _CoM = CoM; 47 40 48 _outSocket = 0; 49 _sOpenTrial = 0; 50 51 _isToBeDeleted = false; 41 // Member that receives the ephemeris 42 // ---------------------------------- 43 _ephUser = new bncEphUser(); 52 44 53 45 // Raw Output … … 182 174 _t0 = settings.value("trafo_t0").toDouble(); 183 175 } 184 185 // Member that receives the ephemeris186 // ----------------------------------187 _ephUser = new bncEphUser();188 }189 190 // Safe Desctructor191 ////////////////////////////////////////////////////////////////////////////192 void bncUploadCaster::deleteSafely() {193 _isToBeDeleted = true;194 if (!isRunning()) {195 delete this;196 }197 176 } 198 177 199 178 // Destructor 200 179 //////////////////////////////////////////////////////////////////////////// 201 bnc UploadCaster::~bncUploadCaster() {180 bncRtnetUploadCaster::~bncRtnetUploadCaster() { 202 181 if (isRunning()) { 203 182 wait(); … … 211 190 // Endless Loop 212 191 //////////////////////////////////////////////////////////////////////////// 213 void bnc UploadCaster::run() {192 void bncRtnetUploadCaster::run() { 214 193 while (true) { 215 194 if (_isToBeDeleted) { … … 224 203 } 225 204 226 // Start the Communication with NTRIP Caster227 ////////////////////////////////////////////////////////////////////////////228 void bncUploadCaster::open() {229 230 if (_mountpoint.isEmpty()) {231 return;232 }233 234 if (_outSocket != 0 &&235 _outSocket->state() == QAbstractSocket::ConnectedState) {236 return;237 }238 239 delete _outSocket; _outSocket = 0;240 241 double minDt = pow(2.0,_sOpenTrial);242 if (++_sOpenTrial > 4) {243 _sOpenTrial = 4;244 }245 if (_outSocketOpenTime.isValid() &&246 _outSocketOpenTime.secsTo(QDateTime::currentDateTime()) < minDt) {247 return;248 }249 else {250 _outSocketOpenTime = QDateTime::currentDateTime();251 }252 253 bncSettings settings;254 _outSocket = new QTcpSocket();255 _outSocket->connectToHost(_outHost, _outPort);256 257 const int timeOut = 5000; // 5 seconds258 if (!_outSocket->waitForConnected(timeOut)) {259 delete _outSocket;260 _outSocket = 0;261 emit(newMessage("Broadcaster: Connect timeout", true));262 return;263 }264 265 QByteArray msg = "SOURCE " + _password.toAscii() + " /" +266 _mountpoint.toAscii() + "\r\n" +267 "Source-Agent: NTRIP BNC/" BNCVERSION "\r\n\r\n";268 269 _outSocket->write(msg);270 _outSocket->waitForBytesWritten();271 272 _outSocket->waitForReadyRead();273 QByteArray ans = _outSocket->readLine();274 275 if (ans.indexOf("OK") == -1) {276 delete _outSocket;277 _outSocket = 0;278 emit(newMessage("Broadcaster: Connection broken", true));279 }280 else {281 emit(newMessage("Broadcaster: Connection opened", true));282 _sOpenTrial = 0;283 }284 }285 286 // Write buffer287 ////////////////////////////////////////////////////////////////////////////288 void bncUploadCaster::write(char* buffer, unsigned len) {289 if (_outSocket && _outSocket->state() == QAbstractSocket::ConnectedState) {290 _outSocket->write(buffer, len);291 _outSocket->flush();292 }293 }294 295 205 // 296 206 //////////////////////////////////////////////////////////////////////////// 297 void bnc UploadCaster::decodeRtnetStream(char* buffer, int bufLen) {207 void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) { 298 208 299 209 QMutexLocker locker(&_mutex); … … 310 220 // Function called in separate thread 311 221 //////////////////////////////////////////////////////////////////////// 312 void bnc UploadCaster::uploadClockOrbitBias() {222 void bncRtnetUploadCaster::uploadClockOrbitBias() { 313 223 314 224 QMutexLocker locker(&_mutex); … … 472 382 // 473 383 //////////////////////////////////////////////////////////////////////////// 474 void bnc UploadCaster::processSatellite(t_eph* eph, int GPSweek,384 void bncRtnetUploadCaster::processSatellite(t_eph* eph, int GPSweek, 475 385 double GPSweeks, const QString& prn, 476 386 const ColumnVector& xx, … … 558 468 // Transform Coordinates 559 469 //////////////////////////////////////////////////////////////////////////// 560 void bnc UploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz) {470 void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz) { 561 471 562 472 // Current epoch minus 2000.0 in years
Note:
See TracChangeset
for help on using the changeset viewer.