Skip to content
ParameterInterface.cc 2.53 KiB
Newer Older
pixhawk's avatar
pixhawk committed
#include "ParameterInterface.h"
pixhawk's avatar
pixhawk committed
#include "UASManager.h"
#include "ui_ParameterInterface.h"

pixhawk's avatar
pixhawk committed
ParameterInterface::ParameterInterface(QWidget *parent) :
        QWidget(parent),
        m_ui(new Ui::parameterWidget)
pixhawk's avatar
pixhawk committed
{
    m_ui->setupUi(this);
    connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
    treeView = new QTreeView(this);
    treeView->setModel(tree);

    QStackedWidget* stack = m_ui->stackedWidget;
    stack->addWidget(treeView);
    stack->setCurrentWidget(treeView);

pixhawk's avatar
pixhawk committed
}

ParameterInterface::~ParameterInterface()
{
    delete m_ui;
}

/**
 *
 * @param uas System to add to list
 */
void ParameterInterface::addUAS(UASInterface* uas)
{
    m_ui->vehicleComboBox->addItem(uas->getUASName());

    mav = uas;

    // Setup UI connections
    connect(m_ui->readParamsButton, SIGNAL(clicked()), this, SLOT(requestParameterList()));

    // Connect signals
    connect(uas, SIGNAL(parameterChanged(int,int,QString,float)), this, SLOT(receiveParameter(int,int,QString,float)));
pixhawk's avatar
pixhawk committed
    //if (!paramViews.contains(uas))
    //{
    //uasViews.insert(uas, new UASView(uas, this));
    //listLayout->addWidget(uasViews.value(uas));
pixhawk's avatar
pixhawk committed

    //}
}

void ParameterInterface::requestParameterList()
{
    mav->requestParameters();
}

pixhawk's avatar
pixhawk committed
/**
 *
 * @param uas System which has the component
 * @param component id of the component
 * @param componentName human friendly name of the component
 */
void ParameterInterface::addComponent(UASInterface* uas, int component, QString componentName)
{
pixhawk's avatar
pixhawk committed
}

void ParameterInterface::receiveParameter(int uas, int component, QString parameterName, float value)
pixhawk's avatar
pixhawk committed
{
    Q_UNUSED(uas);
    // Insert parameter into map
    tree->appendParam(component, parameterName, value);
    // Refresh view
lm's avatar
lm committed
    treeView->update();
pixhawk's avatar
pixhawk committed
}

/**
 * @param uas system
 * @param component the subsystem which has the parameter
 * @param parameterName name of the parameter, as delivered by the system
 * @param value value of the parameter
 */
void ParameterInterface::setParameter(UASInterface* uas, int component, QString parameterName, float value)
{
pixhawk's avatar
pixhawk committed
}

/**
 * @param
 */
void ParameterInterface::commitParameter(UASInterface* uas, int component, QString parameterName, float value)
{

}

/**
 *
 */


void ParameterInterface::changeEvent(QEvent *e)
{
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}