source: ntrip/trunk/BNC/src/bncmain.cpp@ 5923

Last change on this file since 5923 was 5905, checked in by mervart, 10 years ago
File size: 6.1 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 <signal.h>
43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
47#include "app.h"
48#include "bnccore.h"
49#include "bncwindow.h"
50#include "bncsettings.h"
51#include "bncversion.h"
52#include "upload/bncephuploadcaster.h"
53#include "rinex/reqcedit.h"
54#include "rinex/reqcanalyze.h"
55
56using namespace std;
57
58void catch_signal(int) {
59 cout << "Program Interrupted by Ctrl-C" << endl;
60 exit(0);
61}
62
63// Main Program
64/////////////////////////////////////////////////////////////////////////////
65int main(int argc, char* argv[]) {
66
67 bool interactive = true;
68#ifdef WIN32
69 bool displaySet = true;
70#else
71 bool displaySet = false;
72#endif
73 QByteArray rawFileName;
74 QString confFileName;
75
76 QByteArray printHelp = "Usage: bnc --nw \n"
77 " --display <XXX> \n"
78 " --conf <confFileName> \n"
79 " --file <rawFileName> \n"
80 " --key <keyName> <keyValue>\n";
81
82 for (int ii = 1; ii < argc; ii++) {
83 if (QRegExp("--?help").exactMatch(argv[ii])) {
84 cout << printHelp.data();
85 exit(0);
86 }
87 if (QRegExp("--?nw").exactMatch(argv[ii])) {
88 interactive = false;
89 }
90 if (QRegExp("--?display").exactMatch(argv[ii])) {
91 displaySet = true;
92 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
93 }
94 if (ii + 1 < argc) {
95 if (QRegExp("--?conf").exactMatch(argv[ii])) {
96 confFileName = QString(argv[ii+1]);
97 }
98 if (QRegExp("--?file").exactMatch(argv[ii])) {
99 interactive = false;
100 rawFileName = QByteArray(argv[ii+1]);
101 }
102 }
103 }
104
105#ifdef Q_OS_MAC
106 if (argc== 3 && interactive) {
107 confFileName = QString(argv[2]);
108 }
109#else
110 if (argc == 2 && interactive) {
111 confFileName = QString(argv[1]);
112 }
113#endif
114
115 bool GUIenabled = interactive || displaySet;
116 t_app app(argc, argv, GUIenabled);
117
118 app.setApplicationName("BNC");
119 app.setOrganizationName("BKG");
120 app.setOrganizationDomain("www.bkg.bund.de");
121
122 BNC_CORE->setGUIenabled(GUIenabled);
123 BNC_CORE->setConfFileName( confFileName );
124
125 bncSettings settings;
126
127 for (int ii = 1; ii < argc - 2; ii++) {
128 if (QRegExp("--?key").exactMatch(argv[ii])) {
129 QString key(argv[ii+1]);
130 QString val(argv[ii+2]);
131 settings.setValue(key, val);
132 }
133 }
134
135 // Interactive Mode - open the main window
136 // ---------------------------------------
137 if (interactive) {
138
139 BNC_CORE->setMode(t_bncCore::interactive);
140
141 QString fontString = settings.value("font").toString();
142 if ( !fontString.isEmpty() ) {
143 QFont newFont;
144 if (newFont.fromString(fontString)) {
145 QApplication::setFont(newFont);
146 }
147 }
148
149 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
150
151 bncWindow* bncWin = new bncWindow();
152 BNC_CORE->setMainWindow(bncWin);
153 bncWin->show();
154 }
155
156 // Post-Processing reqc edit
157 // -------------------------
158 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
159 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
160 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
161 reqcEdit->start();
162 }
163
164 // Post-Processing reqc analyze
165 // ----------------------------
166 else if (settings.value("reqcAction").toString() == "Analyze") {
167 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
168 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
169 reqcAnalyze->start();
170 }
171
172 // Non-Interactive (data gathering)
173 // --------------------------------
174 else {
175
176 signal(SIGINT, catch_signal);
177
178 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
179
180 bncCaster* caster = new bncCaster();
181
182 BNC_CORE->setCaster(caster);
183 BNC_CORE->setPort(settings.value("outEphPort").toInt());
184 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
185 BNC_CORE->initCombination();
186
187 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
188
189 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
190
191 // Normal case - data from Internet
192 // --------------------------------
193 if ( rawFileName.isEmpty() ) {
194 BNC_CORE->setMode(t_bncCore::nonInteractive);
195 BNC_CORE->startPPP(true);
196
197 caster->readMountPoints();
198 if (caster->numStations() == 0) {
199 exit(0);
200 }
201 }
202
203 // Special case - data from file
204 // -----------------------------
205 else {
206 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
207 BNC_CORE->startPPP(false);
208
209 bncRawFile* rawFile = new bncRawFile(rawFileName, "", bncRawFile::input);
210 bncGetThread* getThread = new bncGetThread(rawFile);
211 caster->addGetThread(getThread, true);
212 }
213 }
214
215 // Start the application
216 // ---------------------
217 return app.exec();
218}
Note: See TracBrowser for help on using the repository browser.