Commit 1142b6f3 authored by Michael Carpenter's avatar Michael Carpenter

Implemented Sonar Config

parent be00fa35
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
<file>files/images/mavs/frames-05.png</file> <file>files/images/mavs/frames-05.png</file>
<file>files/images/devices/BR-HMC5883-01-2.jpg</file> <file>files/images/devices/BR-HMC5883-01-2.jpg</file>
<file>files/images/devices/BR-APMPWRDEAN-2.jpg</file> <file>files/images/devices/BR-APMPWRDEAN-2.jpg</file>
<file>files/images/devices/AC-0004-11-2.jpg</file>
</qresource> </qresource>
<qresource prefix="/general"> <qresource prefix="/general">
<file alias="vera.ttf">files/styles/Vera.ttf</file> <file alias="vera.ttf">files/styles/Vera.ttf</file>
......
#include "SonarConfig.h" #include "SonarConfig.h"
#include <QMessageBox>
SonarConfig::SonarConfig(QWidget *parent) : AP2ConfigWidget(parent)
SonarConfig::SonarConfig(QWidget *parent) : QWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(checkBoxToggled(bool)));
connect(ui.sonarTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(sonarTypeChanged(int)));
ui.sonarTypeComboBox->addItem("XL-EZ0 / XL-EZ4");
ui.sonarTypeComboBox->addItem("LV-EZ0");
ui.sonarTypeComboBox->addItem("XL-EZL0");
ui.sonarTypeComboBox->addItem("HRLV");
} }
SonarConfig::~SonarConfig() SonarConfig::~SonarConfig()
{ {
} }
void SonarConfig::checkBoxToggled(bool enabled)
{
if (enabled)
{
ui.sonarTypeComboBox->setEnabled(false);
}
if (!m_uas)
{
QMessageBox::information(0,tr("Error"),tr("Please connect to a MAV before attempting to set configuration"));
return;
}
m_uas->setParameter(0,"SONAR_ENABLE",ui.enableCheckBox->isChecked() ? 1 : 0);
}
void SonarConfig::sonarTypeChanged(int index)
{
if (!m_uas)
{
QMessageBox::information(0,tr("Error"),tr("Please connect to a MAV before attempting to set configuration"));
return;
}
m_uas->setParameter(0,"SONAR_TYPE",ui.sonarTypeComboBox->currentIndex());
}
void SonarConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
if (parameterName == "SONAR_ENABLE")
{
if (value.toInt() == 0)
{
//Disabled
disconnect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(checkBoxToggled(bool)));
ui.enableCheckBox->setChecked(false);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(checkBoxToggled(bool)));
ui.sonarTypeComboBox->setEnabled(false);
}
else
{
disconnect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(checkBoxToggled(bool)));
ui.enableCheckBox->setChecked(true);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(checkBoxToggled(bool)));
ui.sonarTypeComboBox->setEnabled(true);
}
}
else if (parameterName == "SONAR_TYPE")
{
disconnect(ui.sonarTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(sonarTypeChanged(int)));
ui.sonarTypeComboBox->setCurrentIndex(value.toInt());
connect(ui.sonarTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(sonarTypeChanged(int)));
}
}
...@@ -2,16 +2,20 @@ ...@@ -2,16 +2,20 @@
#define SONARCONFIG_H #define SONARCONFIG_H
#include <QWidget> #include <QWidget>
#include "AP2ConfigWidget.h"
#include "ui_SonarConfig.h" #include "ui_SonarConfig.h"
class SonarConfig : public QWidget class SonarConfig : public AP2ConfigWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SonarConfig(QWidget *parent = 0); explicit SonarConfig(QWidget *parent = 0);
~SonarConfig(); ~SonarConfig();
private slots:
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void checkBoxToggled(bool enabled);
void sonarTypeChanged(int index);
private: private:
Ui::SonarConfig ui; Ui::SonarConfig ui;
}; };
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>651</width>
<height>300</height> <height>432</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -29,7 +29,51 @@ ...@@ -29,7 +29,51 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>30</x>
<y>60</y>
<width>91</width>
<height>81</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../qgroundcontrol.qrc">:/files/images/devices/AC-0004-11-2.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="enableCheckBox">
<property name="geometry">
<rect>
<x>140</x>
<y>60</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
<widget class="QComboBox" name="sonarTypeComboBox">
<property name="geometry">
<rect>
<x>150</x>
<y>100</y>
<width>171</width>
<height>22</height>
</rect>
</property>
</widget>
</widget> </widget>
<resources/> <resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment