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

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

* empty log message *

File size: 4.4 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
52bncCaster* _caster = 0;
53
54void catch_signal(int) {
55 delete _caster;
56 cout << "Program Interrupted by Ctrl-C" << endl;
57 ((bncApp*)qApp)->quit();
58}
59
60// Main Program
61/////////////////////////////////////////////////////////////////////////////
62int main(int argc, char *argv[]) {
63
64 bool GUIenabled = true;
65 for (int ii = 1; ii < argc; ii++) {
66 if (QString(argv[ii]) == "-nw") {
67 GUIenabled = false;
68 break;
69 }
70 }
71
72 QCoreApplication::setOrganizationName("BKG");
73 QCoreApplication::setOrganizationDomain("www.ifag.de");
74 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
75
76 // Default Settings
77 // ----------------
78 QSettings settings;
79 if (settings.allKeys().size() == 0) {
80 settings.setValue("casterHost", "www.euref-ip.net");
81 settings.setValue("casterPort", 80);
82 settings.setValue("rnxIntr", "15 min");
83 settings.setValue("ephIntr", "1 day");
84 settings.setValue("rnxSkel", "SKL");
85 settings.setValue("waitTime", 5);
86 }
87
88 bncApp app(argc, argv, GUIenabled);
89
90 // Interactive Mode - open the main window
91 // ---------------------------------------
92 if (GUIenabled) {
93
94 QString fontString = settings.value("font").toString();
95 if ( !fontString.isEmpty() ) {
96 QFont newFont;
97 if (newFont.fromString(fontString)) {
98 QApplication::setFont(newFont);
99 }
100 }
101
102 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
103
104 bncWindow* bncWin = new bncWindow();
105 bncWin->show();
106 }
107
108 // Non-Interactive (Batch) Mode
109 // ----------------------------
110 else {
111 // Ctrl-C Signal Handling
112 // ----------------------
113 signal(SIGINT, catch_signal);
114
115 _caster = new bncCaster(settings.value("outFile").toString(),
116 settings.value("outPort").toInt());
117
118 app.setPort(settings.value("outEphPort").toInt());
119
120 app.connect(_caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
121 app.connect(_caster, SIGNAL(newMessage(const QByteArray&)),
122 &app, SLOT(slotMessage(const QByteArray&)));
123
124 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
125
126 int iMount = -1;
127 QListIterator<QString> it(settings.value("mountPoints").toStringList());
128 while (it.hasNext()) {
129 ++iMount;
130 QStringList hlp = it.next().split(" ");
131 if (hlp.size() <= 1) continue;
132 QUrl url(hlp[0]);
133 QByteArray format = hlp[1].toAscii();
134 QByteArray latitude = hlp[2].toAscii();
135 QByteArray longitude = hlp[3].toAscii();
136 QByteArray nmea = hlp[4].toAscii();
137 bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
138 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
139 &app, SLOT(slotMessage(const QByteArray&)));
140
141 _caster->addGetThread(getThread);
142
143 getThread->start();
144 }
145 if (_caster->numStations() == 0) {
146 return 0;
147 }
148 }
149
150 // Start the application
151 // ---------------------
152 return app.exec();
153}
Note: See TracBrowser for help on using the repository browser.