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

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

* empty log message *

File size: 8.2 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
70 for (int ii = 1; ii < argc; ii++) {
71 if (QByteArray(argv[ii]) == "-nw") {
72 GUIenabled = false;
73 break;
74 }
75 }
76
77 for (int ii = 1; ii < argc; ii++) {
78 if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
79 GUIenabled = false;
80 fileInput = true;
81 if (ii+1 < argc) {
82 fileName = QByteArray(argv[ii+1]);
83 }
84 }
85 if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
86 GUIenabled = false;
87 fileInput = true;
88 if (ii+1 < argc) {
89 format = QByteArray(argv[ii+1]);
90 }
91 }
92 if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
93 if (ii+1 < argc) {
94 dateString = QString(argv[ii+1]);
95 }
96 }
97 if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
98 if (ii+1 < argc) {
99 timeString = QString(argv[ii+1]);
100 }
101 }
102 if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
103 confFile = true;
104 if (ii+1 < argc) {
105 confFileName = QString(argv[ii+1]);
106 }
107 }
108 }
109
110 QString printHelp;
111 printHelp = "Usage: bnc --conf <confFileName>\n"
112 " --file <inputFileName>\n"
113 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
114 " --date YYYY-MM-DD --time HH:MM:SS";
115
116 if (confFile && confFileName.isEmpty() ) {
117 cout << printHelp.toAscii().data() << endl;
118 exit(0);
119 }
120
121 QCoreApplication::setOrganizationName("BKG");
122 QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
123 if (!confFileName.isEmpty()) {
124 QCoreApplication::setApplicationName(confFileName);
125 } else {
126 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
127 }
128
129 // Default Settings
130 // ----------------
131 QSettings settings;
132 if (settings.allKeys().size() == 0) {
133 settings.setValue("adviseFail", "15");
134 settings.setValue("adviseReco", "5");
135 settings.setValue("adviseScript", "");
136 settings.setValue("autoStart", "0");
137 settings.setValue("binSampl", "0");
138 settings.setValue("casterUrlList", "http://user:pass@www.euref-ip.net:2101");
139 settings.setValue("corrIntr", "1 day");
140 settings.setValue("corrPath", "");
141 settings.setValue("corrPort", "");
142 settings.setValue("corrTime", "5");
143 settings.setValue("ephIntr", "1 day");
144 settings.setValue("ephPath", "");
145 settings.setValue("ephV3", "0");
146 settings.setValue("logFile", "");
147 settings.setValue("makePause", "0");
148 settings.setValue("miscMount", "");
149 settings.setValue("mountPoints", "");
150 settings.setValue("ntripVersion", "1");
151 settings.setValue("obsRate", "");
152 settings.setValue("onTheFlyInterval", "1 day");
153 settings.setValue("outEphPort", "");
154 settings.setValue("outFile", "");
155 settings.setValue("outPort", "");
156 settings.setValue("outUPort", "");
157 settings.setValue("perfIntr", "");
158 settings.setValue("proxyHost", "");
159 settings.setValue("proxyPort", "");
160 settings.setValue("rnxAppend", "0");
161 settings.setValue("rnxIntr", "15 min");
162 settings.setValue("rnxPath", "");
163 settings.setValue("rnxSampl", "0");
164 settings.setValue("rnxScript", "");
165 settings.setValue("rnxSkel", "SKL");
166 settings.setValue("rnxV3", "0");
167 settings.setValue("scanRTCM", "0");
168 settings.setValue("serialAutoNMEA", "0");
169 settings.setValue("serialBaudRate", "9600");
170 settings.setValue("serialDataBits", "8");
171 settings.setValue("serialMountPoint", "");
172 settings.setValue("serialParity", "NONE");
173 settings.setValue("serialPortName", "");
174 settings.setValue("serialStopBits", "1");
175 settings.setValue("startTab", "0");
176 settings.setValue("waitTime", "5");
177
178 }
179
180 // Truncate list of casters
181 // ------------------------
182 int maxListSize = 5;
183 QStringList casterHostList = settings.value("casterHostList").toStringList();
184 if ( casterHostList.count() > maxListSize ) {
185 QStringList listCopy;
186 for (int ii = 0; ii < maxListSize; ii++) {
187 listCopy.push_back(casterHostList[ii]);
188 }
189 settings.setValue("casterHostList", listCopy);
190 }
191
192
193 bncApp app(argc, argv, GUIenabled);
194
195 int waitCoTime = settings.value("corrTime").toInt();
196 if (waitCoTime < 1) {
197 waitCoTime = 1;
198 }
199 app.setWaitCoTime(waitCoTime);
200
201 // Interactive Mode - open the main window
202 // ---------------------------------------
203 if (GUIenabled) {
204
205 QString fontString = settings.value("font").toString();
206 if ( !fontString.isEmpty() ) {
207 QFont newFont;
208 if (newFont.fromString(fontString)) {
209 QApplication::setFont(newFont);
210 }
211 }
212
213 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
214
215 bncWindow* bncWin = new bncWindow();
216 bncWin->show();
217 }
218
219 // Non-Interactive (Batch) Mode
220 // ----------------------------
221 else {
222
223 signal(SIGINT, catch_signal);
224
225 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
226 settings.value("outPort").toInt());
227
228 app.setCaster(caster);
229 app.setPort(settings.value("outEphPort").toInt());
230 app.setPortCorr(settings.value("corrPort").toInt());
231
232 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
233
234 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
235
236 // Normal case - data from Internet
237 // --------------------------------
238 if (!fileInput) {
239 caster->slotReadMountPoints();
240 if (caster->numStations() == 0) {
241 return 0;
242 }
243 }
244
245 // Special case - data from file
246 // -----------------------------
247 else {
248 if ( fileName.isEmpty() || format.isEmpty() ||
249 dateString.isEmpty() || timeString.isEmpty() ) {
250 cout << printHelp.toAscii().data() << endl;
251 exit(0);
252 }
253
254 app._currentDateAndTimeGPS =
255 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
256 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
257
258 bncGetThread* getThread = new bncGetThread(fileName, format);
259 caster->addGetThread(getThread);
260 }
261 }
262
263 // Start the application
264 // ---------------------
265 return app.exec();
266}
Note: See TracBrowser for help on using the repository browser.