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: bncRawFile
|
---|
30 | *
|
---|
31 | * Purpose: This class stores/reads BNC raw file
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 23-Aug-2010
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include "bncrawfile.h"
|
---|
42 | #include "bncapp.h"
|
---|
43 | #include "bncutils.h"
|
---|
44 |
|
---|
45 | using namespace std;
|
---|
46 |
|
---|
47 | // Constructor
|
---|
48 | ////////////////////////////////////////////////////////////////////////////
|
---|
49 | bncRawFile::bncRawFile(const QByteArray& fileName, const QByteArray& format,
|
---|
50 | inpOutFlag ioFlg) {
|
---|
51 | _fileName = fileName;
|
---|
52 | _format = format;
|
---|
53 | _staID = fileName.mid(fileName.lastIndexOf(QDir::separator())+1,5);
|
---|
54 | _inpFile = 0;
|
---|
55 | _outFile = 0;
|
---|
56 | _version = 0;
|
---|
57 |
|
---|
58 | // Initialize for Input
|
---|
59 | // --------------------
|
---|
60 | if (ioFlg == input) {
|
---|
61 | _inpFile = new QFile(_fileName);
|
---|
62 | _inpFile->open(QIODevice::ReadOnly);
|
---|
63 | QString line = _inpFile->readLine();
|
---|
64 | QStringList lst1 = line.split(' ');
|
---|
65 | _version = lst1.value(0).toInt();
|
---|
66 |
|
---|
67 | line = _inpFile->readLine();
|
---|
68 | bncApp* app = (bncApp*) qApp;
|
---|
69 | app->_currentDateAndTimeGPS =
|
---|
70 | new QDateTime(QDateTime::fromString(line, Qt::ISODate));
|
---|
71 | }
|
---|
72 |
|
---|
73 | // Initialize for Output
|
---|
74 | // ---------------------
|
---|
75 | else {
|
---|
76 | _outFile = new QFile(_fileName);
|
---|
77 | _outFile->open(QIODevice::WriteOnly);
|
---|
78 | QByteArray header = "1 Version of BNC raw file\n" +
|
---|
79 | currentDateAndTimeGPS().toString(Qt::ISODate).toAscii();
|
---|
80 | _outFile->write(header);
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | // Destructor
|
---|
85 | ////////////////////////////////////////////////////////////////////////////
|
---|
86 | bncRawFile::~bncRawFile() {
|
---|
87 |
|
---|
88 | }
|
---|
89 |
|
---|
90 | // Raw Output
|
---|
91 | ////////////////////////////////////////////////////////////////////////////
|
---|
92 | void bncRawFile::writeRawData(const QByteArray& data, const QByteArray& staID,
|
---|
93 | const QByteArray& format) {
|
---|
94 | if (_outFile) {
|
---|
95 | QString chunkHeader =
|
---|
96 | QString("\n%1 %2 %3\n").arg(QString(staID)).arg(QString(format)).arg(data.size());
|
---|
97 | _outFile->write(chunkHeader.toAscii());
|
---|
98 | _outFile->write(data);
|
---|
99 | _outFile->flush();
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 | // Raw Input
|
---|
105 | ////////////////////////////////////////////////////////////////////////////
|
---|
106 | QByteArray bncRawFile::readChunk() {
|
---|
107 |
|
---|
108 | return "";
|
---|
109 |
|
---|
110 | //// beg test
|
---|
111 | //// msleep(10);
|
---|
112 | //// end test
|
---|
113 | }
|
---|
114 |
|
---|