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

Last change on this file since 1170 was 1170, checked in by mervart, 16 years ago

* empty log message *

File size: 6.1 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("casterPort", 2101);
112 settings.setValue("rnxIntr", "15 min");
113 settings.setValue("ephIntr", "1 day");
114 settings.setValue("corrIntr", "1 day");
115 settings.setValue("rnxSkel", "SKL");
116 settings.setValue("waitTime", "5");
117 settings.setValue("makePause", 0);
118 settings.setValue("obsRate", "");
119 settings.setValue("adviseFail", "15");
120 settings.setValue("adviseReco", "5");
121 settings.setValue("perfIntr", "");
122 settings.setValue("corrTime", "5");
123 settings.setValue("messTypes", "");
124 }
125
126 bncApp app(argc, argv, GUIenabled);
127
128 int waitCoTime = settings.value("corrTime").toInt();
129 if (waitCoTime < 1) {
130 waitCoTime = 1;
131 }
132 app.setWaitCoTime(waitCoTime);
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 app.connect(caster, SIGNAL(newMessage(QByteArray)),
167 &app, SLOT(slotMessage(QByteArray)));
168
169 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
170
171 // Normal case - data from Internet
172 // --------------------------------
173 if (!fileInput) {
174 caster->slotReadMountpoints();
175 if (caster->numStations() == 0) {
176 return 0;
177 }
178 }
179
180 // Special case - data from file
181 // -----------------------------
182 else {
183 if ( fileName.isEmpty() || format.isEmpty() ||
184 dateString.isEmpty() || timeString.isEmpty() ) {
185 cout << "Usage: bnc --file <fileName>\n"
186 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
187 " --date YYYY-MM-DD --time HH:MM:SS" << endl;
188 exit(0);
189 }
190
191 app._currentDateAndTimeGPS =
192 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
193 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
194
195 bncGetThread* getThread = new bncGetThread(fileName, format);
196 app.connect(getThread, SIGNAL(newMessage(QByteArray)),
197 &app, SLOT(slotMessage(const QByteArray)));
198
199 caster->addGetThread(getThread);
200 }
201 }
202
203 // Start the application
204 // ---------------------
205 return app.exec();
206}
Note: See TracBrowser for help on using the repository browser.