Skip to content
Snippets Groups Projects
Commit 8a5eba17 authored by C-Glick's avatar C-Glick
Browse files

Added colors to logging variable selectors

parent 55399f2c
No related branches found
No related tags found
1 merge request!77Groundstation gui rough edits
...@@ -8,12 +8,15 @@ crazyflieworker.h ...@@ -8,12 +8,15 @@ crazyflieworker.h
gamepadmonitor.cpp gamepadmonitor.cpp
gamepadmonitor.h gamepadmonitor.h
gridlines.gif gridlines.gif
logworker.cpp
logworker.h
main.cpp main.cpp
mainwindow.cpp mainwindow.cpp
mainwindow.h mainwindow.h
mainwindow.ui mainwindow.ui
moc_controlworker.cpp moc_controlworker.cpp
moc_crazyflieworker.cpp moc_crazyflieworker.cpp
moc_logworker.cpp
moc_mainwindow.cpp moc_mainwindow.cpp
moc_predefs.h moc_predefs.h
moc_qFlightInstruments.cpp moc_qFlightInstruments.cpp
......
...@@ -232,7 +232,7 @@ void MainWindow::on_pbStart_clicked() ...@@ -232,7 +232,7 @@ void MainWindow::on_pbStart_clicked()
void MainWindow::backendStarted() void MainWindow::backendStarted()
{ {
ui->pbStart->setEnabled(false); //ui->pbStart->setEnabled(false);
ui->pbStop->setEnabled(true); ui->pbStop->setEnabled(true);
workerStartTimer->start(750); workerStartTimer->start(750);
} }
...@@ -251,7 +251,7 @@ void MainWindow::workerConnected() ...@@ -251,7 +251,7 @@ void MainWindow::workerConnected()
{ {
connectedWorkers++; connectedWorkers++;
if (connectedWorkers == 2) { if (connectedWorkers == 2) {
ui->pbStart->setEnabled(false); //ui->pbStart->setEnabled(false);
ui->pbConnect->setEnabled(false); ui->pbConnect->setEnabled(false);
ui->pbStop->setEnabled(true); ui->pbStop->setEnabled(true);
ui->pb_logBlockRefresh->setEnabled(true); ui->pb_logBlockRefresh->setEnabled(true);
...@@ -266,7 +266,7 @@ void MainWindow::workerDisconnected() ...@@ -266,7 +266,7 @@ void MainWindow::workerDisconnected()
if (( connectedWorkers == 0) && (backendProcess->state() == QProcess::Running)) { if (( connectedWorkers == 0) && (backendProcess->state() == QProcess::Running)) {
backendProcess->terminate(); backendProcess->terminate();
} else if (connectedWorkers == 0) { } else if (connectedWorkers == 0) {
ui->pbStart->setEnabled(true); //ui->pbStart->setEnabled(true);
ui->pbConnect->setEnabled(true); ui->pbConnect->setEnabled(true);
ui->pbStop->setEnabled(false); ui->pbStop->setEnabled(false);
ui->pb_getParam->setEnabled(false); ui->pb_getParam->setEnabled(false);
...@@ -278,7 +278,7 @@ void MainWindow::workerDisconnected() ...@@ -278,7 +278,7 @@ void MainWindow::workerDisconnected()
void MainWindow::backendFinished(int exitCode, QProcess::ExitStatus exitStatus) void MainWindow::backendFinished(int exitCode, QProcess::ExitStatus exitStatus)
{ {
ui->pbStart->setEnabled(true); //ui->pbStart->setEnabled(true);
ui->pbConnect->setEnabled(true); ui->pbConnect->setEnabled(true);
ui->pbStop->setEnabled(false); ui->pbStop->setEnabled(false);
} }
...@@ -632,22 +632,25 @@ void MainWindow::on_gamepadPitchScale_valueChanged(int arg1) ...@@ -632,22 +632,25 @@ void MainWindow::on_gamepadPitchScale_valueChanged(int arg1)
void MainWindow::graphLogs(QStringList logs) void MainWindow::graphLogs(QStringList logs)
{ {
// qInfo() << "start" << endl;
ui->dataPlot->addGraph(); ui->dataPlot->addGraph();
ui->dataPlot->addGraph(); ui->dataPlot->addGraph();
ui->dataPlot->addGraph(); ui->dataPlot->addGraph();
ui->dataPlot->addGraph(); ui->dataPlot->addGraph();
ui->dataPlot->addGraph(); ui->dataPlot->addGraph();
//set colors
ui->dataPlot->graph(0)->setPen(QPen(Qt::blue, 2)); ui->dataPlot->graph(0)->setPen(QPen(Qt::blue, 2));
ui->dataPlot->graph(1)->setPen(QPen(Qt::red, 2)); ui->dataPlot->graph(1)->setPen(QPen(Qt::red, 2));
ui->dataPlot->graph(2)->setPen(QPen(Qt::green, 2)); ui->dataPlot->graph(2)->setPen(QPen(Qt::green, 2));
ui->dataPlot->graph(3)->setPen(QPen(Qt::black, 2)); ui->dataPlot->graph(3)->setPen(QPen(Qt::black, 2));
ui->dataPlot->graph(4)->setPen(QPen(Qt::yellow, 2)); ui->dataPlot->graph(4)->setPen(QPen(Qt::darkMagenta, 2));
// qInfo() << "color" << endl;
ui->logEntriesComboBox1->setStyleSheet("QComboBox { color: blue; }");
ui->logEntriesComboBox2->setStyleSheet("QComboBox { color: red; }");
ui->logEntriesComboBox3->setStyleSheet("QComboBox { color: green; }");
ui->logEntriesComboBox4->setStyleSheet("QComboBox { color: black; }");
ui->logEntriesComboBox5->setStyleSheet("QComboBox { color: darkMagenta; }");
//parse data and put into vector //parse data and put into vector
QVector<double> x0(logs.size()), y0(logs.size()); QVector<double> x0(logs.size()), y0(logs.size());
QVector<double> x1(logs.size()), y1(logs.size()); QVector<double> x1(logs.size()), y1(logs.size());
...@@ -655,12 +658,9 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -655,12 +658,9 @@ void MainWindow::graphLogs(QStringList logs)
QVector<double> x3(logs.size()), y3(logs.size()); QVector<double> x3(logs.size()), y3(logs.size());
QVector<double> x4(logs.size()), y4(logs.size()); QVector<double> x4(logs.size()), y4(logs.size());
// qInfo() << "vector size" << endl;
QVector<std::string> tempConv; QVector<std::string> tempConv;
for(int i=0; i<logs.size(); i++) { for(int i=0; i<logs.size(); i++) {
// qInfo() << "i:" << i << endl;
tempConv.append(logs.at(i).toStdString()); tempConv.append(logs.at(i).toStdString());
} }
// qInfo() << QString::fromStdString(tempConv.at(0)) << endl; // qInfo() << QString::fromStdString(tempConv.at(0)) << endl;
...@@ -695,7 +695,12 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -695,7 +695,12 @@ void MainWindow::graphLogs(QStringList logs)
// qInfo() << QString::fromStdString(tokens[5]) << endl; // qInfo() << QString::fromStdString(tokens[5]) << endl;
//assign x and y values for log variables //assign x and y values for log variables
if(tokens[1] != "NULL") { if(tokens[1] == "nan"){
//do not include point
}else if(tokens[1] == "NULL"){
//disable this variable if encounter "NULL"
log0 = false;
}else {
x0[i] = std::stod(tokens[0]); x0[i] = std::stod(tokens[0]);
y0[i] = std::stod(tokens[1]); y0[i] = std::stod(tokens[1]);
if(y0[i]<ymin) { if(y0[i]<ymin) {
...@@ -711,13 +716,14 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -711,13 +716,14 @@ void MainWindow::graphLogs(QStringList logs)
xmin = x0[i]; xmin = x0[i];
} }
} }
else { qInfo() << ymin << endl;
log0 = false;
}
// qInfo() << ymin << endl;
if(tokens[2] != "NULL") { if(tokens[2] == "nan"){
//do not include point
}else if(tokens[2] == "NULL"){
//disable this variable if encounter "NULL"
log1 = false;
}else {
x1[i] = std::stod(tokens[0]); x1[i] = std::stod(tokens[0]);
y1[i] = std::stod(tokens[2]); y1[i] = std::stod(tokens[2]);
if(y1[i]<ymin) { if(y1[i]<ymin) {
...@@ -733,10 +739,13 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -733,10 +739,13 @@ void MainWindow::graphLogs(QStringList logs)
xmin = x0[i]; xmin = x0[i];
} }
} }
else {
log1 = false; if(tokens[3] == "nan"){
} //do not include point
if(tokens[3] != "NULL") { }else if(tokens[3] == "NULL"){
//disable this variable if encounter "NULL"
log2 = false;
}else {
x2[i] = std::stod(tokens[0]); x2[i] = std::stod(tokens[0]);
y2[i] = std::stod(tokens[3]); y2[i] = std::stod(tokens[3]);
if(y2[i]<ymin) { if(y2[i]<ymin) {
...@@ -752,10 +761,13 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -752,10 +761,13 @@ void MainWindow::graphLogs(QStringList logs)
xmin = x0[i]; xmin = x0[i];
} }
} }
else {
log2 = false; if(tokens[4] == "nan"){
} //do not include point
if(tokens[4] != "NULL") { }else if(tokens[4] == "NULL"){
//disable this variable if encounter "NULL"
log3 = false;
}else {
x3[i] = std::stod(tokens[0]); x3[i] = std::stod(tokens[0]);
y3[i] = std::stod(tokens[4]); y3[i] = std::stod(tokens[4]);
if(y3[i]<ymin) { if(y3[i]<ymin) {
...@@ -771,10 +783,14 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -771,10 +783,14 @@ void MainWindow::graphLogs(QStringList logs)
xmin = x0[i]; xmin = x0[i];
} }
} }
else {
log3 = false;
} if(tokens[5] == "nan"){
if(tokens[5] != "NULL") { //do not include point
}else if(tokens[5] == "NULL"){
//disable this variable if encounter "NULL"
log4 = false;
}else {
x4[i] = std::stod(tokens[0]); x4[i] = std::stod(tokens[0]);
y4[i] = std::stod(tokens[5]); y4[i] = std::stod(tokens[5]);
if(y4[i]<ymin) { if(y4[i]<ymin) {
...@@ -790,10 +806,6 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -790,10 +806,6 @@ void MainWindow::graphLogs(QStringList logs)
xmin = x0[i]; xmin = x0[i];
} }
} }
else {
log4 = false;
}
// qInfo() << "i: " << i << endl;
} }
// qInfo() << "yMin: " << ymin << endl; // qInfo() << "yMin: " << ymin << endl;
...@@ -820,7 +832,7 @@ void MainWindow::graphLogs(QStringList logs) ...@@ -820,7 +832,7 @@ void MainWindow::graphLogs(QStringList logs)
} }
//set lables and boundaries //set lables and boundaries
ui->dataPlot->xAxis->setLabel("Time"); ui->dataPlot->xAxis->setLabel("Time (s)");
ui->dataPlot->yAxis->setLabel("Value"); ui->dataPlot->yAxis->setLabel("Value");
ui->dataPlot->xAxis->setRange(xmin, xmax); ui->dataPlot->xAxis->setRange(xmin, xmax);
ui->dataPlot->yAxis->setRange(ymin, ymax); ui->dataPlot->yAxis->setRange(ymin, ymax);
...@@ -879,6 +891,7 @@ void MainWindow::setLogButtons(bool isEnabled) { ...@@ -879,6 +891,7 @@ void MainWindow::setLogButtons(bool isEnabled) {
} }
void MainWindow::fillLogVariablesBox(QStringList activeVars) { void MainWindow::fillLogVariablesBox(QStringList activeVars) {
ui->logEntriesComboBox1->setCurrentIndex(0); ui->logEntriesComboBox1->setCurrentIndex(0);
ui->logEntriesComboBox2->setCurrentIndex(0); ui->logEntriesComboBox2->setCurrentIndex(0);
ui->logEntriesComboBox3->setCurrentIndex(0); ui->logEntriesComboBox3->setCurrentIndex(0);
...@@ -1056,20 +1069,14 @@ void MainWindow::graphLogData(QStringList results) ...@@ -1056,20 +1069,14 @@ void MainWindow::graphLogData(QStringList results)
graphLogs(results); graphLogs(results);
} }
// void MainWindow::on_pb_startLog_clicked()
// {
// qInfo() << "Hello?" << endl;
// QStringList test = {"0,10,NULL,NULL,NULL,25","1,210,NULL,NULL,NULL,-10"};
// graphLogs(test);
// }
void MainWindow::receiveLogFile(QString filename) { void MainWindow::receiveLogFile(QString filename) {
emit(beginReadingLogFile(filename)); emit(beginReadingLogFile(filename));
} }
void MainWindow::sendStartLog() { void MainWindow::sendStartLog() {
ui->pb_stopLog->setEnabled(true);
ui->pb_startLog->setEnabled(false);
QString name1 = ui->logEntriesComboBox1->currentText(); QString name1 = ui->logEntriesComboBox1->currentText();
QString name2 = ui->logEntriesComboBox2->currentText(); QString name2 = ui->logEntriesComboBox2->currentText();
QString name3 = ui->logEntriesComboBox3->currentText(); QString name3 = ui->logEntriesComboBox3->currentText();
...@@ -1080,5 +1087,9 @@ void MainWindow::sendStartLog() { ...@@ -1080,5 +1087,9 @@ void MainWindow::sendStartLog() {
} }
void MainWindow::sendStopLog() { void MainWindow::sendStopLog() {
ui->pb_startLog->setEnabled(true);
ui->pb_stopLog->setEnabled(false);
logWorker->logFlag = 2; logWorker->logFlag = 2;
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="backend"> <widget class="QWidget" name="backend">
<attribute name="title"> <attribute name="title">
...@@ -66,16 +66,6 @@ ...@@ -66,16 +66,6 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pbStart">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="pbConnect"> <widget class="QPushButton" name="pbConnect">
<property name="enabled"> <property name="enabled">
...@@ -1198,6 +1188,9 @@ ...@@ -1198,6 +1188,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="logEntriesComboBox1"> <widget class="QComboBox" name="logEntriesComboBox1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentText"> <property name="currentText">
<string>Logging Variable 1</string> <string>Logging Variable 1</string>
</property> </property>
...@@ -1210,6 +1203,9 @@ ...@@ -1210,6 +1203,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="logEntriesComboBox2"> <widget class="QComboBox" name="logEntriesComboBox2">
<property name="enabled">
<bool>true</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Logging Variable 2</string> <string>Logging Variable 2</string>
...@@ -1219,6 +1215,9 @@ ...@@ -1219,6 +1215,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="logEntriesComboBox3"> <widget class="QComboBox" name="logEntriesComboBox3">
<property name="enabled">
<bool>true</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Logging Variable 3</string> <string>Logging Variable 3</string>
...@@ -1228,6 +1227,9 @@ ...@@ -1228,6 +1227,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="logEntriesComboBox4"> <widget class="QComboBox" name="logEntriesComboBox4">
<property name="enabled">
<bool>true</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Logging Variable 4</string> <string>Logging Variable 4</string>
...@@ -1237,6 +1239,9 @@ ...@@ -1237,6 +1239,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="logEntriesComboBox5"> <widget class="QComboBox" name="logEntriesComboBox5">
<property name="enabled">
<bool>true</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Logging Variable 5</string> <string>Logging Variable 5</string>
...@@ -1246,6 +1251,9 @@ ...@@ -1246,6 +1251,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pb_startLog"> <widget class="QPushButton" name="pb_startLog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>Start Logging</string> <string>Start Logging</string>
</property> </property>
...@@ -1253,6 +1261,9 @@ ...@@ -1253,6 +1261,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pb_stopLog"> <widget class="QPushButton" name="pb_stopLog">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Stop Logging</string> <string>Stop Logging</string>
</property> </property>
...@@ -1424,7 +1435,7 @@ ...@@ -1424,7 +1435,7 @@
<resources/> <resources/>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="AngleRateButtonGroup"/>
<buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_2"/>
<buttongroup name="AngleRateButtonGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>
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