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

Last change on this file since 978 was 978, checked in by mervart, 16 years ago

* empty log message *

File size: 21.8 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
23using namespace std;
24
25// About Dialog - Constructor
26////////////////////////////////////////////////////////////////////////////
27bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
28 QDialog(parent) {
29
30 QTextBrowser* tb = new QTextBrowser;
31 QUrl url; url.setPath(":bnsabout.html");
32 tb->setSource(url);
33 tb->setReadOnly(true);
34
35 int ww = QFontMetrics(font()).width('w');
36 QPushButton* _closeButton = new QPushButton("Close");
37 _closeButton->setMaximumWidth(10*ww);
38 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
39
40 QGridLayout* dlgLayout = new QGridLayout();
41 QLabel* img = new QLabel();
42 img->setPixmap(QPixmap(":ntrip-logo.png"));
43 dlgLayout->addWidget(img, 0,0);
44 dlgLayout->addWidget(new QLabel("BKG Ntrip Server (BNS) Version 1.0"), 0,1);
45 dlgLayout->addWidget(tb,1,0,1,2);
46 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
47
48 setLayout(dlgLayout);
49 resize(60*ww, 60*ww);
50 show();
51}
52
53// About Dialog - Destructor
54////////////////////////////////////////////////////////////////////////////
55bnsAboutDlg::~bnsAboutDlg() {
56};
57
58// Constructor
59////////////////////////////////////////////////////////////////////////////
60bnsWindow::bnsWindow() {
61
62 _bns = 0;
63
64 QSettings settings;
65
66 QString fontString = settings.value("font").toString();
67 if ( !fontString.isEmpty() ) {
68 QFont newFont;
69 if (newFont.fromString(fontString)) {
70 this->setFont(newFont);
71 }
72 }
73
74 int ww = QFontMetrics(this->font()).width('w');
75 setMinimumSize(77*ww, 65*ww);
76 setWindowTitle(tr("BKG Ntrip Server (BNS) Version 1.0"));
77 setWindowIcon(QPixmap(":ntrip-logo.png"));
78
79 // Create Actions
80 // --------------
81 _actHelp = new QAction(tr("&Help Contents"),this);
82 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
83
84 _actAbout = new QAction(tr("&About BNS"),this);
85 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
86
87 _actFontSel = new QAction(tr("Select &Font"),this);
88 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
89
90 _actSaveOpt = new QAction(tr("&Save Options"),this);
91 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
92
93 _actQuit = new QAction(tr("&Quit"),this);
94 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
95
96 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
97 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
98
99 _actStart = new QAction(tr("Sta&rt"),this);
100 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
101
102 _actStop = new QAction(tr("Sto&p"),this);
103 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
104 _actStop->setEnabled(false);
105
106 CreateMenu();
107 AddToolbar();
108
109 // Canvas with Editable Fields
110 // ---------------------------
111 _canvas = new QWidget;
112 setCentralWidget(_canvas);
113
114 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
115 _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>"));
116 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
117 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
118 _proxyPortLineEdit->setMaximumWidth(9*ww);
119
120 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
121 _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>"));
122 _fileAppendCheckBox = new QCheckBox();
123 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
124 _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>"));
125
126 _refSysComboBox = new QComboBox;
127 _refSysComboBox->setMaximumWidth(9*ww);
128 _refSysComboBox->setEditable(false);
129 _refSysComboBox->addItems(QString("IGS05,ETRS89").split(","));
130 int ii = _refSysComboBox->findText(settings.value("refSys").toString());
131 if (ii != -1) {
132 _refSysComboBox->setCurrentIndex(ii);
133 }
134 _refSysComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
135
136 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
137 _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."));
138 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
139 _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."));
140 _ephPortLineEdit->setMaximumWidth(9*ww);
141
142 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
143 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in plain ASCII format from an IP address. Specify the IP port e.g. of a RTNet installation providing this information."));
144 _clkFileLineEdit = new QLineEdit(settings.value("clkFile").toString());
145 _clkFileLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming IGS Clocks & Orbits are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming Clocks & Orbits corrections are not saved."));
146 _clkPortLineEdit->setMaximumWidth(9*ww);
147
148 _outHostLineEdit = new QLineEdit(settings.value("outHost").toString());
149 _outHostLineEdit->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."));
150 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
151 _outPortLineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
152 _outPortLineEdit->setMaximumWidth(9*ww);
153 _mountpointLineEdit = new QLineEdit(settings.value("mountpoint").toString());
154 _mountpointLineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
155 _mountpointLineEdit->setMaximumWidth(9*ww);
156 _passwordLineEdit = new QLineEdit(settings.value("password").toString());
157 _passwordLineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
158 _passwordLineEdit->setMaximumWidth(9*ww);
159 _passwordLineEdit->setEchoMode(QLineEdit::Password);
160 _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
161 _outFileLineEdit->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."));
162
163 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
164 _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."));
165 _rnxIntrComboBox = new QComboBox;
166 _rnxIntrComboBox->setMaximumWidth(9*ww);
167 _rnxIntrComboBox->setEditable(false);
168 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
169 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
170 if (ii != -1) {
171 _rnxIntrComboBox->setCurrentIndex(ii);
172 }
173 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
174 _rnxSamplSpinBox = new QSpinBox;
175 _rnxSamplSpinBox->setMinimum(0);
176 _rnxSamplSpinBox->setMaximum(60);
177 _rnxSamplSpinBox->setSingleStep(5);
178 _rnxSamplSpinBox->setMaximumWidth(9*ww);
179 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
180 _rnxSamplSpinBox->setSuffix(" sec");
181 _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."));
182
183 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
184 _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."));
185 _sp3IntrComboBox = new QComboBox;
186 _sp3IntrComboBox->setMaximumWidth(9*ww);
187 _sp3IntrComboBox->setEditable(false);
188 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
189 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
190 if (ii != -1) {
191 _sp3IntrComboBox->setCurrentIndex(ii);
192 }
193 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
194 _sp3SamplSpinBox = new QSpinBox;
195 _sp3SamplSpinBox->setMinimum(0);
196 _sp3SamplSpinBox->setMaximum(900);
197 _sp3SamplSpinBox->setSingleStep(60);
198 _sp3SamplSpinBox->setMaximumWidth(9*ww);
199 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
200 _sp3SamplSpinBox->setSuffix(" sec");
201 _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."));
202
203 // TabWidget
204 // ---------
205 QTabWidget* tabs = new QTabWidget();
206
207 // Proxy Tab
208 // ---------
209 QWidget* tab_prx = new QWidget();
210 tabs->setMaximumHeight(20*ww);
211 tabs->addTab(tab_prx, "Proxy");
212
213 QGridLayout* layout_prx = new QGridLayout;
214 layout_prx->setColumnMinimumWidth(0,9*ww);
215
216 layout_prx->addWidget(new QLabel("Proxy host"), 0, 0, Qt::AlignLeft);
217 layout_prx->addWidget(_proxyHostLineEdit, 0, 1);
218 layout_prx->addWidget(new QLabel("Proxy port"), 1, 0, Qt::AlignLeft);
219 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
220 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 2, Qt::AlignLeft);
221 layout_prx->addWidget(new QLabel(" "), 3, 0);
222 layout_prx->addWidget(new QLabel(" "), 4, 0);
223
224 tab_prx->setLayout(layout_prx);
225
226 // General Tab
227 // -----------
228 QWidget* tab_gen = new QWidget();
229 tabs->addTab(tab_gen, "General");
230
231 QGridLayout* layout_gen = new QGridLayout;
232 layout_gen->setColumnMinimumWidth(0,9*ww);
233
234 layout_gen->addWidget(new QLabel("Logfile (full path)"), 0, 0);
235 layout_gen->addWidget(_logFileLineEdit, 0, 1);
236 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
237 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
238 layout_gen->addWidget(new QLabel("Reference System"), 2, 0);
239 layout_gen->addWidget(_refSysComboBox, 2, 1);
240 layout_gen->addWidget(new QLabel("General settings for logfile, file handling and target reference system."),3, 0, 1, 2, Qt::AlignLeft);
241 layout_gen->addWidget(new QLabel(" "), 4, 0);
242
243 tab_gen->setLayout(layout_gen);
244
245 // Input Tab
246 // ---------
247 QWidget* tab_inp = new QWidget();
248 tabs->addTab(tab_inp, "Input");
249
250 QGridLayout* layout_inp = new QGridLayout;
251 layout_inp->setColumnMinimumWidth(0, 9*ww);
252
253 layout_inp->addWidget(new QLabel("Ephemeris"), 0, 0, Qt::AlignLeft);
254 layout_inp->addWidget(new QLabel("Host"), 0, 1, Qt::AlignRight);
255 layout_inp->addWidget(_ephHostLineEdit, 0, 2);
256 layout_inp->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
257 layout_inp->addWidget(_ephPortLineEdit, 0, 4);
258 layout_inp->addWidget(new QLabel("Clocks & Orbits"), 1, 0, Qt::AlignLeft);
259 layout_inp->addWidget(new QLabel("Server listening on Port"), 1, 1, 1, 3, Qt::AlignRight);
260 layout_inp->addWidget(_clkPortLineEdit, 1, 4);
261 layout_inp->addWidget(new QLabel("Save Clocks & Orbits"), 2, 0, Qt::AlignLeft);
262 layout_inp->addWidget(new QLabel("(full path)"), 2, 1, Qt::AlignRight);
263 layout_inp->addWidget(_clkFileLineEdit, 2, 2);
264 layout_inp->addWidget(new QLabel("Read broadcast ephemeris and IGS clocks and orbits."), 3, 0, 1, 6, Qt::AlignLeft);
265 layout_inp->addWidget(new QLabel(""), 4, 0);
266
267 tab_inp->setLayout(layout_inp);
268
269 // NTRIP Caster Tab
270 // ----------------
271 QWidget* tab_cas = new QWidget();
272 tabs->addTab(tab_cas, "NTRIP Caster");
273
274 QGridLayout* layout_cas = new QGridLayout;
275 layout_cas->setColumnMinimumWidth(0, 9*ww);
276
277 layout_cas->addWidget(new QLabel("Host"), 0, 0, Qt::AlignLeft);
278 layout_cas->addWidget(_outHostLineEdit, 0, 1);
279 layout_cas->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
280 layout_cas->addWidget(_outPortLineEdit, 0, 4);
281 layout_cas->addWidget(new QLabel("Mountpoint"), 1, 0, Qt::AlignLeft);
282 layout_cas->addWidget(_mountpointLineEdit, 1, 1);
283 layout_cas->addWidget(new QLabel("Password"), 1, 3, Qt::AlignLeft);
284 layout_cas->addWidget(_passwordLineEdit, 1, 4);
285 layout_cas->addWidget(new QLabel("Save stream (full path)"), 2, 0, Qt::AlignLeft);
286 layout_cas->addWidget(_outFileLineEdit, 2, 1);
287 layout_cas->addWidget(new QLabel("Stream upload of clock and orbit corrections to NTRIP broadcaster."),4, 0, 1, 2, Qt::AlignLeft);
288
289 tab_cas->setLayout(layout_cas);
290
291 // RINEX Tab
292 // ---------
293 QWidget* tab_rin = new QWidget();
294 tabs->addTab(tab_rin, "RINEX Clocks ");
295
296 QGridLayout* layout_rin = new QGridLayout;
297 layout_rin->setColumnMinimumWidth(0, 9*ww);
298
299 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
300 layout_rin->addWidget(_rnxPathLineEdit, 0, 1);
301 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
302 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
303 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
304 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
305 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 2, Qt::AlignLeft);
306 layout_rin->addWidget(new QLabel(""), 4, 0);
307
308 tab_rin->setLayout(layout_rin);
309
310 // SP3 Tab
311 // -------
312 QWidget* tab_sp3 = new QWidget();
313 tabs->addTab(tab_sp3, "SP3 Orbits");
314
315 QGridLayout* layout_sp3 = new QGridLayout;
316 layout_sp3->setColumnMinimumWidth(0, 9*ww);
317
318 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
319 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1);
320 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
321 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
322 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
323 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
324 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 2, Qt::AlignLeft);
325 layout_sp3->addWidget(new QLabel(""), 4, 0);
326
327 tab_sp3->setLayout(layout_sp3);
328
329 // Log
330 // ---
331 _log = new QTextBrowser();
332 _log->setReadOnly(true);
333 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
334
335 // Main Layout
336 // -----------
337 QVBoxLayout* mainLayout = new QVBoxLayout;
338 mainLayout->addWidget(tabs);
339 mainLayout->addWidget(_log);
340
341 _canvas->setLayout(mainLayout);
342}
343
344// Destructor
345////////////////////////////////////////////////////////////////////////////
346bnsWindow::~bnsWindow() {
347}
348
349// Close Application gracefully
350////////////////////////////////////////////////////////////////////////////
351void bnsWindow::closeEvent(QCloseEvent* event) {
352
353int iRet = QMessageBox::question(this, "Close", "Save Options?",
354 QMessageBox::Yes, QMessageBox::No,
355 QMessageBox::Cancel);
356
357 if (iRet == QMessageBox::Cancel) {
358 event->ignore();
359 return;
360 }
361 else if (iRet == QMessageBox::Yes) {
362 slotSaveOptions();
363 }
364
365 QMainWindow::closeEvent(event);
366}
367
368// About Message
369////////////////////////////////////////////////////////////////////////////
370void bnsWindow::slotAbout() {
371 new bnsAboutDlg(0);
372}
373
374// Help Window
375////////////////////////////////////////////////////////////////////////////
376void bnsWindow::slotHelp() {
377 QUrl url;
378 url.setPath(":bnshelp.html");
379 new bnsHlpDlg(0, url);
380}
381
382// Select Fonts
383////////////////////////////////////////////////////////////////////////////
384void bnsWindow::slotFontSel() {
385 bool ok;
386 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
387 if (ok) {
388 QSettings settings;
389 settings.setValue("font", newFont.toString());
390 QApplication::setFont(newFont);
391 int ww = QFontMetrics(newFont).width('w');
392 setMinimumSize(77*ww, 65*ww);
393 }
394}
395
396// Whats This Help
397////////////////////////////////////////////////////////////////////////////
398void bnsWindow::slotWhatsThis() {
399QWhatsThis::enterWhatsThisMode();
400}
401
402// Create Menus
403////////////////////////////////////////////////////////////////////////////
404void bnsWindow::CreateMenu() {
405 _menuFile = menuBar()->addMenu(tr("&File"));
406 _menuFile->addAction(_actFontSel);
407 _menuFile->addSeparator();
408 _menuFile->addAction(_actSaveOpt);
409 _menuFile->addSeparator();
410 _menuFile->addAction(_actQuit);
411
412 _menuHlp = menuBar()->addMenu(tr("&Help"));
413 _menuHlp->addAction(_actHelp);
414 _menuHlp->addAction(_actAbout);
415}
416
417// Tool (Command) Bar
418////////////////////////////////////////////////////////////////////////////
419void bnsWindow::AddToolbar() {
420 QToolBar* toolBar = new QToolBar;
421 addToolBar(Qt::BottomToolBarArea, toolBar);
422 toolBar->setMovable(false);
423 toolBar->addAction(_actStart);
424 toolBar->addAction(_actStop);
425 toolBar->addWidget(new QLabel(" "));
426 toolBar->addAction(_actWhatsThis);
427}
428
429// Save Options
430////////////////////////////////////////////////////////////////////////////
431void bnsWindow::slotSaveOptions() {
432 QSettings settings;
433 settings.setValue("proxyHost", _proxyHostLineEdit->text());
434 settings.setValue("proxyPort", _proxyPortLineEdit->text());
435 settings.setValue("logFile", _logFileLineEdit->text());
436 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
437 settings.setValue("refSys", _refSysComboBox->currentText());
438 settings.setValue("ephHost", _ephHostLineEdit->text());
439 settings.setValue("ephPort", _ephPortLineEdit->text());
440 settings.setValue("clkPort", _clkPortLineEdit->text());
441 settings.setValue("clkFile", _clkFileLineEdit->text());
442 settings.setValue("outHost", _outHostLineEdit->text());
443 settings.setValue("outPort", _outPortLineEdit->text());
444 settings.setValue("mountpoint", _mountpointLineEdit->text());
445 settings.setValue("outFile", _outFileLineEdit->text());
446 settings.setValue("password", _passwordLineEdit->text());
447 settings.setValue("rnxPath", _rnxPathLineEdit->text());
448 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
449 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
450 settings.setValue("sp3Path", _sp3PathLineEdit->text());
451 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
452 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
453}
454
455// Display Program Messages
456////////////////////////////////////////////////////////////////////////////
457void bnsWindow::slotMessage(const QByteArray msg) {
458
459 const int maxBufferSize = 10000;
460
461 QString txt = _log->toPlainText() + "\n" +
462 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
463 _log->clear();
464 _log->append(txt.right(maxBufferSize));
465}
466
467// Delete bns
468////////////////////////////////////////////////////////////////////////////
469void bnsWindow::deleteBns() {
470 _actStart->setEnabled(true);
471 _actStop->setEnabled(false);
472 _bns->terminate();
473 _bns->wait(100);
474 delete _bns;
475 _bns = 0;
476}
477
478// Error in bns
479////////////////////////////////////////////////////////////////////////////
480void bnsWindow::slotError(const QByteArray msg) {
481 slotMessage(msg);
482 deleteBns();
483}
484
485// Stop
486////////////////////////////////////////////////////////////////////////////
487void bnsWindow::slotStop() {
488 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
489 QMessageBox::Yes, QMessageBox::No,
490 QMessageBox::NoButton);
491 if (iRet == QMessageBox::Yes) {
492 deleteBns();
493 }
494}
495
496// Start
497////////////////////////////////////////////////////////////////////////////
498void bnsWindow::slotStart() {
499 slotSaveOptions();
500
501 _actStart->setEnabled(false);
502 _actStop->setEnabled(true);
503
504 _bns = new t_bns(0);
505
506 connect(_bns, SIGNAL(newMessage(QByteArray)),
507 this, SLOT(slotMessage(const QByteArray)));
508
509 connect(_bns, SIGNAL(error(QByteArray)),
510 this, SLOT(slotError(const QByteArray)));
511
512 _bns->start();
513}
Note: See TracBrowser for help on using the repository browser.