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

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

* empty log message *

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