Changeset 82 in ntrip
- Timestamp:
- Aug 30, 2006, 5:35:40 PM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnc.pro
r73 r82 1 1 2 2 HEADERS = bncgetthread.h bncwindow.h bnctabledlg.h \ 3 bnccaster.h bncrinex.h 3 bnccaster.h bncrinex.h bncapp.h bncutils.h \ 4 4 RTCM/format.h RTCM/GPSDecoder.h RTCM/m_data.h RTCM/RTCM.h \ 5 5 RTCM3/rtcm3.h RTCM3/rtcm3torinex.h \ … … 9 9 10 10 SOURCES = bncmain.cpp bncgetthread.cpp bncwindow.cpp bnctabledlg.cpp \ 11 bnccaster.cpp bncrinex.cpp 11 bnccaster.cpp bncrinex.cpp bncapp.cpp bncutils.cpp \ 12 12 RTCM/m_date.cpp RTCM/RTCM.cpp \ 13 13 RTCM3/rtcm3.cpp RTCM3/rtcm3torinex.cpp \ -
trunk/BNC/bnccaster.cpp
r73 r82 120 120 void bncCaster::slotGetThreadError(const QByteArray& mountPoint) { 121 121 _mountPoints.removeAll(mountPoint); 122 qWarning("Mountpoint size %d", _mountPoints.size()); 122 emit( newMessage( 123 QString("Mountpoint size %1").arg(_mountPoints.size()).toAscii()) ); 123 124 if (_mountPoints.size() == 0) { 124 qWarning("bncCaster:: last get thread terminated\n");125 emit(newMessage("bncCaster:: last get thread terminated")); 125 126 emit getThreadErrors(); 126 127 } -
trunk/BNC/bnccaster.h
r73 r82 20 20 ~bncCaster(); 21 21 void addGetThread(bncGetThread* getThread); 22 int nMountPoints() const {return _mountPoints.size();} 22 23 23 24 signals: 24 25 void getThreadErrors(); 26 void newMessage(const QByteArray& msg); 25 27 26 28 public slots: -
trunk/BNC/bncgetthread.cpp
r65 r82 61 61 const QByteArray& mountPoint, 62 62 const QByteArray& user, 63 const QByteArray& password) { 63 const QByteArray& password, 64 QString& msg) { 65 66 msg.clear(); 64 67 65 68 QTcpSocket* socket = new QTcpSocket(); … … 82 85 83 86 if (!socket->waitForConnected(timeOut)) { 84 qWarning("Connect timeout");87 msg += "Connect timeout\n"; 85 88 delete socket; 86 89 return 0; … … 95 98 "\r\n\r\n"; 96 99 97 qWarning(reqStr);100 msg += reqStr; 98 101 99 102 socket->write(reqStr, reqStr.length()); 100 103 101 104 if (!socket->waitForBytesWritten(timeOut)) { 102 qWarning("Write timeout");105 msg += "Write timeout\n"; 103 106 delete socket; 104 107 return 0; … … 114 117 // Send the Request 115 118 // ---------------- 119 QString msg; 116 120 _socket = bncGetThread::request(_host, _port, _proxyHost, _proxyPort, 117 _mountPoint, _user, _password); 121 _mountPoint, _user, _password, msg); 122 emit(newMessage(msg.toAscii())); 123 118 124 if (!_socket) { 119 125 return exit(1); … … 126 132 QString line = _socket->readLine(); 127 133 if (line.indexOf("ICY 200 OK") != 0) { 128 qWarning(("Wrong Caster Response:\n" + line).toAscii());134 emit(newMessage(("Wrong Caster Response:\n" + line).toAscii())); 129 135 return exit(1); 130 136 } 131 137 } 132 138 else { 133 qWarning("Response Timeout");139 emit(newMessage("Response Timeout")); 134 140 return exit(1); 135 141 } … … 140 146 141 147 if (_format.indexOf("RTCM_2") != -1) { 142 qWarning("Get Data: " + _mountPoint + " in RTCM 2.x format");148 emit(newMessage("Get Data: " + _mountPoint + " in RTCM 2.x format")); 143 149 decoder = new RTCM('A',true); 144 150 } 145 151 else if (_format.indexOf("RTCM_3") != -1) { 146 qWarning("Get Data: " + _mountPoint + " in RTCM 3.0 format");152 emit(newMessage("Get Data: " + _mountPoint + " in RTCM 3.0 format")); 147 153 decoder = new rtcm3(); 148 154 } 149 155 else if (_format.indexOf("RTIGS") != -1) { 150 qWarning("Get Data: " + _mountPoint + " in RTIGS format");156 emit(newMessage("Get Data: " + _mountPoint + " in RTIGS format")); 151 157 decoder = new rtigs(); 152 158 } 153 159 else { 154 qWarning(_mountPoint + " Unknown data format " + _format);160 emit(newMessage(_mountPoint + " Unknown data format " + _format)); 155 161 return exit(1); 156 162 } … … 173 179 } 174 180 else { 175 qWarning("Data Timeout");181 emit(newMessage("Data Timeout")); 176 182 return exit(1); 177 183 } … … 188 194 QThread::exit(exitCode); 189 195 } 196 -
trunk/BNC/bncgetthread.h
r59 r82 23 23 const QByteArray& mountPoint, 24 24 const QByteArray& user, 25 const QByteArray& password); 25 const QByteArray& password, 26 QString& msg); 26 27 QByteArray mountPoint() {return _mountPoint;} 27 28 … … 29 30 void newObs(const QByteArray& mountPoint, Observation* obs); 30 31 void error(const QByteArray& mountPoint); 32 void newMessage(const QByteArray& msg); 31 33 32 34 protected: 33 35 virtual void run(); 34 36 private: 37 void message(const QString&); 35 38 void exit(int exitCode = 0); 36 39 QTcpSocket* _socket; -
trunk/BNC/bncmain.cpp
r59 r82 16 16 * -----------------------------------------------------------------------*/ 17 17 18 #ifdef WIN3219 #include <windows.h>20 #endif21 22 18 #include <QApplication> 23 19 #include <QFile> 24 20 #include <iostream> 25 21 22 #include "bncapp.h" 26 23 #include "bncwindow.h" 27 24 28 25 using namespace std; 29 26 30 #ifdef WIN32 31 QFile logFile("BNC.LOG"); 32 QTextStream logStream; 33 #endif 34 35 void myMessageOutput(QtMsgType, const char *msg) { 36 #ifdef WIN32 37 logStream << msg << endl; 38 logStream.flush(); 39 #else 40 cerr << msg << endl; 41 #endif 42 } 43 27 // Main Program 28 ///////////////////////////////////////////////////////////////////////////// 44 29 int main(int argc, char *argv[]) { 45 30 … … 49 34 } 50 35 51 QApplication app(argc, argv, GUIenabled); 52 53 #ifdef WIN32 54 logFile.open(QIODevice::WriteOnly); 55 logStream.setDevice(&logFile); 56 #endif 57 qInstallMsgHandler(myMessageOutput); 36 bncApp app(argc, argv, GUIenabled); 58 37 59 38 QCoreApplication::setOrganizationName("AIUB"); … … 61 40 QCoreApplication::setApplicationName("Bernese NTRIP Client"); 62 41 63 bncWindow* bncWin = 0;64 65 42 if (GUIenabled) { 66 bncWin = new bncWindow();43 bncWindow* bncWin = new bncWindow(); 67 44 bncWin->show(); 68 45 } … … 78 55 79 56 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit())); 57 app.connect(caster, SIGNAL(newMessage(const QByteArray&)), 58 &app, SLOT(slotMessage(const QByteArray&))); 80 59 81 60 caster->start(); … … 84 63 while (it.hasNext()) { 85 64 QStringList hlp = it.next().split(" "); 65 if (hlp.size() <= 1) continue; 86 66 QUrl url(hlp[0]); 87 67 QByteArray mountPoint = url.path().mid(1).toAscii(); … … 92 72 mountPoint, user, password, 93 73 format); 74 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)), 75 &app, SLOT(slotMessage(const QByteArray&))); 76 94 77 caster->addGetThread(getThread); 95 78 96 79 getThread->start(); 97 80 } 81 if (caster->nMountPoints() == 0) { 82 return 0; 83 } 98 84 } 99 85 return app.exec(); -
trunk/BNC/bncrinex.cpp
r79 r82 16 16 * -----------------------------------------------------------------------*/ 17 17 18 #include <QSettings> 19 #include <QDir> 20 #include <QDate> 21 #include <QFile> 22 #include <QTextStream> 18 23 #include <iomanip> 19 24 20 25 #include "bncrinex.h" 21 26 #include "bncutils.h" 22 27 #include "RTCM3/rtcm3torinex.h" 23 28 … … 29 34 _statID = StatID; 30 35 _headerWritten = false; 36 readSkeleton(); 31 37 } 32 38 … … 37 43 } 38 44 45 // Read Skeleton Header File 46 //////////////////////////////////////////////////////////////////////////// 47 void bncRinex::readSkeleton() { 48 49 // Resolve Skeleton File Name 50 // -------------------------- 51 QSettings settings; 52 QString sklName = settings.value("rnxPath").toString(); 53 expandEnvVar(sklName); 54 if ( sklName[sklName.length()-1] != QDir::separator() ) { 55 sklName += QDir::separator(); 56 } 57 sklName += _statID.left(4) + "." + settings.value("rnxSkel").toString(); 58 59 // Read the File 60 // ------------- 61 QFile skl(sklName); 62 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) { 63 QTextStream in(&skl); 64 while ( !in.atEnd() ) { 65 _headerLines.append( in.readLine() ); 66 if (_headerLines.last().indexOf("END OF HEADER") != -1) { 67 break; 68 } 69 } 70 } 71 } 72 73 // File Name according to RINEX Standards 74 //////////////////////////////////////////////////////////////////////////// 75 void bncRinex::resolveFileName(struct converttimeinfo& cti) { 76 77 QSettings settings; 78 QString path = settings.value("rnxPath").toString(); 79 expandEnvVar(path); 80 81 if ( path[path.length()-1] != QDir::separator() ) { 82 path += QDir::separator(); 83 } 84 85 QDate date(cti.year, cti.month, cti.day); 86 87 QChar ch = '0'; 88 89 path += _statID.left(4) + 90 QString("%1%2.%3O").arg(date.dayOfYear(), 3, 10, QChar('0')) 91 .arg(ch) 92 .arg(date.year() % 100, 2, 10, QChar('0')); 93 94 _fName = path.toAscii(); 95 } 96 39 97 // Write RINEX Header 40 98 //////////////////////////////////////////////////////////////////////////// … … 43 101 // Open the Output File 44 102 // -------------------- 45 QByteArray fname = _statID + ".RXO"; 46 _out.open(fname.data()); 47 48 // Write mandatory Records 49 // ----------------------- 103 resolveFileName(cti); 104 _out.open(_fName.data()); 50 105 _out.setf(ios::fixed); 51 106 _out.setf(ios::left); 52 53 double approxPos[3]; approxPos[0] = approxPos[1] = approxPos[2] = 0.0; 54 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0; 55 56 _out << " 2.10 OBSERVATION DATA G (GPS) RINEX VERSION / TYPE" << endl; 57 _out << "BNC LM 27-Aug-2006 PGM / RUN BY / DATE" << endl; 58 _out << setw(60) << _statID.data() << "MARKER NAME" << endl; 59 _out << setw(60) << "BKG" << "OBSERVER / AGENCY" << endl; 60 _out << setw(20) << "unknown" 61 << setw(20) << "unknown" 62 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl; 63 _out << setw(20) << "unknown" 64 << setw(20) << "unknown" 65 << setw(20) << " " << "ANT # / TYPE" << endl; 66 _out.unsetf(ios::left); 67 _out << setw(14) << setprecision(4) << approxPos[0] 68 << setw(14) << setprecision(4) << approxPos[1] 69 << setw(14) << setprecision(4) << approxPos[2] 70 << " " << "APPROX POSITION XYZ" << endl; 71 _out << setw(14) << setprecision(4) << antennaNEU[0] 72 << setw(14) << setprecision(4) << antennaNEU[1] 73 << setw(14) << setprecision(4) << antennaNEU[2] 74 << " " << "ANTENNA: DELTA H/E/N" << endl; 75 _out << " 1 1 WAVELENGTH FACT L1/2" << endl; 76 _out << " 4 P1 P2 L1 L2 # / TYPES OF OBSERV" << endl; 77 _out << setw(6) << cti.year 78 << setw(6) << cti.month 79 << setw(6) << cti.day 80 << setw(6) << cti.hour 81 << setw(6) << cti.minute 82 << setw(13) << setprecision(7) << second 83 << " " << "TIME OF FIRST OBS" << endl; 84 _out << " END OF HEADER" << endl; 107 108 109 // Copy Skeleton Header 110 // -------------------- 111 if (_headerLines.size() > 0) { 112 QStringListIterator it(_headerLines); 113 while (it.hasNext()) { 114 QString line = it.next(); 115 if (line.indexOf("# / TYPES OF OBSERV") != -1) { 116 _out << " 4 P1 P2 L1 L2" 117 " # / TYPES OF OBSERV" << endl; 118 } 119 else if (line.indexOf("TIME OF FIRST OBS") != -1) { 120 _out << setw(6) << cti.year 121 << setw(6) << cti.month 122 << setw(6) << cti.day 123 << setw(6) << cti.hour 124 << setw(6) << cti.minute 125 << setw(13) << setprecision(7) << second 126 << " TIME OF FIRST OBS" << endl; 127 } 128 else { 129 _out << line.toAscii().data() << endl; 130 } 131 } 132 } 133 134 // Write Dummy Header 135 // ------------------ 136 else { 137 double approxPos[3]; approxPos[0] = approxPos[1] = approxPos[2] = 0.0; 138 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0; 139 140 _out << " 2.10 OBSERVATION DATA G (GPS) RINEX VERSION / TYPE" << endl; 141 _out << "BNC LM 27-Aug-2006 PGM / RUN BY / DATE" << endl; 142 _out << setw(60) << _statID.data() << "MARKER NAME" << endl; 143 _out << setw(60) << "BKG" << "OBSERVER / AGENCY" << endl; 144 _out << setw(20) << "unknown" 145 << setw(20) << "unknown" 146 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl; 147 _out << setw(20) << "unknown" 148 << setw(20) << "unknown" 149 << setw(20) << " " << "ANT # / TYPE" << endl; 150 _out.unsetf(ios::left); 151 _out << setw(14) << setprecision(4) << approxPos[0] 152 << setw(14) << setprecision(4) << approxPos[1] 153 << setw(14) << setprecision(4) << approxPos[2] 154 << " " << "APPROX POSITION XYZ" << endl; 155 _out << setw(14) << setprecision(4) << antennaNEU[0] 156 << setw(14) << setprecision(4) << antennaNEU[1] 157 << setw(14) << setprecision(4) << antennaNEU[2] 158 << " " << "ANTENNA: DELTA H/E/N" << endl; 159 _out << " 1 1 WAVELENGTH FACT L1/2" << endl; 160 _out << " 4 P1 P2 L1 L2 # / TYPES OF OBSERV" << endl; 161 _out << setw(6) << cti.year 162 << setw(6) << cti.month 163 << setw(6) << cti.day 164 << setw(6) << cti.hour 165 << setw(6) << cti.minute 166 << setw(13) << setprecision(7) << second 167 << " " << "TIME OF FIRST OBS" << endl; 168 _out << " END OF HEADER" << endl; 169 } 85 170 86 171 _headerWritten = true; -
trunk/BNC/bncrinex.h
r78 r82 18 18 19 19 private: 20 void resolveFileName(struct converttimeinfo& cti); 21 void readSkeleton(); 20 22 void writeHeader(struct converttimeinfo& cti, double second); 21 23 22 24 QByteArray _statID; 25 QByteArray _fName; 23 26 QList<Observation*> _obs; 24 27 ofstream _out; 28 QStringList _headerLines; 25 29 bool _headerWritten; 26 30 }; -
trunk/BNC/bnctabledlg.cpp
r59 r82 89 89 // Send the Request 90 90 // ---------------- 91 QString msg; 91 92 QTcpSocket* socket = bncGetThread::request(host, port, _proxyHost, 92 93 _proxyPort, mountPoint, 93 user, password );94 user, password, msg); 94 95 if (!socket) { 96 QMessageBox::warning(0, "BNC", msg); 95 97 return; 96 98 } -
trunk/BNC/bnctabledlg.h
r35 r82 14 14 signals: 15 15 void newMountPoints(QStringList* mountPoints); 16 16 17 17 private slots: 18 18 virtual void accept();
Note:
See TracChangeset
for help on using the changeset viewer.