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 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | bncCaster* _global_caster = 0;
|
---|
53 |
|
---|
54 | // Main Program
|
---|
55 | /////////////////////////////////////////////////////////////////////////////
|
---|
56 | int main(int argc, char *argv[]) {
|
---|
57 |
|
---|
58 | bool GUIenabled = true;
|
---|
59 | for (int ii = 1; ii < argc; ii++) {
|
---|
60 | if (QString(argv[ii]) == "-nw") {
|
---|
61 | GUIenabled = false;
|
---|
62 | break;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | bncApp app(argc, argv, GUIenabled);
|
---|
67 |
|
---|
68 | QCoreApplication::setOrganizationName("BKG");
|
---|
69 | QCoreApplication::setOrganizationDomain("www.ifag.de");
|
---|
70 | QCoreApplication::setApplicationName("BKG_NTRIP_Client");
|
---|
71 |
|
---|
72 | // Default Settings
|
---|
73 | // ----------------
|
---|
74 | QSettings settings;
|
---|
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 | }
|
---|
82 |
|
---|
83 | // Interactive Mode - open the main window
|
---|
84 | // ---------------------------------------
|
---|
85 | if (GUIenabled) {
|
---|
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 | }
|
---|
94 |
|
---|
95 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
96 |
|
---|
97 | bncWindow* bncWin = new bncWindow();
|
---|
98 | bncWin->show();
|
---|
99 | }
|
---|
100 |
|
---|
101 | // Non-Interactive (Batch) Mode
|
---|
102 | // ----------------------------
|
---|
103 | else {
|
---|
104 | _global_caster = new bncCaster(settings.value("outFile").toString(),
|
---|
105 | settings.value("outPort").toInt());
|
---|
106 |
|
---|
107 | app.connect(_global_caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
108 | app.connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
109 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
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 | bncGetThread* getThread = new bncGetThread(url, format, iMount);
|
---|
120 | app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
121 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
122 |
|
---|
123 | _global_caster->addGetThread(getThread);
|
---|
124 |
|
---|
125 | getThread->start();
|
---|
126 | #ifndef WIN32
|
---|
127 | usleep(100000); // sleep 0.1 sec
|
---|
128 | #endif
|
---|
129 | }
|
---|
130 | if (_global_caster->numStations() == 0) {
|
---|
131 | return 0;
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | // Start the application
|
---|
136 | // ---------------------
|
---|
137 | return app.exec();
|
---|
138 | }
|
---|