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: main
|
---|
30 | *
|
---|
31 | * Purpose: Application starts here
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 24-Dec-2005
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <unistd.h>
|
---|
42 | #include <signal.h>
|
---|
43 | #include <QApplication>
|
---|
44 | #include <QFile>
|
---|
45 | #include <iostream>
|
---|
46 |
|
---|
47 | #include "bncapp.h"
|
---|
48 | #include "bncwindow.h"
|
---|
49 | #include "bncsettings.h"
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | void catch_signal(int) {
|
---|
54 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
55 | ((bncApp*)qApp)->slotQuit();
|
---|
56 | }
|
---|
57 |
|
---|
58 | // Main Program
|
---|
59 | /////////////////////////////////////////////////////////////////////////////
|
---|
60 | int main(int argc, char *argv[]) {
|
---|
61 |
|
---|
62 | bool GUIenabled = true;
|
---|
63 | bool fileInput = false;
|
---|
64 | bool confFile = false;
|
---|
65 | bool dragAndDrop = true;
|
---|
66 | QByteArray fileName;
|
---|
67 | QByteArray format;
|
---|
68 | QString dateString;
|
---|
69 | QString timeString;
|
---|
70 | QString confFileName;
|
---|
71 |
|
---|
72 | for (int ii = 1; ii < argc; ii++) {
|
---|
73 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
74 | GUIenabled = false;
|
---|
75 | break;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | for (int ii = 1; ii < argc; ii++) {
|
---|
80 | if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
|
---|
81 | GUIenabled = false;
|
---|
82 | fileInput = true;
|
---|
83 | if (ii+1 < argc) {
|
---|
84 | fileName = QByteArray(argv[ii+1]);
|
---|
85 | }
|
---|
86 | }
|
---|
87 | if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
|
---|
88 | GUIenabled = false;
|
---|
89 | fileInput = true;
|
---|
90 | dragAndDrop = false;
|
---|
91 | if (ii+1 < argc) {
|
---|
92 | format = QByteArray(argv[ii+1]);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
|
---|
96 | dragAndDrop = false;
|
---|
97 | if (ii+1 < argc) {
|
---|
98 | dateString = QString(argv[ii+1]);
|
---|
99 | }
|
---|
100 | }
|
---|
101 | if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
|
---|
102 | dragAndDrop = false;
|
---|
103 | if (ii+1 < argc) {
|
---|
104 | timeString = QString(argv[ii+1]);
|
---|
105 | }
|
---|
106 | }
|
---|
107 | if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
|
---|
108 | confFile = true;
|
---|
109 | dragAndDrop = false;
|
---|
110 | if (ii+1 < argc) {
|
---|
111 | confFileName = QString(argv[ii+1]);
|
---|
112 | }
|
---|
113 | }
|
---|
114 | if (dragAndDrop && ii == 1) {
|
---|
115 | confFile = true;
|
---|
116 | if (ii < argc) {
|
---|
117 | confFileName = QString(argv[ii]);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | QString printHelp;
|
---|
123 | printHelp = "Usage: bnc --conf <confFileName>\n"
|
---|
124 | " --file <inputFileName>\n"
|
---|
125 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
126 | " --date YYYY-MM-DD --time HH:MM:SS";
|
---|
127 |
|
---|
128 | if (confFile && confFileName.isEmpty() ) {
|
---|
129 | cout << printHelp.toAscii().data() << endl;
|
---|
130 | exit(0);
|
---|
131 | }
|
---|
132 |
|
---|
133 | bncApp app(argc, argv, GUIenabled);
|
---|
134 |
|
---|
135 | app.setApplicationName("BNC");
|
---|
136 | app.setOrganizationName("BKG");
|
---|
137 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
138 | app.setConfFileName( confFileName );
|
---|
139 |
|
---|
140 | bncSettings settings;
|
---|
141 |
|
---|
142 | // Interactive Mode - open the main window
|
---|
143 | // ---------------------------------------
|
---|
144 | if (GUIenabled) {
|
---|
145 |
|
---|
146 | QString fontString = settings.value("font").toString();
|
---|
147 | if ( !fontString.isEmpty() ) {
|
---|
148 | QFont newFont;
|
---|
149 | if (newFont.fromString(fontString)) {
|
---|
150 | QApplication::setFont(newFont);
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
155 |
|
---|
156 | bncWindow* bncWin = new bncWindow();
|
---|
157 | bncWin->show();
|
---|
158 | }
|
---|
159 |
|
---|
160 | // Non-Interactive (Batch) Mode
|
---|
161 | // ----------------------------
|
---|
162 | else {
|
---|
163 |
|
---|
164 | signal(SIGINT, catch_signal);
|
---|
165 |
|
---|
166 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
167 | settings.value("outPort").toInt());
|
---|
168 |
|
---|
169 | app.setCaster(caster);
|
---|
170 | app.setPort(settings.value("outEphPort").toInt());
|
---|
171 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
172 |
|
---|
173 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
174 |
|
---|
175 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
|
---|
176 |
|
---|
177 | // Normal case - data from Internet
|
---|
178 | // --------------------------------
|
---|
179 | if (!fileInput) {
|
---|
180 | caster->slotReadMountPoints();
|
---|
181 | if (caster->numStations() == 0) {
|
---|
182 | return 0;
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 | // Special case - data from file
|
---|
187 | // -----------------------------
|
---|
188 | else {
|
---|
189 | if ( fileName.isEmpty() || format.isEmpty() ||
|
---|
190 | dateString.isEmpty() || timeString.isEmpty() ) {
|
---|
191 | cout << printHelp.toAscii().data() << endl;
|
---|
192 | exit(0);
|
---|
193 | }
|
---|
194 |
|
---|
195 | app._currentDateAndTimeGPS =
|
---|
196 | new QDateTime(QDate::fromString(dateString, Qt::ISODate),
|
---|
197 | QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
|
---|
198 |
|
---|
199 | bncGetThread* getThread = new bncGetThread(fileName, format);
|
---|
200 | caster->addGetThread(getThread);
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | // Start the application
|
---|
205 | // ---------------------
|
---|
206 | return app.exec();
|
---|
207 | }
|
---|