- Timestamp:
- Oct 15, 2015, 2:47:01 PM (9 years ago)
- Location:
- trunk/Gps
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gps/CMakeLists.txt
r59 r99 1 #########################quick start############################################ 2 #cmake ../ -G "CodeBlocks - Unix Makefiles" 3 #make 4 #make install 5 #make clean 6 ################################################################################ 1 7 project(Gps) 8 set(${PROJECT_NAME}_VERSION_MAJOR 0) 9 set(${PROJECT_NAME}_VERSION_MINOR 1) 10 add_definitions( -DGPS_EXPORTS ) 2 11 ################################################################################ 12 create_export(EXPORT_HDR ${PROJECT_NAME}) 13 pacpus_plugin(PLUGIN_CPP PLUGIN_HDR ${PROJECT_NAME}) 14 add_definitions (${QT_DEFINITIONS}) 3 15 4 add_definitions( -DGPS_EXPORTS ) 5 6 # ======================================== 7 # Configure qt4 8 # ======================================== 9 if(QT4_FOUND) 10 set(QT_USE_QTXML true) 11 set(QT_USE_QTNETWORK true) 12 include(${QT_USE_FILE}) 13 else() 14 message(ERROR "Qt4 needed") 15 endif() 16 17 # ======================================== 18 # Compiler definitions 19 # ======================================== 20 add_definitions( 21 ${QT_DEFINITIONS} 22 ) 23 24 # ======================================== 25 # Include directories 26 # ======================================== 27 include_directories( 28 ${PROJECT_BINARY_DIR} 29 ${QT_INCLUDE_DIR} 16 find_package(Qt5Network REQUIRED) 17 find_package(Qt5Widgets REQUIRED) 18 ################################################################################ 19 # DIRECTORIES 20 include_directories( 21 ${PROJECT_BINARY_DIR} 22 ${QT_INCLUDE_DIR} 23 ${PACPUS_INCLUDE_DIR} 24 ${PACPUS_INCLUDE_DIR}/Pacpus/ 30 25 ) 31 26 … … 38 33 39 34 40 pacpus_plugin(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} ) 41 42 # ======================================== 43 # List of sources 44 # ======================================== 45 set( 46 PROJECT_SRCS 47 gpsComponent.cpp 48 gpsComponent.h 49 GpsFrames.h 50 # SeptentrioSocket.h 51 # SeptentrioSocket.cpp 52 # SeptentrioComponent.h 53 # SeptentrioComponent.cpp 54 #UbloxComponent.h 55 #UbloxComponent.cpp 56 #polarxGPSTKsolver.cpp 57 # ui/polarxmainwindow.hpp 58 # ui/polarxmainwindow.cpp 35 ################################################################################ 36 # FILES 37 set(PROJECT_HDRS 38 ${EXPORT_HDR} 39 gpsComponent.h 40 GpsFrames.h 41 SeptentrioSocket.h 42 SbfFrames.h 43 structure_gps.h 44 xml/gps_nmea.xml 45 ) 46 set(PROJECT_SRCS 59 47 ${PLUGIN_CPP} 48 gpsComponent.cpp 49 SeptentrioSocket.cpp 50 ui/polarxmainwindow.cpp 60 51 ) 61 52 … … 76 67 endif(UNIX) 77 68 78 79 # ========================================80 # Files to MOC81 # ========================================82 83 69 if(UNIX) 84 70 set(FILES_TO_MOC 85 71 # add here the header files that you want to MOC 86 72 gpsComponent.h 87 SeptentrioComponent.h 73 GpsFrames.h 74 #SeptentrioComponent.h 88 75 SeptentrioSocket.h 89 76 ../driver/PosixSerialPort.h 90 77 ui/polarxmainwindow.hpp 91 ${PLUGIN_H}78 ${PLUGIN_HDR} 92 79 ) 93 80 endif(UNIX) … … 97 84 # add here the header files that you want to MOC 98 85 gpsComponent.h 99 #SeptentrioComponent.h100 #SeptentrioSocket.h86 # SeptentrioComponent.h 87 # SeptentrioSocket.h 101 88 ../driver/Win32SerialPort.h 102 # ui/polarxmainwindow.hpp103 ${PLUGIN_H }89 # ui/polarxmainwindow.hpp 90 ${PLUGIN_HDR} 104 91 ) 105 92 endif(WIN32) 106 93 107 set( 108 UI_FILES 94 set(UI_FILES 109 95 ) 110 96 111 # ======================================== 112 # Call MOC 113 # ======================================== 114 qt4_wrap_cpp( 115 PROJECT_MOC_SRCS 97 ################################################################################ 98 # Qt: call moc, uic 99 qt_wrap_cpp(PROJECT_MOC_SRCS 116 100 ${FILES_TO_MOC} 117 101 ) 118 102 119 qt4_wrap_ui( 120 PROJECT_UI_SRCS 103 qt_wrap_ui(PROJECT_UI_SRCS 121 104 ${UI_FILES} 122 105 ) 123 106 124 # ======================================== 125 # Build a library 126 # ======================================== 127 pacpus_add_library( 128 ${PROJECT_NAME} SHARED 107 ################################################################################ 108 # BUILD and LINK 109 pacpus_add_library(${PROJECT_NAME} SHARED 110 ${PROJECT_HDRS} 129 111 ${PROJECT_SRCS} 130 112 ${PROJECT_MOC_SRCS} … … 132 114 ) 133 115 116 134 117 # ======================================== 135 118 # Libraries 136 119 # ======================================== 137 if(WIN32) 138 set(LIBS 139 # add your specific libraries to link here 140 optimized NMEA0183LIB debug NMEA0183LIB_d 120 set(LIBS 121 optimized FileLib debug FileLib_d 122 optimized PacpusLib debug PacpusLib_d 123 optimized PacpusTools debug PacpusTools_d 124 optimized NMEA0183LIB debug NMEA0183LIB_d 125 ) 126 if (WIN32) 127 list(APPEND LIBS 128 optimized ROAD_TIME debug ROAD_TIME_d 141 129 ) 142 endif(WIN32) 143 144 if(UNIX) 145 set(LIBS 146 # add your specific libraries to link here 147 148 ) 149 endif(UNIX) 150 151 # All the platform 152 target_link_libraries( 153 ${PROJECT_NAME} 154 ${PACPUS_LIBRARIES} 155 ${QT_LIBRARIES} 156 ${PACPUS_DEPENDENCIES_LIB} 157 ${LIBS} 158 # optimized PacpusTools debug PacpusTools_d 159 ) 130 endif() 131 # LINK 132 target_link_libraries(${PROJECT_NAME} 133 ${PACPUS_LIBRARIES} 134 ${PACPUS_DEPENDENCIES_LIB} 135 ${LIBS} 136 ${QT_LIBRARIES} 137 ) 138 qt5_use_modules(${PROJECT_NAME} Network) 139 ################################################################################ 140 # FOLDERS 160 141 pacpus_folder(${PROJECT_NAME} "components") 161 162 # ======================================== 163 # Install 164 # ======================================== 165 pacpus_install(${PROJECT_NAME}) 142 ################################################################################ 143 # INSTALL 144 pacpus_install(${PROJECT_NAME}) -
trunk/Gps/SeptentrioComponent.h
r59 r99 15 15 // #include "polarxGPSTKsolver.hpp" 16 16 17 #include "structure /structure_septentrio.h"17 #include "structure_gps.h" 18 18 #include "SerialCom/SerialCOM_Handle_Stream.hpp" 19 19 #include "SerialCom/SBF/SerialCOM_Protocol_SBF.hpp" -
trunk/Gps/SeptentrioSocket.cpp
r59 r99 15 15 16 16 #include "SeptentrioSocket.h" 17 #include "SeptentrioComponent.h"17 //#include "SeptentrioComponent.h" 18 18 #include <QApplication> 19 19 #include <QtDebug> -
trunk/Gps/gpsComponent.cpp
r77 r99 18 18 #include <iostream> 19 19 20 #define PACPUS_PI 3.1415926 21 20 22 namespace pacpus { 21 23 22 24 /// Construct the factory 23 ComponentFactory<GpsComponent> sFactory("GpsComponent"); 25 ComponentFactory<GpsComponent> sFactory("GpsComponent"); 24 26 25 27 DECLARE_STATIC_LOGGER("pacpus.base.GpsComponent"); … … 35 37 : semaphore_(0) 36 38 , ComponentBase(name) 37 38 { 39 40 ppsRecording = TRUE;41 ggaRecording = TRUE;42 gsaRecording = TRUE;43 gstRecording = TRUE;44 gsvRecording = TRUE;45 hdtRecording = TRUE;46 rmcRecording = TRUE;47 rotRecording = TRUE;48 vtgRecording = TRUE;49 zdaRecording = TRUE;50 51 /* ppshdFile = NULL; 52 ggahdFile = NULL; 53 gsahdFile = NULL; 54 gsthdFile = NULL; 55 gsvhdFile = NULL; 56 hdthdFile = NULL; 57 rmchdFile = NULL; 58 rothdFile = NULL; 59 vtghdFile = NULL; 60 zdahdFile = NULL; 39 40 { 41 42 ppsRecording = true;//TRUE 43 ggaRecording = true; 44 gsaRecording = true; 45 gstRecording = true; 46 gsvRecording = true; 47 hdtRecording = true; 48 rmcRecording = true; 49 rotRecording = true; 50 vtgRecording = true; 51 zdaRecording = true; 52 53 /* ppshdFile = NULL; 54 ggahdFile = NULL; 55 gsahdFile = NULL; 56 gsthdFile = NULL; 57 gsvhdFile = NULL; 58 hdthdFile = NULL; 59 rmchdFile = NULL; 60 rothdFile = NULL; 61 vtghdFile = NULL; 62 zdahdFile = NULL; 61 63 */ 62 63 64 65 64 66 nextByteToProcess_ = 0; 65 67 currentFrame_ = NULL; 66 newFrameToDecode_ = false; 67 startOfFrame_ = false; 68 newFrameToDecode_ = false; 69 startOfFrame_ = false; 68 70 endOfFrame_ = false; 69 71 } … … 81 83 ComponentBase::COMPONENT_CONFIGURATION GpsComponent::configureComponent(XmlComponentConfig config) 82 84 { 83 setPortCOM( config.getProperty("port").toLatin1() ); 85 setPortCOM( config.getProperty("port").toLatin1() ); 84 86 setRecording ((config.getProperty("recording") == "true" ? true : false)); 85 87 … … 90 92 void GpsComponent::setPortCOM(const char * port) 91 93 { 92 portName_ = port; 94 portName_ = port; 93 95 } 94 96 … … 111 113 void GpsComponent::run() 112 114 { 113 int type = -1; 114 115 int type = -1; 116 115 117 // parity:0-4=no,odd,even,mark,space 116 118 // byteSize:number of bits/byte, 4-8 117 // baudRate:port speed (ex:38400) 118 // stopBits:0,1,2 = 1, 1.5, 2 119 120 serialPort->configurePort(xmlParameters().getProperty("baudrate").toLong(), 119 // baudRate:port speed (ex:38400) 120 // stopBits:0,1,2 = 1, 1.5, 2 121 122 serialPort->configurePort(xmlParameters().getProperty("baudrate").toLong(), 121 123 xmlParameters().getProperty("bytesize").toUInt(), 122 124 // config.getProperty("parity").at(0).toLatin1(), 123 125 xmlParameters().getProperty("parity").toShort(), 124 xmlParameters().getProperty("stopbits").toUInt() - 1); 125 126 127 serialPort->start(); 128 126 xmlParameters().getProperty("stopbits").toUInt() - 1); 127 128 129 serialPort->start(); 130 129 131 while (isActive()) 130 { 132 { 131 133 // If there are no bytes remaining in the current frame, delete it 132 134 if ((currentFrame_ != NULL) && (nextByteToProcess_ >= currentFrame_->data.length())) { 133 delete currentFrame_; 135 delete currentFrame_; 134 136 currentFrame_ = NULL; 135 137 } … … 139 141 semaphore_.acquire(); 140 142 if ((currentFrame_ = serialPort->getNextFrame()) == NULL) { 141 // Should never get to this point as the semaphore counts the frames, unless 143 // Should never get to this point as the semaphore counts the frames, unless 142 144 // the thread is being stopped. 143 145 continue; … … 151 153 lastPpsTime_ = currentFrame_->t; 152 154 decodeFrame(SIGNAL_PPS); 153 } else if (analyzeFrame()) { 155 } else if (analyzeFrame()) { 154 156 // a new complete NMEA frame has arrived, decode it. 155 type = frameType(frameToDecode_.data); 157 type = frameType(frameToDecode_.data); 156 158 if (type != -1) { 157 159 if (decodeFrame(type) == -1) { 158 qWarning("Failed to decode the dataframe\n"); 160 qWarning("Failed to decode the dataframe\n"); 159 161 } 160 162 } … … 164 166 } 165 167 166 qDebug() << "The thread of " << name() << " GPS component is stopped"; 168 qDebug() << "The thread of " << name() << " GPS component is stopped"; 167 169 } 168 170 … … 174 176 void GpsComponent::stopActivity() 175 177 { 176 setActive( FALSE );178 setActive( false ); 177 179 unlockProcessing(1); // to unblock the thread that is waiting new data 178 179 serialPort->THREAD_ALIVE = FALSE;180 181 serialPort->THREAD_ALIVE = false; 180 182 181 183 if (!serialPort->wait(2000)) 182 184 { 183 serialPort->terminate(); 185 serialPort->terminate(); 184 186 qDebug("The Win32SerialPort thread blocks anormally, it has been killed !!"); 185 187 } 186 if ( !serialPort->closePort() ) 187 qDebug("Failed to close the port"); 188 if ( !serialPort->closePort() ) 189 qDebug("Failed to close the port"); 188 190 else 189 qDebug("The port is closed"); 191 qDebug("The port is closed"); 190 192 delete serialPort; 191 193 192 194 if (ppshdFile.isOpen()) 193 ppshdFile.close(); 195 ppshdFile.close(); 194 196 if (ggahdFile.isOpen()) 195 197 ggahdFile.close(); 196 198 if (gsahdFile.isOpen()) 197 gsahdFile.close(); 199 gsahdFile.close(); 198 200 if (gsthdFile.isOpen()) 199 201 gsthdFile.close(); … … 203 205 hdthdFile.close(); 204 206 if (rmchdFile.isOpen()) 205 rmchdFile.close(); 207 rmchdFile.close(); 206 208 if (rothdFile.isOpen()) 207 209 rothdFile.close(); 208 210 if (vtghdFile.isOpen()) 209 vtghdFile.close(); 211 vtghdFile.close(); 210 212 if (zdahdFile.isOpen()) 211 213 zdahdFile.close(); … … 219 221 { 220 222 ppsIndex_ = 0; 221 222 setActive( TRUE );223 223 224 setActive( true ); 225 224 226 #if WIN32 225 serialPort = new Win32SerialPort(portName_.toLatin1()); 227 serialPort = new Win32SerialPort(portName_.toLatin1()); 226 228 // Asynchrone 227 serialPort->setMode(FILE_FLAG_OVERLAPPED); 229 serialPort->setMode(FILE_FLAG_OVERLAPPED); 228 230 // Synchrone 229 //serialPort->setMode(0); 230 #else 231 serialPort = new PosixSerialPort(portName .toLatin1());231 //serialPort->setMode(0); 232 #else 233 serialPort = new PosixSerialPort(portName_.toLatin1()); 232 234 #endif 233 235 234 236 if (!serialPort->openPort(portName_.toLatin1())) 235 237 { 236 238 qDebug() << "Failed to open the port " << portName_; 237 239 qDebug() << "The GPS Component " << name() << " didn't start"; 238 return; 240 return; 239 241 } 240 241 serialPort->THREAD_ALIVE = TRUE;242 243 serialPort->THREAD_ALIVE = true; 242 244 if (!QApplication::connect(serialPort,SIGNAL(newDataAvailable(int)),this, SLOT(unlockProcessing(int)))) 243 qWarning("Failed to connect SIGNAL(newDataAvailable(int)) with SLOT(unlockProcessing(int)\n" ); 244 start(); 245 qWarning("Failed to connect SIGNAL(newDataAvailable(int)) with SLOT(unlockProcessing(int)\n" ); 246 start(); 245 247 qDebug() << "The Component " << name() << " is started"; 246 248 } … … 299 301 300 302 // first looking for start-of-frame 301 if (!startOfFrame_ && (currentChar == '$')) { 303 if (!startOfFrame_ && (currentChar == '$')) { 302 304 startOfFrame_ = true; 303 305 endOfFrame_ = false; … … 313 315 return true; // There is a new frame to decode 314 316 } 315 317 316 318 if ((startOfFrame_) && (!endOfFrame_)) { 317 frameToDecode_.data.append(currentChar); 319 frameToDecode_.data.append(currentChar); 318 320 } 319 321 } … … 325 327 { 326 328 // new frame available 327 semaphore_.release( v ); 329 semaphore_.release( v ); 328 330 } 329 331 … … 331 333 int GpsComponent::decodeFrame(int type) 332 334 { 333 double lat_rad = 0, lon_rad = 0; 334 int indexGSV = 0; 335 double lat_rad = 0, lon_rad = 0; 336 int indexGSV = 0; 335 337 int indexGSA = 0; 336 337 338 SENTENCE sentence; 339 sentence.Sentence = frameToDecode_.data; 340 341 switch(type) 338 339 340 SENTENCE sentence; 341 sentence.Sentence = frameToDecode_.data; 342 343 switch(type) 342 344 { 343 case UNKNOWN_NMEA_FRAME: 344 qDebug("Unknown frame received !"); 345 break; 345 case UNKNOWN_NMEA_FRAME: 346 qDebug("Unknown frame received !"); 347 break; 346 348 case SIGNAL_PPS: 347 349 ppsFrame.setRoadTime(lastPpsTime_); … … 351 353 { 352 354 if (!(ppshdFile.isOpen())) 353 ppshdFile.open((char *)(name() + "_pps.dbt").toLatin1().data(),WriteMode,TYPE_INT,sizeof(int)); 355 ppshdFile.open((char *)(name() + "_pps.dbt").toLatin1().data(),WriteMode,TYPE_INT,sizeof(int)); 354 356 if ( ppshdFile.writeRecord(frameToDecode_.t,frameToDecode_.tr,(char *) ppsFrame.getFrameData(),sizeof(int)) == 0) 355 qWarning("Failed to record PPS data ...\n"); 357 qWarning("Failed to record PPS data ...\n"); 356 358 } 357 359 ppsFrame.notifyObservers(); 358 360 359 361 break; 360 361 case TRAME_GGA_DBL: 362 363 case TRAME_GGA_DBL: 362 364 if (!nmea0183_.Gga.Parse(sentence)) { 363 365 LOG_ERROR("Failed to parse the frame " << nmea0183_.Gga.ErrorMessage.toLatin1().data()); … … 377 379 ggaFrame.getFrameData()->d_geoidal = nmea0183_.Gga.GeoidalSeparationMeters; 378 380 ggaFrame.getFrameData()->age = nmea0183_.Gga.AgeOfDifferentialGPSDataSeconds; 379 ggaFrame.getFrameData()->dir_lat = ( (nmea0183_.Gga.Position.Latitude.Northing == North) ? 'N' : 'S' ); 380 ggaFrame.getFrameData()->dir_lon = ( (nmea0183_.Gga.Position.Longitude.Easting == East) ? 'E' : 'W' ); 381 ggaFrame.getFrameData()->ref_station_ID = nmea0183_.Gga.DifferentialReferenceStationID; 381 ggaFrame.getFrameData()->dir_lat = ( (nmea0183_.Gga.Position.Latitude.Northing == North) ? 'N' : 'S' ); 382 ggaFrame.getFrameData()->dir_lon = ( (nmea0183_.Gga.Position.Longitude.Easting == East) ? 'E' : 'W' ); 383 ggaFrame.getFrameData()->ref_station_ID = nmea0183_.Gga.DifferentialReferenceStationID; 382 384 ggaFrame.setRoadTime(frameToDecode_.t); 383 384 sendDataToServerSocket(*ggaFrame.getFrameData(),type); 385 386 sendDataToServerSocket(*ggaFrame.getFrameData(),type); 385 387 ggaFrame.notifyObservers(); 386 388 387 389 if ( (isRecording()) && (ggaRecording) ) { 388 390 if (!(ggahdFile.isOpen())) 389 ggahdFile.open((char *)(name() + "_gga.dbt").toLatin1().data(),WriteMode,TRAME_GGA_DBL,sizeof(trame_gga_dbl)); 390 if ( !ggahdFile.writeRecord(frameToDecode_.t,frameToDecode_.tr,(char *) ggaFrame.getFrameData(),sizeof(trame_gga_dbl))) 391 qWarning("Failed to record GGA data ...\n"); 391 ggahdFile.open((char *)(name() + "_gga.dbt").toLatin1().data(),WriteMode,TRAME_GGA_DBL,sizeof(trame_gga_dbl)); 392 if ( !ggahdFile.writeRecord(frameToDecode_.t,frameToDecode_.tr,(char *) ggaFrame.getFrameData(),sizeof(trame_gga_dbl))) 393 qWarning("Failed to record GGA data ...\n"); 392 394 } 393 395 //printf("lon=%f lat=%f\n",ggaFrame.getFrameData()->lon, ggaFrame.getFrameData()->lat); 394 396 } 395 397 break; 396 398 397 399 case TRAME_GSA: 398 400 if (!nmea0183_.Gsa.Parse(sentence)) … … 401 403 gsaFrame.getFrameData()->mode_result = 0; 402 404 if (nmea0183_.Gsa.FixMode == GSA::FixUnavailable) 403 gsaFrame.getFrameData()->mode_result = 1; 405 gsaFrame.getFrameData()->mode_result = 1; 404 406 if (nmea0183_.Gsa.FixMode == GSA::TwoDimensional) 405 gsaFrame.getFrameData()->mode_result = 2; 407 gsaFrame.getFrameData()->mode_result = 2; 406 408 if (nmea0183_.Gsa.FixMode == GSA::ThreeDimensional) 407 gsaFrame.getFrameData()->mode_result = 3; 409 gsaFrame.getFrameData()->mode_result = 3; 408 410 for (indexGSA = 0 ; indexGSA<12 ; indexGSA++) 409 gsaFrame.getFrameData()->SV_PRN[indexGSA] = nmea0183_.Gsa.SatelliteNumber[indexGSA]; 410 gsaFrame.getFrameData()->pdop = nmea0183_.Gsa.PDOP; 411 gsaFrame.getFrameData()->hdop = nmea0183_.Gsa.HDOP; 412 gsaFrame.getFrameData()->vdop = nmea0183_.Gsa.VDOP; 411 gsaFrame.getFrameData()->SV_PRN[indexGSA] = nmea0183_.Gsa.SatelliteNumber[indexGSA]; 412 gsaFrame.getFrameData()->pdop = nmea0183_.Gsa.PDOP; 413 gsaFrame.getFrameData()->hdop = nmea0183_.Gsa.HDOP; 414 gsaFrame.getFrameData()->vdop = nmea0183_.Gsa.VDOP; 413 415 gsaFrame.setRoadTime(frameToDecode_.t); 414 416 415 417 gsaFrame.notifyObservers(); 416 417 sendDataToServerSocket(*gsaFrame.getFrameData(),type); 418 418 419 sendDataToServerSocket(*gsaFrame.getFrameData(),type); 420 419 421 if ( (isRecording()) && (gsaRecording) ) 420 422 { 421 423 if (!(gsahdFile.isOpen())) 422 424 gsahdFile.open((char *)(name() + "_gsa.dbt").toLatin1().data(),WriteMode, TRAME_GSA,sizeof(trame_gsa)); 423 if ( gsahdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) gsaFrame.getFrameData(),sizeof(trame_gsa)) != 1) 424 qWarning("Failed to record GSA data ...\n"); 425 if ( gsahdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) gsaFrame.getFrameData(),sizeof(trame_gsa)) != 1) 426 qWarning("Failed to record GSA data ...\n"); 425 427 } 426 428 break; 427 429 428 430 429 431 430 432 case TRAME_GST: 431 433 if (!nmea0183_.Gst.Parse( sentence )) … … 443 445 gstFrame.getFrameData()->Ms = nmea0183_.Gst.Time.time().msec(); 444 446 gstFrame.setRoadTime(frameToDecode_.t); 445 446 sendDataToServerSocket(*gstFrame.getFrameData(),type); 447 448 sendDataToServerSocket(*gstFrame.getFrameData(),type); 447 449 gstFrame.notifyObservers(); 448 450 449 451 450 452 if ( (isRecording()) && (gstRecording) ) { 451 if (!gsthdFile.isOpen()) 452 gsthdFile.open((char *)(name() + "_gst.dbt").toLatin1().data(),WriteMode,TRAME_GST,sizeof(trame_gst)); 453 if (!gsthdFile.isOpen()) 454 gsthdFile.open((char *)(name() + "_gst.dbt").toLatin1().data(),WriteMode,TRAME_GST,sizeof(trame_gst)); 453 455 if ( !gsthdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) gstFrame.getFrameData(),sizeof(trame_gst)) ) 454 qWarning("Failed to record GST data ...\n"); 455 } 456 break; 457 456 qWarning("Failed to record GST data ...\n"); 457 } 458 break; 459 458 460 case TRAME_GSV: 459 461 indexGSV = 0; … … 462 464 break; 463 465 } 464 // it's a new frame, reset stored value in case of the number of satellites 466 // it's a new frame, reset stored value in case of the number of satellites 465 467 // in view has decreased 466 468 if (nmea0183_.Gsv.message_number == 1) … … 477 479 gsvFrame.getFrameData()->NumberOfSatellites = nmea0183_.Gsv.NumberOfSatellites; 478 480 gsvFrame.getFrameData()->Totalmessages = nmea0183_.Gsv.Totalmessages; 479 481 480 482 for ( indexGSV=4*(nmea0183_.Gsv.message_number-1); indexGSV<=(4*nmea0183_.Gsv.message_number)-1; indexGSV++ ) 481 483 { … … 487 489 488 490 if (nmea0183_.Gsv.Totalmessages == nmea0183_.Gsv.message_number) { 489 sendDataToServerSocket(*gsvFrame.getFrameData(),type); 491 sendDataToServerSocket(*gsvFrame.getFrameData(),type); 490 492 gsvFrame.setRoadTime(frameToDecode_.t); 491 493 gsvFrame.notifyObservers(); … … 493 495 if ( (isRecording()) && (gsvRecording) && (nmea0183_.Gsv.Totalmessages == nmea0183_.Gsv.message_number) ) 494 496 { 495 if (!gsvhdFile.isOpen()) 496 gsvhdFile.open((char *)(name() + "_gsv.dbt").toLatin1().data(),WriteMode,TRAME_GSV,sizeof(trame_gsv)); 497 if (!gsvhdFile.isOpen()) 498 gsvhdFile.open((char *)(name() + "_gsv.dbt").toLatin1().data(),WriteMode,TRAME_GSV,sizeof(trame_gsv)); 497 499 if ( gsvhdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) gsvFrame.getFrameData(),sizeof(trame_gsv)) == 0) 498 qWarning("Failed to record GSV data ...\n"); 499 } 500 break; 501 500 qWarning("Failed to record GSV data ...\n"); 501 } 502 break; 503 502 504 case TRAME_HDT: 503 505 if (!nmea0183_.Hdt.Parse( sentence )) … … 505 507 hdtFrame.getFrameData()->DegreesTrue = nmea0183_.Hdt.DegreesTrue; 506 508 hdtFrame.setRoadTime(frameToDecode_.t); 507 508 sendDataToServerSocket(hdtFrame,type); 509 510 sendDataToServerSocket(hdtFrame,type); 509 511 hdtFrame.notifyObservers(); 510 512 511 513 if ( (isRecording()) && (hdtRecording) ) 512 514 { 513 515 if (!hdthdFile.isOpen()) 514 hdthdFile.open((char *)(name() + "_hdt.dbt").toLatin1().data(),WriteMode,TRAME_HDT,sizeof(trame_hdt)); 516 hdthdFile.open((char *)(name() + "_hdt.dbt").toLatin1().data(),WriteMode,TRAME_HDT,sizeof(trame_hdt)); 515 517 if ( hdthdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) hdtFrame.getFrameData(),sizeof(trame_hdt)) == 0) 516 qWarning("Failed to record HDT data ...\n"); 517 } 518 break; 519 518 qWarning("Failed to record HDT data ...\n"); 519 } 520 break; 521 520 522 case TRAME_RMC: 521 523 if (!nmea0183_.Rmc.Parse( sentence )) … … 545 547 rmcFrame.getFrameData()->vitesse = nmea0183_.Rmc.SpeedOverGroundKnots * 1852.0 / 3600.0; // 1 knot = 1852 m/h 546 548 rmcFrame.setRoadTime(frameToDecode_.t); 547 548 sendDataToServerSocket(*rmcFrame.getFrameData(),type); 549 550 sendDataToServerSocket(*rmcFrame.getFrameData(),type); 549 551 rmcFrame.notifyObservers(); 550 552 551 553 if ( (isRecording()) && (rmcRecording) ) 552 554 { 553 555 if (!rmchdFile.isOpen()) 554 rmchdFile.open((char *)(name() + "_rmc.dbt").toLatin1().data(),WriteMode,TRAME_RMC,sizeof(trame_rmc)); 556 rmchdFile.open((char *)(name() + "_rmc.dbt").toLatin1().data(),WriteMode,TRAME_RMC,sizeof(trame_rmc)); 555 557 if (rmchdFile.writeRecord(frameToDecode_.t ,frameToDecode_.tr,(char *) rmcFrame.getFrameData(),sizeof(trame_rmc)) == 0) 556 qWarning("Failed to record RMC data ...\n"); 558 qWarning("Failed to record RMC data ...\n"); 557 559 } 558 560 break; 559 561 560 562 case TRAME_ROT: 561 563 if (!nmea0183_.Rot.Parse( sentence )) … … 564 566 rotFrame.getFrameData()->valid_data = ( (nmea0183_.Rot.IsDataValid == True) ? 1 : 0 ); 565 567 rotFrame.setRoadTime(frameToDecode_.t); 566 567 sendDataToServerSocket(*rotFrame.getFrameData(),type); 568 569 sendDataToServerSocket(*rotFrame.getFrameData(),type); 568 570 rotFrame.notifyObservers(); 569 571 570 572 if ( (isRecording()) && (rotRecording) ) 571 573 { 572 574 if (!rothdFile.isOpen()) 573 rothdFile.open((char *)(name() + "_rot.dbt").toLatin1().data(),WriteMode,TRAME_ROT,sizeof(trame_rot)); 575 rothdFile.open((char *)(name() + "_rot.dbt").toLatin1().data(),WriteMode,TRAME_ROT,sizeof(trame_rot)); 574 576 if ( rothdFile.writeRecord(frameToDecode_.t ,frameToDecode_.tr,(char *) rotFrame.getFrameData(),sizeof(trame_rot)) == 0) 575 qWarning("Failed to record ROT data ...\n"); 576 } 577 break; 578 577 qWarning("Failed to record ROT data ...\n"); 578 } 579 break; 580 579 581 case TRAME_VTG: 580 582 if (!nmea0183_.Vtg.Parse( sentence )) { … … 582 584 } else { 583 585 vtgFrame.getFrameData()->v = nmea0183_.Vtg.SpeedKilometersPerHour; 584 vtgFrame.getFrameData()->track_true_north = nmea0183_.Vtg.TrackDegreesTrue; 585 vtgFrame.getFrameData()->track_magnet_north = nmea0183_.Vtg.TrackDegreesMagnetic; 586 vtgFrame.getFrameData()->track_true_north = nmea0183_.Vtg.TrackDegreesTrue; 587 vtgFrame.getFrameData()->track_magnet_north = nmea0183_.Vtg.TrackDegreesMagnetic; 586 588 vtgFrame.setRoadTime(frameToDecode_.t); 587 589 588 590 sendDataToServerSocket(vtgFrame,type); 589 591 vtgFrame.notifyObservers(); 590 592 591 593 if (isRecording() && vtgRecording) { 592 if (!vtghdFile.isOpen()) 593 vtghdFile.open((char *)(name() + "_vtg.dbt").toLatin1().data(),WriteMode,TRAME_VTG,sizeof(trame_vtg)); 594 if (!vtghdFile.isOpen()) 595 vtghdFile.open((char *)(name() + "_vtg.dbt").toLatin1().data(),WriteMode,TRAME_VTG,sizeof(trame_vtg)); 594 596 if ( vtghdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) vtgFrame.getFrameData(),sizeof(trame_vtg)) == 0) 595 qWarning("Failed to record VTG data ...\n"); 597 qWarning("Failed to record VTG data ...\n"); 596 598 } 597 599 } 598 break; 599 600 break; 601 600 602 case TRAME_ZDA: 601 603 if (!nmea0183_.Zda.Parse( sentence )) { … … 609 611 zdaFrame.getFrameData()->MM = nmea0183_.Zda.Time.date().month(); 610 612 zdaFrame.getFrameData()->JJ = nmea0183_.Zda.Time.date().day(); 611 zdaFrame.getFrameData()->H_offset = nmea0183_.Zda.LocalHourDeviation; 612 zdaFrame.getFrameData()->Mi_offset = nmea0183_.Zda.LocalMinutesDeviation; 613 613 zdaFrame.getFrameData()->H_offset = nmea0183_.Zda.LocalHourDeviation; 614 zdaFrame.getFrameData()->Mi_offset = nmea0183_.Zda.LocalMinutesDeviation; 615 614 616 sendDataToServerSocket(*zdaFrame.getFrameData(), type); 615 617 zdaFrame.setRoadTime(frameToDecode_.t); 616 618 zdaFrame.notifyObservers(); 617 619 618 620 if ( (isRecording()) && (zdaRecording) ) { 619 if (!zdahdFile.isOpen()) 620 zdahdFile.open((char *)(name() + "_zda.dbt").toLatin1().data(),WriteMode,TRAME_ZDA,sizeof(trame_zda)); 621 if (!zdahdFile.isOpen()) 622 zdahdFile.open((char *)(name() + "_zda.dbt").toLatin1().data(),WriteMode,TRAME_ZDA,sizeof(trame_zda)); 621 623 if ( zdahdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) zdaFrame.getFrameData(),sizeof(trame_zda)) == 0) { 622 624 LOG_WARN("Failed to record ZDA data ..."); … … 641 643 } 642 644 */ 643 644 break; 645 645 646 break; 647 646 648 default: 647 return 0; 649 return 0; 648 650 } 649 650 return 1; 651 652 return 1; 651 653 } 652 654 -
trunk/Gps/gpsComponent.h
r59 r99 21 21 #include <QSemaphore> 22 22 #include <QThread> 23 #include <QByteArray> 24 #include <QString> 23 25 24 26 #ifdef WIN32 25 27 # include "../driver/win32SerialPort.h" 26 28 //# include "network/gpsServerSocket.h" 27 #else 29 #else 28 30 # include "../driver/PosixSerialPort.h" 29 31 #endif … … 41 43 # endif 42 44 #else 43 // On other platforms, simply ignore this 45 // On other platforms, simply ignore this 44 46 # define GPS_API /* nothing */ 45 47 #endif … … 58 60 { 59 61 Q_OBJECT 60 62 61 63 public: 62 GpsComponent(QString name); 63 ~GpsComponent(); 64 64 GpsComponent(QString name); 65 ~GpsComponent(); 66 65 67 virtual void stopActivity(); /*!< to stop the processing thread */ 66 68 virtual void startActivity(); /*!< to start the processing thread */ 67 virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config); 69 virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config); 68 70 69 71 … … 71 73 void disableSocketServer(); /*!< to disable the socket server interface */ 72 74 73 void setPortCOM(const char * port); 75 void setPortCOM(const char * port); 74 76 75 77 76 77 public slots: 78 79 public slots: 78 80 void unlockProcessing(int v); /*!< to unlock the processing thread */ 79 81 80 82 protected: 81 83 private: 82 void run(); /*!< the main loop of the thread */ 83 int frameType(const QByteArray& frame); /*!< to get the type of the frame */ 84 int decodeFrame(int type); /*!< parse the string in the NMEA0183 class to get the frame informations */ 84 void run(); /*!< the main loop of the thread */ 85 int frameType(const QByteArray& frame); /*!< to get the type of the frame */ 86 int decodeFrame(int type); /*!< parse the string in the NMEA0183 class to get the frame informations */ 85 87 bool currentFrameIsPps(); /*!< checks if a frame is an out-of-band pps signal */ 86 bool analyzeFrame(); /*!< reconstruct the entire frame starting from the received pieces */ 88 bool analyzeFrame(); /*!< reconstruct the entire frame starting from the received pieces */ 87 89 88 90 #ifdef WIN32 … … 104 106 static FrameTypeMap frameTypes[MAX_FRAMES]; 105 107 106 NMEA0183 nmea0183_; 107 QSemaphore semaphore_; 108 NMEA0183 nmea0183_; 109 QSemaphore semaphore_; 108 110 109 FRAME* currentFrame_; 111 FRAME* currentFrame_; 110 112 111 FRAME frameToDecode_; 113 FRAME frameToDecode_; 112 114 113 115 road_time_t lastPpsTime_; 114 116 115 bool newFrameToDecode_; 116 bool startOfFrame_; 117 bool endOfFrame_; 117 bool newFrameToDecode_; 118 bool startOfFrame_; 119 bool endOfFrame_; 118 120 int nextByteToProcess_; 119 121 120 122 121 123 unsigned int ppsIndex_; 122 124 123 125 DbiteFile ppshdFile; /*!< pointer to the pps dbt file */ 124 126 DbiteFile ggahdFile; /*!< pointer to the gga dbt file */ … … 139 141 bool ggaRecording; 140 142 bool gsaRecording; 141 bool gstRecording; 143 bool gstRecording; 142 144 bool gsvRecording; 143 145 bool hdtRecording; 144 bool rmcRecording; 145 bool rotRecording; 146 bool vtgRecording; 147 bool zdaRecording; 148 149 QString portName_; 146 bool rmcRecording; 147 bool rotRecording; 148 bool vtgRecording; 149 bool zdaRecording; 150 151 QString portName_; 150 152 151 153 ShMem * shMem_; 152 154 153 155 /// For the socket server 154 156 /* Qt3 version - 17/12/2007 155 BOOL socketServerEnabled; 156 void *frameToSend; 157 BOOL socketServerEnabled; 158 void *frameToSend; 157 159 QCustomEvent *evt; 158 160 */ 159 160 /* 161 * VC6 doesn't support out-of-class template defintions 162 * see on http://support.microsoft.com kb q243451 and more particulary 241949 161 162 /* 163 * VC6 doesn't support out-of-class template defintions 164 * see on http://support.microsoft.com kb q243451 and more particulary 241949 163 165 */ 164 166 template<typename T> … … 168 170 if (socketServerEnabled) 169 171 { 170 frameToSend = new T; 171 *(T*)frameToSend = frame; 172 evt = new QCustomEvent(QEvent::User + type); 173 evt->setData(frameToSend); 174 postEvent(serverSocket,evt); 172 frameToSend = new T; 173 *(T*)frameToSend = frame; 174 evt = new QCustomEvent(QEvent::User + type); 175 evt->setData(frameToSend); 176 postEvent(serverSocket,evt); 175 177 } 176 178 */ -
trunk/Gps/ui/polarxmainwindow.cpp
r59 r99 362 362 } 363 363 } 364 364 /* 365 365 void PolarxMainWindow::setReceiverStatus( SbfDataReceiverStatus * msg ) 366 366 { … … 479 479 } 480 480 } 481 */ -
trunk/Gps/ui/polarxmainwindow.hpp
r59 r99 2 2 #define __POLARXMAINWINDOW__ 3 3 4 #include <QtGui> 4 //#include <QtGui> 5 #include <QtWidgets> 5 6 #include <bitset> 6 #include " structure/structure_septentrio.h"7 #include "../structure_gps.h" 7 8 #include "../SeptentrioSocket.h" 8 9 #include "PacpusTools/BinaryDecoder.h" … … 17 18 18 19 void setData( unsigned char * data , int buf_size ) ; 19 void setReceiverStatus( SbfDataReceiverStatus * msg ) ;20 /*void setReceiverStatus( SbfDataReceiverStatus * msg ) ; 20 21 void setTrackingStatus( SbfDataTrackingStatus * msg ) ; 21 void setPVTGeodetic( SbfDataPVTGeodetic * msg ) ; 22 void setPVTGeodetic( SbfDataPVTGeodetic * msg ) ;*/ 22 23 void setSocket( SeptentrioSocket * socket ) ; 23 24
Note:
See TracChangeset
for help on using the changeset viewer.