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 | QByteArray fileName;
|
---|
66 | QByteArray format;
|
---|
67 | QString dateString;
|
---|
68 | QString timeString;
|
---|
69 | QString confFileName;
|
---|
70 |
|
---|
71 | for (int ii = 1; ii < argc; ii++) {
|
---|
72 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
73 | GUIenabled = false;
|
---|
74 | break;
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | for (int ii = 1; ii < argc; ii++) {
|
---|
79 | if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
|
---|
80 | GUIenabled = false;
|
---|
81 | fileInput = true;
|
---|
82 | if (ii+1 < argc) {
|
---|
83 | fileName = QByteArray(argv[ii+1]);
|
---|
84 | }
|
---|
85 | }
|
---|
86 | if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
|
---|
87 | GUIenabled = false;
|
---|
88 | fileInput = true;
|
---|
89 | if (ii+1 < argc) {
|
---|
90 | format = QByteArray(argv[ii+1]);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
|
---|
94 | if (ii+1 < argc) {
|
---|
95 | dateString = QString(argv[ii+1]);
|
---|
96 | }
|
---|
97 | }
|
---|
98 | if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
|
---|
99 | if (ii+1 < argc) {
|
---|
100 | timeString = QString(argv[ii+1]);
|
---|
101 | }
|
---|
102 | }
|
---|
103 | if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
|
---|
104 | confFile = true;
|
---|
105 | if (ii+1 < argc) {
|
---|
106 | confFileName = QString(argv[ii+1]);
|
---|
107 | }
|
---|
108 | }
|
---|
109 | }
|
---|
110 |
|
---|
111 | QString printHelp;
|
---|
112 | printHelp = "Usage: bnc --conf <confFileName>\n"
|
---|
113 | " --file <inputFileName>\n"
|
---|
114 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
115 | " --date YYYY-MM-DD --time HH:MM:SS";
|
---|
116 |
|
---|
117 | if (confFile && confFileName.isEmpty() ) {
|
---|
118 | cout << printHelp.toAscii().data() << endl;
|
---|
119 | exit(0);
|
---|
120 | }
|
---|
121 |
|
---|
122 | QCoreApplication::setOrganizationName("BKG");
|
---|
123 | QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
|
---|
124 | if (!confFileName.isEmpty()) {
|
---|
125 | QCoreApplication::setApplicationName(confFileName);
|
---|
126 | } else {
|
---|
127 | QCoreApplication::setApplicationName("BNC");
|
---|
128 | }
|
---|
129 |
|
---|
130 | bncApp app(argc, argv, GUIenabled);
|
---|
131 |
|
---|
132 | bncSettings settings;
|
---|
133 |
|
---|
134 | // Interactive Mode - open the main window
|
---|
135 | // ---------------------------------------
|
---|
136 | if (GUIenabled) {
|
---|
137 |
|
---|
138 | QString fontString = settings.value("font").toString();
|
---|
139 | if ( !fontString.isEmpty() ) {
|
---|
140 | QFont newFont;
|
---|
141 | if (newFont.fromString(fontString)) {
|
---|
142 | QApplication::setFont(newFont);
|
---|
143 | }
|
---|
144 | }
|
---|
145 |
|
---|
146 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
147 |
|
---|
148 | bncWindow* bncWin = new bncWindow();
|
---|
149 | bncWin->show();
|
---|
150 | }
|
---|
151 |
|
---|
152 | // Non-Interactive (Batch) Mode
|
---|
153 | // ----------------------------
|
---|
154 | else {
|
---|
155 |
|
---|
156 | signal(SIGINT, catch_signal);
|
---|
157 |
|
---|
158 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
159 | settings.value("outPort").toInt());
|
---|
160 |
|
---|
161 | app.setCaster(caster);
|
---|
162 | app.setPort(settings.value("outEphPort").toInt());
|
---|
163 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
164 |
|
---|
165 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
166 |
|
---|
167 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
|
---|
168 |
|
---|
169 | // Normal case - data from Internet
|
---|
170 | // --------------------------------
|
---|
171 | if (!fileInput) {
|
---|
172 | caster->slotReadMountPoints();
|
---|
173 | if (caster->numStations() == 0) {
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | // Special case - data from file
|
---|
179 | // -----------------------------
|
---|
180 | else {
|
---|
181 | if ( fileName.isEmpty() || format.isEmpty() ||
|
---|
182 | dateString.isEmpty() || timeString.isEmpty() ) {
|
---|
183 | cout << printHelp.toAscii().data() << endl;
|
---|
184 | exit(0);
|
---|
185 | }
|
---|
186 |
|
---|
187 | app._currentDateAndTimeGPS =
|
---|
188 | new QDateTime(QDate::fromString(dateString, Qt::ISODate),
|
---|
189 | QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
|
---|
190 |
|
---|
191 | bncGetThread* getThread = new bncGetThread(fileName, format);
|
---|
192 | caster->addGetThread(getThread);
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | // Start the application
|
---|
197 | // ---------------------
|
---|
198 | return app.exec();
|
---|
199 | }
|
---|