QGCHilConfiguration.cc 1.73 KB
Newer Older
1 2 3
#include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h"

4 5 6 7
#include "QGCHilFlightGearConfiguration.h"
#include "QGCHilXPlaneConfiguration.h"

QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
8
    QWidget(parent),
9
    mav(mav),
10 11 12 13 14
    ui(new Ui::QGCHilConfiguration)
{
    ui->setupUi(this);
}

15 16 17 18 19
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
{
    ui->statusLabel->setText(message);
}

20 21 22 23 24 25
QGCHilConfiguration::~QGCHilConfiguration()
{
    delete ui;
}

void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
26
{
27
    if(1 == index)
28
    {
Lorenz Meier's avatar
Lorenz Meier committed
29 30
        // Ensure the sim exists and is disabled
        mav->enableHilFlightGear(false, "");
31 32
        QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this);
        hfgconf->show();
33 34 35 36 37 38
        ui->simulatorConfigurationLayout->addWidget(hfgconf);
        QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(mav->getHILSimulation());
        if (fg)
        {
            connect(fg, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
        }
39

40
    }
41
    else if(2 == index || 3 == index)
42
    {
Lorenz Meier's avatar
Lorenz Meier committed
43 44
        // Ensure the sim exists and is disabled
        mav->enableHilXPlane(false);
45 46
        QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(mav->getHILSimulation(), this);
        hxpconf->show();
47
        ui->simulatorConfigurationLayout->addWidget(hxpconf);
48

Lorenz Meier's avatar
Lorenz Meier committed
49 50 51 52 53
        // Select correct version of XPlane
        QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(mav->getHILSimulation());
        if (xplane)
        {
            xplane->setVersion((index == 2) ? 10 : 9);
54
            connect(xplane, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
Lorenz Meier's avatar
Lorenz Meier committed
55
        }
56
    }
57
}