Changeset 88 in ntrip
- Timestamp:
- Aug 31, 2006, 7:20:36 PM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnccaster.cpp
r82 r88 69 69 // New Observations 70 70 //////////////////////////////////////////////////////////////////////////// 71 void bncCaster::slotNewObs(const QByteArray& mountPoint, Observation* obs) {71 void bncCaster::slotNewObs(const QByteArray& staID, Observation* obs) { 72 72 73 73 long newTime = obs->GPSWeek * 7*24*3600 + obs->GPSWeeks; … … 88 88 // Rename the station and save the observation 89 89 // ------------------------------------------- 90 strncpy(obs->StatID, mountPoint.constData(),sizeof(obs->StatID));90 strncpy(obs->StatID, staID.constData(),sizeof(obs->StatID)); 91 91 _epochs->insert(newTime, obs); 92 92 … … 113 113 this, SLOT(slotGetThreadError(const QByteArray&))); 114 114 115 _ mountPoints.push_back(getThread->mountPoint());115 _staIDs.push_back(getThread->staID()); 116 116 } 117 117 118 118 // Error in get thread 119 119 //////////////////////////////////////////////////////////////////////////// 120 void bncCaster::slotGetThreadError(const QByteArray& mountPoint) {121 _ mountPoints.removeAll(mountPoint);120 void bncCaster::slotGetThreadError(const QByteArray& staID) { 121 _staIDs.removeAll(staID); 122 122 emit( newMessage( 123 QString("Mountpoint size %1").arg(_ mountPoints.size()).toAscii()) );124 if (_ mountPoints.size() == 0) {123 QString("Mountpoint size %1").arg(_staIDs.size()).toAscii()) ); 124 if (_staIDs.size() == 0) { 125 125 emit(newMessage("bncCaster:: last get thread terminated")); 126 126 emit getThreadErrors(); -
trunk/BNC/bnccaster.h
r82 r88 20 20 ~bncCaster(); 21 21 void addGetThread(bncGetThread* getThread); 22 int n MountPoints() const {return _mountPoints.size();}22 int numStations() const {return _staIDs.size();} 23 23 24 24 signals: … … 27 27 28 28 public slots: 29 void slotNewObs(const QByteArray& mountPoint, Observation* obs);29 void slotNewObs(const QByteArray& staID, Observation* obs); 30 30 31 31 private slots: 32 32 void slotNewConnection(); 33 void slotGetThreadError(const QByteArray& mountPoint);33 void slotGetThreadError(const QByteArray& staID); 34 34 35 35 protected: … … 46 46 QTcpServer* _server; 47 47 QList<QTcpSocket*>* _sockets; 48 QList<QByteArray> _ mountPoints;48 QList<QByteArray> _staIDs; 49 49 QMap<QString, bncRinex*> _rinexWriters; 50 50 }; -
trunk/BNC/bncgetthread.cpp
r87 r88 32 32 // Constructor 33 33 //////////////////////////////////////////////////////////////////////////// 34 bncGetThread::bncGetThread(const QString& host, int port, 35 const QString& proxyHost, int proxyPort, 36 const QByteArray& mountPoint, 37 const QByteArray& user, 38 const QByteArray& password, 39 const QByteArray& format) { 40 _host = host; 41 _port = port; 42 _proxyHost = proxyHost; 43 _proxyPort = proxyPort; 34 bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format) { 44 35 _mountPoint = mountPoint; 45 _user = user; 46 _password = password; 36 _staID = mountPoint.path().toAscii(); 47 37 _format = format; 48 38 _socket = 0; … … 57 47 // Connect to Caster, send the Request (static) 58 48 //////////////////////////////////////////////////////////////////////////// 59 QTcpSocket* bncGetThread::request(const QString& host, int port, 60 const QString& proxyHost, int proxyPort, 61 const QByteArray& mountPoint, 62 const QByteArray& user, 63 const QByteArray& password, 64 QString& msg) { 49 QTcpSocket* bncGetThread::request(const QUrl& mountPoint, QString& msg) { 65 50 66 msg.clear(); 67 51 // Connect the Socket 52 // ------------------ 53 QSettings settings; 54 QString proxyHost = settings.value("proxyHost").toString(); 55 int proxyPort = settings.value("proxyPort").toInt(); 56 68 57 QTcpSocket* socket = new QTcpSocket(); 69 70 QByteArray l_mountPoint = mountPoint;71 72 58 if ( proxyHost.isEmpty() ) { 73 socket->connectToHost( host, port);59 socket->connectToHost(mountPoint.host(), mountPoint.port()); 74 60 } 75 61 else { 76 62 socket->connectToHost(proxyHost, proxyPort); 77 if (!proxyHost.isEmpty()) {78 QUrl proxyUrl;79 proxyUrl.setScheme("http");80 proxyUrl.setHost(host);81 proxyUrl.setPort(port);82 l_mountPoint = proxyUrl.resolved(QUrl(mountPoint)).toEncoded();83 }84 63 } 85 86 64 if (!socket->waitForConnected(timeOut)) { 87 65 msg += "Connect timeout\n"; … … 92 70 // Send Request 93 71 // ------------ 94 QByteArray userAndPwd = user + ":" + password; 95 QByteArray reqStr = "GET " + l_mountPoint + " HTTP/1.0\r\n" 96 "User-Agent: NTRIP BNC 1.0\r\n" 97 "Authorization: Basic " + userAndPwd.toBase64() + 98 "\r\n\r\n"; 72 QByteArray userAndPwd = mountPoint.userName().toAscii() + ":" + 73 mountPoint.password().toAscii(); 74 QByteArray reqStr = "GET " + mountPoint.path().toAscii() + 75 " HTTP/1.0\r\n" 76 "User-Agent: NTRIP BNC 1.0\r\n" 77 "Authorization: Basic " + 78 userAndPwd.toBase64() + "\r\n\r\n"; 99 79 100 80 msg += reqStr; … … 118 98 // ---------------- 119 99 QString msg; 120 _socket = bncGetThread::request(_host, _port, _proxyHost, _proxyPort, 121 _mountPoint, _user, _password, msg); 100 101 _socket = bncGetThread::request(_mountPoint, msg); 102 122 103 emit(newMessage(msg.toAscii())); 123 104 … … 146 127 147 128 if (_format.indexOf("RTCM_2") != -1) { 148 emit(newMessage("Get Data: " + _ mountPoint+ " in RTCM 2.x format"));129 emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format")); 149 130 decoder = new RTCM('A',true); 150 131 } 151 132 else if (_format.indexOf("RTCM_3") != -1) { 152 emit(newMessage("Get Data: " + _ mountPoint+ " in RTCM 3.0 format"));133 emit(newMessage("Get Data: " + _staID + " in RTCM 3.0 format")); 153 134 decoder = new rtcm3(); 154 135 } 155 136 else if (_format.indexOf("RTIGS") != -1) { 156 emit(newMessage("Get Data: " + _ mountPoint+ " in RTIGS format"));137 emit(newMessage("Get Data: " + _staID + " in RTIGS format")); 157 138 decoder = new rtigs(); 158 139 } 159 140 else { 160 emit(newMessage(_ mountPoint+ " Unknown data format " + _format));141 emit(newMessage(_staID + " Unknown data format " + _format)); 161 142 return exit(1); 162 143 } … … 174 155 for (list<Observation*>::iterator it = decoder->m_lObsList.begin(); 175 156 it != decoder->m_lObsList.end(); it++) { 176 emit newObs(_ mountPoint, *it);157 emit newObs(_staID, *it); 177 158 } 178 159 decoder->m_lObsList.clear(); … … 190 171 void bncGetThread::exit(int exitCode) { 191 172 if (exitCode!= 0) { 192 emit error(_ mountPoint);173 emit error(_staID); 193 174 } 194 175 QThread::exit(exitCode); -
trunk/BNC/bncgetthread.h
r82 r88 12 12 13 13 public: 14 bncGetThread(const QString& host, int port, 15 const QString& proxyHost, int proxyPort, 16 const QByteArray& mountPoint, 17 const QByteArray& user, 18 const QByteArray& password, 19 const QByteArray& format); 14 bncGetThread(const QUrl& mountPoint, const QByteArray& format); 20 15 ~bncGetThread(); 21 static QTcpSocket* bncGetThread::request(const QString& host, int port, 22 const QString& proxyHost, int proxyPort, 23 const QByteArray& mountPoint, 24 const QByteArray& user, 25 const QByteArray& password, 26 QString& msg); 27 QByteArray mountPoint() {return _mountPoint;} 16 17 static QTcpSocket* bncGetThread::request(const QUrl& mountPoint, 18 QString& msg); 19 20 QByteArray staID() const {return _staID;} 28 21 29 22 signals: 30 void newObs(const QByteArray& mountPoint, Observation* obs);31 void error(const QByteArray& mountPoint);23 void newObs(const QByteArray& staID, Observation* obs); 24 void error(const QByteArray& staID); 32 25 void newMessage(const QByteArray& msg); 33 26 … … 38 31 void exit(int exitCode = 0); 39 32 QTcpSocket* _socket; 40 QString _host; 41 int _port; 42 QString _proxyHost; 43 int _proxyPort; 44 QByteArray _mountPoint; 45 QByteArray _user; 46 QByteArray _password; 33 QUrl _mountPoint; 34 QByteArray _staID; 47 35 QByteArray _format; 48 36 }; -
trunk/BNC/bncmain.cpp
r82 r88 46 46 else { 47 47 QSettings settings; 48 QString proxyHost = settings.value("proxyHost").toString();49 int proxyPort = settings.value("proxyPort").toInt();50 QByteArray user = settings.value("user").toString().toAscii();51 QByteArray password = settings.value("password").toString().toAscii();52 53 48 bncCaster* caster = new bncCaster(settings.value("outFile").toString(), 54 49 settings.value("outPort").toInt()); … … 65 60 if (hlp.size() <= 1) continue; 66 61 QUrl url(hlp[0]); 67 QByteArray mountPoint = url.path().mid(1).toAscii(); 68 QByteArray format = hlp[1].toAscii(); 69 70 bncGetThread* getThread = new bncGetThread(url.host(), url.port(), 71 proxyHost, proxyPort, 72 mountPoint, user, password, 73 format); 62 QByteArray format = hlp[1].toAscii(); 63 bncGetThread* getThread = new bncGetThread(url, format); 74 64 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)), 75 65 &app, SLOT(slotMessage(const QByteArray&))); … … 79 69 getThread->start(); 80 70 } 81 if (caster->n MountPoints() == 0) {71 if (caster->numStations() == 0) { 82 72 return 0; 83 73 } -
trunk/BNC/bnctabledlg.cpp
r83 r88 31 31 QVBoxLayout* mainLayout = new QVBoxLayout(this); 32 32 33 _casterHostLabel = new QLabel(tr("caster host")); 34 _casterPortLabel = new QLabel(tr("caster port")); 33 _casterHostLabel = new QLabel(tr("caster host")); 34 _casterPortLabel = new QLabel(tr("caster port")); 35 _casterUserLabel = new QLabel(tr("user")); 36 _casterPasswordLabel = new QLabel(tr("password")); 35 37 QSettings settings; 36 _casterHostLineEdit = new QLineEdit(settings.value("casterHost").toString()); 37 _casterPortLineEdit = new QLineEdit(settings.value("casterPort").toString()); 38 39 QHBoxLayout* editLayout = new QHBoxLayout; 40 editLayout->addWidget(_casterHostLabel); 41 editLayout->addWidget(_casterHostLineEdit); 42 editLayout->addWidget(_casterPortLabel); 43 editLayout->addWidget(_casterPortLineEdit); 38 _casterHostLineEdit = new QLineEdit(settings.value("casterHost").toString()); 39 int ww = QFontMetrics(_casterHostLineEdit->font()).width('w'); 40 _casterHostLineEdit->setMaximumWidth(18*ww); 41 _casterPortLineEdit = new QLineEdit(settings.value("casterPort").toString()); 42 _casterPortLineEdit->setMaximumWidth(9*ww); 43 _casterUserLineEdit = new QLineEdit(settings.value("casterUser").toString()); 44 _casterUserLineEdit->setMaximumWidth(9*ww); 45 _casterPasswordLineEdit = new QLineEdit(settings.value("casterPassword").toString()); 46 _casterPasswordLineEdit->setMaximumWidth(9*ww); 47 _casterPasswordLineEdit->setEchoMode(QLineEdit::Password); 48 49 QGridLayout* editLayout = new QGridLayout; 50 editLayout->addWidget(_casterHostLabel, 0, 0); 51 editLayout->addWidget(_casterHostLineEdit, 0, 1); 52 editLayout->addWidget(_casterPortLabel, 0, 2); 53 editLayout->addWidget(_casterPortLineEdit, 0, 3); 54 editLayout->addWidget(_casterUserLabel, 1, 0); 55 editLayout->addWidget(_casterUserLineEdit, 1, 1); 56 editLayout->addWidget(_casterPasswordLabel, 1, 2); 57 editLayout->addWidget(_casterPasswordLineEdit, 1, 3); 58 44 59 mainLayout->addLayout(editLayout); 45 60 … … 81 96 void bncTableDlg::slotGetTable() { 82 97 83 QString host = _casterHostLineEdit->text(); 84 int port = _casterPortLineEdit->text().toInt(); 85 QByteArray mountPoint = "/"; 86 QByteArray user; 87 QByteArray password; 98 QUrl url; 99 url.setHost(_casterHostLineEdit->text()); 100 url.setPort(_casterPortLineEdit->text().toInt()); 88 101 89 102 // Send the Request 90 103 // ---------------- 91 104 QString msg; 92 QTcpSocket* socket = bncGetThread::request(host, port, _proxyHost, 93 _proxyPort, mountPoint, 94 user, password, msg); 105 QTcpSocket* socket = bncGetThread::request(url, msg); 106 95 107 if (!socket) { 96 108 QMessageBox::warning(0, "BNC", msg); … … 163 175 settings.setValue("casterHost", _casterHostLineEdit->text()); 164 176 settings.setValue("casterPort", _casterPortLineEdit->text()); 177 settings.setValue("casterUser", _casterUserLineEdit->text()); 178 settings.setValue("casterPassword", _casterPasswordLineEdit->text()); 165 179 166 180 QStringList* mountPoints = new QStringList; … … 173 187 if (_table->isItemSelected(item)) { 174 188 QUrl url; 189 url.setUserName(_casterUserLineEdit->text()); 190 url.setPassword(_casterPasswordLineEdit->text()); 175 191 url.setHost(_casterHostLineEdit->text()); 176 192 url.setPort(_casterPortLineEdit->text().toInt()); -
trunk/BNC/bnctabledlg.h
r82 r88 27 27 QLineEdit* _casterHostLineEdit; 28 28 QLineEdit* _casterPortLineEdit; 29 QLabel* _casterUserLabel; 30 QLabel* _casterPasswordLabel; 31 QLineEdit* _casterUserLineEdit; 32 QLineEdit* _casterPasswordLineEdit; 29 33 30 34 QPushButton* _buttonGet; -
trunk/BNC/bncwindow.cpp
r83 r88 76 76 _canvas->setLayout(layout); 77 77 78 _userLabel = new QLabel("user"); 79 _passwordLabel = new QLabel("password"); 78 _timeOutLabel = new QLabel("timeout (sec)"); 80 79 _proxyHostLabel = new QLabel("proxy host"); 81 80 _proxyPortLabel = new QLabel("proxy port"); … … 95 94 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString()); 96 95 _proxyPortLineEdit->setMaximumWidth(9*ww); 97 _userLineEdit = new QLineEdit(settings.value("user").toString()); 98 _userLineEdit->setMaximumWidth(9*ww); 99 _passwordLineEdit = new QLineEdit(settings.value("password").toString()); 100 _passwordLineEdit->setMaximumWidth(9*ww); 101 _passwordLineEdit->setEchoMode(QLineEdit::Password); 96 _timeOutLineEdit = new QLineEdit(settings.value("timeOut").toString()); 97 _timeOutLineEdit->setMaximumWidth(9*ww); 102 98 _outFileLineEdit = new QLineEdit(settings.value("outFile").toString()); 103 99 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString()); … … 144 140 _log->setReadOnly(true); 145 141 146 layout->addWidget(_userLabel, 0, 0); 147 layout->addWidget(_userLineEdit, 0, 1); 148 layout->addWidget(_passwordLabel, 0, 2); 149 layout->addWidget(_passwordLineEdit, 0, 3); 150 layout->addWidget(_proxyHostLabel, 1, 0); 151 layout->addWidget(_proxyHostLineEdit, 1, 1); 152 layout->addWidget(_proxyPortLabel, 1, 2); 153 layout->addWidget(_proxyPortLineEdit, 1, 3); 142 layout->addWidget(_proxyHostLabel, 0, 0); 143 layout->addWidget(_proxyHostLineEdit, 0, 1); 144 layout->addWidget(_proxyPortLabel, 0, 2); 145 layout->addWidget(_proxyPortLineEdit, 0, 3); 146 layout->addWidget(_timeOutLabel, 1, 1); 147 layout->addWidget(_timeOutLineEdit, 1, 2); 154 148 layout->addWidget(_outFileLabel, 2, 1); 155 149 layout->addWidget(_outFileLineEdit, 2, 2, 1, 2); … … 234 228 settings.setValue("proxyHost", _proxyHostLineEdit->text()); 235 229 settings.setValue("proxyPort", _proxyPortLineEdit->text()); 236 settings.setValue("user", _userLineEdit->text()); 237 settings.setValue("password", _passwordLineEdit->text()); 230 settings.setValue("timeOut", _timeOutLineEdit->text()); 238 231 settings.setValue("outFile", _outFileLineEdit->text()); 239 232 settings.setValue("outPort", _outPortLineEdit->text()); … … 264 257 _actGetData->setEnabled(false); 265 258 266 QString proxyHost = _proxyHostLineEdit->text();267 int proxyPort = _proxyPortLineEdit->text().toInt();268 QByteArray user = _userLineEdit->text().toAscii();269 QByteArray password = _passwordLineEdit->text().toAscii();270 271 259 _bncCaster = new bncCaster(_outFileLineEdit->text(), 272 260 _outPortLineEdit->text().toInt()); … … 282 270 for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) { 283 271 QUrl url(_mountPointsTable->item(iRow, 0)->text()); 284 QByteArray mountPoint = url.path().mid(1).toAscii();285 272 QByteArray format = _mountPointsTable->item(iRow, 1)->text().toAscii(); 286 273 287 bncGetThread* getThread = new bncGetThread(url.host(), url.port(), 288 proxyHost, proxyPort, 289 mountPoint, user, password, 290 format); 274 bncGetThread* getThread = new bncGetThread(url, format); 291 275 292 276 connect(getThread, SIGNAL(newMessage(const QByteArray&)), -
trunk/BNC/bncwindow.h
r83 r88 43 43 QLabel* _proxyHostLabel; 44 44 QLabel* _proxyPortLabel; 45 QLabel* _userLabel; 46 QLabel* _passwordLabel; 45 QLabel* _timeOutLabel; 47 46 QLabel* _rnxPathLabel; 48 47 QLabel* _rnxSkelLabel; … … 55 54 QLineEdit* _proxyHostLineEdit; 56 55 QLineEdit* _proxyPortLineEdit; 57 QLineEdit* _userLineEdit; 58 QLineEdit* _passwordLineEdit; 56 QLineEdit* _timeOutLineEdit; 59 57 QLineEdit* _outFileLineEdit; 60 58 QLineEdit* _outPortLineEdit;
Note:
See TracChangeset
for help on using the changeset viewer.