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

Last change on this file since 295 was 295, 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
52bncCaster* _global_caster = 0;
53
54// Main Program
55/////////////////////////////////////////////////////////////////////////////
56int 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 ((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 bncGetThread* getThread = new bncGetThread(url, format, iMount);
122 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
123 &app, SLOT(slotMessage(const QByteArray&)));
124
125 _global_caster->addGetThread(getThread);
126
127 getThread->start();
128#ifndef WIN32
129 usleep(100000); // sleep 0.1 sec
130#endif
131 }
132 if (_global_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.