Skip to content

Commit

Permalink
Qt widget: use editingFinished instead of valueChanged in spin boxes …
Browse files Browse the repository at this point in the history
…to avoid to many events
  • Loading branch information
adeguet1 committed Apr 29, 2019
1 parent d1ccf7c commit 12fa102
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions components/code/Qt/mtsRobotIO1394QtWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ void mtsRobotIO1394QtWidget::SlotBiasEncodersAll()
}
}

void mtsRobotIO1394QtWidget::SlotWatchdogPeriod(double period_ms)
void mtsRobotIO1394QtWidget::SlotWatchdogPeriod(void)
{
double period_ms = QSBWatchdogPeriod->value();
if (period_ms == 0.0) {
QMessageBox message;
message.setText("Setting the watchdog period to 0 disables the watchdog!");
Expand Down Expand Up @@ -428,10 +429,13 @@ void mtsRobotIO1394QtWidget::timerEvent(QTimerEvent * CMN_UNUSED(event))
UpdateRobotInfo();
}

// refresh watchdog period
// refresh watchdog period if needed
double watchdogPeriodInSeconds;
Robot.WatchdogPeriod(watchdogPeriodInSeconds);
QSBWatchdogPeriod->setValue(cmnInternalTo_ms(watchdogPeriodInSeconds));
if (watchdogPeriodInSeconds != WatchdogPeriodInSeconds) {
WatchdogPeriodInSeconds = watchdogPeriodInSeconds;
QSBWatchdogPeriod->setValue(cmnInternalTo_ms(watchdogPeriodInSeconds));
}
}

////------------ Private Methods ----------------
Expand Down Expand Up @@ -750,8 +754,8 @@ void mtsRobotIO1394QtWidget::setupUi(void)
this, SLOT(SlotBiasEncodersAll()));
connect(QCBUsePotsForSafetyCheck, SIGNAL(toggled(bool)),
this, SLOT(SlotUsePotsForSafetyCheck(bool)));
connect(QSBWatchdogPeriod, SIGNAL(valueChanged(double)),
this, SLOT(SlotWatchdogPeriod(double)));
connect(QSBWatchdogPeriod, SIGNAL(editingFinished()),
this, SLOT(SlotWatchdogPeriod()));
connect(QVWActuatorCurrentEnableEach, SIGNAL(valueChanged()),
this, SLOT(SlotActuatorAmpEnable()));
connect(QVWActuatorCurrentSpinBox, SIGNAL(valueChanged()),
Expand Down
6 changes: 3 additions & 3 deletions components/include/sawRobotIO1394/mtsRobotIO1394QtWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Author(s): Zihan Chen
Created on: 2012-07-20
(C) Copyright 2012-2017 Johns Hopkins University (JHU), All Rights Reserved.
(C) Copyright 2012-2019 Johns Hopkins University (JHU), All Rights Reserved.
--- begin cisst license - do not edit ---
Expand Down Expand Up @@ -62,13 +62,13 @@ private slots:
void SlotEnableDirectControl(bool toggle);
void SlotActuatorAmpEnable(void);
void SlotResetCurrentAll(void);
void SlotActuatorCurrentValueChanged();
void SlotActuatorCurrentValueChanged(void);
void SlotSliderActuatorCurrentValueChanged(void);
void SlotBrakeAmpEnable(void);
void SlotResetEncodersAll(void);
void SlotBiasEncodersAll(void);
void SlotUsePotsForSafetyCheck(bool status);
void SlotWatchdogPeriod(double period_ms);
void SlotWatchdogPeriod(void);
void SlotBrakeEngage(void);
void SlotBrakeRelease(void);

Expand Down

0 comments on commit 12fa102

Please sign in to comment.