Ignore:
Timestamp:
Jul 28, 2016, 5:55:31 PM (9 years ago)
Author:
Sanahuja Guillaume
Message:

simu gps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/NmeaGps.cpp

    r51 r55  
    4747  nmea_zero_INFO(&info);
    4848  nmea_parser_init(&parser);
    49   alt_ref = 0;
     49  altRef = 0;
    5050
    5151  if ((NMEAFlags & GGA) == 0) {
     
    6363
    6464  // station sol
    65   main_tab = new Tab(parent->GetTabWidget(), name);
    66   tab = new TabWidget(main_tab->NewRow(), name);
    67   sensor_tab = new Tab(tab, "Reglages");
    68   GroupBox *reglages_groupbox = new GroupBox(sensor_tab->NewRow(), name);
    69   button_ref = new PushButton(reglages_groupbox->NewRow(), "set ref");
    70   nb_sat_label = new Label(reglages_groupbox->NewRow(), "nb_sat");
    71   fix_label = new Label(reglages_groupbox->LastRowLastCol(), "fix");
     65  mainTab = new Tab(parent->GetTabWidget(), name);
     66  tab = new TabWidget(mainTab->NewRow(), name);
     67  sensorTab = new Tab(tab, "Setup");
     68  setupGroupbox = new GroupBox(sensorTab->NewRow(), name);
     69  buttonRef = new PushButton(setupGroupbox->NewRow(), "set ref");
     70  nbSatLabel = new Label(setupGroupbox->NewRow(), "nb_sat");
     71  fixLabel = new Label(setupGroupbox->LastRowLastCol(), "fix");
    7272
    7373  position = new GeoCoordinate((IODevice *)this, "position", 0, 0, 0);
    7474
    75   take_ref = false;
     75  takeRef = false;
    7676
    7777  gpsData = new GpsData(this);
    7878  AddDataToLog(gpsData);
    7979
    80   nb_sat_label->SetText("nb_sat: %i", gpsData->GetNumberOfSatellites());
    81   fix_label->SetText("fix: %i", gpsData->GetFixQuality());
     80  nbSatLabel->SetText("number of satellies: %i", gpsData->GetNumberOfSatellites());
     81  fixLabel->SetText("fix quality: %i", gpsData->GetFixQuality());
     82}
     83
     84NmeaGps::NmeaGps(const IODevice *parent, std::string name) : IODevice(parent, name) {
     85  gpsData = new GpsData(this);
     86  mainTab = NULL;
     87  tab = NULL;
     88  sensorTab = NULL;
    8289}
    8390
    8491NmeaGps::~NmeaGps() {
    85   nmea_parser_destroy(&parser);
    86   delete main_tab;
    87 }
     92  if (mainTab != NULL) {
     93    nmea_parser_destroy(&parser);
     94    delete mainTab;
     95  }
     96}
     97
     98GroupBox *NmeaGps::GetGroupBox(void) const { return setupGroupbox; }
    8899
    89100const GpsData *NmeaGps::GetDatas(void) const {
     
    96107
    97108void NmeaGps::UseDefaultPlot(void) {
    98   plot_tab = new Tab(tab, "Mesures");
    99 
    100   if ((NMEAFlags & GGA) != 0) {
    101     e_plot = new DataPlot1D(plot_tab->NewRow(), "e", -10, 10);
    102     e_plot->AddCurve(gpsData->Element(GpsData::East));
    103     n_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "n", -10, 10);
    104     n_plot->AddCurve(gpsData->Element(GpsData::North));
    105     u_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "u", -10, 10);
    106     u_plot->AddCurve(gpsData->Element(GpsData::Up));
     109  plotTab = new Tab(tab, "Mesures");
     110
     111  if ((NMEAFlags & GGA) != 0) {
     112    ePlot = new DataPlot1D(plotTab->NewRow(), "e", -10, 10);
     113    ePlot->AddCurve(gpsData->Element(GpsData::East));
     114    nPlot = new DataPlot1D(plotTab->LastRowLastCol(), "n", -10, 10);
     115    nPlot->AddCurve(gpsData->Element(GpsData::North));
     116    uPlot = new DataPlot1D(plotTab->LastRowLastCol(), "u", -10, 10);
     117    uPlot->AddCurve(gpsData->Element(GpsData::Up));
    107118  }
    108119  if ((NMEAFlags & VTG) != 0) {
    109     ve_plot = new DataPlot1D(plot_tab->NewRow(), "ve", -10, 10);
    110     ve_plot->AddCurve(gpsData->Element(GpsData::EastVelocity));
    111     vn_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "vn", -10, 10);
    112     vn_plot->AddCurve(gpsData->Element(GpsData::NorthVelocity));
     120    vePlot = new DataPlot1D(plotTab->NewRow(), "ve", -10, 10);
     121    vePlot->AddCurve(gpsData->Element(GpsData::EastVelocity));
     122    vnPlot = new DataPlot1D(plotTab->LastRowLastCol(), "vn", -10, 10);
     123    vnPlot->AddCurve(gpsData->Element(GpsData::NorthVelocity));
    113124  }
    114125
     
    120131DataPlot1D *NmeaGps::EPlot(void) const {
    121132  if ((NMEAFlags & GGA) != 0) {
    122     return e_plot;
     133    return ePlot;
    123134  } else {
    124135    Err("GGA sentence not requested\n");
     
    129140DataPlot1D *NmeaGps::NPlot(void) const {
    130141  if ((NMEAFlags & GGA) != 0) {
    131     return n_plot;
     142    return nPlot;
    132143  } else {
    133144    Err("GGA sentence not requested\n");
     
    138149DataPlot1D *NmeaGps::UPlot(void) const {
    139150  if ((NMEAFlags & GGA) != 0) {
    140     return u_plot;
     151    return uPlot;
    141152  } else {
    142153    Err("GGA sentence not requested\n");
     
    147158DataPlot1D *NmeaGps::VEPlot(void) const {
    148159  if ((NMEAFlags & VTG) != 0) {
    149     return ve_plot;
     160    return vePlot;
    150161  } else {
    151162    Err("GGA sentence not requested\n");
     
    156167DataPlot1D *NmeaGps::VNPlot(void) const {
    157168  if ((NMEAFlags & VTG) != 0) {
    158     return vn_plot;
    159   } else {
    160     Err("GGA sentence not requested\n");
    161     return NULL;
    162   }
    163 }
    164 
    165 Layout *NmeaGps::GetLayout(void) const { return sensor_tab; }
    166 
    167 Tab *NmeaGps::GetPlotTab(void) const { return plot_tab; }
     169    return vnPlot;
     170  } else {
     171    Err("GGA sentence not requested\n");
     172    return NULL;
     173  }
     174}
     175
     176Layout *NmeaGps::GetLayout(void) const { return sensorTab; }
     177
     178Tab *NmeaGps::GetPlotTab(void) const { return plotTab; }
    168179
    169180TabWidget *NmeaGps::GetTab(void) const { return tab; }
    170181
    171 void NmeaGps::SetRef(void) { take_ref = true; }
     182void NmeaGps::SetRef(void) { takeRef = true; }
    172183
    173184void NmeaGps::GetEnu(Vector3D *point) {
     
    197208    if (gpsData->GetFixQuality() != (GpsData::FixQuality_t)pack.sig) {
    198209      gpsData->SetFixQuality((GpsData::FixQuality_t)pack.sig);
    199       fix_label->SetText("fix: %i", pack.sig);
     210      fixLabel->SetText("fix: %i", pack.sig);
    200211    }
    201212    if (gpsData->GetNumberOfSatellites() != pack.satinuse) {
    202213      gpsData->SetNumberOfSatellites(pack.satinuse) ;
    203       nb_sat_label->SetText("nb_sat: %i", pack.satinuse);
     214      nbSatLabel->SetText("nb_sat: %i", pack.satinuse);
    204215    }
    205216    gpsData->ReleaseMutex();
     
    209220                             info.elv);
    210221
    211     if ((info.sig == 2 && alt_ref == 0) || button_ref->Clicked() == true ||
    212         take_ref == true) {
     222    if ((info.sig == 2 && altRef == 0) || buttonRef->Clicked() == true ||
     223        takeRef == true) {
    213224      Printf("prise pos ref\n");
    214       lat_ref = pos.lat;
    215       long_ref = pos.lon;
    216       alt_ref = info.elv;
    217       take_ref = false;
     225      latRef = pos.lat;
     226      longRef = pos.lon;
     227      altRef = info.elv;
     228      takeRef = false;
    218229    }
    219230    // if(alt_ref!=0)
     
    222233      double e, n, u;
    223234      Geographique_2_ECEF(pos.lon, pos.lat, info.elv, x, y, z);
    224       ECEF_2_ENU(x, y, z, e, n, u, long_ref, lat_ref, alt_ref);
     235      ECEF_2_ENU(x, y, z, e, n, u, longRef, latRef, altRef);
    225236      // Printf("lon:%f lat:%f elv:%f\n",pos.lon,pos.lat,info.elv);
    226237
Note: See TracChangeset for help on using the changeset viewer.