Skip to content
Snippets Groups Projects
Unverified Commit 661fd825 authored by Jake's avatar Jake
Browse files

Control graph param setting works!

parent ad2b1001
No related branches found
No related tags found
No related merge requests found
......@@ -26,3 +26,26 @@ HEADERS += mainwindow.h \
controlworker.h
FORMS += mainwindow.ui
INCLUDEPATH += $$PWD/../../../quad/inc
DEPENDPATH += $$PWD/../../../quad/inc
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../quad/lib/release/ -lgraph_blocks
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../quad/lib/debug/ -lgraph_blocks
else:unix: LIBS += -L$$PWD/../../../quad/lib/ -lgraph_blocks
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/release/libgraph_blocks.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/debug/libgraph_blocks.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/release/graph_blocks.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/debug/graph_blocks.lib
else:unix: PRE_TARGETDEPS += $$PWD/../../../quad/lib/libgraph_blocks.a
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../quad/lib/release/ -lcomputation_graph
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../quad/lib/debug/ -lcomputation_graph
else:unix: LIBS += -L$$PWD/../../../quad/lib/ -lcomputation_graph
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/release/libcomputation_graph.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/debug/libcomputation_graph.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/release/computation_graph.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../quad/lib/debug/computation_graph.lib
else:unix: PRE_TARGETDEPS += $$PWD/../../../quad/lib/libcomputation_graph.a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.2, 2017-03-28T12:37:18. -->
<!-- Written by QtCreator 4.0.1, 2017-04-09T15:34:48. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{9578df81-eac2-4831-8e1a-80abf90f9c0f}</value>
<value type="QByteArray">{ec588c71-c0cc-43f4-8233-a07fa24de8ad}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
......@@ -40,6 +40,7 @@
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
......@@ -60,12 +61,12 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{199b6d60-acb7-4eec-805c-8e68ddaba3f6}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c6f8ca21-0eb9-4188-b2e8-fae8725afa1b}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/MicroCART_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
......@@ -73,9 +74,10 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
......@@ -124,7 +126,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/MicroCART_17-18/groundStation/gui/build-MicroCART-Desktop-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
......@@ -132,9 +134,10 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
......@@ -198,6 +201,11 @@
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
......@@ -236,12 +244,13 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MicroCART</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jake/MicroCART_17-18/groundStation/gui/MicroCART/MicroCART.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jake/Microcart_17-18/groundStation/gui/MicroCART/MicroCART.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">MicroCART.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
......@@ -258,10 +267,10 @@
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">16</value>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">16</value>
<value type="int">18</value>
</data>
</qtcreator>
#include "controlworker.h"
#include "frontend_nodes.h"
#include "frontend_param.h"
#include "graph_blocks.h"
ControlWorker::ControlWorker(QObject *parent) :
QObject(parent), conn(NULL)
......@@ -8,11 +9,6 @@ ControlWorker::ControlWorker(QObject *parent) :
}
ControlWorker::ControlWorker() :
QObject(), conn(NULL)
{
}
ControlWorker::~ControlWorker()
{
disconnectBackend();
......@@ -31,22 +27,26 @@ void ControlWorker::disconnectBackend()
}
}
ControlWorker::getNodes()
void ControlWorker::getNodes()
{
if (conn) {
frontend_node_data * nd = NULL;
size_t num_nodes = 0;
frontend_getnodes(conn, &nd, &num_nodes);
QStringList nodes;
QStringList const_block_nodes;
for (size_t i = 0; i < num_nodes; i++) {
nodes << QString(nd[i].name);
nodes.append(QString(nd[i].name));
if (nd[i].type == BLOCK_CONSTANT) {
const_block_nodes.append(nd[i].name);
}
}
frontend_free_node_data(nd, num_nodes);
emit(gotNodes(nodes));
}
}
ControlWorker::getParams(QString node)
void ControlWorker::getParams(QString node)
{
if (conn) {
frontend_node_data * nd = NULL;
......@@ -56,16 +56,52 @@ ControlWorker::getParams(QString node)
for (size_t i = 0; i < num_nodes; i++) {
if (QString(nd[i].name) == node) {
QStringList params;
// TODO: Get list of params based on node type
/* Get type definition */
const struct graph_node_type * type = blockDefs[nd[i].type];
/* Iterate through param names to append, and then emit signal */
for (ssize_t j = 0; j < type->n_params; j++) {
params.append(QString(type->param_names[j]));
}
emit(gotParams(params));
}
}
fontend_free_node_data(nd, num_nodes);
frontend_free_node_data(nd, num_nodes);
}
}
ControlWorker::getParamValue(QString node, QString param)
void ControlWorker::getParamValue(QString node, QString param)
{
if (conn) {
frontend_node_data * nd = NULL;
size_t num_nodes = 0;
frontend_getnodes(conn, &nd, &num_nodes);
for (size_t i = 0; i < num_nodes; i++) {
if (QString(nd[i].name) == node) {
frontend_param_data pd;
pd.block = nd[i].block;
/* Get the type definition, then iterate through to find the param */
const struct graph_node_type * type = blockDefs[nd[i].type];
for (ssize_t j = 0; j < type->n_params; j++) {
/* Found param */
if (QString(type->param_names[j]) == param) {
/* Set pd.param and finish the job */
pd.param = j;
frontend_getparam(conn, &pd);
emit(gotParamValue(pd.value));
}
}
}
}
frontend_free_node_data(nd, num_nodes);
}
}
void ControlWorker::setParamValue(QString node, QString param, float value)
{
if (conn) {
frontend_node_data * nd = NULL;
......@@ -76,11 +112,18 @@ ControlWorker::getParamValue(QString node, QString param)
if (QString(nd[i].name) == node) {
frontend_param_data pd;
pd.block = nd[i].block;
pd.param = 0; //TODO: Map string param to param ID based on block type? (Might not be needed...)
frontend_getparam(conn, &pd);
emit(gotParamValue(pd.value));
const struct graph_node_type * type = blockDefs[nd[i].type];
for (ssize_t j = 0; j < type->n_params; j++) {
if (QString(type->param_names[j]) == param) {
pd.param = j;
pd.value = value;
frontend_setparam(conn, &pd);
emit(paramSet(node, param));
}
}
}
}
fontend_free_node_data(nd, num_nodes);
frontend_free_node_data(nd, num_nodes);
}
}
......@@ -2,6 +2,7 @@
#define CONTROLWORKER_H
#include <QObject>
#include <QStringList>
#include "frontend_common.h"
class ControlWorker : public QObject
......@@ -9,11 +10,14 @@ class ControlWorker : public QObject
Q_OBJECT
public:
explicit ControlWorker(QObject *parent = 0);
~ControlWorker();
signals:
void gotNodes(QStringList nodes);
void gotParams(QStringList params);
void gotParamValue(float value);
void gotConstantBlocks(QStringList blocks);
void paramSet(QString node, QString param);
public slots:
void connectBackend();
......@@ -21,7 +25,7 @@ public slots:
void getNodes();
void getParams(QString node);
void getParamValue(QString node, QString param);
void setParamValue(QString node, QString name, float value);
private:
struct backend_conn * conn;
......
......@@ -7,6 +7,7 @@
#include "wrappers.h"
#include "trackerworker.h"
#include "controlworker.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
......@@ -35,6 +36,19 @@ MainWindow::MainWindow(QWidget *parent) :
ControlWorker * controlWorker = new ControlWorker();
controlWorker->moveToThread(cwThread);
/* Connect signals from control worker */
connect(controlWorker, SIGNAL (gotNodes(QStringList)), this, SLOT (newNodes(QStringList)));
connect(controlWorker, SIGNAL (gotParams(QStringList)), this, SLOT (newParams(QStringList)));
connect(controlWorker, SIGNAL (gotParamValue(float)), this, SLOT (newParamValue(float)));
connect(controlWorker, SIGNAL (gotConstantBlocks(QStringList)), this, SLOT (newConstantBlocks(QStringList)));
connect(controlWorker, SIGNAL (paramSet(QString, QString)), controlWorker, SLOT (getParamValue(QString, QString)));
/* Signals to control worker */
connect(findChild<QPushButton *>("pbControlRefresh"), SIGNAL (clicked()), controlWorker, SLOT (getNodes()));
connect(findChild<QComboBox *>("nodeSelect"), SIGNAL (currentIndexChanged(QString)), controlWorker, SLOT (getParams(QString)));
connect(this, SIGNAL (getParamValue(QString, QString)), controlWorker, SLOT (getParamValue(QString, QString)));
connect(this, SIGNAL (setParamValue(QString, QString, float)), controlWorker, SLOT (setParamValue(QString, QString, float)));
/* Connect and disconnect from backend when signals emitted */
connect(this, SIGNAL (connectWorkers()), trackerWorker, SLOT (connectBackend()));
connect(this, SIGNAL (disconnectWorkers()), trackerWorker, SLOT (disconnectBackend()));
......@@ -49,9 +63,7 @@ MainWindow::MainWindow(QWidget *parent) :
/* Start the things */
trackerTimer->start(300);
workerThread->start();
/* Create a timer to poll stdout and populate virtual console */
QTimer * consoleTimer = new QTimer(this);
cwThread->start();
}
MainWindow::~MainWindow()
......@@ -65,9 +77,7 @@ void MainWindow::updateConsole()
char buf[256];
size_t len = 0;
len = readBackend(backendPipe, buf, len);
printf("%d\n", len);
if (len > 0) {
printf("From pipe: %s", buf);
QLineEdit * con = findChild<QLineEdit *>("vConsole");
con->setText(con->text().append(buf));
}
......@@ -121,3 +131,51 @@ void MainWindow::on_chooseBackend_clicked()
tr("Path to Backend Executable"));
findChild<QLineEdit *>("backendPath")->setText(backendPath);
}
void MainWindow::newNodes(QStringList blocks)
{
QComboBox * select = findChild<QComboBox *>("nodeSelect");
select->clear(); /* Hopefully this clears the list */
select->addItems(blocks);
}
void MainWindow::newConstantBlocks(QStringList blocks)
{
QComboBox * select = findChild<QComboBox *>("xSetpointSelect");
select->clear(); /* Hopefully this clears the list */
select->addItems(blocks);
select = findChild<QComboBox *>("ySetpointSelect");
select->clear(); /* Hopefully this clears the list */
select->addItems(blocks);
select = findChild<QComboBox *>("zSetpointSelect");
select->clear(); /* Hopefully this clears the list */
select->addItems(blocks);
}
void MainWindow::newParams(QStringList params)
{
QComboBox * select = findChild<QComboBox *>("paramSelect");
select->clear(); /* Hopefully this clears the list */
select->addItems(params);
}
void MainWindow::newParamValue(float val)
{
findChild<QLineEdit *>("paramValue")->setText(QString::number(val));
}
void MainWindow::on_paramSelect_currentIndexChanged(const QString &arg1)
{
emit(getParamValue(findChild<QComboBox *>("nodeSelect")->currentText(), arg1));
}
void MainWindow::on_paramValue_returnPressed()
{
emit (setParamValue(findChild<QComboBox *>("nodeSelect")->currentText(),
findChild<QComboBox *>("paramSelect")->currentText(),
findChild<QLineEdit *>("paramValue")->text().toFloat()));
}
......@@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStringList>
namespace Ui {
class MainWindow;
......@@ -18,6 +19,8 @@ public:
signals:
void connectWorkers();
void disconnectWorkers();
void getParamValue(QString node, QString param);
void setParamValue(QString node, QString param, float value);
private slots:
void on_pbStart_clicked();
......@@ -32,6 +35,15 @@ private slots:
void updateConsole();
void newNodes(QStringList blocks);
void newParams(QStringList params);
void newParamValue(float val);
void newConstantBlocks(QStringList blocks);
void on_paramSelect_currentIndexChanged(const QString &arg1);
void on_paramValue_returnPressed();
private:
Ui::MainWindow *ui;
pid_t backendPid;
......
......@@ -30,7 +30,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="backend">
<attribute name="title">
......@@ -327,20 +327,34 @@
<widget class="QComboBox" name="paramSelect"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QLineEdit" name="paramValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Value:</string>
<string>X Setpoint</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="paramValue">
<widget class="QComboBox" name="xSetpointSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -349,6 +363,38 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Y Setpoint</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="ySetpointSelect"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Z Setpoint</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="zSetpointSelect"/>
</item>
</layout>
</item>
<item>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment