source: ntrip/trunk/BNC/bncmain.cpp@ 1501

Last change on this file since 1501 was 1501, checked in by weber, 15 years ago

* empty log message *

File size: 7.0 KB
Line 
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
50using namespace std;
51
52void catch_signal(int) {
53 cout << "Program Interrupted by Ctrl-C" << endl;
54 ((bncApp*)qApp)->slotQuit();
55}
56
57// Main Program
58/////////////////////////////////////////////////////////////////////////////
59int main(int argc, char *argv[]) {
60
61 bool GUIenabled = true;
62 bool fileInput = false;
63 bool confFile = false;
64 QByteArray fileName;
65 QByteArray format;
66 QString dateString;
67 QString timeString;
68 QString confFileName;
69 QString confFileIs;
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 if (confFile && confFileName.isEmpty() ) {
112 cout << "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" << endl;
116 exit(0);
117 }
118
119 QCoreApplication::setOrganizationName("BKG");
120 QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
121 if (!confFileName.isEmpty()) {
122 confFileIs = confFileName;
123 } else {
124 confFileIs = "BKG_NTRIP_Client";
125 }
126 QCoreApplication::setApplicationName(confFileIs);
127
128 // Default Settings
129 // ----------------
130 QSettings settings;
131 if (settings.allKeys().size() == 0) {
132 settings.setValue("casterHost", "www.euref-ip.net");
133 settings.setValue("casterHostList", QStringList());
134 settings.setValue("casterPort", 2101);
135 settings.setValue("rnxIntr", "15 min");
136 settings.setValue("ephIntr", "1 day");
137 settings.setValue("corrIntr", "1 day");
138 settings.setValue("rnxSkel", "SKL");
139 settings.setValue("waitTime", "5");
140 settings.setValue("makePause", 0);
141 settings.setValue("obsRate", "");
142 settings.setValue("adviseFail", "15");
143 settings.setValue("adviseReco", "5");
144 settings.setValue("perfIntr", "");
145 settings.setValue("corrTime", "5");
146 settings.setValue("miscMount", "");
147 }
148
149 // Truncate list of casters
150 // ------------------------
151 int maxListSize = 5;
152 QStringList casterHostList = settings.value("casterHostList").toStringList();
153 if ( casterHostList.count() > maxListSize ) {
154 QStringList listCopy;
155 for (int ii = 0; ii < maxListSize; ii++) {
156 listCopy.push_back(casterHostList[ii]);
157 }
158 settings.setValue("casterHostList", listCopy);
159 }
160
161
162 bncApp app(argc, argv, GUIenabled);
163
164 int waitCoTime = settings.value("corrTime").toInt();
165 if (waitCoTime < 1) {
166 waitCoTime = 1;
167 }
168 app.setWaitCoTime(waitCoTime);
169
170 // Interactive Mode - open the main window
171 // ---------------------------------------
172 if (GUIenabled) {
173
174 QString fontString = settings.value("font").toString();
175 if ( !fontString.isEmpty() ) {
176 QFont newFont;
177 if (newFont.fromString(fontString)) {
178 QApplication::setFont(newFont);
179 }
180 }
181
182 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
183
184 bncWindow* bncWin = new bncWindow();
185 bncWin->show();
186 }
187
188 // Non-Interactive (Batch) Mode
189 // ----------------------------
190 else {
191
192 signal(SIGINT, catch_signal);
193
194 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
195 settings.value("outPort").toInt());
196
197 app.setCaster(caster);
198 app.setPort(settings.value("outEphPort").toInt());
199 app.setPortCorr(settings.value("corrPort").toInt());
200
201 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
202
203 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
204
205 // Normal case - data from Internet
206 // --------------------------------
207 if (!fileInput) {
208 caster->slotReadMountPoints();
209 if (caster->numStations() == 0) {
210 return 0;
211 }
212 }
213
214 // Special case - data from file
215 // -----------------------------
216 else {
217 if ( fileName.isEmpty() || format.isEmpty() ||
218 dateString.isEmpty() || timeString.isEmpty() ) {
219 cout << "Usage: bnc --conf <confFileName>\n"
220 " --file <inputFileName>\n"
221 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
222 " --date YYYY-MM-DD --time HH:MM:SS" << endl;
223 exit(0);
224 }
225
226 app._currentDateAndTimeGPS =
227 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
228 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
229
230 bncGetThread* getThread = new bncGetThread(fileName, format);
231 caster->addGetThread(getThread);
232 }
233 }
234
235 // Start the application
236 // ---------------------
237 return app.exec();
238}
Note: See TracBrowser for help on using the repository browser.