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

Last change on this file since 366 was 366, checked in by mervart, 17 years ago

* empty log message *

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