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

Last change on this file since 3531 was 3531, checked in by mervart, 12 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"
[3251]51#include "upload/bncephuploadcaster.h"
[35]52
53using namespace std;
54
[603]55void catch_signal(int) {
56 cout << "Program Interrupted by Ctrl-C" << endl;
[3005]57 exit(0);
[603]58}
59
[82]60// Main Program
61/////////////////////////////////////////////////////////////////////////////
[35]62int main(int argc, char *argv[]) {
63
[1146]64 bool GUIenabled = true;
[1552]65 QByteArray rawFileName;
[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 }
[1156]80 }
[1146]81 }
82
[1585]83 if (argc == 2 && GUIenabled) {
84 confFileName = QString(argv[1]);
85 }
86
[3076]87 QString printHelp = "Usage: bnc --nw\n"
88 " --conf <confFileName>\n"
89 " --file <rawFileName>\n"
[3524]90 " --mountpoint <station>\n";
[1503]91
[1536]92 bncApp app(argc, argv, GUIenabled);
[1516]93
[1538]94 app.setApplicationName("BNC");
95 app.setOrganizationName("BKG");
96 app.setOrganizationDomain("www.bkg.bund.de");
97 app.setConfFileName( confFileName );
98
[1535]99 bncSettings settings;
[1503]100
[180]101 // Interactive Mode - open the main window
102 // ---------------------------------------
[35]103 if (GUIenabled) {
[113]104
[3280]105 app.setMode(bncApp::interactive);
106
[113]107 QString fontString = settings.value("font").toString();
108 if ( !fontString.isEmpty() ) {
109 QFont newFont;
110 if (newFont.fromString(fontString)) {
111 QApplication::setFont(newFont);
112 }
113 }
[142]114
[173]115 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]116
[82]117 bncWindow* bncWin = new bncWindow();
[35]118 bncWin->show();
119 }
[180]120
121 // Non-Interactive (Batch) Mode
122 // ----------------------------
[35]123 else {
[621]124
[1138]125 signal(SIGINT, catch_signal);
126
[3251]127 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
128
[621]129 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
130 settings.value("outPort").toInt());
131
132 app.setCaster(caster);
[592]133 app.setPort(settings.value("outEphPort").toInt());
[937]134 app.setPortCorr(settings.value("corrPort").toInt());
[2909]135 app.initCombination();
[592]136
[1556]137 app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[295]138
[2012]139 ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[35]140
[1170]141 // Normal case - data from Internet
142 // --------------------------------
[1552]143 if ( rawFileName.isEmpty() ) {
[3280]144 app.setMode(bncApp::nonInteractive);
[1179]145 caster->slotReadMountPoints();
[1170]146 if (caster->numStations() == 0) {
[1552]147 exit(0);
[1170]148 }
149 }
150
151 // Special case - data from file
152 // -----------------------------
153 else {
[3280]154 app.setMode(bncApp::batchPostProcessing);
[3531]155 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
156 bncRawFile::input);
[2519]157 bncGetThread* getThread = new bncGetThread(rawFile);
[2528]158 caster->addGetThread(getThread, true);
[35]159 }
[2909]160
[35]161 }
[180]162
163 // Start the application
164 // ---------------------
[35]165 return app.exec();
166}
Note: See TracBrowser for help on using the repository browser.