source: pacpussensors/trunk/Gps/ui/polarxmainwindow.cpp@ 63

Last change on this file since 63 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 17.6 KB
Line 
1#include "polarxmainwindow.hpp"
2
3using namespace std ;
4
5PolarxMainWindow::PolarxMainWindow() : QWidget()
6{
7
8 this->setFixedSize(800,600);
9
10 QTabWidget *tab = new QTabWidget( this );
11 tab->resize( this->size() );
12
13 QWidget *recPage = new QWidget ;
14 initStatusBlock( recPage );
15 tab->addTab( recPage , "Receiver Status" ) ;
16
17 QWidget *sbfPage = new QWidget ;
18 initSbfBlock(sbfPage);
19 tab->addTab( sbfPage , "SBF Block" ) ;
20
21 QWidget *setupPage = new QWidget ;
22 initSetupBlock(setupPage);
23 tab->addTab( setupPage , "Setup" ) ;
24
25 show() ;
26
27 connect( upFrame , SIGNAL( clicked() ) , this , SLOT( sendNewFrame() ) );
28 connect( upSetup , SIGNAL( clicked() ) , this , SLOT( sendNewSetup() ) ) ;
29 ipID = 0 ;
30 elevMask_set = 100 ;
31}
32
33void PolarxMainWindow::setData( unsigned char * data , int buf_size )
34{
35
36 // $PolaRx:
37 if ( data[0] == '$' & data[1] == 'P' )
38 {
39 QString cmd ;
40 for ( int i = 0 ; i < buf_size ; i++ )
41 cmd.append( data[i] );
42 commandManager(cmd.split( "#EoL" ));
43 }
44
45}
46
47void PolarxMainWindow::pvtError( QString err )
48{
49 PVT_lat->setText( err );
50 PVT_lon->setText( QString::null );
51 PVT_elv->setText( QString::null );
52}
53
54void PolarxMainWindow::setSocket( SeptentrioSocket * socket )
55{
56 socketIf_ = socket ;
57 socketIf_->sendToServer("GetSBFOutput curr" ) ;
58 socketIf_->sendToServer("GetPVTInterval" ) ;
59 socketIf_->sendToServer("GetPVTMode" ) ;
60 socketIf_->sendToServer("GetElevationMask" ) ;
61 socketIf_->sendToServer("GetMeasInterval" );
62 socketIf_->sendToServer("GetTrackingMode" );
63}
64
65void PolarxMainWindow::getAvailableFrame( QString cmd )
66{
67 // $PolaRx: SetSBFOutput IP10, PVTgeo #EoL
68 cmd.remove( 0 , 27 ) ;
69 avFrame = cmd.simplified().split("+");
70
71 for ( QMap< QString , QCheckBox* >::iterator I = sbfBlock_disp.begin() ; I != sbfBlock_disp.end() ; I++ )
72 {
73 if ( avFrame.contains( I.key() ) ) I.value()->setChecked( true ) ;
74 else I.value()->setChecked( false );
75 }
76
77 if ( !avFrame.contains("Status") | !avFrame.contains("PVTgeo") )
78 {
79 avFrame << "Status" << "PVTgeo" ;
80 requestFrame();
81 }
82
83}
84
85void PolarxMainWindow::requestFrame()
86{
87 QString cmd = QString("SetSBFOutput IP%1 %2").arg(ipID).arg(avFrame.join("+") ) ;
88 socketIf_->sendToServer( cmd );
89}
90
91void PolarxMainWindow::initSbfBlock(QWidget * parent)
92{
93 QMap<QString,QStringList> bname ;
94
95 bname["Raw Data"] << "Meas" << "ShortMeas" << "GenMeas" << "Nav" << "Alm" << "IonUtc" << "MeoRaw"<< "Rinex" ;
96 bname["PVT"] << "PVTcar" << "PVTgeo" << "CovCar" << "CovGeo" << "DOP" << "PVTRes" << "RAIM" ;
97 bname["SBAS"] << "GEOcorr" << "GEOInfo" ;
98 bname["Attitude"] << "AttEuler" << "CovEuler" << "AttQuat" << "CovQuat" << "AuxPos" ;
99 bname["Monitoring"] << "PPS" << "Commands" << "Off" << "RxInfo" << "Status" << "EndOfEpoch" << "DiffCorr" << "BaseInfo" << "BaseLine" << "ExtEvent" ;
100
101 QVBoxLayout * layout_ = new QVBoxLayout ;
102 for ( QMap<QString,QStringList>::iterator Il = bname.begin() ; Il != bname.end() ; Il++ )
103 {
104 QGroupBox * box = new QGroupBox( Il.key() , parent );
105 QGridLayout * layout = new QGridLayout ;
106 box->setLayout( layout );
107 int l = 0 ;
108 int c = 0 ;
109 for ( QStringList::iterator Iv = Il.value().begin() ; Iv != Il.value().end() ; Iv++ )
110 {
111 sbfBlock_disp[*Iv] = new QCheckBox(*Iv,box);
112 layout->addWidget(sbfBlock_disp[*Iv],l,c);
113 if (c++ == 4 )
114 {
115 c = 0 ;
116 l++ ;
117 } ;
118 }
119 layout_->addWidget( box );
120 }
121
122 upFrame = new QPushButton("Send",parent);
123 layout_->addWidget( upFrame );
124 parent->setLayout( layout_ );
125
126}
127
128void PolarxMainWindow::sendNewFrame()
129{
130 avFrame.clear() ;
131 for ( QMap< QString , QCheckBox* >::iterator I = sbfBlock_disp.begin() ; I != sbfBlock_disp.end() ; I++ )
132 if ( I.value()->isChecked() )
133 avFrame << I.key() ;
134 requestFrame() ;
135}
136
137void PolarxMainWindow::initStatusBlock( QWidget * parent )
138{
139 //! Receiver status page
140 TOW = new QLabel( parent );
141 WNC = new QLabel( parent );
142 RXLOAD = new QLabel( parent );
143 UPTIME = new QLabel( parent );
144 CHAN_USED = new QLabel( parent );
145 TRACKINGSTATUS = new QStandardItemModel( 1 , 1 );
146 PVT_lat = new QLabel( parent );
147 PVT_lon = new QLabel( parent );
148 PVT_elv = new QLabel( parent );
149 SYSTEM = new QLabel( parent );
150 SYSTEM2 = new QLabel( parent );
151 SYSTEM3 = new QLabel( parent );
152 MODE = new QLabel( parent );
153 PVT_USED = new QLabel( parent );
154
155 QVBoxLayout * rmain_layout = new QVBoxLayout ;
156 QGroupBox * gpstime = new QGroupBox( "GPS Time" , parent );
157 QGroupBox * tracking = new QGroupBox( "Tracking" , parent );
158 QGroupBox * status = new QGroupBox( "Status" , parent );
159 rmain_layout->addWidget( gpstime );
160 rmain_layout->addWidget( status );
161 rmain_layout->addWidget( tracking );
162
163 QGridLayout * ssub_layout = new QGridLayout ;
164 ssub_layout->addWidget( new QLabel("Mode : ") ,0,0 );
165 ssub_layout->addWidget( MODE ,0,1 );
166 ssub_layout->addWidget( CHAN_USED ,0,2 );
167 ssub_layout->addWidget( PVT_USED ,0,3 );
168 ssub_layout->addWidget( new QLabel("System : ") ,2,0 );
169 ssub_layout->addWidget( SYSTEM ,2,1 );
170 ssub_layout->addWidget( SYSTEM2 ,2,2 );
171 ssub_layout->addWidget( SYSTEM3 ,2,3 );
172 ssub_layout->addWidget( new QLabel("PVT : ") ,3,0 );
173 ssub_layout->addWidget( PVT_lat ,3,1 );
174 ssub_layout->addWidget( PVT_lon ,3,2 );
175 ssub_layout->addWidget( PVT_elv ,3,3 );
176 status->setLayout( ssub_layout );
177
178
179 QHBoxLayout * gp_layout = new QHBoxLayout;
180 gp_layout->addWidget(WNC);
181 gp_layout->addWidget(TOW);
182 gp_layout->addWidget( UPTIME );
183 gp_layout->addWidget( RXLOAD );
184 gpstime->setLayout( gp_layout ) ;
185
186 QTableView * trackingView = new QTableView ;
187
188 trackingView->setModel( TRACKINGSTATUS );
189 QHBoxLayout * t_layout = new QHBoxLayout ;
190 tracking->setLayout( t_layout );
191 t_layout->addWidget( trackingView );
192
193 parent->setLayout(rmain_layout);
194}
195
196void PolarxMainWindow::initSetupBlock( QWidget * parent )
197{
198 QVBoxLayout * layout = new QVBoxLayout() ;
199 QGridLayout * blayout = new QGridLayout();
200 upSetup = new QPushButton("Send",parent);
201 layout->addLayout(blayout);
202 layout->addWidget(upSetup);
203 parent->setLayout(layout);
204
205 QGroupBox * pvt_ = new QGroupBox("PVT",parent);
206 blayout->addWidget( pvt_ , 0 , 0 );
207 QGroupBox * tracking_ = new QGroupBox("Tracking",parent);
208 blayout->addWidget( tracking_ , 1 , 0 );
209 QGroupBox * meas_ = new QGroupBox("Measurements",parent);
210 blayout->addWidget( meas_ , 0,1,2,1);
211
212 // PVT
213 QGridLayout * pvtLayout = new QGridLayout ;
214 pvt_->setLayout( pvtLayout );
215 pvtLayout->addWidget( new QLabel("Mode :") , 0 , 0 );
216 pvtLayout->addWidget( new QLabel("PVT Frequency :") , 3 , 0 );
217 pvtLayout->addWidget( new QLabel("ClockSync Thres. :") , 4 , 0 );
218 pvtLayout->addWidget( new QLabel("PPS Rate :") , 5 , 0 );
219
220 QStringList temp_ = QStringList() << "standalone" << "SBAS" << "DGPS" << "RTKfloat" << "RTK" ;
221 int n = 0 ;
222 for ( QStringList::iterator I = temp_.begin() ; I !=temp_.end() ; I++ )
223 {
224 pvtMode[*I] = new QCheckBox( *I , parent );
225 pvtLayout->addWidget( pvtMode[*I] , n++ , 1 );
226 }
227
228 pvtInterval = new QComboBox() ;
229 pvtInterval->addItems( QStringList() << "0.10" << "0.20" << "0.50" << "1.00" ) ;
230 pvtLayout->addWidget( pvtInterval , 3 , 1 ) ;
231
232 // Meas
233 QGridLayout * measLayout = new QGridLayout ;
234 meas_->setLayout( measLayout );
235 measLayout->addWidget( new QLabel("Meas. Interval :") , 0 , 0 );
236 measLayout->addWidget( new QLabel("Multipath Mitigation :") , 1 , 0 );
237 measLayout->addWidget( new QLabel("Meas. Smoothing :") , 2 , 0 );
238 measLayout->addWidget( new QLabel("Meas. Fit :") , 3 , 0 );
239
240 measInterval = new QComboBox() ;
241 measInterval->addItems( QStringList() << "0.10" << "0.20" << "0.50" << "1.00" ) ;
242 measLayout->addWidget( measInterval , 0 , 1 ) ;
243
244 // Tracking
245 QGridLayout * trkLayout = new QGridLayout ;
246 tracking_->setLayout( trkLayout );
247 trkLayout->addWidget( new QLabel("Tracking Mode :") , 0 , 0 );
248 trkLayout->addWidget( new QLabel("Channel Alloc :") , 1 , 0 );
249 trkLayout->addWidget( new QLabel("Elevation Mask :") , 2 , 0 );
250 trkLayout->addWidget( new QLabel("Tracking Sens. :") , 3 , 0 );
251
252 trkMode = new QComboBox() ;
253 trkMode->addItems( QStringList() << "dynamic" << "static" << "timing" );
254 trkLayout->addWidget( trkMode , 0 , 1 );
255
256 elevMask = new QSpinBox() ;
257 elevMask->setRange(-90,90);
258 elevMask->setSingleStep(1) ;
259 trkLayout->addWidget(elevMask,2,1);
260
261}
262
263void PolarxMainWindow::sendNewSetup()
264{
265 QStringList tosend ;
266 for ( QMap< QString , QCheckBox * >::iterator I = pvtMode.begin() ; I != pvtMode.end() ; I++ )
267 {
268 if ( I.value()->isChecked() )
269 {
270 tosend << I.key();
271 socketIf_->sendToServer( QString("SetPVTMode %1").arg(tosend.join("+")) );
272 }
273 }
274
275 if ( pvtInterval->currentText() != pvtInt_set )
276 socketIf_->sendToServer( "SetPVTInterval " + pvtInterval->currentText() );
277
278 if ( elevMask->value() != elevMask_set )
279 socketIf_->sendToServer( QString("SetElevationMask %1").arg(elevMask->value()) );
280
281 if ( measInterval->currentText() != measInt_set )
282 socketIf_->sendToServer( "SetMeasInterval " + measInterval->currentText() );
283
284 if ( trkMode->currentText() != trkMode_set )
285 socketIf_->sendToServer( "SetTRackingmode " + trkMode->currentText() );
286
287}
288
289void PolarxMainWindow::extractIpID( QString cmd )
290{
291 QString ip_ ;
292 ip_.append( cmd.at(24) );
293 ip_.append( cmd.at(25) );
294 ipID = ip_.toInt() ;
295}
296
297void PolarxMainWindow::getPvtInterval( QString cmd )
298{
299 cmd.remove(0,23);
300 int idx = pvtInterval->findText( cmd.simplified() ) ;
301 pvtInterval->setCurrentIndex( idx );
302 pvtInt_set = cmd.simplified() ;
303}
304
305void PolarxMainWindow::getPvtMode( QString cmd )
306{
307 if ( cmd.at(6) == 'x' )
308 {
309 cmd.remove(0,20);
310 cmd.truncate( cmd.indexOf( "$" ) );
311 QStringList avMod = cmd.simplified().split("+");
312 for ( QMap< QString , QCheckBox * >::iterator I = pvtMode.begin() ; I != pvtMode.end() ; I++ )
313 if ( avMod.contains( I.key() ) )
314 I.value()->setChecked( true );
315 }
316}
317
318void PolarxMainWindow::getElevationMask( QString cmd )
319{
320// $PolaRx: SetElevationMask -10 #EoL
321 QString tmp_ ;
322 for (int k = 26 ; k < cmd.size() ; k++ )
323 tmp_.append(cmd.at(k)) ;
324// tmp_.append(cmd.at(26)) ;
325// tmp_.append(cmd.at(27)) ;
326// if ( tmp_.at(1) == '-' ) tmp_.append(cmd.at(28)) ;
327 elevMask->setValue( tmp_.toInt() );
328 elevMask_set = tmp_.toInt() ;
329}
330
331void PolarxMainWindow::getMeasInterval( QString cmd )
332{
333 cmd.remove(0,24);
334 int idx = measInterval->findText( cmd.simplified() ) ;
335 measInterval->setCurrentIndex( idx );
336 measInt_set = cmd.simplified() ;
337}
338
339void PolarxMainWindow::getTrackingMode(QString cmd)
340{
341// $PolaRx: SetTRackingmode dynamic
342 cmd.remove(0,24);
343 int idx = trkMode->findText( cmd.simplified() ) ;
344 trkMode->setCurrentIndex( idx );
345 trkMode_set = cmd.simplified() ;
346}
347
348void PolarxMainWindow::commandManager( QStringList cmdList )
349{
350 for ( QStringList::iterator cmd = cmdList.begin() ; cmd != cmdList.end() ; cmd++ )
351 {
352 QString cmd_ = (*cmd).simplified() ;
353 qDebug() << cmd_ ;
354 bool toto = cmd_.contains( "SetSBFOutput") ;
355 if ( (ipID == 0) & toto ) extractIpID( cmd_ );
356 if ( cmd_.contains( QString("SetSBFOutput IP%1").arg(ipID) ) ) getAvailableFrame( cmd_ ) ;
357 if ( cmd_.contains( "SetPVTInterval" )) getPvtInterval( cmd_ ) ;
358 if ( cmd_.contains( "SetPVTMode" ) ) getPvtMode( cmd_ );
359 if ( cmd_.contains( "SetElevationMask" ) ) getElevationMask( cmd_ );
360 if ( cmd_.contains( "SetMeasInterval" ) ) getMeasInterval( cmd_ );
361 if ( cmd_.contains( "SetTRackingmode" ) ) getTrackingMode( cmd_ );
362 }
363}
364
365void PolarxMainWindow::setReceiverStatus( SbfDataReceiverStatus * msg )
366{
367 RXLOAD->setText( QString("Load: %1%").arg( msg->CPULoad ) ) ;
368 UPTIME->setText( QString("Uptime: %1s").arg( msg->UpTime )) ;
369
370 bool CPU_OVERLOAD = ( msg->RxState >> 7 )&1 ;
371// bool CPU_OVERLOAD = ( msg->RxState&64 ) == 64 ;
372 if (CPU_OVERLOAD)
373 RXLOAD->setStyleSheet("background-color:red");
374 else
375 RXLOAD->setStyleSheet("");
376}
377
378void PolarxMainWindow::setTrackingStatus( SbfDataTrackingStatus * msg )
379{
380 CHAN_USED->setText( QString("Tracking: %1").arg(msg->N) ) ;
381 for ( int k = 0 ; k < msg->N ; k++ )
382 {
383 TRACKINGSTATUS->setItem( k , 0 , new QStandardItem( QString("%1").arg( msg->ChannelData[k].RxChannel ) ) );
384 TRACKINGSTATUS->setItem( k , 1 , new QStandardItem( QString("%1").arg( msg->ChannelData[k].SVID ) ) ) ;
385
386 unsigned char AntFlag = msg->ChannelData[k].main_tracking ;
387 if ( AntFlag == 0 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "-" ) );
388 else if ( AntFlag == 1 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "Searching" ));
389 else if ( AntFlag == 2 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "Sync." ));
390 else if ( AntFlag == 3 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "C/A" ));
391 else if ( AntFlag == 4 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "C/A+P(y)" ));
392 else if ( AntFlag == 5 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "C/A+L2C" ));
393 else if ( AntFlag == 6 ) TRACKINGSTATUS->setItem( k , 3 , new QStandardItem( "C/A+P(y)+L2C" ));
394
395 unsigned char PVTFlag = msg->ChannelData[k].PVT_usage ;
396 if ( PVTFlag == 0 ) TRACKINGSTATUS->setItem( k,5 , new QStandardItem( "Not Used" ));
397 else if ( PVTFlag == 1 ) TRACKINGSTATUS->setItem( k,5 , new QStandardItem( "Used" ));
398 else if ( PVTFlag == 2 ) TRACKINGSTATUS->setItem( k,5 , new QStandardItem( "Rejected" ));
399
400 TRACKINGSTATUS->setItem( k,2 , new QStandardItem( QString("%1 / %2").arg( (int)msg->ChannelData[k].Elevation ).arg( (int)msg->ChannelData[k].Azimuth ) )) ;
401
402 int Health = (int)msg->ChannelData[k].Health;
403 if ( Health == 0 ) TRACKINGSTATUS->setItem( k,4 , new QStandardItem( "Healty" )) ;
404 else if ( Health == 1) TRACKINGSTATUS->setItem( k,4 , new QStandardItem( "Unhealty" )) ;
405 else if ( Health == 2) TRACKINGSTATUS->setItem( k,4 , new QStandardItem( "-" )) ;
406 }
407 if ( TRACKINGSTATUS->rowCount() > msg->N )
408 TRACKINGSTATUS->removeRows( TRACKINGSTATUS->rowCount() , TRACKINGSTATUS->rowCount()-msg->N ) ;
409}
410
411void PolarxMainWindow::setPVTGeodetic( SbfDataPVTGeodetic * msg )
412{
413 TOW->setText( QString("Tow : %1s").arg(msg->TOW) );
414 WNC->setText( QString("Week : %1").arg(msg->WNc) );
415
416 PVT_USED->setText( QString("PVT: %1").arg( msg->nrSV ) );
417 if ( msg->error == 0 )
418 {
419 PVT_lat->setText( QString("%1").arg(msg->lat) );
420 PVT_lon->setText( QString("%1").arg(msg->lon) );
421 PVT_elv->setText( QString("%1").arg(msg->h ) );
422 }
423 else if ( msg->error == 1 ) pvtError( "Not Enough Meas" );
424 else if ( msg->error == 2 ) pvtError( "Not Enough Eph" );
425 else if ( msg->error == 3 ) pvtError( "DOP too large" );
426 else if ( msg->error == 4 ) pvtError( "SSR too large" );
427 else if ( msg->error == 5 ) pvtError( "No convergence" );
428 else if ( msg->error == 6 ) pvtError( "Not Enough Meas after outlier rejection" );
429 else if ( msg->error == 7 ) pvtError( "Unvalid Data" );
430 else if ( msg->error == 8 ) pvtError( "Not Enough Diff Corr" );
431 else if ( msg->error == 9 ) pvtError( "Base station coor unavailable" );
432
433 if ( msg->mode == 0 ) MODE->setText( "No PVT" );
434 else if ( msg->mode == 1 ) MODE->setText( "Standalone PVT" );
435 else if ( msg->mode == 2 ) MODE->setText( "Differential PVT" );
436 else if ( msg->mode == 3 ) MODE->setText( "Fixed Base" );
437 else if ( msg->mode == 4 ) MODE->setText( "RTK fixed" );
438 else if ( msg->mode == 5 ) MODE->setText( "RTK float" );
439 else if ( msg->mode == 9 ) MODE->setText( "RTK fixed (FKP)" );
440 else if ( msg->mode == 10 ) MODE->setText( "RTK float (FKP)" );
441 else MODE->setText( "-" );
442
443 QString sys ;
444 if ( msg->gpsUsed & !msg->glonassUsed )
445 sys += "GPS";
446 else if ( !msg->gpsUsed & msg->glonassUsed )
447 sys += "GLONASS" ;
448 else if ( msg->gpsUsed & msg->glonassUsed )
449 sys += "GPS+GLONASS" ;
450
451 if ( !msg->PVTFix3D )
452 sys += " (2D PVT)";
453 else if ( msg->L1SignalUsed & !msg->L2SignalUsed )
454 sys += " (L1)" ;
455 else if ( !msg->L1SignalUsed & msg->L2SignalUsed )
456 sys += " (L2)" ;
457 else if ( msg->L1SignalUsed & msg->L2SignalUsed )
458 sys += " (L1/L2)" ;
459 SYSTEM->setText( sys );
460
461 sys.clear() ;
462 if ( msg->sbas == 0 ) sys += "No SBAS" ;
463 else if ( msg->sbas == 1 ) sys += "EGNOS" ;
464 else if ( msg->sbas == 2 ) sys += "WAAS" ;
465 else if ( msg->sbas == 3 ) sys += "MSAS" ;
466 else if ( msg->sbas == 15 ) sys += "Other" ;
467
468 if ( msg->sbas )
469 {
470 sys += " (" ;
471 if ( msg->sbasLTC ) sys += "LTC" ;
472 if ( msg->sbasFC ) sys += "+FC" ;
473 if ( msg->sbasIono ) sys += "+Iono" ;
474 sys += ")";
475 if ( msg->sbasPA ) sys += " - PA active" ;
476 SYSTEM2->setText( sys );
477
478 SYSTEM3->setText( QString("PRN : %1").arg(msg->sbasPrn) );
479 }
480}
Note: See TracBrowser for help on using the repository browser.