[748] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
[749] | 3 | * BKG NTRIP Server
|
---|
[748] | 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 |
|
---|
[749] | 18 | #include <iostream>
|
---|
| 19 |
|
---|
[748] | 20 | #include "bnswindow.h"
|
---|
[749] | 21 | #include "bnshlpdlg.h"
|
---|
[748] | 22 |
|
---|
| 23 | using namespace std;
|
---|
| 24 |
|
---|
[754] | 25 | // About Dialog - Constructor
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 27 | bnsAboutDlg::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 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | bnsAboutDlg::~bnsAboutDlg() {
|
---|
| 56 | };
|
---|
| 57 |
|
---|
[748] | 58 | // Constructor
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
[758] | 60 | bnsWindow::bnsWindow() {
|
---|
[749] | 61 |
|
---|
[758] | 62 | _bns = 0;
|
---|
[757] | 63 |
|
---|
[752] | 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 |
|
---|
[749] | 74 | int ww = QFontMetrics(this->font()).width('w');
|
---|
| 75 | setMinimumSize(77*ww, 65*ww);
|
---|
| 76 | setWindowTitle(tr("BKG Ntrip Server (BNS) Version 1.0"));
|
---|
[752] | 77 | setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[749] | 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 |
|
---|
[753] | 96 | _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
|
---|
| 97 | connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
|
---|
[749] | 98 |
|
---|
[753] | 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 |
|
---|
[749] | 106 | CreateMenu();
|
---|
| 107 | AddToolbar();
|
---|
| 108 |
|
---|
| 109 | // Canvas with Editable Fields
|
---|
| 110 | // ---------------------------
|
---|
| 111 | _canvas = new QWidget;
|
---|
| 112 | setCentralWidget(_canvas);
|
---|
| 113 |
|
---|
[752] | 114 | _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
|
---|
| 115 | _ephPortLineEdit->setWhatsThis(tr("Port for broadcast ephemeris (from BNC)"));
|
---|
| 116 | _ephPortLineEdit->setMaximumWidth(9*ww);
|
---|
| 117 |
|
---|
[787] | 118 | _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
|
---|
| 119 | _clkPortLineEdit->setWhatsThis(tr("Port for clock results (from RTNET)"));
|
---|
| 120 | _clkPortLineEdit->setMaximumWidth(9*ww);
|
---|
[750] | 121 |
|
---|
[813] | 122 | _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
|
---|
| 123 | _outHostLineEdit = new QLineEdit(settings.value("outHost").toString());
|
---|
| 124 | _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
|
---|
[814] | 125 | _outPortLineEdit->setMaximumWidth(9*ww);
|
---|
[813] | 126 | _mountpointLineEdit = new QLineEdit(settings.value("mountpoint").toString());
|
---|
[844] | 127 | _mountpointLineEdit->setMaximumWidth(9*ww);
|
---|
[813] | 128 | _passwordLineEdit = new QLineEdit(settings.value("password").toString());
|
---|
[814] | 129 | _passwordLineEdit->setMaximumWidth(9*ww);
|
---|
[815] | 130 | _passwordLineEdit->setEchoMode(QLineEdit::Password);
|
---|
[813] | 131 | _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
|
---|
| 132 |
|
---|
[846] | 133 | _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
|
---|
[845] | 134 | _rnxIntrComboBox = new QComboBox;
|
---|
[846] | 135 | _rnxIntrComboBox->setMaximumWidth(9*ww);
|
---|
| 136 | _rnxIntrComboBox->setEditable(false);
|
---|
| 137 | _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
|
---|
| 138 | int ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
|
---|
| 139 | if (ii != -1) {
|
---|
| 140 | _rnxIntrComboBox->setCurrentIndex(ii);
|
---|
| 141 | }
|
---|
[845] | 142 | _rnxSamplSpinBox = new QSpinBox;
|
---|
[846] | 143 | _rnxSamplSpinBox->setMinimum(0);
|
---|
| 144 | _rnxSamplSpinBox->setMaximum(60);
|
---|
| 145 | _rnxSamplSpinBox->setSingleStep(5);
|
---|
| 146 | _rnxSamplSpinBox->setMaximumWidth(9*ww);
|
---|
| 147 | _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
|
---|
| 148 | _rnxSamplSpinBox->setSuffix(" sec");
|
---|
[845] | 149 |
|
---|
[846] | 150 | _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
|
---|
[845] | 151 | _sp3IntrComboBox = new QComboBox;
|
---|
[846] | 152 | _sp3IntrComboBox->setMaximumWidth(9*ww);
|
---|
| 153 | _sp3IntrComboBox->setEditable(false);
|
---|
| 154 | _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
|
---|
| 155 | ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
|
---|
| 156 | if (ii != -1) {
|
---|
| 157 | _sp3IntrComboBox->setCurrentIndex(ii);
|
---|
| 158 | }
|
---|
[845] | 159 | _sp3SamplSpinBox = new QSpinBox;
|
---|
[846] | 160 | _sp3SamplSpinBox->setMinimum(0);
|
---|
[855] | 161 | _sp3SamplSpinBox->setMaximum(900);
|
---|
| 162 | _sp3SamplSpinBox->setSingleStep(60);
|
---|
[846] | 163 | _sp3SamplSpinBox->setMaximumWidth(9*ww);
|
---|
| 164 | _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
|
---|
| 165 | _sp3SamplSpinBox->setSuffix(" sec");
|
---|
[845] | 166 |
|
---|
[750] | 167 | // TabWidget
|
---|
| 168 | // ---------
|
---|
[844] | 169 | QTabWidget* tabs = new QTabWidget();
|
---|
[813] | 170 |
|
---|
[844] | 171 | // Basic Input/Output Tab
|
---|
| 172 | // ----------------------
|
---|
| 173 | QWidget* tab_bas = new QWidget();
|
---|
[845] | 174 | tabs->addTab(tab_bas, "Basic Options");
|
---|
[750] | 175 |
|
---|
[844] | 176 | QGridLayout* layout_bas = new QGridLayout;
|
---|
[845] | 177 | layout_bas->setColumnMinimumWidth(2, 9*ww);
|
---|
| 178 |
|
---|
| 179 | layout_bas->addWidget(new QLabel("Input Ports"), 0, 0, 1, 2);
|
---|
| 180 | layout_bas->addWidget(new QLabel("Output Files"), 0, 3, 1, 2);
|
---|
[844] | 181 | layout_bas->addWidget(new QLabel("Ephemeris"), 1, 0, Qt::AlignLeft);
|
---|
| 182 | layout_bas->addWidget(_ephPortLineEdit, 1, 1);
|
---|
[845] | 183 | layout_bas->addWidget(new QLabel("Log"), 1, 3, Qt::AlignLeft);
|
---|
| 184 | layout_bas->addWidget(_logFileLineEdit, 1, 4);
|
---|
[844] | 185 | layout_bas->addWidget(new QLabel("Clocks"), 2, 0, Qt::AlignLeft);
|
---|
| 186 | layout_bas->addWidget(_clkPortLineEdit, 2, 1);
|
---|
| 187 | layout_bas->addWidget(new QLabel("Data"), 2, 3, Qt::AlignLeft);
|
---|
[845] | 188 | layout_bas->addWidget(_outFileLineEdit, 2, 4);
|
---|
| 189 | layout_bas->addWidget(new QLabel(""), 3, 0);
|
---|
| 190 | layout_bas->addWidget(new QLabel(""), 4, 0);
|
---|
| 191 | layout_bas->addWidget(new QLabel(""), 5, 0);
|
---|
[813] | 192 |
|
---|
[844] | 193 | tab_bas->setLayout(layout_bas);
|
---|
[752] | 194 |
|
---|
[844] | 195 | // NTRIP Caster Tab
|
---|
| 196 | // ----------------
|
---|
| 197 | QWidget* tab_cas = new QWidget();
|
---|
[845] | 198 | tabs->addTab(tab_cas, "NTRIP Caster");
|
---|
[813] | 199 |
|
---|
[844] | 200 | QGridLayout* layout_cas = new QGridLayout;
|
---|
[845] | 201 | layout_cas->setColumnMinimumWidth(2, 9*ww);
|
---|
| 202 |
|
---|
[844] | 203 | layout_cas->addWidget(new QLabel(""), 0, 0);
|
---|
| 204 | layout_cas->addWidget(new QLabel("Host"), 1, 0, Qt::AlignLeft);
|
---|
| 205 | layout_cas->addWidget(_outHostLineEdit, 1, 1);
|
---|
[845] | 206 | layout_cas->addWidget(new QLabel("Port"), 1, 3, Qt::AlignLeft);
|
---|
| 207 | layout_cas->addWidget(_outPortLineEdit, 1, 4);
|
---|
[844] | 208 | layout_cas->addWidget(new QLabel("Mountpoint"), 2, 0, Qt::AlignLeft);
|
---|
| 209 | layout_cas->addWidget(_mountpointLineEdit, 2, 1);
|
---|
| 210 | layout_cas->addWidget(new QLabel("Password"), 2, 3, Qt::AlignLeft);
|
---|
| 211 | layout_cas->addWidget(_passwordLineEdit, 2, 4);
|
---|
| 212 | layout_cas->addWidget(new QLabel(""), 3, 0);
|
---|
| 213 | layout_cas->addWidget(new QLabel(""), 4, 0);
|
---|
| 214 | layout_cas->addWidget(new QLabel(""), 5, 0);
|
---|
| 215 |
|
---|
| 216 | tab_cas->setLayout(layout_cas);
|
---|
| 217 |
|
---|
[845] | 218 | // RINEX and SP3 Tab
|
---|
| 219 | // -----------------
|
---|
| 220 | QWidget* tab_rin = new QWidget();
|
---|
| 221 | tabs->addTab(tab_rin, "RINEX and SP3");
|
---|
| 222 |
|
---|
| 223 | QGridLayout* layout_rin = new QGridLayout;
|
---|
| 224 |
|
---|
| 225 | layout_rin->addWidget(new QLabel("Clocks in RINEX Format"), 0, 0, 1, 4);
|
---|
| 226 | layout_rin->addWidget(new QLabel("Directory"), 1, 0);
|
---|
| 227 | layout_rin->addWidget(_rnxPathLineEdit, 1, 1, 1, 3);
|
---|
| 228 | layout_rin->addWidget(new QLabel("Interval"), 2, 0);
|
---|
| 229 | layout_rin->addWidget(_rnxIntrComboBox, 2, 1);
|
---|
| 230 | layout_rin->addWidget(new QLabel("Sampling"), 2, 2, Qt::AlignRight);
|
---|
| 231 | layout_rin->addWidget(_rnxSamplSpinBox, 2, 3, Qt::AlignLeft);
|
---|
| 232 | layout_rin->addWidget(new QLabel(""), 3, 0);
|
---|
| 233 | layout_rin->addWidget(new QLabel("Ephemeris in SP3 Format"), 4, 0, 1, 4);
|
---|
| 234 | layout_rin->addWidget(new QLabel("Directory"), 5, 0);
|
---|
| 235 | layout_rin->addWidget(_sp3PathLineEdit, 5, 1, 1, 3);
|
---|
| 236 | layout_rin->addWidget(new QLabel("Interval"), 6, 0);
|
---|
| 237 | layout_rin->addWidget(_sp3IntrComboBox, 6, 1);
|
---|
| 238 | layout_rin->addWidget(new QLabel("Sampling"), 6, 2, Qt::AlignRight);
|
---|
| 239 | layout_rin->addWidget(_sp3SamplSpinBox, 6, 3, Qt::AlignLeft);
|
---|
| 240 |
|
---|
| 241 | tab_rin->setLayout(layout_rin);
|
---|
| 242 |
|
---|
[750] | 243 | // Log
|
---|
| 244 | // ---
|
---|
| 245 | _log = new QTextBrowser();
|
---|
| 246 | _log->setReadOnly(true);
|
---|
| 247 | _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
|
---|
| 248 |
|
---|
| 249 | // Main Layout
|
---|
| 250 | // -----------
|
---|
| 251 | QVBoxLayout* mainLayout = new QVBoxLayout;
|
---|
| 252 | mainLayout->addWidget(tabs);
|
---|
| 253 | mainLayout->addWidget(_log);
|
---|
| 254 |
|
---|
| 255 | _canvas->setLayout(mainLayout);
|
---|
[748] | 256 | }
|
---|
| 257 |
|
---|
| 258 | // Destructor
|
---|
| 259 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 260 | bnsWindow::~bnsWindow() {
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 | // Close Application gracefully
|
---|
| 264 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 265 | void bnsWindow::closeEvent(QCloseEvent* event) {
|
---|
[749] | 266 |
|
---|
| 267 | int iRet = QMessageBox::question(this, "Close", "Save Options?",
|
---|
| 268 | QMessageBox::Yes, QMessageBox::No,
|
---|
| 269 | QMessageBox::Cancel);
|
---|
| 270 |
|
---|
| 271 | if (iRet == QMessageBox::Cancel) {
|
---|
| 272 | event->ignore();
|
---|
| 273 | return;
|
---|
| 274 | }
|
---|
| 275 | else if (iRet == QMessageBox::Yes) {
|
---|
| 276 | slotSaveOptions();
|
---|
| 277 | }
|
---|
| 278 |
|
---|
[748] | 279 | QMainWindow::closeEvent(event);
|
---|
[749] | 280 |
|
---|
[748] | 281 | delete this;
|
---|
| 282 | }
|
---|
| 283 |
|
---|
[749] | 284 | // About Message
|
---|
| 285 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 286 | void bnsWindow::slotAbout() {
|
---|
| 287 | new bnsAboutDlg(0);
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | // Help Window
|
---|
| 291 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 292 | void bnsWindow::slotHelp() {
|
---|
| 293 | QUrl url;
|
---|
| 294 | url.setPath(":bnshelp.html");
|
---|
| 295 | new bnsHlpDlg(0, url);
|
---|
| 296 | }
|
---|
| 297 |
|
---|
| 298 | // Select Fonts
|
---|
| 299 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 300 | void bnsWindow::slotFontSel() {
|
---|
| 301 | bool ok;
|
---|
| 302 | QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
|
---|
| 303 | if (ok) {
|
---|
| 304 | QSettings settings;
|
---|
| 305 | settings.setValue("font", newFont.toString());
|
---|
| 306 | QApplication::setFont(newFont);
|
---|
| 307 | int ww = QFontMetrics(newFont).width('w');
|
---|
[752] | 308 | setMinimumSize(77*ww, 65*ww);
|
---|
[749] | 309 | }
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | // Whats This Help
|
---|
| 313 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 314 | void bnsWindow::slotWhatsThis() {
|
---|
| 315 | QWhatsThis::enterWhatsThisMode();
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | // Create Menus
|
---|
| 319 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 320 | void bnsWindow::CreateMenu() {
|
---|
| 321 | _menuFile = menuBar()->addMenu(tr("&File"));
|
---|
| 322 | _menuFile->addAction(_actFontSel);
|
---|
| 323 | _menuFile->addSeparator();
|
---|
| 324 | _menuFile->addAction(_actSaveOpt);
|
---|
| 325 | _menuFile->addSeparator();
|
---|
| 326 | _menuFile->addAction(_actQuit);
|
---|
| 327 |
|
---|
| 328 | _menuHlp = menuBar()->addMenu(tr("&Help"));
|
---|
| 329 | _menuHlp->addAction(_actHelp);
|
---|
| 330 | _menuHlp->addAction(_actAbout);
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | // Tool (Command) Bar
|
---|
| 334 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 335 | void bnsWindow::AddToolbar() {
|
---|
| 336 | QToolBar* toolBar = new QToolBar;
|
---|
| 337 | addToolBar(Qt::BottomToolBarArea, toolBar);
|
---|
| 338 | toolBar->setMovable(false);
|
---|
[753] | 339 | toolBar->addAction(_actStart);
|
---|
| 340 | toolBar->addAction(_actStop);
|
---|
[749] | 341 | toolBar->addWidget(new QLabel(" "));
|
---|
[753] | 342 | toolBar->addAction(_actWhatsThis);
|
---|
[749] | 343 | }
|
---|
| 344 |
|
---|
| 345 | // Save Options
|
---|
| 346 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 347 | void bnsWindow::slotSaveOptions() {
|
---|
[750] | 348 | QSettings settings;
|
---|
[813] | 349 | settings.setValue("ephPort", _ephPortLineEdit->text());
|
---|
| 350 | settings.setValue("clkPort", _clkPortLineEdit->text());
|
---|
| 351 | settings.setValue("logFile", _logFileLineEdit->text());
|
---|
| 352 | settings.setValue("outHost", _outHostLineEdit->text());
|
---|
| 353 | settings.setValue("outPort", _outPortLineEdit->text());
|
---|
| 354 | settings.setValue("mountpoint", _mountpointLineEdit->text());
|
---|
| 355 | settings.setValue("password", _passwordLineEdit->text());
|
---|
| 356 | settings.setValue("outFile", _outFileLineEdit->text());
|
---|
[846] | 357 | settings.setValue("rnxPath", _rnxPathLineEdit->text());
|
---|
| 358 | settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
|
---|
| 359 | settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
|
---|
| 360 | settings.setValue("sp3Path", _sp3PathLineEdit->text());
|
---|
| 361 | settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
|
---|
| 362 | settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
|
---|
[749] | 363 | }
|
---|
| 364 |
|
---|
[750] | 365 | // Display Program Messages
|
---|
| 366 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 367 | void bnsWindow::slotMessage(const QByteArray msg) {
|
---|
| 368 |
|
---|
| 369 | const int maxBufferSize = 10000;
|
---|
| 370 |
|
---|
| 371 | QString txt = _log->toPlainText() + "\n" +
|
---|
| 372 | QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
|
---|
| 373 | _log->clear();
|
---|
| 374 | _log->append(txt.right(maxBufferSize));
|
---|
| 375 | }
|
---|
[753] | 376 |
|
---|
[760] | 377 | // Delete bns
|
---|
| 378 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 379 | void bnsWindow::deleteBns() {
|
---|
| 380 | _actStart->setEnabled(true);
|
---|
| 381 | _actStop->setEnabled(false);
|
---|
[762] | 382 | _bns->terminate();
|
---|
[764] | 383 | _bns->wait(100);
|
---|
[760] | 384 | delete _bns;
|
---|
| 385 | _bns = 0;
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | // Error in bns
|
---|
| 389 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 390 | void bnsWindow::slotError(const QByteArray msg) {
|
---|
| 391 | slotMessage(msg);
|
---|
| 392 | deleteBns();
|
---|
| 393 | }
|
---|
| 394 |
|
---|
[753] | 395 | // Stop
|
---|
| 396 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 397 | void bnsWindow::slotStop() {
|
---|
| 398 | int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
|
---|
| 399 | QMessageBox::Yes, QMessageBox::No,
|
---|
| 400 | QMessageBox::NoButton);
|
---|
| 401 | if (iRet == QMessageBox::Yes) {
|
---|
[760] | 402 | deleteBns();
|
---|
[753] | 403 | }
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | // Start
|
---|
| 407 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 408 | void bnsWindow::slotStart() {
|
---|
| 409 | slotSaveOptions();
|
---|
| 410 |
|
---|
| 411 | _actStart->setEnabled(false);
|
---|
| 412 | _actStop->setEnabled(true);
|
---|
| 413 |
|
---|
[758] | 414 | _bns = new t_bns(0);
|
---|
[760] | 415 |
|
---|
[758] | 416 | connect(_bns, SIGNAL(newMessage(QByteArray)),
|
---|
| 417 | this, SLOT(slotMessage(const QByteArray)));
|
---|
[760] | 418 |
|
---|
| 419 | connect(_bns, SIGNAL(error(QByteArray)),
|
---|
| 420 | this, SLOT(slotError(const QByteArray)));
|
---|
| 421 |
|
---|
[757] | 422 | _bns->start();
|
---|
[753] | 423 | }
|
---|