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

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