source: ntrip/trunk/BNS/bnswindow.cpp@ 1670

Last change on this file since 1670 was 1670, checked in by weber, 15 years ago

* empty log message *

File size: 39.6 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bnsWindow
7 *
8 * Purpose: This class implements the main application window.
9 *
10 * Author: L. Mervart
11 *
12 * Created: 29-Mar-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19
20#include "bnswindow.h"
21#include "bnshlpdlg.h"
22#include "bnssettings.h"
23
24using namespace std;
25
26// About Dialog - Constructor
27////////////////////////////////////////////////////////////////////////////
28bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
29 QDialog(parent) {
30
31 QTextBrowser* tb = new QTextBrowser;
32 QUrl url; url.setPath(":bnsabout.html");
33 tb->setSource(url);
34 tb->setReadOnly(true);
35
36 int ww = QFontMetrics(font()).width('w');
37 QPushButton* _closeButton = new QPushButton("Close");
38 _closeButton->setMaximumWidth(10*ww);
39 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
40
41 QGridLayout* dlgLayout = new QGridLayout();
42 QLabel* img = new QLabel();
43 img->setPixmap(QPixmap(":ntrip-logo.png"));
44 dlgLayout->addWidget(img, 0,0);
45 dlgLayout->addWidget(new QLabel("BKG Ntrip State Space Server (BNS) Version 1.1"), 0,1);
46 dlgLayout->addWidget(tb,1,0,1,2);
47 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
48
49 setLayout(dlgLayout);
50 resize(60*ww, 60*ww);
51 show();
52}
53
54// About Dialog - Destructor
55////////////////////////////////////////////////////////////////////////////
56bnsAboutDlg::~bnsAboutDlg() {
57};
58
59// Flowchart Dialog - Constructor
60////////////////////////////////////////////////////////////////////////////
61bnsFlowchartDlg::bnsFlowchartDlg(QWidget* parent) :
62 QDialog(parent) {
63
64 int ww = QFontMetrics(font()).width('w');
65 QPushButton* _closeButton = new QPushButton("Close");
66 _closeButton->setMaximumWidth(10*ww);
67 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
68
69 QGridLayout* dlgLayout = new QGridLayout();
70 QLabel* img = new QLabel();
71 img->setPixmap(QPixmap(":bnsflowchart.png"));
72 dlgLayout->addWidget(img, 0,0);
73 dlgLayout->addWidget(_closeButton,1,0,Qt::AlignLeft);
74
75 setLayout(dlgLayout);
76 show();
77}
78
79// Flowchart Dialog - Destructor
80////////////////////////////////////////////////////////////////////////////
81bnsFlowchartDlg::~bnsFlowchartDlg() {
82};
83
84// Constructor
85////////////////////////////////////////////////////////////////////////////
86bnsWindow::bnsWindow() {
87
88 _bns = 0;
89
90 bnsSettings settings;
91
92 QString fontString = settings.value("font").toString();
93 if ( !fontString.isEmpty() ) {
94 QFont newFont;
95 if (newFont.fromString(fontString)) {
96 QApplication::setFont(newFont);
97 }
98 }
99
100 int ww = QFontMetrics(this->font()).width('w');
101 setMinimumSize(77*ww, 65*ww);
102 setWindowTitle(tr("BKG Ntrip State Space Server (BNS) Version 1.1"));
103 setWindowIcon(QPixmap(":ntrip-logo.png"));
104
105 // Create Actions
106 // --------------
107 _actHelp = new QAction(tr("&Help Contents"),this);
108 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
109
110 _actAbout = new QAction(tr("&About BNS"),this);
111 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
112
113 _actFlowchart = new QAction(tr("&Flow Chart"),this);
114 connect(_actFlowchart, SIGNAL(triggered()), SLOT(slotFlowchart()));
115
116 _actFontSel = new QAction(tr("Select &Font"),this);
117 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
118
119 _actSaveOpt = new QAction(tr("&Save Options"),this);
120 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
121
122 _actQuit = new QAction(tr("&Quit"),this);
123 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
124
125 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
126 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
127
128 _actStart = new QAction(tr("Sta&rt"),this);
129 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
130
131 _actStop = new QAction(tr("Sto&p"),this);
132 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
133 _actStop->setEnabled(false);
134
135 CreateMenu();
136 AddToolbar();
137
138 // Canvas with Editable Fields
139 // ---------------------------
140 _canvas = new QWidget;
141 setCentralWidget(_canvas);
142
143 // Proxy Options
144 // -------------
145 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
146 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
147
148 // General Options
149 // ---------------
150 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
151 _fileAppendCheckBox = new QCheckBox();
152 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
153 _autoStartCheckBox = new QCheckBox();
154 _autoStartCheckBox->setCheckState(Qt::CheckState(
155 settings.value("autoStart").toInt()));
156
157 // RINEX Ephemeris Options
158 // -----------------------
159 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
160 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
161 _ephEchoLineEdit = new QLineEdit(settings.value("ephEcho").toString());
162
163 // Clocks & Orbits Options
164 // -----------------------
165 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
166 _inpEchoLineEdit = new QLineEdit(settings.value("inpEcho").toString());
167
168
169 // Ephemeris Corrections I Options
170 // -------------------------------
171 _outHost_1_LineEdit = new QLineEdit(settings.value("outHost1").toString());
172 _outPort_1_LineEdit = new QLineEdit(settings.value("outPort1").toString());
173 _password_1_LineEdit = new QLineEdit(settings.value("password1").toString());
174 _password_1_LineEdit->setEchoMode(QLineEdit::Password);
175 _mountpoint_1_LineEdit = new QLineEdit(settings.value("mountpoint_1").toString());
176 _refSys_1_ComboBox = new QComboBox;
177 _refSys_1_ComboBox->setEditable(false);
178 _refSys_1_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
179 int ii = _refSys_1_ComboBox->findText(settings.value("refSys_1").toString());
180 if (ii != -1) {
181 _refSys_1_ComboBox->setCurrentIndex(ii);
182 }
183 _outFile_1_LineEdit = new QLineEdit(settings.value("outFile_1").toString());
184 _beClocks1CheckBox = new QCheckBox();
185 _beClocks1CheckBox->setCheckState(Qt::CheckState(settings.value("beClocks1").toInt()));
186
187 // Ephemeris Corrections II Options
188 // --------------------------------
189 _outHost_2_LineEdit = new QLineEdit(settings.value("outHost2").toString());
190 _outPort_2_LineEdit = new QLineEdit(settings.value("outPort2").toString());
191 _password_2_LineEdit = new QLineEdit(settings.value("password2").toString());
192 _password_2_LineEdit->setEchoMode(QLineEdit::Password);
193 _mountpoint_2_LineEdit = new QLineEdit(settings.value("mountpoint_2").toString());
194 _refSys_2_ComboBox = new QComboBox;
195 _refSys_2_ComboBox->setEditable(false);
196 _refSys_2_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
197 ii = _refSys_2_ComboBox->findText(settings.value("refSys_2").toString());
198 if (ii != -1) {
199 _refSys_2_ComboBox->setCurrentIndex(ii);
200 }
201 _outFile_2_LineEdit = new QLineEdit(settings.value("outFile_2").toString());
202 _beClocks2CheckBox = new QCheckBox();
203 _beClocks2CheckBox->setCheckState(Qt::CheckState(settings.value("beClocks2").toInt()));
204
205 // RINEX Clocks Options
206 // --------------------
207 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
208 _rnxIntrComboBox = new QComboBox;
209 _rnxIntrComboBox->setEditable(false);
210 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
211 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
212 if (ii != -1) {
213 _rnxIntrComboBox->setCurrentIndex(ii);
214 }
215 _rnxSamplSpinBox = new QSpinBox;
216 _rnxSamplSpinBox->setMinimum(0);
217 _rnxSamplSpinBox->setMaximum(60);
218 _rnxSamplSpinBox->setSingleStep(5);
219 _rnxSamplSpinBox->setMaximumWidth(9*ww);
220 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
221 _rnxSamplSpinBox->setSuffix(" sec");
222
223 // SP3 Orbits Options
224 // ------------------
225 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
226 _sp3IntrComboBox = new QComboBox;
227 _sp3IntrComboBox->setEditable(false);
228 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
229 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
230 if (ii != -1) {
231 _sp3IntrComboBox->setCurrentIndex(ii);
232 }
233 _sp3SamplSpinBox = new QSpinBox;
234 _sp3SamplSpinBox->setMinimum(0);
235 _sp3SamplSpinBox->setMaximum(900);
236 _sp3SamplSpinBox->setSingleStep(60);
237 _sp3SamplSpinBox->setMaximumWidth(9*ww);
238 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
239 _sp3SamplSpinBox->setSuffix(" sec");
240
241 // Whats This
242 // ----------
243 _proxyHostLineEdit->setWhatsThis(tr("<p>If you are running BNS within a protected Local Area Network (LAN), you might need to use a proxy server to access the Internet. Enter your proxy server IP and port number in case one is operated in front of BNS. If you do not know the IP and port of your proxy server, check the proxy server settings in your Internet browser or ask your network administrator.</p><p>Note that IP streaming is sometimes not allowed in a LAN. In this case you need to ask your network administrator for an appropriate modification of the local security policy or for the installation of a TCP relay to the NTRIP broadcasters. If these are not possible, you might need to run BNS outside your LAN on a network that has unobstructed connection to the Internet.</p>"));
244 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
245 _logFileLineEdit->setWhatsThis(tr("<p>Records of BNS activities are shown in the Log section on the bottom of this window. They can be saved into a file when a valid path is specified in the 'Logfile (full path)' field.</p>"));
246 _fileAppendCheckBox->setWhatsThis(tr("<p>When BNS is started, new files are created by default and any existing files with the same name will be overwritten. However, users might want to append already existing files following a restart of BNS, a system crash or when BNS crashed. Tick 'Append files' to continue with existing files and keep what has been recorded so far.</p>"));
247 _inpEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming clocks and orbits are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming clocks and orbits are not saved."));
248 _ephHostLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the host IP e.g. of a BNC installation providing this information."));
249 _ephPortLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the IP port e.g. of a BNC installation providing this information."));
250 _ephEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming Broadcast Ephemeris are not saved."));
251 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in SP3 format from an IP port. Specify a local IP port e.g. for an RTNet installation to provide this information."));
252 _outHost_1_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
253 _outPort_1_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
254 _password_1_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
255 _mountpoint_1_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
256 _refSys_1_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
257 _outHost_2_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
258 _outPort_2_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
259 _password_2_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
260 _mountpoint_2_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
261 _refSys_2_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
262 _outFile_1_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
263 _outFile_2_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
264 _rnxPathLineEdit->setWhatsThis(tr("Specify the path for saving the generated clock corrections as Clock RINEX files. If the specified directory does not exist, BNS will not create Clock RINEX files."));
265 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
266 _rnxSamplSpinBox->setWhatsThis(tr("Select the Clock RINEX file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into Clock RINEX files."));
267 _sp3PathLineEdit->setWhatsThis(tr("Specify the path for saving the generated orbit corrections as SP3 orbit files. If the specified directory does not exist, BNS will not create SP3 orbit files."));
268 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
269 _sp3SamplSpinBox->setWhatsThis(tr("Select the SP3 orbit file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into SP3 orbit files."));
270 _autoStartCheckBox->setWhatsThis(tr("<p>Tick 'Auto start' for auto-start of BNS at startup time in window mode with preassigned processing options.</p>"));
271 _beClocks1CheckBox->setWhatsThis(tr("<p>Send broadcast clocks instead of broadcast clock corrections and ignore the incoming clock estimates.</p>"));
272 _beClocks2CheckBox->setWhatsThis(tr("<p>Send broadcast clocks instead of broadcast clock corrections and ignore the incoming clock estimates.</p>"));
273
274
275 // TabWidget
276 // ---------
277 tabs = new QTabWidget();
278
279 // Proxy Tab
280 // ---------
281 QWidget* tab_prx = new QWidget();
282 tabs->setMaximumHeight(20*ww);
283 tabs->addTab(tab_prx, "Proxy");
284
285 QGridLayout* layout_prx = new QGridLayout;
286
287 layout_prx->setColumnMinimumWidth(0,9*ww);
288 _proxyPortLineEdit->setMaximumWidth(9*ww);
289
290 layout_prx->addWidget(new QLabel("Host"), 0, 0);
291 layout_prx->addWidget(_proxyHostLineEdit, 0, 1, 1, 10);
292 layout_prx->addWidget(new QLabel("Port"), 1, 0);
293 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
294 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 50, Qt::AlignLeft);
295 layout_prx->addWidget(new QLabel(" "), 3, 0);
296
297 tab_prx->setLayout(layout_prx);
298
299 connect(_proxyHostLineEdit, SIGNAL(textChanged(const QString &)),
300 this, SLOT(bnsText(const QString &)));
301 if (_proxyHostLineEdit->text().isEmpty()) {
302 _proxyPortLineEdit->setStyleSheet("background-color: lightGray");
303 _proxyPortLineEdit->setEnabled(false);
304 }
305
306 // General Tab
307 // -----------
308 QWidget* tab_gen = new QWidget();
309 tabs->addTab(tab_gen, "General");
310
311 QGridLayout* layout_gen = new QGridLayout;
312
313 layout_gen->setColumnMinimumWidth(0,9*ww);
314 _logFileLineEdit->setMaximumWidth(40*ww);
315
316 layout_gen->addWidget(new QLabel("Logfile (full path) "), 0, 0);
317 layout_gen->addWidget(_logFileLineEdit, 0, 1);
318 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
319 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
320 layout_gen->addWidget(new QLabel("Auto start"), 2, 0);
321 layout_gen->addWidget(_autoStartCheckBox, 2, 1);
322 layout_gen->addWidget(new QLabel("General settings for logfile and file handling."), 3, 0, 1, 50, Qt::AlignLeft);
323
324 tab_gen->setLayout(layout_gen);
325
326 // RINEX Ephemeris Tab
327 // -------------------
328 QWidget* tab_eph = new QWidget();
329 tabs->addTab(tab_eph, "RINEX Ephemeris");
330
331 QGridLayout* layout_eph = new QGridLayout;
332
333 layout_eph->setColumnMinimumWidth(0, 9*ww);
334 _ephPortLineEdit->setMaximumWidth(9*ww);
335
336 layout_eph->addWidget(new QLabel("Host"), 0, 0);
337 layout_eph->addWidget(_ephHostLineEdit, 0, 1, 1, 10);
338 layout_eph->addWidget(new QLabel("Port"), 1, 0);
339 layout_eph->addWidget(_ephPortLineEdit, 1, 1);
340 layout_eph->addWidget(new QLabel("Save (full path)"), 2, 0);
341 layout_eph->addWidget(_ephEchoLineEdit, 2, 1, 1, 26);
342 layout_eph->addWidget(new QLabel("Read broadcast ephemeris in RINEX Version 3 Navigation format."), 3, 0, 1, 50, Qt::AlignLeft);
343
344 tab_eph->setLayout(layout_eph);
345
346 // Clocks & Orbits Tab
347 // -------------------
348 QWidget* tab_co = new QWidget();
349 tabs->addTab(tab_co,"Clocks && Orbits");
350
351 QGridLayout* layout_co = new QGridLayout;
352
353 layout_co->setColumnMinimumWidth(0, 9*ww);
354 _clkPortLineEdit->setMaximumWidth(9*ww);
355
356 layout_co->addWidget(new QLabel("Listening port"), 0, 0);
357 layout_co->addWidget(_clkPortLineEdit, 0, 1);
358 layout_co->addWidget(new QLabel("Save (full path) "), 1, 0);
359 layout_co->addWidget(_inpEchoLineEdit, 1, 1);
360 layout_co->addWidget(new QLabel("Read clocks and orbits in SP3 format."), 2, 0, 1, 50, Qt::AlignLeft);
361 layout_co->addWidget(new QLabel(""), 3, 0);
362
363 tab_co->setLayout(layout_co);
364
365 // Ephemeris Corrections I Tab
366 // ---------------------------
367 QWidget* tab_cas1 = new QWidget();
368 tabs->addTab(tab_cas1, "Ephemeris Corrections I");
369
370 QGridLayout* layout_cas1 = new QGridLayout;
371
372 layout_cas1->setColumnMinimumWidth(0, 9*ww);
373 _outPort_1_LineEdit->setMaximumWidth(9*ww);
374 _password_1_LineEdit->setMaximumWidth(9*ww);
375 _mountpoint_1_LineEdit->setMaximumWidth(12*ww);
376 _refSys_1_ComboBox->setMaximumWidth(12*ww);
377
378 layout_cas1->addWidget(new QLabel("Host"), 0, 0);
379 layout_cas1->addWidget(_outHost_1_LineEdit, 0, 1, 1, 3);
380 layout_cas1->addWidget(new QLabel(" Port"), 0, 4, Qt::AlignRight);
381 layout_cas1->addWidget(_outPort_1_LineEdit, 0, 5);
382 layout_cas1->addWidget(new QLabel("Mountpoint"), 1, 0);
383 layout_cas1->addWidget(_mountpoint_1_LineEdit, 1, 1);
384 layout_cas1->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
385 layout_cas1->addWidget(_password_1_LineEdit, 1, 3);
386 layout_cas1->addWidget(new QLabel(" "), 1, 4);
387 layout_cas1->addWidget(new QLabel(" "), 1, 5);
388 layout_cas1->addWidget(new QLabel("System"), 2, 0);
389 layout_cas1->addWidget(_refSys_1_ComboBox, 2, 1);
390 layout_cas1->addWidget(new QLabel(" Save (full path)"), 2, 2, Qt::AlignRight);
391 layout_cas1->addWidget(_outFile_1_LineEdit, 2, 3, 1, 30);
392 layout_cas1->addWidget(new QLabel("Broadcast clocks"), 3, 0);
393 layout_cas1->addWidget(_beClocks1CheckBox, 3, 1);
394 layout_cas1->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 4, 0, 1, 50);
395
396 tab_cas1->setLayout(layout_cas1);
397
398 connect(_outHost_1_LineEdit, SIGNAL(textChanged(const QString &)),
399 this, SLOT(bnsText(const QString &)));
400 if (_outHost_1_LineEdit->text().isEmpty()) {
401 _outPort_1_LineEdit->setStyleSheet("background-color: lightGray");
402 _mountpoint_1_LineEdit->setStyleSheet("background-color: lightGray");
403 _password_1_LineEdit->setStyleSheet("background-color: lightGray");
404 _outFile_1_LineEdit->setStyleSheet("background-color: lightGray");
405 _refSys_1_ComboBox->setStyleSheet("background-color: lightGray");
406 _outPort_1_LineEdit->setEnabled(false);
407 _mountpoint_1_LineEdit->setEnabled(false);
408 _password_1_LineEdit->setEnabled(false);
409 _outFile_1_LineEdit->setEnabled(false);
410 _refSys_1_ComboBox->setEnabled(false);
411 }
412
413 // Ephemeris Corrections II Tab
414 // ----------------------------
415 QWidget* tab_cas2 = new QWidget();
416 tabs->addTab(tab_cas2, "Ephemeris Corrections II");
417
418 QGridLayout* layout_cas2 = new QGridLayout;
419
420 layout_cas2->setColumnMinimumWidth(0, 9*ww);
421 _outPort_2_LineEdit->setMaximumWidth(9*ww);
422 _password_2_LineEdit->setMaximumWidth(9*ww);
423 _mountpoint_2_LineEdit->setMaximumWidth(12*ww);
424 _refSys_2_ComboBox->setMaximumWidth(12*ww);
425
426 layout_cas2->addWidget(new QLabel("Host"), 0, 0);
427 layout_cas2->addWidget(_outHost_2_LineEdit, 0, 1, 1, 3);
428 layout_cas2->addWidget(new QLabel(" Port"), 0, 4, Qt::AlignRight);
429 layout_cas2->addWidget(_outPort_2_LineEdit, 0, 5);
430 layout_cas2->addWidget(new QLabel("Mountpoint"), 1, 0);
431 layout_cas2->addWidget(_mountpoint_2_LineEdit, 1, 1);
432 layout_cas2->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
433 layout_cas2->addWidget(_password_2_LineEdit, 1, 3);
434 layout_cas2->addWidget(new QLabel(" "), 1, 4);
435 layout_cas2->addWidget(new QLabel(" "), 1, 5);
436 layout_cas2->addWidget(new QLabel("System"), 2, 0);
437 layout_cas2->addWidget(_refSys_2_ComboBox, 2, 1);
438 layout_cas2->addWidget(new QLabel(" Save (full path)"), 2, 2, Qt::AlignRight);
439 layout_cas2->addWidget(_outFile_2_LineEdit, 2, 3, 1, 30);
440 layout_cas2->addWidget(new QLabel("Broadcast clocks"), 3, 0);
441 layout_cas2->addWidget(_beClocks2CheckBox, 3, 1);
442 layout_cas2->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 4, 0, 1, 50);
443
444 tab_cas2->setLayout(layout_cas2);
445
446 connect(_outHost_2_LineEdit, SIGNAL(textChanged(const QString &)),
447 this, SLOT(bnsText(const QString &)));
448 if (_outHost_2_LineEdit->text().isEmpty()) {
449 _outPort_2_LineEdit->setStyleSheet("background-color: lightGray");
450 _mountpoint_2_LineEdit->setStyleSheet("background-color: lightGray");
451 _password_2_LineEdit->setStyleSheet("background-color: lightGray");
452 _outFile_2_LineEdit->setStyleSheet("background-color: lightGray");
453 _refSys_2_ComboBox->setStyleSheet("background-color: lightGray");
454 _outPort_2_LineEdit->setEnabled(false);
455 _mountpoint_2_LineEdit->setEnabled(false);
456 _password_2_LineEdit->setEnabled(false);
457 _outFile_2_LineEdit->setEnabled(false);
458 _refSys_2_ComboBox->setEnabled(false);
459 }
460
461 // RINEX Clocks Tab
462 // ----------------
463 QWidget* tab_rin = new QWidget();
464 tabs->addTab(tab_rin, "RINEX Clocks ");
465
466 QGridLayout* layout_rin = new QGridLayout;
467
468 layout_rin->setColumnMinimumWidth(0, 9*ww);
469 _rnxIntrComboBox->setMaximumWidth(9*ww);
470
471 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
472 layout_rin->addWidget(_rnxPathLineEdit, 0, 1, 1, 27);
473 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
474 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
475 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
476 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
477 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 50, Qt::AlignLeft);
478 layout_rin->addWidget(new QLabel(" "), 3, 0);
479
480 tab_rin->setLayout(layout_rin);
481
482 connect(_rnxPathLineEdit, SIGNAL(textChanged(const QString &)),
483 this, SLOT(bnsText(const QString &)));
484 if (_rnxPathLineEdit->text().isEmpty()) {
485 _rnxIntrComboBox->setStyleSheet("background-color: lightGray");
486 _rnxSamplSpinBox->setStyleSheet("background-color: lightGray");
487 _rnxIntrComboBox->setEnabled(false);
488 _rnxSamplSpinBox->setEnabled(false);
489 }
490
491 // SP3 Orbits Tab
492 // --------------
493 QWidget* tab_sp3 = new QWidget();
494 tabs->addTab(tab_sp3, "SP3 Orbits");
495
496 QGridLayout* layout_sp3 = new QGridLayout;
497
498 layout_sp3->setColumnMinimumWidth(0, 9*ww);
499 _sp3IntrComboBox->setMaximumWidth(9*ww);
500
501 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
502 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1, 1, 27);
503 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
504 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
505 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
506 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
507 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 50, Qt::AlignLeft);
508 layout_sp3->addWidget(new QLabel(" "), 3, 0);
509
510 tab_sp3->setLayout(layout_sp3);
511
512 connect(_sp3PathLineEdit, SIGNAL(textChanged(const QString &)),
513 this, SLOT(bnsText(const QString &)));
514 if (_sp3PathLineEdit->text().isEmpty()) {
515 _sp3IntrComboBox->setStyleSheet("background-color: lightGray");
516 _sp3SamplSpinBox->setStyleSheet("background-color: lightGray");
517 _sp3IntrComboBox->setEnabled(false);
518 _sp3SamplSpinBox->setEnabled(false);
519 }
520
521 tabs->setCurrentIndex(settings.value("startTab").toInt());
522
523 // Log
524 // ---
525 _log = new QTextBrowser();
526 _log->setReadOnly(true);
527 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
528
529 // Status
530 // ------
531 _status = new QGroupBox(tr("Status"));
532 QGridLayout* layout_status = new QGridLayout;
533
534 _statusLbl[0] = new QLabel("0 byte(s)"); _statusCnt[0] = 0;
535 _statusLbl[1] = new QLabel("0 byte(s)"); _statusCnt[1] = 0;
536 _statusLbl[2] = new QLabel("0 byte(s)"); _statusCnt[2] = 0;
537 _statusLbl[7] = new QLabel("RINEX Ephemeris:");
538 _statusLbl[4] = new QLabel("Clocks & Orbits:");
539 _statusLbl[5] = new QLabel("Ephemeris Corrections I:");
540 _statusLbl[6] = new QLabel("Ephemeris Corrections II:");
541 _statusLbl[3] = new QLabel("0 byte(s)"); _statusCnt[3] = 0;
542
543 _statusLbl[0]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
544 _statusLbl[1]->setWhatsThis(tr("Status of incoming stream of clocks and orbits."));
545 _statusLbl[2]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster."));
546 _statusLbl[7]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
547 _statusLbl[4]->setWhatsThis(tr("Status of incoming stream of clocks and orbits I."));
548 _statusLbl[5]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster I."));
549 _statusLbl[6]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster II."));
550 _statusLbl[3]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster II."));
551
552 layout_status->addWidget(_statusLbl[7], 0, 0);
553 layout_status->addWidget(_statusLbl[0], 0, 1);
554 layout_status->addWidget(_statusLbl[4], 1, 0);
555 layout_status->addWidget(_statusLbl[1], 1, 1);
556 layout_status->addWidget(_statusLbl[5], 0, 2);
557 layout_status->addWidget(_statusLbl[2], 0, 3);
558 layout_status->addWidget(_statusLbl[6], 1, 2);
559 layout_status->addWidget(_statusLbl[3], 1, 3);
560 _status->setLayout(layout_status);
561
562 // Main Layout
563 // -----------
564 QVBoxLayout* mainLayout = new QVBoxLayout;
565 mainLayout->addWidget(tabs);
566 mainLayout->addWidget(_log);
567 mainLayout->addWidget(_status);
568
569 _canvas->setLayout(mainLayout);
570
571 // Auto start
572 // ----------
573 if ( Qt::CheckState(settings.value("autoStart").toInt()) == Qt::Checked) {
574 slotStart();
575 }
576
577}
578
579// Destructor
580////////////////////////////////////////////////////////////////////////////
581bnsWindow::~bnsWindow() {
582}
583
584// Close Application gracefully
585////////////////////////////////////////////////////////////////////////////
586void bnsWindow::closeEvent(QCloseEvent* event) {
587
588int iRet = QMessageBox::question(this, "Close", "Save Options?",
589 QMessageBox::Yes, QMessageBox::No,
590 QMessageBox::Cancel);
591
592 if (iRet == QMessageBox::Cancel) {
593 event->ignore();
594 return;
595 }
596 else if (iRet == QMessageBox::Yes) {
597 slotSaveOptions();
598 }
599
600 QMainWindow::closeEvent(event);
601}
602
603// About Message
604////////////////////////////////////////////////////////////////////////////
605void bnsWindow::slotAbout() {
606 new bnsAboutDlg(0);
607}
608
609// Flowchart
610////////////////////////////////////////////////////////////////////////////
611void bnsWindow::slotFlowchart() {
612 new bnsFlowchartDlg(0);
613}
614
615// Help Window
616////////////////////////////////////////////////////////////////////////////
617void bnsWindow::slotHelp() {
618 QUrl url;
619 url.setPath(":bnshelp.html");
620 new bnsHlpDlg(0, url);
621}
622
623// Select Fonts
624////////////////////////////////////////////////////////////////////////////
625void bnsWindow::slotFontSel() {
626 bool ok;
627 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
628 if (ok) {
629 bnsSettings settings;
630 settings.setValue("font", newFont.toString());
631 QApplication::setFont(newFont);
632 int ww = QFontMetrics(newFont).width('w');
633 setMinimumSize(77*ww, 65*ww);
634 }
635}
636
637// Whats This Help
638////////////////////////////////////////////////////////////////////////////
639void bnsWindow::slotWhatsThis() {
640QWhatsThis::enterWhatsThisMode();
641}
642
643// Create Menus
644////////////////////////////////////////////////////////////////////////////
645void bnsWindow::CreateMenu() {
646 _menuFile = menuBar()->addMenu(tr("&File"));
647 _menuFile->addAction(_actFontSel);
648 _menuFile->addSeparator();
649 _menuFile->addAction(_actSaveOpt);
650 _menuFile->addSeparator();
651 _menuFile->addAction(_actQuit);
652
653 _menuHlp = menuBar()->addMenu(tr("&Help"));
654 _menuHlp->addAction(_actHelp);
655 _menuHlp->addAction(_actFlowchart);
656 _menuHlp->addAction(_actAbout);
657}
658
659// Tool (Command) Bar
660////////////////////////////////////////////////////////////////////////////
661void bnsWindow::AddToolbar() {
662 QToolBar* toolBar = new QToolBar;
663 addToolBar(Qt::BottomToolBarArea, toolBar);
664 toolBar->setMovable(false);
665 toolBar->addAction(_actStart);
666 toolBar->addAction(_actStop);
667 toolBar->addWidget(new QLabel(" "));
668 toolBar->addAction(_actWhatsThis);
669}
670
671// Save Options
672////////////////////////////////////////////////////////////////////////////
673void bnsWindow::slotSaveOptions() {
674 bnsSettings settings;
675 settings.setValue("proxyHost", _proxyHostLineEdit->text());
676 settings.setValue("proxyPort", _proxyPortLineEdit->text());
677 settings.setValue("logFile", _logFileLineEdit->text());
678 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
679 settings.setValue("autoStart", _autoStartCheckBox->checkState());
680 settings.setValue("refSys_1", _refSys_1_ComboBox->currentText());
681 settings.setValue("refSys_2", _refSys_2_ComboBox->currentText());
682 settings.setValue("inpEcho", _inpEchoLineEdit->text());
683 settings.setValue("ephHost", _ephHostLineEdit->text());
684 settings.setValue("ephPort", _ephPortLineEdit->text());
685 settings.setValue("ephEcho", _ephEchoLineEdit->text());
686 settings.setValue("clkPort", _clkPortLineEdit->text());
687 settings.setValue("outHost1", _outHost_1_LineEdit->text());
688 settings.setValue("outPort1", _outPort_1_LineEdit->text());
689 settings.setValue("outHost2", _outHost_2_LineEdit->text());
690 settings.setValue("outPort2", _outPort_2_LineEdit->text());
691 settings.setValue("mountpoint_1",_mountpoint_1_LineEdit->text());
692 settings.setValue("mountpoint_2",_mountpoint_2_LineEdit->text());
693 settings.setValue("outFile_1", _outFile_1_LineEdit->text());
694 settings.setValue("outFile_2", _outFile_2_LineEdit->text());
695 settings.setValue("password1", _password_1_LineEdit->text());
696 settings.setValue("password2", _password_2_LineEdit->text());
697 settings.setValue("rnxPath", _rnxPathLineEdit->text());
698 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
699 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
700 settings.setValue("sp3Path", _sp3PathLineEdit->text());
701 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
702 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
703 settings.setValue("startTab", tabs->currentIndex());
704 settings.setValue("beClocks1", _beClocks1CheckBox->checkState());
705 settings.setValue("beClocks2", _beClocks2CheckBox->checkState());
706}
707
708// Display Program Messages
709////////////////////////////////////////////////////////////////////////////
710void bnsWindow::slotMessage(const QByteArray msg) {
711
712 const int maxBufferSize = 10000;
713
714 QString txt = _log->toPlainText() + "\n" +
715 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
716 _log->clear();
717 _log->append(txt.right(maxBufferSize));
718}
719
720// Delete bns
721////////////////////////////////////////////////////////////////////////////
722void bnsWindow::deleteBns() {
723 _actStart->setEnabled(true);
724 _actStop->setEnabled(false);
725 _bns->terminate();
726 _bns->wait(100);
727 delete _bns;
728 _bns = 0;
729}
730
731// Error in bns
732////////////////////////////////////////////////////////////////////////////
733void bnsWindow::slotError(const QByteArray msg) {
734 slotMessage(msg);
735 deleteBns();
736}
737
738// Stop
739////////////////////////////////////////////////////////////////////////////
740void bnsWindow::slotStop() {
741 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
742 QMessageBox::Yes, QMessageBox::No,
743 QMessageBox::NoButton);
744 if (iRet == QMessageBox::Yes) {
745 deleteBns();
746 }
747}
748
749// Start
750////////////////////////////////////////////////////////////////////////////
751void bnsWindow::slotStart() {
752 slotSaveOptions();
753
754 _actStart->setEnabled(false);
755 _actStop->setEnabled(true);
756
757 _bns = new t_bns(0);
758
759 connect(_bns, SIGNAL(newMessage(QByteArray)),
760 this, SLOT(slotMessage(const QByteArray)));
761
762 connect(_bns, SIGNAL(error(QByteArray)),
763 this, SLOT(slotError(const QByteArray)));
764
765 connect(_bns, SIGNAL(newEphBytes(int)), this, SLOT(slotEphBytes(int)));
766 connect(_bns, SIGNAL(newClkBytes(int)), this, SLOT(slotClkBytes(int)));
767 connect(_bns, SIGNAL(newOutBytes1(int)), this, SLOT(slotOutBytes1(int)));
768 connect(_bns, SIGNAL(newOutBytes2(int)), this, SLOT(slotOutBytes2(int)));
769
770 _bns->start();
771}
772
773// Input and output bytes statistics
774////////////////////////////////////////////////////////////////////////////
775void bnsWindow::slotEphBytes(int nBytes) {
776 updateStatus(0, nBytes);
777}
778void bnsWindow::slotClkBytes(int nBytes) {
779 updateStatus(1, nBytes);
780}
781void bnsWindow::slotOutBytes1(int nBytes) {
782 updateStatus(2, nBytes);
783}
784void bnsWindow::slotOutBytes2(int nBytes) {
785 updateStatus(3, nBytes);
786}
787
788void bnsWindow::updateStatus(int ii, int nBytes) {
789 QMutexLocker locker(&_mutex);
790
791 _statusCnt[ii] += nBytes;
792
793 if (_statusCnt[ii] < 1e3) {
794 _statusLbl[ii]->setText(QString("%1 byte(s)").arg((int)_statusCnt[ii]));
795 }
796 else if (_statusCnt[ii] < 1e6) {
797 _statusLbl[ii]->setText(QString("%1 kb").arg(_statusCnt[ii]/1.e3, 5));
798 }
799 else {
800 _statusLbl[ii]->setText(QString("%1 Mb").arg(_statusCnt[ii]/1.e6, 5));
801 }
802}
803
804// Bns Text
805////////////////////////////////////////////////////////////////////////////
806void bnsWindow::bnsText(const QString &text){
807
808 bool isEmpty = text.isEmpty();
809
810 QPalette palette;
811 QColor lightGray(230, 230, 230);
812 QColor white(255, 255, 255);
813
814 // Enable/disable Proxy Options
815 // -----
816 if (tabs->currentIndex() == 0) {
817 if (!isEmpty) {
818 _proxyPortLineEdit->setStyleSheet("background-color: white");
819 _proxyPortLineEdit->setEnabled(true);
820 } else {
821 _proxyPortLineEdit->setStyleSheet("background-color: lightGray");
822 _proxyPortLineEdit->setEnabled(false);
823 }
824 }
825
826 // Enable/disable Ephemeris Corrections I Options
827 // -----------------------------------------------
828 if (tabs->currentIndex() == 4) {
829 if (!isEmpty) {
830 _outPort_1_LineEdit->setStyleSheet("background-color: white");
831 _mountpoint_1_LineEdit->setStyleSheet("background-color: white");
832 _password_1_LineEdit->setStyleSheet("background-color: white");
833 _outFile_1_LineEdit->setStyleSheet("background-color: white");
834 _refSys_1_ComboBox->setStyleSheet("background-color: white");
835 _outPort_1_LineEdit->setEnabled(true);
836 _mountpoint_1_LineEdit->setEnabled(true);
837 _password_1_LineEdit->setEnabled(true);
838 _outFile_1_LineEdit->setEnabled(true);
839 _refSys_1_ComboBox->setEnabled(true);
840 } else {
841 _outPort_1_LineEdit->setStyleSheet("background-color: lightGray");
842 _mountpoint_1_LineEdit->setStyleSheet("background-color: lightGray");
843 _password_1_LineEdit->setStyleSheet("background-color: lightGray");
844 _outFile_1_LineEdit->setStyleSheet("background-color: lightGray");
845 _refSys_1_ComboBox->setStyleSheet("background-color: lightGray");
846 _outPort_1_LineEdit->setEnabled(false);
847 _mountpoint_1_LineEdit->setEnabled(false);
848 _password_1_LineEdit->setEnabled(false);
849 _outFile_1_LineEdit->setEnabled(false);
850 _refSys_1_ComboBox->setEnabled(false);
851 }
852 }
853
854 // Enable/disable Ephemeris Corrections II Options
855 // -----------------------------------------------
856 if (tabs->currentIndex() == 5) {
857 if (!isEmpty) {
858 _outPort_2_LineEdit->setStyleSheet("background-color: white");
859 _mountpoint_2_LineEdit->setStyleSheet("background-color: white");
860 _password_2_LineEdit->setStyleSheet("background-color: white");
861 _outFile_2_LineEdit->setStyleSheet("background-color: white");
862 _refSys_2_ComboBox->setStyleSheet("background-color: white");
863 _outPort_2_LineEdit->setEnabled(true);
864 _mountpoint_2_LineEdit->setEnabled(true);
865 _password_2_LineEdit->setEnabled(true);
866 _outFile_2_LineEdit->setEnabled(true);
867 _refSys_2_ComboBox->setEnabled(true);
868 } else {
869 _outPort_2_LineEdit->setStyleSheet("background-color: lightGray");
870 _mountpoint_2_LineEdit->setStyleSheet("background-color: lightGray");
871 _password_2_LineEdit->setStyleSheet("background-color: lightGray");
872 _outFile_2_LineEdit->setStyleSheet("background-color: lightGray");
873 _refSys_2_ComboBox->setStyleSheet("background-color: lightGray");
874 _outPort_2_LineEdit->setEnabled(false);
875 _mountpoint_2_LineEdit->setEnabled(false);
876 _password_2_LineEdit->setEnabled(false);
877 _outFile_2_LineEdit->setEnabled(false);
878 _refSys_2_ComboBox->setEnabled(false);
879 }
880 }
881
882 // Enable/disable RINEX Clocks Options
883 // -----------------------------------
884 if (tabs->currentIndex() == 6) {
885 if (!isEmpty) {
886 _rnxIntrComboBox->setStyleSheet("background-color: white");
887 _rnxSamplSpinBox->setStyleSheet("background-color: white");
888 _rnxIntrComboBox->setEnabled(true);
889 _rnxSamplSpinBox->setEnabled(true);
890 } else {
891 _rnxIntrComboBox->setStyleSheet("background-color: lightGray");
892 _rnxSamplSpinBox->setStyleSheet("background-color: lightGray");
893 _rnxIntrComboBox->setEnabled(false);
894 _rnxSamplSpinBox->setEnabled(false);
895 }
896 }
897
898 // Enable/disable SP3 Orbits Options
899 // ---------------------------------
900 if (tabs->currentIndex() == 7) {
901 if (!isEmpty) {
902 _sp3IntrComboBox->setStyleSheet("background-color: white");
903 _sp3SamplSpinBox->setStyleSheet("background-color: white");
904 _sp3IntrComboBox->setEnabled(true);
905 _sp3SamplSpinBox->setEnabled(true);
906 } else {
907 _sp3IntrComboBox->setStyleSheet("background-color: lightGray");
908 _sp3SamplSpinBox->setStyleSheet("background-color: lightGray");
909 _sp3IntrComboBox->setEnabled(false);
910 _sp3SamplSpinBox->setEnabled(false);
911 }
912 }
913
914}
Note: See TracBrowser for help on using the repository browser.