Changeset 437 in flair-src for trunk/tools/FlairGCS


Ignore:
Timestamp:
08/24/21 17:33:19 (3 years ago)
Author:
Sanahuja Guillaume
Message:

prepare for graphs buffering

Location:
trunk/tools/FlairGCS/src
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/ComboBox.cpp

    r269 r437  
    88#include <QFormLayout>
    99
    10 ComboBox::ComboBox(Layout *parent, int row, int col, QString name, int value)
     10ComboBox::ComboBox(Layout *parent, int row, int col, QString name, uint16_t value)
    1111    : FormLayout(parent, row, col, name, "ComboBox") {
    1212  combobox = new QComboBox();
  • trunk/tools/FlairGCS/src/ComboBox.h

    r269 r437  
    1515
    1616public:
    17   ComboBox(Layout *parent, int row, int col, QString name, int value);
     17  ComboBox(Layout *parent, int row, int col, QString name, uint16_t value);
    1818  ~ComboBox();
    1919
    2020private:
    2121  QComboBox *combobox;
    22   int combobox_value;
     22  uint16_t combobox_value;
    2323  void XmlEvent(QDomElement *dom);
    2424  void SetUptodate(void);
  • trunk/tools/FlairGCS/src/DataPlot1D.cpp

    r436 r437  
    1313
    1414DataPlot1D::DataPlot1D(Layout *parent, int row, int col, QString title,
    15                        float ymin, float ymax, bool enabled, int period)
     15                       float ymin, float ymax, bool enabled, uint16_t period, uint16_t nb_buffering)
    1616    : ScopeFixedStep(title, ymin, ymax, period / 1000.),
    17       DataRemote(title, "DataPlot1D", parent, enabled, period) {
     17      DataRemote(title, "DataPlot1D", parent, enabled, period, nb_buffering) {
    1818
    1919  setEnabled(enabled);
  • trunk/tools/FlairGCS/src/DataPlot1D.h

    r269 r437  
    1515public:
    1616  DataPlot1D(Layout *parent, int row, int col, QString title, float ymin,
    17              float ymax, bool enabled, int period);
     17             float ymax, bool enabled, uint16_t period, uint16_t nb_buffering=1);
    1818  ~DataPlot1D();
    1919
  • trunk/tools/FlairGCS/src/DataPlot2D.cpp

    r269 r437  
    2222DataPlot2D::DataPlot2D(Layout *parent, int row, int col, QString plot_name,
    2323                       QString x_name, QString y_name, float xmin, float xmax,
    24                        float ymin, float ymax, bool enabled, int period)
    25     : DataRemote(plot_name, "DataPlot2D", parent, enabled, period) {
     24                       float ymin, float ymax, bool enabled, uint16_t period, uint16_t nb_buffering)
     25    : DataRemote(plot_name, "DataPlot2D", parent, enabled, period, nb_buffering) {
    2626  plot = new QwtPlot(NULL);
    2727  plot->setEnabled(enabled);
  • trunk/tools/FlairGCS/src/DataPlot2D.h

    r269 r437  
    2222  DataPlot2D(Layout *parent, int row, int col, QString plot_name,
    2323             QString x_name, QString y_name, float xmin, float xmax, float ymin,
    24              float ymax, bool enabled, int period);
     24             float ymax, bool enabled, uint16_t period, uint16_t nb_buffering=1);
    2525  ~DataPlot2D();
    2626  void addCurve(QPen pen, QString legend, QString type);
  • trunk/tools/FlairGCS/src/DataRemote.cpp

    r436 r437  
    1010
    1111DataRemote::DataRemote(QString name, QString type, XmlWidget *parent,
    12                        bool enabled, int period)
     12                       bool enabled, uint16_t period, uint16_t nb_buffering)
    1313    : XmlWidget(name, type, parent) {
    1414  auto_refresh = enabled;
     
    1616  receivesize = 0;
    1717  refresh_rate = (double)period / 1000.;
    18 
     18  this->nb_buffering=nb_buffering;
     19 
    1920  connectionLayout()->addDataRemote(this);
    2021
     
    2829  menu->addSeparator();
    2930
    30   autoRefresh = menu->addAction("auto refresh");
    31   autoRefresh->setCheckable(true);
    32   autoRefresh->setChecked(auto_refresh);
     31  SetAutoRefresh = menu->addAction("auto refresh");
     32  SetAutoRefresh->setCheckable(true);
     33  SetAutoRefresh->setChecked(auto_refresh);
    3334
    3435  setRefreshRate = menu->addAction(QString("set refresh rate (%1ms)")
    3536                          .arg((uint16_t)(qRound(refresh_rate * 1000))));
    3637  setRefreshRate->setEnabled(auto_refresh);
     38 
     39  menu->addSeparator();
     40  setNbBuffering = menu->addAction(QString("set nb buffering (%1)").arg(nb_buffering));
     41 
    3742/*  menu->addSeparator();
    3843
     
    4853  action = menu->exec(point);
    4954
    50   if (action == autoRefresh) {
    51     SendPeriod(RefreshRate_ms(), autoRefresh->isChecked());
     55  if (action == SetAutoRefresh) {
     56    SendPeriod(RefreshRate_ms(), SetAutoRefresh->isChecked());
    5257  }
    5358
     
    5863        parent, "Set refresh rate ", "Value (ms):",
    5964        (uint16_t)(qRound(refresh_rate * 1000)), 1, 65535, 10, &ok);
    60     if (ok == true && time != qRound(refresh_rate * 1000)) {
     65    if (ok && time != qRound(refresh_rate * 1000)) {
    6166      // refresh_rate=time/1000.;
    62       SendPeriod(time, autoRefresh->isChecked());
     67      SendPeriod(time, SetAutoRefresh->isChecked());
     68    }
     69  }
     70 
     71  if (action == setNbBuffering) {
     72    bool ok;
     73 
     74    uint16_t nb_buffering = QInputDialog::getInt(
     75        parent, "Set nb buffering ", "Value :",
     76        this->nb_buffering, 1, 65535, 10, &ok);
     77    if (ok  && nb_buffering !=this->nb_buffering) {
     78      SendNbBuffering(nb_buffering);
    6379    }
    6480  }
     
    7389bool DataRemote::IsEnabled(void) { return auto_refresh; }
    7490
    75 void DataRemote::SendPeriod(int period, bool auto_refresh) {
     91void DataRemote::SendPeriod(uint16_t period, bool auto_refresh) {
    7692  RemoveAllAttributes();
    7793
     
    8399}
    84100
     101void DataRemote::SendNbBuffering(uint16_t nb_buffering) {
     102    RemoveAllAttributes();
     103
     104    SetAttribute("nb_buf", nb_buffering);
     105    connectionLayout()->XmlToSend(XmlDoc());
     106    RemoveAttribute("nb_buf");
     107}
     108
    85109int DataRemote::ReceiveSize(void) { return receivesize; }
    86110
    87111void DataRemote::XmlSetup(QDomElement *dom) {
    88   refresh_rate = dom->attribute("period").toInt() / 1000.;
     112  refresh_rate = dom->attribute("period").toUShort() / 1000.;
     113  nb_buffering = dom->attribute("nb_buf").toUShort();
    89114  if (dom->attribute("enabled") == "1")
    90115    auto_refresh = true;
  • trunk/tools/FlairGCS/src/DataRemote.h

    r269 r437  
    1616public:
    1717  DataRemote(QString name, QString type, XmlWidget *parent, bool enabled,
    18              int period);
     18             uint16_t period, uint16_t nb_buffering=1);
    1919  ~DataRemote();
    2020  uint16_t RefreshRate_ms(void);
     
    3131  double refresh_rate; // en s
    3232  int receivesize;
     33  uint16_t nb_buffering;
    3334
    3435  void XmlSetup(QDomElement *dom);
    3536
    3637private:
    37   void SendPeriod(int period, bool auto_refresh);
    38   QAction *autoRefresh, *setRefreshRate;
     38  void SendPeriod(uint16_t period, bool auto_refresh);
     39  void SendNbBuffering(uint16_t nb_buffering);
     40  QAction *SetAutoRefresh, *setRefreshRate,*setNbBuffering;
    3941  //QAction **log;//todo implement this feature (log directly in gcs, in case of uav program crash)
    4042};
  • trunk/tools/FlairGCS/src/DoubleSpinBox.cpp

    r269 r437  
    1313DoubleSpinBox::DoubleSpinBox(Layout *parent, int row, int col, QString name,
    1414                             QString suffix, QString value, float min,
    15                              float max, float step, int decimals)
     15                             float max, float step, uint16_t decimals)
    1616    : FormLayout(parent, row, col, name, "DoubleSpinBox") {
    1717  doublespinbox = new QDoubleSpinBox();
  • trunk/tools/FlairGCS/src/DoubleSpinBox.h

    r269 r437  
    1717  // handle value as string, becouse double value are not exact
    1818  DoubleSpinBox(Layout *parent, int row, int col, QString name, QString suffix,
    19                 QString value, float min, float max, float step, int decimals);
     19                QString value, float min, float max, float step, uint16_t decimals);
    2020  ~DoubleSpinBox();
    2121
  • trunk/tools/FlairGCS/src/Layout.cpp

    r269 r437  
    127127    double max = dom->attribute("max").toDouble();
    128128    double step = dom->attribute("step").toDouble();
    129     int decimals = dom->attribute("decimals").toInt();
     129    uint16_t decimals = dom->attribute("decimals").toUShort();
    130130    widget = new DoubleSpinBox(this, row, col, name, suffix, value, min, max,
    131131                               step, decimals);
     
    139139    double max = dom->attribute("max").toDouble();
    140140    double step = dom->attribute("step").toDouble();
    141     int decimals = dom->attribute("decimals").toInt();
     141    uint16_t decimals = dom->attribute("decimals").toUShort();
    142142    widget = new Vector3DSpinBox(this, row, col, name, value, min, max, step,
    143143                                 decimals);
     
    148148  }
    149149  if (type == "ComboBox") {
    150     int value = dom->attribute("value").toInt();
     150    uint16_t value = dom->attribute("value").toUShort();
    151151    widget = new ComboBox(this, row, col, name, value);
    152152  }
     
    158158    float ymax = dom->attribute("max").toFloat();
    159159    int enabled = dom->attribute("enabled").toInt();
    160     int period = dom->attribute("period").toInt();
    161     if (enabled == 1) {
    162       widget = new DataPlot1D(this, row, col, name, ymin, ymax, true, period);
    163     } else {
    164       widget = new DataPlot1D(this, row, col, name, ymin, ymax, false, 100);
     160    uint16_t period = dom->attribute("period").toUShort();
     161    uint16_t nb_buffering = dom->attribute("nb_buf").toUShort();
     162    if (enabled == 1) {
     163      widget = new DataPlot1D(this, row, col, name, ymin, ymax, true, period,nb_buffering);
     164    } else {
     165      widget = new DataPlot1D(this, row, col, name, ymin, ymax, false, 100,nb_buffering);
    165166    }
    166167  }
     
    173174    QString y_name = dom->attribute("y_name");
    174175    int enabled = dom->attribute("enabled").toInt();
    175     int period = dom->attribute("period").toInt();
     176    uint16_t period = dom->attribute("period").toUShort();
     177    uint16_t nb_buffering = dom->attribute("nb_buf").toUShort();
    176178    if (enabled == 1) {
    177179      widget = new DataPlot2D(this, row, col, name, x_name, y_name, xmin, xmax,
    178                               ymin, ymax, true, period);
     180                              ymin, ymax, true, period,nb_buffering);
    179181    } else {
    180182      widget = new DataPlot2D(this, row, col, name, x_name, y_name, xmin, xmax,
    181                               ymin, ymax, false, 100);
     183                              ymin, ymax, false, 100,nb_buffering);
    182184    }
    183185  }
     
    187189    QString y_name = dom->attribute("y_name");
    188190    int enabled = dom->attribute("enabled").toInt();
    189     int period = dom->attribute("period").toInt();
     191    uint16_t period = dom->attribute("period").toUShort();
    190192    QString type = dom->attribute("type");
    191193    int samples = dom->attribute("samples").toInt();
     
    210212    uint32_t nb_samples = dom->attribute("nb_samples").toUInt();
    211213    int enabled = dom->attribute("enabled").toInt();
    212     int period = dom->attribute("period").toInt();
     214    uint16_t period = dom->attribute("period").toUShort();
    213215    int invert_axis = dom->attribute("invert_axis").toInt();
    214216    bool invert_axis_bool;
     
    234236    int height = dom->attribute("height").toInt();
    235237    int enabled = dom->attribute("enabled").toInt();
    236     int period = dom->attribute("period").toInt();
     238    uint16_t period = dom->attribute("period").toUShort();
    237239    if (enabled == 1) {
    238240      widget = new Picture(this, row, col, name, width, height, true, period);
     
    242244  }
    243245  if (type == "Map") {
    244     int period = dom->attribute("period").toInt();
     246    uint16_t period = dom->attribute("period").toUShort();
    245247    int enabled = dom->attribute("enabled").toInt();
    246248    int i = 0;
  • trunk/tools/FlairGCS/src/Map.cpp

    r269 r437  
    2424
    2525Map::Map(Layout *parent, int row, int col, QString name,
    26          QList<QGeoCoordinate> coordinates, bool enabled, int period)
     26         QList<QGeoCoordinate> coordinates, bool enabled, uint16_t period)
    2727    : DataRemote(name, "Map", parent, enabled, period) {
    2828  visible_widget = new QWidget();
  • trunk/tools/FlairGCS/src/Map.h

    r269 r437  
    3030public:
    3131  Map(Layout *parent, int row, int col, QString name,
    32       QList<QtMobility::QGeoCoordinate> coordinates, bool enabled, int period);
     32      QList<QtMobility::QGeoCoordinate> coordinates, bool enabled, uint16_t period);
    3333  ~Map();
    3434  void setCenteredPoint(int i);
  • trunk/tools/FlairGCS/src/Picture.cpp

    r269 r437  
    1313
    1414Picture::Picture(Layout *parent, int row, int col, QString name, uint16_t width,
    15                  uint16_t height, bool enabled, int period)
     15                 uint16_t height, bool enabled, uint16_t period)
    1616    : DataRemote(name, "Picture", parent, enabled, period) {
    1717  box = new QGroupBox(name);
  • trunk/tools/FlairGCS/src/Picture.h

    r269 r437  
    2222public:
    2323  Picture(Layout *parent, int row, int col, QString name, uint16_t width,
    24           uint16_t height, bool enabled, int period);
     24          uint16_t height, bool enabled, uint16_t period);
    2525  ~Picture();
    2626
  • trunk/tools/FlairGCS/src/RangeFinderPlot.cpp

    r269 r437  
    2323                                 float start_angle, float end_angle,
    2424                                 uint32_t nb_samples, QString data_type,
    25                                  bool invert_axis, bool enabled, int period)
     25                                 bool invert_axis, bool enabled, uint16_t period)
    2626    : DataRemote(name, "RangeFinderPlot", parent, enabled, period) {
    2727  invert_axis = true;
  • trunk/tools/FlairGCS/src/RangeFinderPlot.h

    r269 r437  
    2222                  float ymin, float ymax, float start_angle, float end_angle,
    2323                  uint32_t nb_samples, QString data_type, bool invert_axis,
    24                   bool enabled, int period);
     24                  bool enabled, uint16_t period);
    2525  ~RangeFinderPlot();
    2626
  • trunk/tools/FlairGCS/src/UsSensorPlot.cpp

    r269 r437  
    2424
    2525UsSensorPlot::UsSensorPlot(Layout *parent, int row, int col, QString plot_name,
    26                        QString y_name, float ymin, float ymax, uint32_t nbSamples,QString datasType,bool enabled, int period)
     26                       QString y_name, float ymin, float ymax, uint32_t nbSamples,QString datasType,bool enabled, uint16_t period)
    2727    : DataRemote(plot_name, "UsSensorPlot", parent, enabled, period) {
    2828  visible_widget = new QWidget();
  • trunk/tools/FlairGCS/src/UsSensorPlot.h

    r269 r437  
    2323public:
    2424  UsSensorPlot(Layout *parent, int row, int col, QString plot_name,
    25              QString y_name, float ymin,float ymax, uint32_t nbSamples,QString datasType,bool enabled, int period);
     25             QString y_name, float ymin,float ymax, uint32_t nbSamples,QString datasType,bool enabled, uint16_t period);
    2626  ~UsSensorPlot();
    2727
  • trunk/tools/FlairGCS/src/Vector3DSpinBox.cpp

    r269 r437  
    1313Vector3DSpinBox::Vector3DSpinBox(Layout *parent, int row, int col, QString name,
    1414                                 QString value[3], float min, float max,
    15                                  float step, int decimals)
     15                                 float step, uint16_t decimals)
    1616    : XmlWidget(name, "Vector3DSpinBox", parent) {
    1717  for (int i = 0; i < 3; i++) {
  • trunk/tools/FlairGCS/src/Vector3DSpinBox.h

    r269 r437  
    2020  Vector3DSpinBox(Layout *parent, int row, int col, QString name,
    2121                  QString value[3], float min, float max, float step,
    22                   int decimals);
     22                  uint16_t decimals);
    2323  ~Vector3DSpinBox();
    2424
Note: See TracChangeset for help on using the changeset viewer.