| [423] | 1 | // Part of BNC, a utility for retrieving decoding and
|
|---|
| 2 | // converting GNSS data streams from NTRIP broadcasters,
|
|---|
| 3 | // written by Leos Mervart.
|
|---|
| 4 | //
|
|---|
| 5 | // Copyright (C) 2006
|
|---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
|---|
| 7 | // http://www.bkg.bund.de
|
|---|
| 8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
|---|
| 9 | // http://www.fsv.cvut.cz
|
|---|
| 10 | //
|
|---|
| 11 | // Email: euref-ip@bkg.bund.de
|
|---|
| 12 | //
|
|---|
| 13 | // This program is free software; you can redistribute it and/or
|
|---|
| 14 | // modify it under the terms of the GNU General Public License
|
|---|
| 15 | // as published by the Free Software Foundation, version 2.
|
|---|
| 16 | //
|
|---|
| 17 | // This program is distributed in the hope that it will be useful,
|
|---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 20 | // GNU General Public License for more details.
|
|---|
| 21 | //
|
|---|
| 22 | // You should have received a copy of the GNU General Public License
|
|---|
| 23 | // along with this program; if not, write to the Free Software
|
|---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 25 |
|
|---|
| 26 | #include <iostream>
|
|---|
| 27 | #include "bnczerodecoder.h"
|
|---|
| [424] | 28 | #include "bncutils.h"
|
|---|
| [423] | 29 |
|
|---|
| 30 | using namespace std;
|
|---|
| 31 |
|
|---|
| 32 | // Constructor
|
|---|
| 33 | ////////////////////////////////////////////////////////////////////////
|
|---|
| [424] | 34 | bncZeroDecoder::bncZeroDecoder(const QString& fileName) {
|
|---|
| 35 | QSettings settings;
|
|---|
| 36 | QString path = settings.value("rnxPath").toString();
|
|---|
| 37 | expandEnvVar(path);
|
|---|
| 38 |
|
|---|
| 39 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
|---|
| 40 | path += QDir::separator();
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | _fileName = path + fileName;
|
|---|
| 44 |
|
|---|
| [427] | 45 | _out = 0;
|
|---|
| [426] | 46 | reopen();
|
|---|
| [423] | 47 | }
|
|---|
| 48 |
|
|---|
| 49 | // Destructor
|
|---|
| 50 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 51 | bncZeroDecoder::~bncZeroDecoder() {
|
|---|
| [427] | 52 | delete _out;
|
|---|
| [423] | 53 | }
|
|---|
| 54 |
|
|---|
| [426] | 55 | // Reopen Output File
|
|---|
| 56 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 57 | void bncZeroDecoder::reopen() {
|
|---|
| 58 | QDate currDate = QDate::currentDate();
|
|---|
| [427] | 59 | if (!_out || _fileDate != currDate) {
|
|---|
| 60 | delete _out;
|
|---|
| 61 | _out = new ofstream( (_fileName + "_" +
|
|---|
| 62 | currDate.toString("yyMMdd")).toAscii().data() );
|
|---|
| [426] | 63 | _fileDate = currDate;
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| [423] | 67 | // Decode Method
|
|---|
| 68 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 69 | void bncZeroDecoder::Decode(char* buffer, int bufLen) {
|
|---|
| [426] | 70 | reopen();
|
|---|
| [427] | 71 | _out->write(buffer, bufLen);
|
|---|
| 72 | _out->flush();
|
|---|
| [423] | 73 | }
|
|---|
| 74 |
|
|---|