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

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

* empty log message *

File size: 4.2 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 QCoreApplication::setOrganizationName("BKG");
64 QCoreApplication::setOrganizationDomain("www.ifag.de");
65 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
66
67 // Default Settings
68 // ----------------
69 QSettings settings;
70 if (settings.allKeys().size() == 0) {
71 settings.setValue("casterHost", "www.euref-ip.net");
72 settings.setValue("casterPort", 80);
73 settings.setValue("rnxIntr", "15 min");
74 settings.setValue("ephIntr", "1 day");
75 settings.setValue("rnxSkel", "SKL");
76 settings.setValue("waitTime", 5);
77 }
78
79 bncApp app(argc, argv, GUIenabled);
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.setPort(settings.value("outEphPort").toInt());
106
107 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
108 app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
109 &app, SLOT(slotMessage(const QByteArray&)));
110
111 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
112
113 int iMount = -1;
114 QListIterator<QString> it(settings.value("mountPoints").toStringList());
115 while (it.hasNext()) {
116 ++iMount;
117 QStringList hlp = it.next().split(" ");
118 if (hlp.size() <= 1) continue;
119 QUrl url(hlp[0]);
120 QByteArray format = hlp[1].toAscii();
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);
125 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
126 &app, SLOT(slotMessage(const QByteArray&)));
127
128 caster->addGetThread(getThread);
129
130 getThread->start();
131 }
132 if (caster->numStations() == 0) {
133 return 0;
134 }
135 }
136
137 // Start the application
138 // ---------------------
139 return app.exec();
140}
Note: See TracBrowser for help on using the repository browser.