QGCHilConfiguration.cc 2.02 KB
Newer Older
1 2
#include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h"
3
#include "QGCXPlaneLink.h"
4 5 6 7 8 9 10 11 12 13

QGCHilConfiguration::QGCHilConfiguration(QGCHilLink* link, QWidget *parent) :
    QWidget(parent),
    link(link),
    ui(new Ui::QGCHilConfiguration)
{
    ui->setupUi(this);

    connect(ui->startButton, SIGNAL(clicked(bool)), this, SLOT(toggleSimulation(bool)));
    connect(ui->hostComboBox, SIGNAL(activated(QString)), link, SLOT(setRemoteHost(QString)));
14 15
    connect(link, SIGNAL(remoteChanged(QString)), ui->hostComboBox, SLOT(setEditText(QString)));
    connect(link, SIGNAL(statusMessage(QString)), this, SLOT(receiveStatusMessage(QString)));
Lorenz Meier's avatar
Lorenz Meier committed
16 17 18
    connect(link, SIGNAL(versionChanged(QString)), ui->simComboBox, SLOT(setEditText(QString)));
    connect(ui->simComboBox, SIGNAL(activated(QString)), link, SLOT(setVersion(QString)));
    ui->simComboBox->setEditText(link->getVersion());
19 20

    ui->startButton->setText(tr("Connect"));
21 22 23 24 25 26 27 28

    QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(link);

    if (xplane)
    {
        connect(ui->randomAttitudeButton, SIGNAL(clicked()), link, SLOT(setRandomAttitude()));
        connect(ui->randomPositionButton, SIGNAL(clicked()), link, SLOT(setRandomPosition()));
        connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(setAirframe(QString)));
Lorenz Meier's avatar
Lorenz Meier committed
29
        ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex());
30
    }
31 32 33

    ui->hostComboBox->clear();
    ui->hostComboBox->addItem(link->getRemoteHost());
34
//    connect(ui->)
35 36
}

37 38 39 40 41
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
{
    ui->statusLabel->setText(message);
}

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
void QGCHilConfiguration::toggleSimulation(bool connect)
{
    Q_UNUSED(connect);
    if (!link->isConnected())
    {
        link->setRemoteHost(ui->hostComboBox->currentText());
        link->connectSimulation();
        ui->startButton->setText(tr("Disconnect"));
    }
    else
    {
        link->disconnectSimulation();
        ui->startButton->setText(tr("Connect"));
    }
}

QGCHilConfiguration::~QGCHilConfiguration()
{
    delete ui;
}