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

GUI work

Can start/stop backend
parent 0d8e89ad
No related branches found
No related tags found
No related merge requests found
test.log
\ No newline at end of file
test.log
groundStation/gui/build*
.gdb_history
......@@ -13,8 +13,10 @@ TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
mainwindow.cpp \
wrappers.c
HEADERS += mainwindow.h
HEADERS += mainwindow.h \
wrappers.h
FORMS += mainwindow.ui
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "wrappers.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
......@@ -12,3 +14,27 @@ MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pbStart_clicked()
{
this->backendPid = startBackend();
findChild<QPushButton *>("pbStart")->setEnabled(false);
findChild<QPushButton *>("pbConnect")->setEnabled(false);
findChild<QPushButton *>("pbStop")->setEnabled(true);
}
void MainWindow::on_pbConnect_clicked()
{
// TODO: Connect to existing backend (what is connected?)
findChild<QPushButton *>("pbStart")->setEnabled(false);
findChild<QPushButton *>("pbConnect")->setEnabled(false);
findChild<QPushButton *>("pbStop")->setEnabled(true);
}
void MainWindow::on_pbStop_clicked()
{
stopBackend(backendPid);
findChild<QPushButton *>("pbStart")->setEnabled(true);
//findChild<QPushButton *>("pbConnect")->setEnabled(true);
findChild<QPushButton *>("pbStop")->setEnabled(false);
}
......@@ -15,8 +15,17 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pbStart_clicked();
void on_pbConnect_clicked();
void on_pbStop_clicked();
private:
Ui::MainWindow *ui;
pid_t backendPid;
int backendState;
};
#endif // MAINWINDOW_H
......@@ -54,6 +54,9 @@
</item>
<item>
<widget class="QPushButton" name="pbConnect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Connect</string>
</property>
......
#include "wrappers.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
int stopBackend(int pid)
{
kill(pid, SIGTERM);
int status;
wait(&status);
return status;
}
int startBackend()
{
int pid = fork();
if (!pid) {
// TODO: Make dynamic
// TODO: Redirect stdout to pipe to GUI
execl("backEnd", "backEnd", NULL);
exit(0);
}
return pid;
}
#ifndef WRAPPERS_H
#define WRAPPERS_H
#ifdef __cplusplus
extern "C"
{
#endif
int startBackend(void);
int stopBackend(int pid);
#ifdef __cplusplus
}
#endif
#endif // WRAPPERS_H
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