[423] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[423] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[423] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[423] | 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 |
|
---|
[464] | 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncZeroDecoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Implementation of zero decoder to by-pass decoding algorithm
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Apr-2007
|
---|
| 36 | *
|
---|
[10503] | 37 | * Changes:
|
---|
[464] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[423] | 41 | #include <iostream>
|
---|
| 42 | #include "bnczerodecoder.h"
|
---|
[424] | 43 | #include "bncutils.h"
|
---|
[1535] | 44 | #include "bncsettings.h"
|
---|
[423] | 45 |
|
---|
| 46 | using namespace std;
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
[10503] | 49 | ////////////////////////////////////////////////////////////////////////
|
---|
| 50 | bncZeroDecoder::bncZeroDecoder(const QString& fileName, bool writeFile) {
|
---|
| 51 | _writeFile = writeFile;
|
---|
[934] | 52 |
|
---|
[10503] | 53 | if (_writeFile) {
|
---|
| 54 | bncSettings settings;
|
---|
| 55 | QString path = settings.value("rnxPath").toString();
|
---|
| 56 | expandEnvVar(path);
|
---|
[424] | 57 |
|
---|
[10503] | 58 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
---|
| 59 | path += QDir::separator();
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | _fileName = path + fileName;
|
---|
[424] | 63 | }
|
---|
| 64 |
|
---|
[427] | 65 | _out = 0;
|
---|
[423] | 66 | }
|
---|
| 67 |
|
---|
| 68 | // Destructor
|
---|
[10503] | 69 | ////////////////////////////////////////////////////////////////////////
|
---|
[423] | 70 | bncZeroDecoder::~bncZeroDecoder() {
|
---|
[427] | 71 | delete _out;
|
---|
[423] | 72 | }
|
---|
| 73 |
|
---|
[426] | 74 | // Reopen Output File
|
---|
[10503] | 75 | ////////////////////////////////////////////////////////////////////////
|
---|
[426] | 76 | void bncZeroDecoder::reopen() {
|
---|
[1154] | 77 | QDate currDate = currentDateAndTimeGPS().date();
|
---|
[427] | 78 | if (!_out || _fileDate != currDate) {
|
---|
| 79 | delete _out;
|
---|
[10503] | 80 | QByteArray fileName =
|
---|
[8203] | 81 | (_fileName + "_" + currDate.toString("yyMMdd")).toLatin1();
|
---|
[1762] | 82 | bncSettings settings;
|
---|
| 83 | if (Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 84 | _out = new ofstream(fileName.data(), ios::out | ios::app);
|
---|
| 85 | }
|
---|
| 86 | else {
|
---|
| 87 | _out = new ofstream(fileName.data());
|
---|
| 88 | }
|
---|
[426] | 89 | _fileDate = currDate;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[423] | 93 | // Decode Method
|
---|
[10503] | 94 | ////////////////////////////////////////////////////////////////////////
|
---|
[1218] | 95 | t_irc bncZeroDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
| 96 | errmsg.clear();
|
---|
[10503] | 97 | if (_writeFile) {
|
---|
| 98 | reopen();
|
---|
| 99 | _out->write(buffer, bufLen);
|
---|
| 100 | _out->flush();
|
---|
| 101 | }
|
---|
[649] | 102 | return success;
|
---|
[423] | 103 | }
|
---|
| 104 |
|
---|