Changeset 99 in pacpussensors for trunk/Gps


Ignore:
Timestamp:
Oct 15, 2015, 2:47:01 PM (9 years ago)
Author:
nguyenhu
Message:

compilation under linux with 0.2.X framework

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################################################################################
    17project(Gps)
     8set(${PROJECT_NAME}_VERSION_MAJOR 0)
     9set(${PROJECT_NAME}_VERSION_MINOR 1)
     10add_definitions( -DGPS_EXPORTS )
    211################################################################################
     12create_export(EXPORT_HDR ${PROJECT_NAME})
     13pacpus_plugin(PLUGIN_CPP PLUGIN_HDR ${PROJECT_NAME})
     14add_definitions (${QT_DEFINITIONS})
    315
    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}
     16find_package(Qt5Network REQUIRED)
     17find_package(Qt5Widgets REQUIRED)
     18################################################################################
     19# DIRECTORIES
     20include_directories(
     21    ${PROJECT_BINARY_DIR}
     22    ${QT_INCLUDE_DIR}
     23    ${PACPUS_INCLUDE_DIR}
     24    ${PACPUS_INCLUDE_DIR}/Pacpus/
    3025)
    3126
     
    3833
    3934
    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
     37set(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)
     46set(PROJECT_SRCS
    5947    ${PLUGIN_CPP}
     48    gpsComponent.cpp
     49    SeptentrioSocket.cpp
     50    ui/polarxmainwindow.cpp
    6051)
    6152
     
    7667endif(UNIX)
    7768
    78 
    79 # ========================================
    80 # Files to MOC
    81 # ========================================
    82 
    8369if(UNIX)
    8470set(FILES_TO_MOC
    8571  # add here the header files that you want to MOC
    8672  gpsComponent.h
    87   SeptentrioComponent.h
     73  GpsFrames.h
     74  #SeptentrioComponent.h
    8875  SeptentrioSocket.h 
    8976  ../driver/PosixSerialPort.h
    9077  ui/polarxmainwindow.hpp
    91     ${PLUGIN_H}
     78  ${PLUGIN_HDR}
    9279  )
    9380endif(UNIX)
     
    9784  # add here the header files that you want to MOC
    9885  gpsComponent.h
    99 # SeptentrioComponent.h
    100 # SeptentrioSocket.h   
     86  # SeptentrioComponent.h
     87  # SeptentrioSocket.h   
    10188  ../driver/Win32SerialPort.h
    102 #  ui/polarxmainwindow.hpp
    103   ${PLUGIN_H}
     89  #  ui/polarxmainwindow.hpp
     90  ${PLUGIN_HDR}
    10491  )
    10592endif(WIN32)
    10693
    107 set(
    108     UI_FILES
     94set(UI_FILES
    10995)
    11096
    111 # ========================================
    112 # Call MOC
    113 # ========================================
    114 qt4_wrap_cpp(
    115     PROJECT_MOC_SRCS
     97################################################################################
     98# Qt: call moc, uic
     99qt_wrap_cpp(PROJECT_MOC_SRCS
    116100    ${FILES_TO_MOC}
    117101)
    118102
    119 qt4_wrap_ui(
    120     PROJECT_UI_SRCS
     103qt_wrap_ui(PROJECT_UI_SRCS
    121104    ${UI_FILES}
    122105)
    123106
    124 # ========================================
    125 # Build a library
    126 # ========================================
    127 pacpus_add_library(
    128     ${PROJECT_NAME} SHARED
     107################################################################################
     108# BUILD and LINK
     109pacpus_add_library(${PROJECT_NAME} SHARED
     110    ${PROJECT_HDRS}
    129111    ${PROJECT_SRCS}
    130112    ${PROJECT_MOC_SRCS}
     
    132114)
    133115
     116
    134117# ========================================
    135118# Libraries
    136119# ========================================
    137 if(WIN32)
    138     set(LIBS
    139         # add your specific libraries to link here
    140         optimized NMEA0183LIB debug NMEA0183LIB_d
     120set(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)
     126if (WIN32)
     127    list(APPEND LIBS
     128        optimized ROAD_TIME debug ROAD_TIME_d
    141129    )
    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 )
     130endif()
     131# LINK
     132target_link_libraries(${PROJECT_NAME}
     133                      ${PACPUS_LIBRARIES}
     134                      ${PACPUS_DEPENDENCIES_LIB}
     135                      ${LIBS}
     136                      ${QT_LIBRARIES} 
     137                     )
     138qt5_use_modules(${PROJECT_NAME} Network)
     139################################################################################
     140# FOLDERS
    160141pacpus_folder(${PROJECT_NAME} "components")
    161 
    162 # ========================================
    163 # Install
    164 # ========================================
    165 pacpus_install(${PROJECT_NAME})
     142################################################################################
     143# INSTALL
     144pacpus_install(${PROJECT_NAME})
  • trunk/Gps/SeptentrioComponent.h

    r59 r99  
    1515// #include "polarxGPSTKsolver.hpp"
    1616
    17 #include "structure/structure_septentrio.h"
     17#include "structure_gps.h"
    1818#include "SerialCom/SerialCOM_Handle_Stream.hpp"
    1919#include "SerialCom/SBF/SerialCOM_Protocol_SBF.hpp"
  • trunk/Gps/SeptentrioSocket.cpp

    r59 r99  
    1515
    1616#include "SeptentrioSocket.h"
    17 #include "SeptentrioComponent.h"
     17//#include "SeptentrioComponent.h"
    1818#include <QApplication>
    1919#include <QtDebug>
  • trunk/Gps/gpsComponent.cpp

    r77 r99  
    1818#include <iostream>
    1919
     20#define PACPUS_PI 3.1415926
     21
    2022namespace pacpus {
    2123
    2224/// Construct the factory
    23 ComponentFactory<GpsComponent> sFactory("GpsComponent"); 
     25ComponentFactory<GpsComponent> sFactory("GpsComponent");
    2426
    2527DECLARE_STATIC_LOGGER("pacpus.base.GpsComponent");
     
    3537    : semaphore_(0)
    3638    , 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;
    6163*/
    62  
    63  
     64
     65
    6466  nextByteToProcess_ = 0;
    6567  currentFrame_ = NULL;
    66   newFrameToDecode_ = false; 
    67   startOfFrame_ = false; 
     68  newFrameToDecode_ = false;
     69  startOfFrame_ = false;
    6870  endOfFrame_ = false;
    6971}
     
    8183ComponentBase::COMPONENT_CONFIGURATION GpsComponent::configureComponent(XmlComponentConfig config)
    8284{
    83   setPortCOM( config.getProperty("port").toLatin1() );   
     85  setPortCOM( config.getProperty("port").toLatin1() );
    8486  setRecording ((config.getProperty("recording") == "true" ? true : false));
    8587
     
    9092void GpsComponent::setPortCOM(const char * port)
    9193{
    92   portName_ = port; 
     94  portName_ = port;
    9395}
    9496
     
    111113void GpsComponent::run()
    112114{
    113   int type = -1; 
    114  
     115  int type = -1;
     116
    115117  // parity:0-4=no,odd,even,mark,space
    116118  // 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(),
    121123    xmlParameters().getProperty("bytesize").toUInt(),
    122124    //  config.getProperty("parity").at(0).toLatin1(),
    123125    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
    129131  while (isActive())
    130   { 
     132  {
    131133    // If there are no bytes remaining in the current frame, delete it
    132134    if ((currentFrame_ != NULL) && (nextByteToProcess_ >= currentFrame_->data.length())) {
    133       delete currentFrame_; 
     135      delete currentFrame_;
    134136      currentFrame_ = NULL;
    135137    }
     
    139141      semaphore_.acquire();
    140142      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
    142144        // the thread is being stopped.
    143145        continue;
     
    151153      lastPpsTime_ = currentFrame_->t;
    152154      decodeFrame(SIGNAL_PPS);
    153     } else if (analyzeFrame()) { 
     155    } else if (analyzeFrame()) {
    154156      // a new complete NMEA frame has arrived, decode it.
    155       type = frameType(frameToDecode_.data); 
     157      type = frameType(frameToDecode_.data);
    156158      if (type != -1) {
    157159        if (decodeFrame(type) == -1) {
    158             qWarning("Failed to decode the dataframe\n"); 
     160            qWarning("Failed to decode the dataframe\n");
    159161        }
    160162      }
     
    164166  }
    165167
    166   qDebug() << "The thread of " << name() << " GPS component is stopped"; 
     168  qDebug() << "The thread of " << name() << " GPS component is stopped";
    167169}
    168170
     
    174176void GpsComponent::stopActivity()
    175177{
    176   setActive( FALSE );
     178  setActive( false );
    177179  unlockProcessing(1); // to unblock the thread that is waiting new data
    178  
    179   serialPort->THREAD_ALIVE = FALSE;
     180
     181  serialPort->THREAD_ALIVE = false;
    180182
    181183  if (!serialPort->wait(2000))
    182184  {
    183     serialPort->terminate(); 
     185    serialPort->terminate();
    184186    qDebug("The Win32SerialPort thread blocks anormally, it has been killed !!");
    185187  }
    186   if ( !serialPort->closePort() ) 
    187     qDebug("Failed to close the port"); 
     188  if ( !serialPort->closePort() )
     189    qDebug("Failed to close the port");
    188190  else
    189     qDebug("The port is closed"); 
     191    qDebug("The port is closed");
    190192  delete serialPort;
    191193
    192194  if (ppshdFile.isOpen())
    193           ppshdFile.close(); 
     195          ppshdFile.close();
    194196  if (ggahdFile.isOpen())
    195197          ggahdFile.close();
    196198  if (gsahdFile.isOpen())
    197     gsahdFile.close(); 
     199    gsahdFile.close();
    198200  if (gsthdFile.isOpen())
    199201    gsthdFile.close();
     
    203205    hdthdFile.close();
    204206  if (rmchdFile.isOpen())
    205           rmchdFile.close(); 
     207          rmchdFile.close();
    206208  if (rothdFile.isOpen())
    207209          rothdFile.close();
    208210  if (vtghdFile.isOpen())
    209           vtghdFile.close(); 
     211          vtghdFile.close();
    210212  if (zdahdFile.isOpen())
    211213          zdahdFile.close();
     
    219221{
    220222  ppsIndex_ = 0;
    221  
    222   setActive( TRUE );   
    223  
     223
     224  setActive( true );
     225
    224226#if WIN32
    225   serialPort = new Win32SerialPort(portName_.toLatin1()); 
     227  serialPort = new Win32SerialPort(portName_.toLatin1());
    226228  // Asynchrone
    227   serialPort->setMode(FILE_FLAG_OVERLAPPED); 
     229  serialPort->setMode(FILE_FLAG_OVERLAPPED);
    228230  // 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());
    232234#endif
    233  
     235
    234236  if (!serialPort->openPort(portName_.toLatin1()))
    235237  {
    236238    qDebug() << "Failed to open the port " << portName_;
    237239    qDebug() << "The GPS Component " << name() << " didn't start";
    238     return; 
     240    return;
    239241  }
    240  
    241   serialPort->THREAD_ALIVE = TRUE;
     242
     243  serialPort->THREAD_ALIVE = true;
    242244  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();
    245247  qDebug() << "The Component " << name() << " is started";
    246248}
     
    299301
    300302    // first looking for start-of-frame
    301     if (!startOfFrame_ && (currentChar == '$')) { 
     303    if (!startOfFrame_ && (currentChar == '$')) {
    302304      startOfFrame_ = true;
    303305      endOfFrame_ = false;
     
    313315      return true;  // There is a new frame to decode
    314316    }
    315    
     317
    316318    if ((startOfFrame_) && (!endOfFrame_)) {
    317       frameToDecode_.data.append(currentChar); 
     319      frameToDecode_.data.append(currentChar);
    318320    }
    319321  }
     
    325327{
    326328  // new frame available
    327   semaphore_.release( v ); 
     329  semaphore_.release( v );
    328330}
    329331
     
    331333int GpsComponent::decodeFrame(int type)
    332334{
    333   double lat_rad = 0, lon_rad = 0; 
    334   int indexGSV = 0; 
     335  double lat_rad = 0, lon_rad = 0;
     336  int indexGSV = 0;
    335337  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)
    342344  {
    343   case UNKNOWN_NMEA_FRAME: 
    344     qDebug("Unknown frame received !"); 
    345     break; 
     345  case UNKNOWN_NMEA_FRAME:
     346    qDebug("Unknown frame received !");
     347    break;
    346348  case SIGNAL_PPS:
    347349    ppsFrame.setRoadTime(lastPpsTime_);
     
    351353    {
    352354                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));
    354356    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");
    356358    }
    357359    ppsFrame.notifyObservers();
    358360
    359361    break;
    360    
    361   case TRAME_GGA_DBL:   
     362
     363  case TRAME_GGA_DBL:
    362364    if (!nmea0183_.Gga.Parse(sentence)) {
    363365      LOG_ERROR("Failed to parse the frame " << nmea0183_.Gga.ErrorMessage.toLatin1().data());
     
    377379      ggaFrame.getFrameData()->d_geoidal = nmea0183_.Gga.GeoidalSeparationMeters;
    378380      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;
    382384      ggaFrame.setRoadTime(frameToDecode_.t);
    383      
    384       sendDataToServerSocket(*ggaFrame.getFrameData(),type); 
     385
     386      sendDataToServerSocket(*ggaFrame.getFrameData(),type);
    385387      ggaFrame.notifyObservers();
    386388
    387389      if ( (isRecording()) && (ggaRecording) ) {
    388390                    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");
    392394      }
    393395      //printf("lon=%f lat=%f\n",ggaFrame.getFrameData()->lon, ggaFrame.getFrameData()->lat);
    394396    }
    395397    break;
    396    
     398
    397399  case TRAME_GSA:
    398400    if (!nmea0183_.Gsa.Parse(sentence))
     
    401403    gsaFrame.getFrameData()->mode_result = 0;
    402404    if (nmea0183_.Gsa.FixMode == GSA::FixUnavailable)
    403       gsaFrame.getFrameData()->mode_result = 1; 
     405      gsaFrame.getFrameData()->mode_result = 1;
    404406    if (nmea0183_.Gsa.FixMode == GSA::TwoDimensional)
    405       gsaFrame.getFrameData()->mode_result = 2; 
     407      gsaFrame.getFrameData()->mode_result = 2;
    406408    if (nmea0183_.Gsa.FixMode == GSA::ThreeDimensional)
    407       gsaFrame.getFrameData()->mode_result = 3; 
     409      gsaFrame.getFrameData()->mode_result = 3;
    408410    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;
    413415    gsaFrame.setRoadTime(frameToDecode_.t);
    414416
    415417    gsaFrame.notifyObservers();
    416    
    417     sendDataToServerSocket(*gsaFrame.getFrameData(),type); 
    418    
     418
     419    sendDataToServerSocket(*gsaFrame.getFrameData(),type);
     420
    419421    if ( (isRecording()) && (gsaRecording) )
    420422    {
    421423                if (!(gsahdFile.isOpen()))
    422424                  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");
    425427    }
    426428    break;
    427429
    428430
    429    
     431
    430432  case TRAME_GST:
    431433    if (!nmea0183_.Gst.Parse( sentence ))
     
    443445    gstFrame.getFrameData()->Ms = nmea0183_.Gst.Time.time().msec();
    444446    gstFrame.setRoadTime(frameToDecode_.t);
    445    
    446     sendDataToServerSocket(*gstFrame.getFrameData(),type); 
     447
     448    sendDataToServerSocket(*gstFrame.getFrameData(),type);
    447449    gstFrame.notifyObservers();
    448450
    449451
    450452    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));
    453455      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
    458460  case TRAME_GSV:
    459461    indexGSV = 0;
     
    462464      break;
    463465    }
    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
    465467    // in view has decreased
    466468    if (nmea0183_.Gsv.message_number == 1)
     
    477479    gsvFrame.getFrameData()->NumberOfSatellites = nmea0183_.Gsv.NumberOfSatellites;
    478480    gsvFrame.getFrameData()->Totalmessages = nmea0183_.Gsv.Totalmessages;
    479    
     481
    480482    for  ( indexGSV=4*(nmea0183_.Gsv.message_number-1); indexGSV<=(4*nmea0183_.Gsv.message_number)-1; indexGSV++ )
    481483    {
     
    487489
    488490    if (nmea0183_.Gsv.Totalmessages == nmea0183_.Gsv.message_number) {
    489       sendDataToServerSocket(*gsvFrame.getFrameData(),type); 
     491      sendDataToServerSocket(*gsvFrame.getFrameData(),type);
    490492      gsvFrame.setRoadTime(frameToDecode_.t);
    491493      gsvFrame.notifyObservers();
     
    493495    if ( (isRecording()) && (gsvRecording) && (nmea0183_.Gsv.Totalmessages == nmea0183_.Gsv.message_number) )
    494496    {
    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));
    497499                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
    502504    case TRAME_HDT:
    503505      if (!nmea0183_.Hdt.Parse( sentence ))
     
    505507      hdtFrame.getFrameData()->DegreesTrue = nmea0183_.Hdt.DegreesTrue;
    506508      hdtFrame.setRoadTime(frameToDecode_.t);
    507      
    508       sendDataToServerSocket(hdtFrame,type); 
     509
     510      sendDataToServerSocket(hdtFrame,type);
    509511      hdtFrame.notifyObservers();
    510      
     512
    511513      if ( (isRecording()) && (hdtRecording) )
    512514      {
    513515                  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));
    515517      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
    520522    case TRAME_RMC:
    521523      if (!nmea0183_.Rmc.Parse( sentence ))
     
    545547      rmcFrame.getFrameData()->vitesse = nmea0183_.Rmc.SpeedOverGroundKnots * 1852.0 / 3600.0; // 1 knot = 1852 m/h
    546548      rmcFrame.setRoadTime(frameToDecode_.t);
    547      
    548       sendDataToServerSocket(*rmcFrame.getFrameData(),type); 
     549
     550      sendDataToServerSocket(*rmcFrame.getFrameData(),type);
    549551      rmcFrame.notifyObservers();
    550      
     552
    551553      if ( (isRecording()) && (rmcRecording) )
    552554      {
    553555        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));
    555557        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");
    557559      }
    558560      break;
    559      
     561
    560562    case TRAME_ROT:
    561563      if (!nmea0183_.Rot.Parse( sentence ))
     
    564566      rotFrame.getFrameData()->valid_data = ( (nmea0183_.Rot.IsDataValid == True) ? 1 : 0 );
    565567      rotFrame.setRoadTime(frameToDecode_.t);
    566      
    567       sendDataToServerSocket(*rotFrame.getFrameData(),type); 
     568
     569      sendDataToServerSocket(*rotFrame.getFrameData(),type);
    568570      rotFrame.notifyObservers();
    569      
     571
    570572      if ( (isRecording()) && (rotRecording) )
    571573      {
    572574        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));
    574576        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
    579581    case TRAME_VTG:
    580582      if (!nmea0183_.Vtg.Parse( sentence )) {
     
    582584      } else {
    583585        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;
    586588        vtgFrame.setRoadTime(frameToDecode_.t);
    587      
     589
    588590        sendDataToServerSocket(vtgFrame,type);
    589591        vtgFrame.notifyObservers();
    590      
     592
    591593        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));
    594596                      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");
    596598        }
    597599      }
    598       break; 
    599      
     600      break;
     601
    600602    case TRAME_ZDA:
    601603      if (!nmea0183_.Zda.Parse( sentence )) {
     
    609611      zdaFrame.getFrameData()->MM = nmea0183_.Zda.Time.date().month();
    610612      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
    614616      sendDataToServerSocket(*zdaFrame.getFrameData(), type);
    615617      zdaFrame.setRoadTime(frameToDecode_.t);
    616618      zdaFrame.notifyObservers();
    617      
     619
    618620      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));
    621623      if ( zdahdFile.writeRecord(frameToDecode_.t, frameToDecode_.tr,(char *) zdaFrame.getFrameData(),sizeof(trame_zda)) == 0) {
    622624            LOG_WARN("Failed to record ZDA data ...");
     
    641643      }
    642644      */
    643      
    644       break; 
    645      
     645
     646      break;
     647
    646648    default:
    647       return 0; 
     649      return 0;
    648650  }
    649  
    650   return 1; 
     651
     652  return 1;
    651653}
    652654
  • trunk/Gps/gpsComponent.h

    r59 r99  
    2121#include <QSemaphore>
    2222#include <QThread>
     23#include <QByteArray>
     24#include <QString>
    2325
    2426#ifdef WIN32
    2527#   include "../driver/win32SerialPort.h"
    2628//#   include "network/gpsServerSocket.h"
    27 #else 
     29#else
    2830#   include "../driver/PosixSerialPort.h"
    2931#endif
     
    4143#   endif
    4244#else
    43     // On other platforms, simply ignore this 
     45    // On other platforms, simply ignore this
    4446#   define GPS_API /* nothing */
    4547#endif
     
    5860{
    5961  Q_OBJECT
    60    
     62
    6163public:
    62   GpsComponent(QString name); 
    63   ~GpsComponent(); 
    64  
     64  GpsComponent(QString name);
     65  ~GpsComponent();
     66
    6567  virtual void stopActivity(); /*!< to stop the processing thread */
    6668  virtual void startActivity(); /*!< to start the processing thread */
    67   virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config); 
     69  virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
    6870
    6971
     
    7173  void disableSocketServer(); /*!< to disable the socket server interface */
    7274
    73   void setPortCOM(const char * port); 
     75  void setPortCOM(const char * port);
    7476
    7577
    76  
    77 public slots: 
     78
     79public slots:
    7880  void unlockProcessing(int v); /*!< to unlock the processing thread */
    7981
    8082protected:
    8183private:
    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 */
    8587  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 */
    8789
    8890#ifdef WIN32
     
    104106  static FrameTypeMap frameTypes[MAX_FRAMES];
    105107
    106   NMEA0183 nmea0183_; 
    107   QSemaphore semaphore_; 
     108  NMEA0183 nmea0183_;
     109  QSemaphore semaphore_;
    108110
    109   FRAME* currentFrame_; 
     111  FRAME* currentFrame_;
    110112
    111   FRAME frameToDecode_; 
     113  FRAME frameToDecode_;
    112114
    113115  road_time_t lastPpsTime_;
    114116
    115   bool newFrameToDecode_; 
    116   bool startOfFrame_; 
    117   bool endOfFrame_; 
     117  bool newFrameToDecode_;
     118  bool startOfFrame_;
     119  bool endOfFrame_;
    118120  int nextByteToProcess_;
    119121
    120122
    121123  unsigned int ppsIndex_;
    122  
     124
    123125  DbiteFile ppshdFile; /*!< pointer to the pps dbt file */
    124126  DbiteFile ggahdFile; /*!< pointer to the gga dbt file */
     
    139141  bool ggaRecording;
    140142  bool gsaRecording;
    141   bool gstRecording; 
     143  bool gstRecording;
    142144  bool gsvRecording;
    143145  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_;
    150152
    151153  ShMem * shMem_;
    152  
     154
    153155  /// For the socket server
    154156  /* Qt3 version - 17/12/2007
    155   BOOL socketServerEnabled; 
    156   void *frameToSend; 
     157  BOOL socketServerEnabled;
     158  void *frameToSend;
    157159  QCustomEvent *evt;
    158160  */
    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
    163165  */
    164166  template<typename T>
     
    168170    if (socketServerEnabled)
    169171    {
    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);
    175177    }
    176178    */
  • trunk/Gps/ui/polarxmainwindow.cpp

    r59 r99  
    362362    }
    363363}
    364 
     364/*
    365365void PolarxMainWindow::setReceiverStatus( SbfDataReceiverStatus * msg )
    366366{
     
    479479    }
    480480}
     481*/
  • trunk/Gps/ui/polarxmainwindow.hpp

    r59 r99  
    22#define __POLARXMAINWINDOW__
    33
    4 #include <QtGui>
     4//#include <QtGui>
     5#include <QtWidgets>
    56#include <bitset>
    6 #include "structure/structure_septentrio.h"
     7#include "../structure_gps.h"
    78#include "../SeptentrioSocket.h"
    89#include "PacpusTools/BinaryDecoder.h"
     
    1718
    1819      void setData( unsigned char * data , int buf_size ) ;
    19       void setReceiverStatus( SbfDataReceiverStatus * msg ) ;
     20      /*void setReceiverStatus( SbfDataReceiverStatus * msg ) ;
    2021      void setTrackingStatus( SbfDataTrackingStatus * msg ) ;
    21       void setPVTGeodetic( SbfDataPVTGeodetic * msg ) ;
     22      void setPVTGeodetic( SbfDataPVTGeodetic * msg ) ;*/
    2223      void setSocket( SeptentrioSocket * socket ) ;
    2324
Note: See TracChangeset for help on using the changeset viewer.