1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncRtnetDecoder
|
---|
30 | *
|
---|
31 | * Purpose: Implementation of RTNet (SP3-like) output decoder
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 28-Mar-2011
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iostream>
|
---|
42 | #include "bncrtnetdecoder.h"
|
---|
43 | #include "bncutils.h"
|
---|
44 | #include "bncsettings.h"
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | // Constructor
|
---|
49 | ////////////////////////////////////////////////////////////////////////
|
---|
50 | bncRtnetDecoder::bncRtnetDecoder() {
|
---|
51 | }
|
---|
52 |
|
---|
53 | // Destructor
|
---|
54 | ////////////////////////////////////////////////////////////////////////
|
---|
55 | bncRtnetDecoder::~bncRtnetDecoder() {
|
---|
56 | for (int ic = 0; ic < _casters->size(); ic++) {
|
---|
57 | delete _casters->at(ic);
|
---|
58 | }
|
---|
59 | delete _casters;
|
---|
60 | }
|
---|
61 |
|
---|
62 | // Run
|
---|
63 | ////////////////////////////////////////////////////////////////////////
|
---|
64 | void bncRtnetDecoder::run() {
|
---|
65 |
|
---|
66 | bncSettings settings;
|
---|
67 |
|
---|
68 | // List of upload casters
|
---|
69 | // ----------------------
|
---|
70 | _casters = new QVector<bncUploadCaster*>;
|
---|
71 | QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
|
---|
72 | while (it.hasNext()) {
|
---|
73 | QStringList hlp = it.next().split(",");
|
---|
74 | if (hlp.size() > 6) {
|
---|
75 | int outPort = hlp[1].toInt();
|
---|
76 | bool CoM = (hlp[5].toInt() == Qt::Checked);
|
---|
77 | _casters->push_back(new bncUploadCaster(hlp[2], hlp[0], outPort,
|
---|
78 | hlp[3], hlp[4], CoM,
|
---|
79 | hlp[6], "", ""));
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | // Endless Loop - Decode
|
---|
84 | // ---------------------
|
---|
85 | while (true) {
|
---|
86 | DecodeInThread();
|
---|
87 | msleep(10);
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | // Decode Method
|
---|
92 | ////////////////////////////////////////////////////////////////////////
|
---|
93 | t_irc bncRtnetDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
94 | QMutexLocker locker(&_mutex);
|
---|
95 | errmsg.clear();
|
---|
96 | _buffer.append(QByteArray(buffer, bufLen));
|
---|
97 | return success;
|
---|
98 | }
|
---|
99 |
|
---|
100 | // Decode and upload in separate thread
|
---|
101 | ////////////////////////////////////////////////////////////////////////
|
---|
102 | void bncRtnetDecoder::DecodeInThread() {
|
---|
103 | QMutexLocker locker(&_mutex);
|
---|
104 |
|
---|
105 | // Prepare list of lines with satellite positions in SP3-like format
|
---|
106 | // -----------------------------------------------------------------
|
---|
107 | QStringList lines;
|
---|
108 | int iLast = _buffer.lastIndexOf('\n');
|
---|
109 | if (iLast != -1) {
|
---|
110 | QStringList hlpLines = _buffer.split('\n', QString::SkipEmptyParts);
|
---|
111 | _buffer = _buffer.mid(iLast+1);
|
---|
112 | for (int ii = 0; ii < hlpLines.size(); ii++) {
|
---|
113 | if (hlpLines[ii].indexOf('*') != -1) {
|
---|
114 | QTextStream in(hlpLines[ii].toAscii());
|
---|
115 | QString hlp;
|
---|
116 | int year, month, day, hour, min;
|
---|
117 | double sec;
|
---|
118 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
---|
119 | _epoTime.set( year, month, day, hour, min, sec);
|
---|
120 | }
|
---|
121 | else if (_epoTime.valid()) {
|
---|
122 | lines << hlpLines[ii];
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | // Satellite positions to be processed
|
---|
128 | // -----------------------------------
|
---|
129 | if (lines.size() > 0) {
|
---|
130 | for (int ic = 0; ic < _casters->size(); ic++) {
|
---|
131 | _casters->at(ic)->uploadClockOrbitBias(_epoTime, _eph, lines);
|
---|
132 | }
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|