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

Last change on this file since 506 was 464, checked in by weber, 18 years ago

* empty log message *

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