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

Last change on this file since 463 was 463, checked in by mervart, 17 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// written by Leos Mervart.
4//
5// Copyright (C) 2006
6// German Federal Agency for Cartography and Geodesy (BKG)
7// http://www.bkg.bund.de
8// Czech Technical University Prague, Department of Advanced Geodesy
9// http://www.fsv.cvut.cz
10//
11// Email: euref-ip@bkg.bund.de
12//
13// This program is free software; you can redistribute it and/or
14// modify it under the terms of the GNU General Public License
15// as published by the Free Software Foundation, version 2.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26/* -------------------------------------------------------------------------
27 * BKG NTRIP Client
28 * -------------------------------------------------------------------------
29 *
30 * Class: main
31 *
32 * Purpose: Application starts here
33 *
34 * Author: L. Mervart
35 *
36 * Created: 24-Dec-2005
37 *
38 * Changes:
39 *
40 * -----------------------------------------------------------------------*/
41
42#include <unistd.h>
43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
47#include "bncapp.h"
48#include "bncwindow.h"
49
50using namespace std;
51
52// Main Program
53/////////////////////////////////////////////////////////////////////////////
54int main(int argc, char *argv[]) {
55
56 bool GUIenabled = true;
57 for (int ii = 1; ii < argc; ii++) {
58 if (QString(argv[ii]) == "-nw") {
59 GUIenabled = false;
60 break;
61 }
62 }
63
64 bncApp app(argc, argv, GUIenabled);
65
66 QCoreApplication::setOrganizationName("BKG");
67 QCoreApplication::setOrganizationDomain("www.ifag.de");
68 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
69
70 // Default Settings
71 // ----------------
72 QSettings settings;
73 if (settings.allKeys().size() == 0) {
74 settings.setValue("casterHost", "www.euref-ip.net");
75 settings.setValue("casterPort", 80);
76 settings.setValue("rnxIntr", "15 min");
77 settings.setValue("rnxSkel", "SKL");
78 settings.setValue("waitTime", 2);
79 }
80
81 // Interactive Mode - open the main window
82 // ---------------------------------------
83 if (GUIenabled) {
84
85 QString fontString = settings.value("font").toString();
86 if ( !fontString.isEmpty() ) {
87 QFont newFont;
88 if (newFont.fromString(fontString)) {
89 QApplication::setFont(newFont);
90 }
91 }
92
93 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
94
95 bncWindow* bncWin = new bncWindow();
96 bncWin->show();
97 }
98
99 // Non-Interactive (Batch) Mode
100 // ----------------------------
101 else {
102 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
103 settings.value("outPort").toInt());
104
105 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
106 app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
107 &app, SLOT(slotMessage(const QByteArray&)));
108
109 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
110
111 int iMount = -1;
112 QListIterator<QString> it(settings.value("mountPoints").toStringList());
113 while (it.hasNext()) {
114 ++iMount;
115 QStringList hlp = it.next().split(" ");
116 if (hlp.size() <= 1) continue;
117 QUrl url(hlp[0]);
118 QByteArray format = hlp[1].toAscii();
119 QByteArray latitude = hlp[2].toAscii();
120 QByteArray longitude = hlp[3].toAscii();
121 QByteArray nmea = hlp[4].toAscii();
122 bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
123 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
124 &app, SLOT(slotMessage(const QByteArray&)));
125
126 caster->addGetThread(getThread);
127
128 getThread->start();
129 }
130 if (caster->numStations() == 0) {
131 return 0;
132 }
133 }
134
135 // Start the application
136 // ---------------------
137 return app.exec();
138}
Note: See TracBrowser for help on using the repository browser.