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
RevLine 
[280]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.
[35]25
26/* -------------------------------------------------------------------------
[93]27 * BKG NTRIP Client
[35]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
[274]42#include <unistd.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
[82]52// Main Program
53/////////////////////////////////////////////////////////////////////////////
[35]54int main(int argc, char *argv[]) {
55
56 bool GUIenabled = true;
[100]57 for (int ii = 1; ii < argc; ii++) {
58 if (QString(argv[ii]) == "-nw") {
59 GUIenabled = false;
60 break;
61 }
[35]62 }
63
[82]64 bncApp app(argc, argv, GUIenabled);
[35]65
[93]66 QCoreApplication::setOrganizationName("BKG");
67 QCoreApplication::setOrganizationDomain("www.ifag.de");
68 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
[35]69
[180]70 // Default Settings
71 // ----------------
[113]72 QSettings settings;
[180]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 }
[114]80
[180]81 // Interactive Mode - open the main window
82 // ---------------------------------------
[35]83 if (GUIenabled) {
[113]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 }
[142]92
[173]93 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]94
[82]95 bncWindow* bncWin = new bncWindow();
[35]96 bncWin->show();
97 }
[180]98
99 // Non-Interactive (Batch) Mode
100 // ----------------------------
[35]101 else {
[463]102 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
103 settings.value("outPort").toInt());
[35]104
[463]105 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
106 app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
[82]107 &app, SLOT(slotMessage(const QByteArray&)));
[295]108
109 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
[35]110
[278]111 int iMount = -1;
[35]112 QListIterator<QString> it(settings.value("mountPoints").toStringList());
113 while (it.hasNext()) {
[278]114 ++iMount;
[59]115 QStringList hlp = it.next().split(" ");
[82]116 if (hlp.size() <= 1) continue;
[59]117 QUrl url(hlp[0]);
[88]118 QByteArray format = hlp[1].toAscii();
[366]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);
[82]123 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
124 &app, SLOT(slotMessage(const QByteArray&)));
125
[463]126 caster->addGetThread(getThread);
[35]127
128 getThread->start();
129 }
[463]130 if (caster->numStations() == 0) {
[82]131 return 0;
132 }
[35]133 }
[180]134
135 // Start the application
136 // ---------------------
[35]137 return app.exec();
138}
Note: See TracBrowser for help on using the repository browser.