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

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

* empty log message *

File size: 6.3 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]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
[274]41#include <unistd.h>
[603]42#include <signal.h>
[35]43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
[82]47#include "bncapp.h"
[35]48#include "bncwindow.h"
49
50using namespace std;
51
[603]52void catch_signal(int) {
53 cout << "Program Interrupted by Ctrl-C" << endl;
[621]54 ((bncApp*)qApp)->slotQuit();
[603]55}
56
[82]57// Main Program
58/////////////////////////////////////////////////////////////////////////////
[35]59int main(int argc, char *argv[]) {
60
[1146]61 bool GUIenabled = true;
62 bool fileInput = false;
63 QByteArray fileName;
64 QByteArray format;
[1156]65 QString dateString;
66 QString timeString;
[1146]67
[100]68 for (int ii = 1; ii < argc; ii++) {
[1146]69 if (QByteArray(argv[ii]) == "-nw") {
[100]70 GUIenabled = false;
71 break;
72 }
[35]73 }
74
[1146]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 }
[1156]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 }
[1146]100 }
101
[93]102 QCoreApplication::setOrganizationName("BKG");
[684]103 QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
[93]104 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
[35]105
[180]106 // Default Settings
107 // ----------------
[113]108 QSettings settings;
[180]109 if (settings.allKeys().size() == 0) {
110 settings.setValue("casterHost", "www.euref-ip.net");
[1273]111 settings.setValue("casterHostList", QStringList());
[684]112 settings.setValue("casterPort", 2101);
[180]113 settings.setValue("rnxIntr", "15 min");
[565]114 settings.setValue("ephIntr", "1 day");
[951]115 settings.setValue("corrIntr", "1 day");
[180]116 settings.setValue("rnxSkel", "SKL");
[1035]117 settings.setValue("waitTime", "5");
[722]118 settings.setValue("makePause", 0);
[686]119 settings.setValue("obsRate", "");
[668]120 settings.setValue("adviseFail", "15");
121 settings.setValue("adviseReco", "5");
[728]122 settings.setValue("perfIntr", "");
[1035]123 settings.setValue("corrTime", "5");
[1307]124 settings.setValue("miscMount", "");
[180]125 }
[114]126
[1282]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
[533]141 bncApp app(argc, argv, GUIenabled);
142
[1166]143 int waitCoTime = settings.value("corrTime").toInt();
144 if (waitCoTime < 1) {
145 waitCoTime = 1;
146 }
147 app.setWaitCoTime(waitCoTime);
148
[180]149 // Interactive Mode - open the main window
150 // ---------------------------------------
[35]151 if (GUIenabled) {
[113]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 }
[142]160
[173]161 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]162
[82]163 bncWindow* bncWin = new bncWindow();
[35]164 bncWin->show();
165 }
[180]166
167 // Non-Interactive (Batch) Mode
168 // ----------------------------
[35]169 else {
[621]170
[1138]171 signal(SIGINT, catch_signal);
172
[621]173 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
174 settings.value("outPort").toInt());
175
176 app.setCaster(caster);
[592]177 app.setPort(settings.value("outEphPort").toInt());
[937]178 app.setPortCorr(settings.value("corrPort").toInt());
[592]179
[621]180 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
[295]181
[1299]182 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
[35]183
[1170]184 // Normal case - data from Internet
185 // --------------------------------
186 if (!fileInput) {
[1179]187 caster->slotReadMountPoints();
[1170]188 if (caster->numStations() == 0) {
189 return 0;
190 }
191 }
192
193 // Special case - data from file
194 // -----------------------------
195 else {
[1156]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;
[1146]201 exit(0);
202 }
203
[1156]204 app._currentDateAndTimeGPS =
[1157]205 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
206 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
[1156]207
[1146]208 bncGetThread* getThread = new bncGetThread(fileName, format);
[621]209 caster->addGetThread(getThread);
[35]210 }
211 }
[180]212
213 // Start the application
214 // ---------------------
[35]215 return app.exec();
216}
Note: See TracBrowser for help on using the repository browser.