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

Last change on this file since 3251 was 3251, checked in by mervart, 13 years ago
File size: 5.0 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
53using namespace std;
54
55void catch_signal(int) {
56 cout << "Program Interrupted by Ctrl-C" << endl;
57 exit(0);
58}
59
60// Main Program
61/////////////////////////////////////////////////////////////////////////////
62int main(int argc, char *argv[]) {
63
64 bool GUIenabled = true;
65 QByteArray rawFileName;
66 QByteArray format;
67 QByteArray staID;
68 QString confFileName;
69
70 for (int ii = 1; ii < argc; ii++) {
71 if (QByteArray(argv[ii]) == "-nw" || QByteArray(argv[ii]) == "--nw") {
72 GUIenabled = false;
73 }
74 if (ii + 1 < argc) {
75 if (QByteArray(argv[ii]).indexOf("-conf") != -1) {
76 confFileName = QString(argv[ii+1]);
77 }
78 if (QByteArray(argv[ii]).indexOf("-file") != -1) {
79 GUIenabled = false;
80 rawFileName = QByteArray(argv[ii+1]);
81 }
82 if (QByteArray(argv[ii]).indexOf("-format") != -1) {
83 format = QByteArray(argv[ii+1]);
84 }
85 if (QByteArray(argv[ii]).indexOf("-mountpoint") != -1) {
86 staID = QByteArray(argv[ii+1]);
87 }
88 }
89 }
90
91 if (argc == 2 && GUIenabled) {
92 confFileName = QString(argv[1]);
93 }
94
95 QString printHelp = "Usage: bnc --nw\n"
96 " --conf <confFileName>\n"
97 " --file <rawFileName>\n"
98 " --mountpoint <station>\n"
99 " --format <RTIGS | RTCM_2 | RTCM_3>\n";
100
101 bncApp app(argc, argv, GUIenabled);
102
103 app.setApplicationName("BNC");
104 app.setOrganizationName("BKG");
105 app.setOrganizationDomain("www.bkg.bund.de");
106 app.setConfFileName( confFileName );
107
108 bncSettings settings;
109
110 // Interactive Mode - open the main window
111 // ---------------------------------------
112 if (GUIenabled) {
113
114 QString fontString = settings.value("font").toString();
115 if ( !fontString.isEmpty() ) {
116 QFont newFont;
117 if (newFont.fromString(fontString)) {
118 QApplication::setFont(newFont);
119 }
120 }
121
122 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
123
124 bncWindow* bncWin = new bncWindow();
125 bncWin->show();
126 }
127
128 // Non-Interactive (Batch) Mode
129 // ----------------------------
130 else {
131
132 signal(SIGINT, catch_signal);
133
134 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
135
136 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
137 settings.value("outPort").toInt());
138
139 app.setCaster(caster);
140 app.setPort(settings.value("outEphPort").toInt());
141 app.setPortCorr(settings.value("corrPort").toInt());
142 app.initCombination();
143
144 app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
145
146 ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
147
148 // Normal case - data from Internet
149 // --------------------------------
150 if ( rawFileName.isEmpty() ) {
151 caster->slotReadMountPoints();
152 if (caster->numStations() == 0) {
153 exit(0);
154 }
155 }
156
157 // Special case - data from file
158 // -----------------------------
159 else {
160 if ( format.isEmpty() || staID.isEmpty() ) {
161 cout << printHelp.toAscii().data() << endl;
162 exit(0);
163 }
164
165 bncRawFile* rawFile = new bncRawFile(rawFileName, staID, format,
166 bncRawFile::input);
167
168 bncGetThread* getThread = new bncGetThread(rawFile);
169 caster->addGetThread(getThread, true);
170 }
171
172 }
173
174 // Start the application
175 // ---------------------
176 return app.exec();
177}
Note: See TracBrowser for help on using the repository browser.