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

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