Changeset 934 in ntrip for trunk/BNC/RTCM3
- Timestamp:
- Jun 8, 2008, 4:33:04 PM (17 years ago)
- Location:
- trunk/BNC/RTCM3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/BNC/RTCM3/RTCM3coDecoder.cpp ¶
r920 r934 44 44 #include "RTCM3coDecoder.h" 45 45 #include "bncutils.h" 46 #include "bncrinex.h" 46 47 47 48 using namespace std; … … 49 50 // Constructor 50 51 //////////////////////////////////////////////////////////////////////////// 51 RTCM3coDecoder::RTCM3coDecoder(const QString& fileName) 52 : bncZeroDecoder(fileName) { 52 RTCM3coDecoder::RTCM3coDecoder(const QString& fileName) { 53 54 // File Output 55 // ----------- 56 QSettings settings; 57 QString path = settings.value("corrPath").toString(); 58 if (!path.isEmpty()) { 59 expandEnvVar(path); 60 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) { 61 path += QDir::separator(); 62 } 63 _fileNameSkl = path + fileName; 64 } 65 _out = 0; 66 67 // Socket Server 68 // ------------- 69 int port = settings.value("corrPort").toInt(); 70 if (port != 0) { 71 _server = new QTcpServer; 72 _server->listen(QHostAddress::Any, port); 73 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); 74 _sockets = new QList<QTcpSocket*>; 75 } 76 else { 77 delete _sockets; 78 delete _server; 79 } 53 80 } 54 81 … … 56 83 //////////////////////////////////////////////////////////////////////////// 57 84 RTCM3coDecoder::~RTCM3coDecoder() { 85 } 86 87 // Reopen Output File 88 //////////////////////////////////////////////////////////////////////// 89 void RTCM3coDecoder::reopen() { 90 91 if (!_fileNameSkl.isEmpty()) { 92 93 QSettings settings; 94 95 QDateTime datTim = QDateTime::currentDateTime().toUTC(); 96 97 QString hlpStr = bncRinex::nextEpochStr(datTim, 98 settings.value("corrIntr").toString()); 99 100 QString fileName = _fileNameSkl 101 + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) 102 + datTim.toString(".yyC"); 103 104 if (_fileName == fileName) { 105 return; 106 } 107 else { 108 _fileName = fileName; 109 } 110 111 delete _out; 112 _out = new ofstream( _fileName.toAscii().data() ); 113 } 114 } 115 116 // New Connection 117 //////////////////////////////////////////////////////////////////////////// 118 void RTCM3coDecoder::slotNewConnection() { 119 _sockets->push_back( _server->nextPendingConnection() ); 58 120 } 59 121 … … 126 188 _co.Sat[ii].Orbit.DeltaAlongTrack, 127 189 _co.Sat[ii].Orbit.DeltaCrossTrack); 128 *_out << line.toAscii().data();190 printLine(line); 129 191 } 130 192 for(int ii = CLOCKORBIT_NUMGPS; … … 137 199 _co.Sat[ii].Orbit.DeltaAlongTrack, 138 200 _co.Sat[ii].Orbit.DeltaCrossTrack); 139 *_out << line.toAscii().data(); 140 } 141 _out->flush(); 201 printLine(line); 202 } 142 203 _buffer = _buffer.substr(bytesused); 143 204 return success; … … 151 212 } 152 213 } 214 215 // 216 //////////////////////////////////////////////////////////////////////////// 217 void RTCM3coDecoder::printLine(const QString& line) { 218 219 if (_out) { 220 *_out << line.toAscii().data(); 221 _out->flush(); 222 } 223 224 if (_sockets) { 225 QMutableListIterator<QTcpSocket*> is(*_sockets); 226 while (is.hasNext()) { 227 QTcpSocket* sock = is.next(); 228 if (sock->state() == QAbstractSocket::ConnectedState) { 229 if (sock->write(line.toAscii()) == -1) { 230 delete sock; 231 is.remove(); 232 } 233 } 234 else if (sock->state() != QAbstractSocket::ConnectingState) { 235 delete sock; 236 is.remove(); 237 } 238 } 239 } 240 } -
TabularUnified trunk/BNC/RTCM3/RTCM3coDecoder.h ¶
r908 r934 26 26 #define RTCM3CODECODER_H 27 27 28 #include "bnczerodecoder.h" 28 #include <fstream> 29 30 #include <QtCore> 31 #include <QtNetwork> 32 33 #include "RTCM/GPSDecoder.h" 29 34 30 35 extern "C" { … … 32 37 } 33 38 34 class RTCM3coDecoder : public bncZeroDecoder { 35 public: 39 class RTCM3coDecoder : public QObject, public GPSDecoder { 40 Q_OBJECT 41 public: 36 42 RTCM3coDecoder(const QString& fileName); 37 43 virtual ~RTCM3coDecoder(); 38 44 virtual t_irc Decode(char* buffer = 0, int bufLen = 0); 39 private: 40 std::string _buffer; 41 ClockOrbit _co; 42 Bias _bias; 43 } ; 45 46 private slots: 47 void slotNewConnection(); 48 49 private: 50 void reopen(); 51 void printLine(const QString& line); 52 53 std::ofstream* _out; 54 QString _fileNameSkl; 55 QString _fileName; 56 std::string _buffer; 57 ClockOrbit _co; 58 Bias _bias; 59 QTcpServer* _server; 60 QList<QTcpSocket*>* _sockets; 61 }; 44 62 45 63 #endif
Note:
See TracChangeset
for help on using the changeset viewer.