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

Last change on this file since 2957 was 2909, checked in by mervart, 14 years ago
File size: 4.7 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]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
[274]41#include <unistd.h>
[603]42#include <signal.h>
[35]43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
[82]47#include "bncapp.h"
[35]48#include "bncwindow.h"
[1535]49#include "bncsettings.h"
[2012]50#include "bncversion.h"
[35]51
52using namespace std;
53
[603]54void catch_signal(int) {
55 cout << "Program Interrupted by Ctrl-C" << endl;
[621]56 ((bncApp*)qApp)->slotQuit();
[603]57}
58
[82]59// Main Program
60/////////////////////////////////////////////////////////////////////////////
[35]61int main(int argc, char *argv[]) {
62
[1146]63 bool GUIenabled = true;
[1552]64 QByteArray rawFileName;
[1146]65 QByteArray format;
[1501]66 QString confFileName;
[1146]67
[100]68 for (int ii = 1; ii < argc; ii++) {
[2832]69 if (QByteArray(argv[ii]) == "-nw" || QByteArray(argv[ii]) == "--nw") {
[100]70 GUIenabled = false;
71 }
[1552]72 if (ii + 1 < argc) {
73 if (QByteArray(argv[ii]).indexOf("-conf") != -1) {
74 confFileName = QString(argv[ii+1]);
[1146]75 }
[1552]76 if (QByteArray(argv[ii]).indexOf("-file") != -1) {
77 GUIenabled = false;
[1553]78 rawFileName = QByteArray(argv[ii+1]);
[1552]79 }
80 if (QByteArray(argv[ii]).indexOf("-format") != -1) {
[1146]81 format = QByteArray(argv[ii+1]);
82 }
[1156]83 }
[1146]84 }
85
[1585]86 if (argc == 2 && GUIenabled) {
87 confFileName = QString(argv[1]);
88 }
89
[1552]90 QString printHelp = "Usage: bnc -nw\n"
91 " --conf <confFileName>\n"
92 " --file <rawFileName>\n"
[2521]93 " --format <RTIGS | RTCM_2 | RTCM_3>\n";
[1503]94
[1536]95 bncApp app(argc, argv, GUIenabled);
[1516]96
[1538]97 app.setApplicationName("BNC");
98 app.setOrganizationName("BKG");
99 app.setOrganizationDomain("www.bkg.bund.de");
100 app.setConfFileName( confFileName );
101
[1535]102 bncSettings settings;
[1503]103
[180]104 // Interactive Mode - open the main window
105 // ---------------------------------------
[35]106 if (GUIenabled) {
[113]107
108 QString fontString = settings.value("font").toString();
109 if ( !fontString.isEmpty() ) {
110 QFont newFont;
111 if (newFont.fromString(fontString)) {
112 QApplication::setFont(newFont);
113 }
114 }
[142]115
[173]116 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]117
[82]118 bncWindow* bncWin = new bncWindow();
[35]119 bncWin->show();
120 }
[180]121
122 // Non-Interactive (Batch) Mode
123 // ----------------------------
[35]124 else {
[621]125
[1138]126 signal(SIGINT, catch_signal);
127
[621]128 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
129 settings.value("outPort").toInt());
130
131 app.setCaster(caster);
[592]132 app.setPort(settings.value("outEphPort").toInt());
[937]133 app.setPortCorr(settings.value("corrPort").toInt());
[2909]134 app.initCombination();
[592]135
[1556]136 app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[295]137
[2012]138 ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[35]139
[1170]140 // Normal case - data from Internet
141 // --------------------------------
[1552]142 if ( rawFileName.isEmpty() ) {
[1179]143 caster->slotReadMountPoints();
[1170]144 if (caster->numStations() == 0) {
[1552]145 exit(0);
[1170]146 }
147 }
148
149 // Special case - data from file
150 // -----------------------------
151 else {
[2519]152 if ( format.isEmpty() ) {
[1552]153 cout << printHelp.toAscii().data() << endl;
[1146]154 exit(0);
155 }
156
[2519]157 bncRawFile* rawFile = new bncRawFile(rawFileName, format,
158 bncRawFile::input);
[1156]159
[2519]160 bncGetThread* getThread = new bncGetThread(rawFile);
[2528]161 caster->addGetThread(getThread, true);
[35]162 }
[2909]163
[35]164 }
[180]165
166 // Start the application
167 // ---------------------
[35]168 return app.exec();
169}
Note: See TracBrowser for help on using the repository browser.