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

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