Changeset 437 in flair-src for trunk/tools/FlairGCS/src/DataRemote.cpp


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

prepare for graphs buffering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.