-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
94 lines (76 loc) · 2.33 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QHostAddress>
#include <QAbstractSocket>
#include <QNetworkInterface>
#include <QObject>
#include <QTimer>
#include <iostream>
#include <fstream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
HandleFullScreen* key = new HandleFullScreen(this);
installEventFilter(key);
QPixmap pix(":/res/test.jpeg");
ui->label_pic->setPixmap(pix);
// This shouldn't be needed, but just in case
ui->label_pic->setScaledContents(true);
QPixmap logo_pix(":/res/aeronu640x120.png");
ui->logo->setPixmap(logo_pix);
// This shouldn't be needed, but just in case
ui->logo->setScaledContents(true);
MainWindow::red = new QPixmap(":/res/red.png");
MainWindow::green = new QPixmap(":/res/green.png");
ui->label_comm_status->setPixmap(*green);
ui->label_mov_status->setAlignment(Qt::AlignRight);
ui->label_mov_status->setPixmap(*red);
ui->label_col_status->setPixmap(*red);
QList<QHostAddress> list = QNetworkInterface::allAddresses();
for(int nIter=0; nIter<list.count(); nIter++)
{
if(!list[nIter].isLoopback())
if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol )
ui->ip_label->setText(ui->ip_label->text() + list[nIter].toString() + " ");
}
ui->pid_label->setText("PID: " + QString::number(QCoreApplication::applicationPid()));
timer = new QTimer(this);
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(check_buttons()));
timer->start(50);
}
MainWindow::~MainWindow()
{
delete ui;
delete red;
delete green;
}
void MainWindow::on_pushButton_clicked()
{
Communication comm;
comm.Move();
ui->label_mov_status->setPixmap(*green);
}
void MainWindow::on_pushButton_2_clicked()
{
Communication comm;
comm.Collect();
ui->label_col_status->setPixmap(*green);
}
void MainWindow::check_buttons()
{
system("sudo ./check_gpio.sh");
if (is_file_exist("./comm/gpio4high"))
{
on_pushButton_clicked();
} else if (is_file_exist("./comm/gpio3high")) {
on_pushButton_2_clicked();
}
}
bool MainWindow::is_file_exist(const char *file_name)
{
std::ifstream f(file_name);
return f.good();
}