Changeset 99 in pacpussensors for trunk/Gps/gpsComponent.cpp
- Timestamp:
- Oct 15, 2015, 2:47:01 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.