- Timestamp:
- Mar 30, 2008, 6:25:06 PM (17 years ago)
- Location:
- trunk/BNS
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/bns.cpp
r758 r760 24 24 //////////////////////////////////////////////////////////////////////////// 25 25 t_bns::t_bns(QObject* parent) : QThread(parent) { 26 26 27 _bnseph = new t_bnseph(parent); 28 27 29 connect(_bnseph, SIGNAL(newMessage(QByteArray)), 28 30 this, SLOT(slotMessage(const QByteArray))); 31 32 connect(_bnseph, SIGNAL(error(QByteArray)), 33 this, SLOT(slotError(const QByteArray))); 29 34 } 30 35 … … 42 47 } 43 48 49 // Write a Program Message 50 //////////////////////////////////////////////////////////////////////////// 51 void t_bns::slotError(const QByteArray msg) { 52 cerr << msg.data() << endl; 53 emit(error(msg)); 54 } 55 44 56 // Start 45 57 //////////////////////////////////////////////////////////////////////////// -
trunk/BNS/bns.h
r758 r760 16 16 signals: 17 17 void newMessage(const QByteArray msg); 18 void error(const QByteArray msg); 18 19 19 20 private slots: 20 21 void slotMessage(const QByteArray msg); 22 void slotError(const QByteArray msg); 21 23 22 24 private: -
trunk/BNS/bnseph.cpp
r759 r760 46 46 _socket->connectToHost(host, port); 47 47 48 const int timeOut = 10*1000; // 10seconds48 const int timeOut = 3*1000; // 3 seconds 49 49 if (!_socket->waitForConnected(timeOut)) { 50 emit(newMessage("bnseph::run Connect Timeout")); 51 delete _socket; _socket = 0; 52 return; 50 emit(error("bnseph::run Connect Timeout")); 53 51 } 54 55 while (true) { 56 if (_socket->canReadLine()) { 57 QByteArray line = _socket->readLine(); 58 emit(newMessage(line)); 59 } 60 else { 61 _socket->waitForReadyRead(10); 52 else { 53 while (true) { 54 if (_socket->canReadLine()) { 55 QByteArray line = _socket->readLine(); 56 emit(newMessage(line)); 57 } 58 else { 59 _socket->waitForReadyRead(10); 60 } 62 61 } 63 62 } -
trunk/BNS/bnseph.h
r759 r760 14 14 signals: 15 15 void newMessage(const QByteArray msg); 16 void error(const QByteArray msg); 16 17 17 18 private: -
trunk/BNS/bnswindow.cpp
r758 r760 280 280 } 281 281 282 // Delete bns 283 //////////////////////////////////////////////////////////////////////////// 284 void bnsWindow::deleteBns() { 285 _actStart->setEnabled(true); 286 _actStop->setEnabled(false); 287 delete _bns; 288 _bns = 0; 289 } 290 291 // Error in bns 292 //////////////////////////////////////////////////////////////////////////// 293 void bnsWindow::slotError(const QByteArray msg) { 294 slotMessage(msg); 295 deleteBns(); 296 } 297 282 298 // Stop 283 299 //////////////////////////////////////////////////////////////////////////// … … 287 303 QMessageBox::NoButton); 288 304 if (iRet == QMessageBox::Yes) { 289 _actStart->setEnabled(true); 290 _actStop->setEnabled(false); 291 delete _bns; 292 _bns = 0; 305 deleteBns(); 293 306 } 294 307 } … … 303 316 304 317 _bns = new t_bns(0); 318 305 319 connect(_bns, SIGNAL(newMessage(QByteArray)), 306 320 this, SLOT(slotMessage(const QByteArray))); 321 322 connect(_bns, SIGNAL(error(QByteArray)), 323 this, SLOT(slotError(const QByteArray))); 324 307 325 _bns->start(); 308 326 } -
trunk/BNS/bnswindow.h
r758 r760 23 23 public slots: 24 24 void slotMessage(const QByteArray msg); 25 void slotError(const QByteArray msg); 25 26 26 27 private slots: … … 39 40 void CreateMenu(); 40 41 void AddToolbar(); 42 void deleteBns(); 41 43 42 44 QMenu* _menuHlp;
Note:
See TracChangeset
for help on using the changeset viewer.