Skip to content

Commit b5bce33

Browse files
committed
LP-551 Disable Bank manipulation while testing output or calibrating inputs
1 parent f93ebd4 commit b5bce33

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

ground/gcs/src/plugins/config/configoutputwidget.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
146146
SystemAlarms *systemAlarmsObj = SystemAlarms::GetInstance(getObjectManager());
147147
connect(systemAlarmsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateBoardWarnings(UAVObject *)));
148148

149+
inputCalibrationStarted = false;
150+
channelTestsStarted = false;
151+
149152
// TODO why do we do that ?
150153
disconnect(this, SLOT(refreshWidgetsValues(UAVObject *)));
151154
}
@@ -219,6 +222,17 @@ void ConfigOutputWidget::runChannelTests(bool state)
219222
}
220223
}
221224

225+
channelTestsStarted = state;
226+
227+
// Disable/Enable banks
228+
for (int i = 0; i < m_banks.count(); i++) {
229+
OutputBankControls controls = m_banks.at(i);
230+
bool isUsed = !(controls.rateCombo()->currentText() == "-" && controls.modeCombo()->currentText() == "PWM");
231+
if (isUsed) {
232+
controls.modeCombo()->setEnabled(!state);
233+
}
234+
}
235+
222236
ActuatorCommand *obj = ActuatorCommand::GetInstance(getObjectManager());
223237
UAVObject::Metadata mdata = obj->getMetadata();
224238
if (state) {
@@ -418,8 +432,8 @@ void ConfigOutputWidget::refreshWidgetsValuesImpl(UAVObject *obj)
418432
controls.rateCombo()->setCurrentIndex(index);
419433
controls.rateCombo()->setEnabled(controls.modeCombo()->currentIndex() == ActuatorSettings::BANKMODE_PWM);
420434
setColor(controls.rateCombo(), controls.color());
421-
controls.modeCombo()->setEnabled(true);
422435
setColor(controls.modeCombo(), controls.color());
436+
controls.modeCombo()->setEnabled((inputCalibrationStarted || channelTestsStarted) ? false : true);
423437
i++;
424438
}
425439

@@ -698,6 +712,7 @@ void ConfigOutputWidget::checkOutputConfig()
698712
void ConfigOutputWidget::stopTests()
699713
{
700714
m_ui->channelOutTest->setChecked(false);
715+
channelTestsStarted = false;
701716
}
702717

703718
void ConfigOutputWidget::updateBoardWarnings(UAVObject *)
@@ -778,11 +793,13 @@ QString ConfigOutputWidget::bankModeName(int index)
778793

779794
void ConfigOutputWidget::inputCalibrationStatus(bool started)
780795
{
796+
inputCalibrationStarted = started;
797+
781798
// Disable UI when a input calibration is started
782799
// so user cannot manipulate settings.
783800
enableControls(!started);
784801

785-
// Disable every channel form
802+
// Disable every channel form when needed
786803
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
787804
OutputChannelForm *form = getOutputChannelForm(i);
788805
form->ui->actuatorRev->setChecked(false);

ground/gcs/src/plugins/config/configoutputwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public slots:
107107
QList<OutputBankControls> m_banks;
108108

109109
bool inputCalibrationStarted;
110+
bool channelTestsStarted;
110111

111112
OutputChannelForm *getOutputChannelForm(const int index) const;
112113
void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value);

ground/gcs/src/plugins/config/outputchannelform.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void OutputChannelForm::enableChannelTest(bool state)
111111
ui->actuatorMin->setEnabled(false);
112112
ui->actuatorMax->setEnabled(false);
113113
ui->actuatorRev->setEnabled(false);
114-
} else if (m_mixerType != "Disabled") {
114+
} else if (!isDisabledOutput()) {
115115
ui->actuatorMin->setEnabled(true);
116116
ui->actuatorMax->setEnabled(true);
117117
if (!isNormalMotor()) {
@@ -332,10 +332,13 @@ void OutputChannelForm::reverseChannel(bool state)
332332
}
333333

334334
/**
335-
* Enable/Disable all UI controls
335+
* Enable/Disable UI controls
336336
*/
337337
void OutputChannelForm::enableControls(bool state)
338338
{
339+
if (isDisabledOutput()) {
340+
state = false;
341+
}
339342
ui->actuatorMin->setEnabled(state);
340343
ui->actuatorMax->setEnabled(state);
341344
ui->actuatorValue->setEnabled(state);

0 commit comments

Comments
 (0)