- Timestamp:
- Jan 4, 2010, 1:48:00 PM (15 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncmodel.cpp
r2171 r2178 187 187 writeNMEAstr(nmStr); 188 188 } 189 190 int port = 7777; 191 192 if (port != 0) { 193 _server = new QTcpServer; 194 if ( !_server->listen(QHostAddress::Any, port) ) { 195 emit newMessage("bncModel: Cannot listen on sync port", true); 196 } 197 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); 198 _sockets = new QList<QTcpSocket*>; 199 } 200 else { 201 _server = 0; 202 _sockets = 0; 203 } 204 205 189 206 } 190 207 … … 194 211 delete _nmeaStream; 195 212 delete _nmeaFile; 213 delete _server; 214 delete _sockets; 215 } 216 217 // New Connection 218 //////////////////////////////////////////////////////////////////////////// 219 void bncModel::slotNewConnection() { 220 _sockets->push_back( _server->nextPendingConnection() ); 221 emit( newMessage(QString("PPP: new connection on port: # %1") 222 .arg(_sockets->size()).toAscii(), true) ); 196 223 } 197 224 … … 562 589 // NMEA Output 563 590 // ----------- 564 if (_nmeaStream) { 591 if (_nmeaStream || _sockets) { 565 592 double xyz[3]; 566 593 xyz[0] = x(); … … 668 695 void bncModel::writeNMEAstr(const QString& nmStr) { 669 696 670 if (!_nmeaStream) {671 return;672 }673 674 697 unsigned char XOR = 0; 675 698 for (int ii = 0; ii < nmStr.length(); ii++) { … … 677 700 } 678 701 679 *_nmeaStream << '$' << nmStr << '*' << hex << (int) XOR << endl; 680 681 _nmeaStream->flush(); 682 } 702 if (_nmeaStream) { 703 *_nmeaStream << '$' << nmStr << '*' << hex << (int) XOR << endl; 704 _nmeaStream->flush(); 705 } 706 707 if (_sockets) { 708 QMutableListIterator<QTcpSocket*> is(*_sockets); 709 while (is.hasNext()) { 710 QTcpSocket* sock = is.next(); 711 if (sock->state() == QAbstractSocket::ConnectedState) { 712 // *sock << '$' << nmStr << '*' << hex << (int) XOR << endl; 713 // sock->flush(); 714 } 715 else if (sock->state() != QAbstractSocket::ConnectingState) { 716 delete sock; 717 is.remove(); 718 } 719 } 720 } 721 } -
trunk/BNC/bncmodel.h
r2143 r2178 27 27 28 28 #include <QtCore> 29 #include <QtNetwork> 29 30 #include <newmat.h> 30 31 … … 68 69 void newMessage(QByteArray msg, bool showOnScreen); 69 70 71 private slots: 72 void slotNewConnection(); 73 70 74 private: 71 75 double cmpValue(t_satData* satData); … … 89 93 QFile* _nmeaFile; 90 94 QTextStream* _nmeaStream; 95 QTcpServer* _server; 96 QList<QTcpSocket*>* _sockets; 91 97 }; 92 98
Note:
See TracChangeset
for help on using the changeset viewer.