- Timestamp:
- Jan 4, 2010, 3:23:44 PM (15 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncapp.h
r2011 r2181 94 94 QTcpServer* _serverCorr; 95 95 QList<QTcpSocket*>* _socketsCorr; 96 int _portNMEA; 97 QTcpServer* _serverNMEA; 98 QList<QTcpSocket*>* _socketsNMEA; 96 99 bncCaster* _caster; 97 100 long _lastDumpCoSec; -
trunk/BNC/bncmodel.cpp
r2180 r2181 163 163 // NMEA Output 164 164 // ----------- 165 int port = 0; // 7777;166 167 if (port != 0) {168 _server = new QTcpServer;169 if ( !_server->listen(QHostAddress::Any, port) ) {170 emit newMessage("bncModel: Cannot listen on sync port", true);171 }172 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));173 _sockets = new QList<QTcpSocket*>;174 }175 else {176 _server = 0;177 _sockets = 0;178 }179 180 181 165 QString nmeaFileName = settings.value("nmeaFile").toString(); 182 166 if (nmeaFileName.isEmpty()) { … … 210 194 delete _nmeaStream; 211 195 delete _nmeaFile; 212 delete _server;213 delete _sockets;214 }215 216 // New Connection217 ////////////////////////////////////////////////////////////////////////////218 void bncModel::slotNewConnection() {219 _sockets->push_back( _server->nextPendingConnection() );220 emit( newMessage(QString("PPP: new connection on port: # %1")221 .arg(_sockets->size()).toAscii(), true) );222 196 } 223 197 … … 588 562 // NMEA Output 589 563 // ----------- 590 if (_nmeaStream || _sockets) { 591 double xyz[3]; 592 xyz[0] = x(); 593 xyz[1] = y(); 594 xyz[2] = z(); 595 double ell[3]; 596 xyz2ell(xyz, ell); 597 double phiDeg = ell[0] * 180 / M_PI; 598 double lamDeg = ell[1] * 180 / M_PI; 599 600 char phiCh = 'N'; 601 if (phiDeg < 0) { 602 phiDeg = -phiDeg; 603 phiCh = 'S'; 604 } 605 char lamCh = 'E'; 606 if (lamDeg < 0) { 607 lamDeg = -lamDeg; 608 lamCh = 'W'; 609 } 610 611 double dop = 2.0; // TODO 612 613 ostringstream str3; 614 str3.setf(ios::fixed); 615 str3 << "GPGGA," 616 << epoData->tt.timestr(0,0) << ',' 617 << setw(2) << setfill('0') << int(phiDeg) 618 << setw(10) << setprecision(7) << setfill('0') 619 << fmod(60*phiDeg,60) << ',' << phiCh << ',' 620 << setw(2) << setfill('0') << int(lamDeg) 621 << setw(10) << setprecision(7) << setfill('0') 622 << fmod(60*lamDeg,60) << ',' << lamCh 623 << ",1," << setw(2) << setfill('0') << epoData->size() << ',' 624 << setw(3) << setprecision(1) << dop << ',' 625 << setprecision(3) << ell[2] << ",M,0.0,M,,,"; 626 627 writeNMEAstr(QString(str3.str().c_str())); 628 } 564 double xyz[3]; 565 xyz[0] = x(); 566 xyz[1] = y(); 567 xyz[2] = z(); 568 double ell[3]; 569 xyz2ell(xyz, ell); 570 double phiDeg = ell[0] * 180 / M_PI; 571 double lamDeg = ell[1] * 180 / M_PI; 572 573 char phiCh = 'N'; 574 if (phiDeg < 0) { 575 phiDeg = -phiDeg; 576 phiCh = 'S'; 577 } 578 char lamCh = 'E'; 579 if (lamDeg < 0) { 580 lamDeg = -lamDeg; 581 lamCh = 'W'; 582 } 583 584 double dop = 2.0; // TODO 585 586 ostringstream str3; 587 str3.setf(ios::fixed); 588 str3 << "GPGGA," 589 << epoData->tt.timestr(0,0) << ',' 590 << setw(2) << setfill('0') << int(phiDeg) 591 << setw(10) << setprecision(7) << setfill('0') 592 << fmod(60*phiDeg,60) << ',' << phiCh << ',' 593 << setw(2) << setfill('0') << int(lamDeg) 594 << setw(10) << setprecision(7) << setfill('0') 595 << fmod(60*lamDeg,60) << ',' << lamCh 596 << ",1," << setw(2) << setfill('0') << epoData->size() << ',' 597 << setw(3) << setprecision(1) << dop << ',' 598 << setprecision(3) << ell[2] << ",M,0.0,M,,,"; 599 600 writeNMEAstr(QString(str3.str().c_str())); 629 601 630 602 return success; … … 698 670 XOR ^= (unsigned char) nmStr[ii].toAscii(); 699 671 } 672 673 QString outStr = '$' + nmStr 674 + QString("*%1\n").arg(int(XOR), 0, 16).toUpper(); 700 675 701 676 if (_nmeaStream) { 702 *_nmeaStream << '$' << nmStr << '*' << hex << (int) XOR << endl;677 *_nmeaStream << outStr; 703 678 _nmeaStream->flush(); 704 679 } 705 680 706 if (_sockets) { 707 QMutableListIterator<QTcpSocket*> is(*_sockets); 708 while (is.hasNext()) { 709 QTcpSocket* sock = is.next(); 710 if (sock->state() == QAbstractSocket::ConnectedState) { 711 QTextStream ts(sock); 712 ts << '$' << nmStr << '*' << hex << (int) XOR << endl; 713 ts.flush(); 714 } 715 else if (sock->state() != QAbstractSocket::ConnectingState) { 716 delete sock; 717 is.remove(); 718 } 719 } 720 } 721 } 681 emit newNMEAstr(outStr.toAscii()); 682 } -
trunk/BNC/bncmodel.h
r2178 r2181 68 68 signals: 69 69 void newMessage(QByteArray msg, bool showOnScreen); 70 71 private slots: 72 void slotNewConnection(); 70 void newNMEAstr(QByteArray str); 73 71 74 72 private: … … 93 91 QFile* _nmeaFile; 94 92 QTextStream* _nmeaStream; 95 QTcpServer* _server;96 QList<QTcpSocket*>* _sockets;97 93 }; 98 94
Note:
See TracChangeset
for help on using the changeset viewer.