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

Last change on this file since 1280 was 1273, checked in by zdenek, 16 years ago

* empty log message *

File size: 5.9 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");
124 settings.setValue("messTypes", "");
[180]125 }
[114]126
[533]127 bncApp app(argc, argv, GUIenabled);
128
[1166]129 int waitCoTime = settings.value("corrTime").toInt();
130 if (waitCoTime < 1) {
131 waitCoTime = 1;
132 }
133 app.setWaitCoTime(waitCoTime);
134
[180]135 // Interactive Mode - open the main window
136 // ---------------------------------------
[35]137 if (GUIenabled) {
[113]138
139 QString fontString = settings.value("font").toString();
140 if ( !fontString.isEmpty() ) {
141 QFont newFont;
142 if (newFont.fromString(fontString)) {
143 QApplication::setFont(newFont);
144 }
145 }
[142]146
[173]147 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]148
[82]149 bncWindow* bncWin = new bncWindow();
[35]150 bncWin->show();
151 }
[180]152
153 // Non-Interactive (Batch) Mode
154 // ----------------------------
[35]155 else {
[621]156
[1138]157 signal(SIGINT, catch_signal);
158
[621]159 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
160 settings.value("outPort").toInt());
161
162 app.setCaster(caster);
[592]163 app.setPort(settings.value("outEphPort").toInt());
[937]164 app.setPortCorr(settings.value("corrPort").toInt());
[592]165
[621]166 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
[295]167
168 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
[35]169
[1170]170 // Normal case - data from Internet
171 // --------------------------------
172 if (!fileInput) {
[1179]173 caster->slotReadMountPoints();
[1170]174 if (caster->numStations() == 0) {
175 return 0;
176 }
177 }
178
179 // Special case - data from file
180 // -----------------------------
181 else {
[1156]182 if ( fileName.isEmpty() || format.isEmpty() ||
183 dateString.isEmpty() || timeString.isEmpty() ) {
184 cout << "Usage: bnc --file <fileName>\n"
185 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
186 " --date YYYY-MM-DD --time HH:MM:SS" << endl;
[1146]187 exit(0);
188 }
189
[1156]190 app._currentDateAndTimeGPS =
[1157]191 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
192 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
[1156]193
[1146]194 bncGetThread* getThread = new bncGetThread(fileName, format);
[621]195 caster->addGetThread(getThread);
[35]196 }
197 }
[180]198
199 // Start the application
200 // ---------------------
[35]201 return app.exec();
202}
Note: See TracBrowser for help on using the repository browser.