Changeset 437 in flair-src


Ignore:
Timestamp:
Aug 24, 2021, 5:33:19 PM (3 years ago)
Author:
Sanahuja Guillaume
Message:

prepare for graphs buffering

Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/DoubleSpinBox.cpp

    r15 r437  
    2424
    2525DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
    26                              double min, double max, double step, int decimals,
     26                             double min, double max, double step, uint16_t decimals,
    2727                             double default_value)
    2828    : Box(position, name, "DoubleSpinBox") {
     
    4646DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
    4747                             string suffix, double min, double max, double step,
    48                              int decimals, double default_value)
     48                             uint16_t decimals, double default_value)
    4949    : Box(position, name, "DoubleSpinBox") {
    5050  // update value from xml file
  • trunk/lib/FlairCore/src/DoubleSpinBox.h

    r15 r437  
    4343  */
    4444  DoubleSpinBox(const LayoutPosition *position, std::string name, double min,
    45                 double max, double step, int decimals = 2,
     45                double max, double step, uint16_t decimals = 2,
    4646                double default_value = 0);
    4747
     
    6363  DoubleSpinBox(const LayoutPosition *position, std::string name,
    6464                std::string suffix, double min, double max, double step,
    65                 int decimals = 2, double default_value = 0);
     65                uint16_t decimals = 2, double default_value = 0);
    6666
    6767  /*!
  • trunk/lib/FlairCore/src/SendData.cpp

    r15 r437  
    3030
    3131SendData::SendData(const LayoutPosition *position, string name, string type,
    32                    uint16_t default_periodms, bool default_enabled)
     32                   uint16_t default_periodms, bool default_enabled, uint16_t default_nb_buffering)
    3333    : Widget(position->getLayout(), name, type) {
    3434  pimpl_ = new SendData_impl();
     
    3939  pimpl_->send_period = default_periodms;
    4040  pimpl_->is_enabled = default_enabled;
     41  pimpl_->nb_buffering = default_nb_buffering;
    4142
    4243  SetVolatileXmlProp("row", position->Row());
     
    4647  GetPersistentXmlProp("enabled", pimpl_->is_enabled);
    4748  SetPersistentXmlProp("enabled", pimpl_->is_enabled);
     49  GetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
     50  SetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
    4851
    4952  delete position;
     
    6770
    6871void SendData::XmlEvent(void) {
    69   uint16_t send_period;
     72  uint16_t send_period,nb_buffering;
    7073  bool is_enabled;
    7174  bool something_changed = false;
    7275
    73   if (GetPersistentXmlProp("period", send_period) &&
    74       GetPersistentXmlProp("enabled", is_enabled)) {
     76  if (GetPersistentXmlProp("period", send_period) && GetPersistentXmlProp("enabled", is_enabled) && GetPersistentXmlProp("nb_buf", nb_buffering)) {
    7577    if (send_period != SendPeriod())
    7678      something_changed = true;
    7779    if (is_enabled != IsEnabled())
     80      something_changed = true;
     81  }
     82 
     83  if (GetPersistentXmlProp("nb_buf", nb_buffering)) {
     84    if (nb_buffering != NbBuffering())
    7885      something_changed = true;
    7986  }
     
    8491    SetSendPeriod(send_period);
    8592    SetEnabled(is_enabled);
     93    SetNbBuffering(nb_buffering);
    8694
    8795    getFrameworkManager()->UpdateSendData(this);
     
    9199    SetVolatileXmlProp("period", send_period);
    92100    SetVolatileXmlProp("enabled", is_enabled);
     101    SetVolatileXmlProp("nb_buf", nb_buffering);
    93102    SendXml();
    94103
     
    102111
    103112uint16_t SendData::SendPeriod(void) const { return pimpl_->send_period; }
     113
     114uint16_t SendData::NbBuffering(void) const { return pimpl_->nb_buffering; }
    104115
    105116bool SendData::IsEnabled(void) const { return pimpl_->is_enabled; }
     
    116127void SendData::SetSendPeriod(uint16_t value) { pimpl_->send_period = value; }
    117128
     129void SendData::SetNbBuffering(uint16_t value) { pimpl_->nb_buffering = value; }
     130
    118131} // end namespace core
    119132} // end namespace flair
  • trunk/lib/FlairCore/src/SendData.h

    r15 r437  
    3434  */
    3535  SendData(const LayoutPosition *position, std::string name, std::string type,
    36            uint16_t default_periodms = 100, bool default_enabled = false);
     36           uint16_t default_periodms = 100, bool default_enabled = false, uint16_t default_nb_buffering=1);
    3737
    3838  /*!
     
    5454  uint16_t SendPeriod(void) const; // in ms
    5555  bool IsEnabled(void) const;
     56  uint16_t NbBuffering(void) const;
    5657
    5758protected:
     
    8889
    8990  void SetSendPeriod(uint16_t value);
     91  void SetNbBuffering(uint16_t value);
    9092  void SetEnabled(bool value);
    9193
  • trunk/lib/FlairCore/src/Vector3DSpinBox.cpp

    r167 r437  
    2626Vector3DSpinBox::Vector3DSpinBox(const LayoutPosition *position, string name,
    2727                                 double min, double max, double step,
    28                                  int decimals, core::Vector3Df default_value)
     28                                 uint16_t decimals, core::Vector3Df default_value)
    2929    : Box(position, name, "Vector3DSpinBox") {
    3030  // update value from xml file
  • trunk/lib/FlairCore/src/Vector3DSpinBox.h

    r199 r437  
    4343  */
    4444  Vector3DSpinBox(const LayoutPosition *position, std::string name, double min,
    45                   double max, double step, int decimals = 2,
     45                  double max, double step, uint16_t decimals = 2,
    4646                  core::Vector3Df default_value = core::Vector3Df(0, 0, 0));
    4747
  • trunk/lib/FlairCore/src/unexported/SendData_impl.h

    r15 r437  
    3030  size_t send_size;
    3131  uint16_t send_period;
     32  uint16_t nb_buffering;
    3233};
    3334
  • 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.