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

Last change on this file since 1479 was 1307, checked in by weber, 16 years ago

* empty log message *

File size: 6.3 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 QByteArray fileName;
64 QByteArray format;
65 QString dateString;
66 QString timeString;
67
68 for (int ii = 1; ii < argc; ii++) {
69 if (QByteArray(argv[ii]) == "-nw") {
70 GUIenabled = false;
71 break;
72 }
73 }
74
75 for (int ii = 1; ii < argc; ii++) {
76 if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
77 GUIenabled = false;
78 fileInput = true;
79 if (ii+1 < argc) {
80 fileName = QByteArray(argv[ii+1]);
81 }
82 }
83 if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
84 GUIenabled = false;
85 fileInput = true;
86 if (ii+1 < argc) {
87 format = QByteArray(argv[ii+1]);
88 }
89 }
90 if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
91 if (ii+1 < argc) {
92 dateString = QString(argv[ii+1]);
93 }
94 }
95 if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
96 if (ii+1 < argc) {
97 timeString = QString(argv[ii+1]);
98 }
99 }
100 }
101
102 QCoreApplication::setOrganizationName("BKG");
103 QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
104 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
105
106 // Default Settings
107 // ----------------
108 QSettings settings;
109 if (settings.allKeys().size() == 0) {
110 settings.setValue("casterHost", "www.euref-ip.net");
111 settings.setValue("casterHostList", QStringList());
112 settings.setValue("casterPort", 2101);
113 settings.setValue("rnxIntr", "15 min");
114 settings.setValue("ephIntr", "1 day");
115 settings.setValue("corrIntr", "1 day");
116 settings.setValue("rnxSkel", "SKL");
117 settings.setValue("waitTime", "5");
118 settings.setValue("makePause", 0);
119 settings.setValue("obsRate", "");
120 settings.setValue("adviseFail", "15");
121 settings.setValue("adviseReco", "5");
122 settings.setValue("perfIntr", "");
123 settings.setValue("corrTime", "5");
124 settings.setValue("miscMount", "");
125 }
126
127 // Truncate list of casters
128 // ------------------------
129 int maxListSize = 5;
130 QStringList casterHostList = settings.value("casterHostList").toStringList();
131 if ( casterHostList.count() > maxListSize ) {
132 QStringList listCopy;
133 for (int ii = 0; ii < maxListSize; ii++) {
134 listCopy.push_back(casterHostList[ii]);
135 }
136 settings.setValue("casterHostList", listCopy);
137 }
138
139
140
141 bncApp app(argc, argv, GUIenabled);
142
143 int waitCoTime = settings.value("corrTime").toInt();
144 if (waitCoTime < 1) {
145 waitCoTime = 1;
146 }
147 app.setWaitCoTime(waitCoTime);
148
149 // Interactive Mode - open the main window
150 // ---------------------------------------
151 if (GUIenabled) {
152
153 QString fontString = settings.value("font").toString();
154 if ( !fontString.isEmpty() ) {
155 QFont newFont;
156 if (newFont.fromString(fontString)) {
157 QApplication::setFont(newFont);
158 }
159 }
160
161 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
162
163 bncWindow* bncWin = new bncWindow();
164 bncWin->show();
165 }
166
167 // Non-Interactive (Batch) Mode
168 // ----------------------------
169 else {
170
171 signal(SIGINT, catch_signal);
172
173 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
174 settings.value("outPort").toInt());
175
176 app.setCaster(caster);
177 app.setPort(settings.value("outEphPort").toInt());
178 app.setPortCorr(settings.value("corrPort").toInt());
179
180 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
181
182 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
183
184 // Normal case - data from Internet
185 // --------------------------------
186 if (!fileInput) {
187 caster->slotReadMountPoints();
188 if (caster->numStations() == 0) {
189 return 0;
190 }
191 }
192
193 // Special case - data from file
194 // -----------------------------
195 else {
196 if ( fileName.isEmpty() || format.isEmpty() ||
197 dateString.isEmpty() || timeString.isEmpty() ) {
198 cout << "Usage: bnc --file <fileName>\n"
199 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
200 " --date YYYY-MM-DD --time HH:MM:SS" << endl;
201 exit(0);
202 }
203
204 app._currentDateAndTimeGPS =
205 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
206 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
207
208 bncGetThread* getThread = new bncGetThread(fileName, format);
209 caster->addGetThread(getThread);
210 }
211 }
212
213 // Start the application
214 // ---------------------
215 return app.exec();
216}
Note: See TracBrowser for help on using the repository browser.