Initial commit where connection window is active and it is possible to

connect to GVRET but this time through the connection window and the
menu option "Connect".
This commit is contained in:
Collin Kidder
2015-10-18 15:34:40 -04:00
parent 49f2525320
commit 4dc8c5b434
8 changed files with 129 additions and 154 deletions
+6 -3
View File
@@ -36,7 +36,8 @@ SOURCES += main.cpp\
filecomparatorwindow.cpp \
mainsettingsdialog.cpp \
firmwareuploaderwindow.cpp \
discretestatewindow.cpp
discretestatewindow.cpp \
connectionwindow.cpp
HEADERS += mainwindow.h \
can_structs.h \
@@ -61,7 +62,8 @@ HEADERS += mainwindow.h \
filecomparatorwindow.h \
mainsettingsdialog.h \
firmwareuploaderwindow.h \
discretestatewindow.h
discretestatewindow.h \
connectionwindow.h
FORMS += mainwindow.ui \
graphingwindow.ui \
@@ -76,7 +78,8 @@ FORMS += mainwindow.ui \
filecomparatorwindow.ui \
mainsettingsdialog.ui \
firmwareuploaderwindow.ui \
discretestatewindow.ui
discretestatewindow.ui \
connectionwindow.ui
DISTFILES +=
+15
View File
@@ -24,6 +24,8 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
ui->cbSpeed1->addItem(tr("500000"));
ui->cbSpeed1->addItem(tr("1000000"));
ui->cbSpeed1->addItem(tr("33333"));
connect(ui->btnOK, SIGNAL(clicked(bool)), this, SLOT(handleOKButton()));
}
ConnectionWindow::~ConnectionWindow()
@@ -40,6 +42,19 @@ void ConnectionWindow::showEvent(QShowEvent* event)
if (ui->rbSocketCAN->isChecked()) getSocketcanPorts();
}
void ConnectionWindow::handleOKButton()
{
QString conn;
if (ui->rbGVRET->isChecked()) conn = "GVRET";
if (ui->rbKvaser->isChecked()) conn = "KVASER";
if (ui->rbSocketCAN->isChecked()) conn = "SOCKETCAN";
emit updateConnectionSettings(conn, getPortName(), getSpeed0(), getSpeed1());
this->close();
}
void ConnectionWindow::getSerialPorts()
{
ui->cbPort->clear();
+4 -1
View File
@@ -33,11 +33,14 @@ public:
ConnectionType::ConnectionType getConnectionType();
signals:
void updateConnectionSettings();
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
public slots:
void setSpeeds(int speed0, int speed1);
private slots:
void handleOKButton();
private:
Ui::ConnectionWindow *ui;
QList<QSerialPortInfo> ports;
+1 -1
View File
@@ -99,7 +99,7 @@
<item>
<widget class="QPushButton" name="btnOK">
<property name="text">
<string>OK</string>
<string>Update Settings</string>
</property>
</widget>
</item>
+75 -49
View File
@@ -63,26 +63,6 @@ MainWindow::MainWindow(QWidget *parent) :
//enabling the below line kills performance in every way imaginable. Left here as a warning. Do not do this.
//ui->canFramesView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ports = QSerialPortInfo::availablePorts();
for (int i = 0; i < ports.count(); i++)
{
ui->cbSerialPorts->addItem(ports[i].portName());
}
ui->cbSpeed1->addItem(tr("Disabled"));
ui->cbSpeed1->addItem(tr("125000"));
ui->cbSpeed1->addItem(tr("250000"));
ui->cbSpeed1->addItem(tr("500000"));
ui->cbSpeed1->addItem(tr("1000000"));
ui->cbSpeed1->addItem(tr("33333"));
ui->cbSpeed2->addItem(tr("Disabled"));
ui->cbSpeed2->addItem(tr("125000"));
ui->cbSpeed2->addItem(tr("250000"));
ui->cbSpeed2->addItem(tr("500000"));
ui->cbSpeed2->addItem(tr("1000000"));
ui->cbSpeed2->addItem(tr("33333"));
worker = new SerialWorker(model);
worker->moveToThread(&serialWorkerThread);
connect(&serialWorkerThread, &QThread::finished, worker, &QObject::deleteLater);
@@ -110,13 +90,13 @@ MainWindow::MainWindow(QWidget *parent) :
settingsDialog = NULL;
firmwareUploaderWindow = NULL;
discreteStateWindow = NULL;
connectionWindow = NULL;
dbcHandler = new DBCHandler;
bDirty = false;
inhibitFilterUpdate = false;
model->setDBCHandler(dbcHandler);
connect(ui->btnConnect, SIGNAL(clicked(bool)), this, SLOT(connButtonPress()));
connect(ui->actionOpen_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleLoadFile()));
connect(ui->actionGraph_Dta, SIGNAL(triggered(bool)), this, SLOT(showGraphingWindow()));
connect(ui->actionFrame_Data_Analysis, SIGNAL(triggered(bool)), this, SLOT(showFrameDataAnalysis()));
@@ -126,7 +106,6 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->actionLoad_Filter_Definition, SIGNAL(triggered(bool)), this, SLOT(handleLoadFilters()));
connect(ui->actionSave_Filter_Definition, SIGNAL(triggered(bool)), this, SLOT(handleSaveFilters()));
connect(ui->action_Playback, SIGNAL(triggered(bool)), this, SLOT(showPlaybackWindow()));
connect(ui->btnBaudSet, SIGNAL(clicked(bool)), this, SLOT(changeBaudRates()));
connect(ui->actionFlow_View, SIGNAL(triggered(bool)), this, SLOT(showFlowViewWindow()));
connect(ui->action_Custom, SIGNAL(triggered(bool)), this, SLOT(showFrameSenderWindow()));
connect(ui->actionLoad_DBC_File, SIGNAL(triggered(bool)), this, SLOT(handleLoadDBC()));
@@ -150,6 +129,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->btnFilterAll, SIGNAL(clicked(bool)), this, SLOT(filterSetAll()));
connect(ui->btnFilterNone, SIGNAL(clicked(bool)), this, SLOT(filterClearAll()));
connect(ui->actionFirmware_Uploader, SIGNAL(triggered(bool)), this, SLOT(showFirmwareUploaderWindow()));
connect(ui->actionSetup, SIGNAL(triggered(bool)), SLOT(showConnectionSettingsWindow()));
connect(ui->actionConnect, SIGNAL(triggered(bool)), this, SLOT(connButtonPress()));
lbStatusConnected.setText(tr("Not connected"));
updateFileStatus();
@@ -237,6 +218,12 @@ MainWindow::~MainWindow()
delete discreteStateWindow;
}
if (connectionWindow)
{
connectionWindow->close();
delete connectionWindow;
}
delete ui;
delete dbcHandler;
model->clearFrames();
@@ -293,6 +280,56 @@ void MainWindow::writeSettings()
}
}
void MainWindow::updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1)
{
connType = connectionType;
portName = port;
canSpeed0 = speed0;
canSpeed1 = speed1;
if (isConnected)
{
emit updateBaudRates(speed0, speed1);
}
}
void MainWindow::connButtonPress()
{
if (!isConnected)
{
if (connType == "GVRET")
{
QList<QSerialPortInfo> ports;
ports = QSerialPortInfo::availablePorts();
for (int i = 0; i < ports.count(); i++)
{
if (ports[i].portName() == portName)
{
portInfo = ports[i];
emit sendSerialPort(&portInfo);
lbStatusConnected.setText(tr("Attempting to connect to port ") + portName);
}
}
}
else if (connType == "KVASER")
{
}
else if (connType == "SOCKETCAN")
{
}
}
else
{
emit closeSerialPort();
isConnected = false;
lbStatusConnected.setText(tr("Not Connected"));
ui->actionConnect->setText(tr("Connect"));
}
}
void MainWindow::gridClicked(QModelIndex idx)
{
if (ui->canFramesView->rowHeight(idx.row()) > normalRowHeight)
@@ -437,8 +474,8 @@ void MainWindow::changeBaudRates()
{
int Speed1 = 0, Speed2 = 0;
Speed1 = ui->cbSpeed1->currentText().toInt();
Speed2 = ui->cbSpeed2->currentText().toInt();
//Speed1 = ui->cbSpeed1->currentText().toInt();
//Speed2 = ui->cbSpeed2->currentText().toInt();
emit updateBaudRates(Speed1, Speed2);
}
@@ -804,29 +841,6 @@ Data Bytes: 88 10 00 13 BB 00 06 00
outFile->close();
}
void MainWindow::connButtonPress()
{
if (!isConnected)
{
for (int x = 0; x < ports.count(); x++)
{
if (ports.at(x).portName() == ui->cbSerialPorts->currentText())
{
emit sendSerialPort(&ports[x]);
lbStatusConnected.setText(tr("Attempting to connect to port ") + ports[x].portName());
return;
}
}
}
else
{
emit closeSerialPort();
isConnected = false;
lbStatusConnected.setText(tr("Not Connected"));
ui->btnConnect->setText(tr("Connect to GVRET"));
}
}
void MainWindow::toggleCapture()
{
allowCapture = !allowCapture;
@@ -847,7 +861,7 @@ void MainWindow::connectionSucceeded(int baud0, int baud1)
lbStatusConnected.setText(tr("Connected to GVRET"));
//finally, find the baud rate in the list of rates or
//add it to the bottom if needed (that'll be weird though...
/*
int idx = ui->cbSpeed1->findText(QString::number(baud0));
if (idx > -1) ui->cbSpeed1->setCurrentIndex(idx);
else
@@ -863,8 +877,9 @@ void MainWindow::connectionSucceeded(int baud0, int baud1)
ui->cbSpeed2->addItem(QString::number(baud1));
ui->cbSpeed2->setCurrentIndex(ui->cbSpeed2->count() - 1);
}
*/
//ui->btnConnect->setEnabled(false);
ui->btnConnect->setText(tr("Disconnect from GVRET"));
ui->actionConnect->setText(tr("Disconnect"));
isConnected = true;
}
@@ -1038,6 +1053,7 @@ void MainWindow::exitApp()
if (frameSenderWindow) frameSenderWindow->close();
if (dbcMainEditor) dbcMainEditor->close();
if (comparatorWindow) comparatorWindow->close();
if (connectionWindow) connectionWindow->close();
this->close();
}
@@ -1071,3 +1087,13 @@ void MainWindow::showDBCEditor()
}
dbcMainEditor->show();
}
void MainWindow::showConnectionSettingsWindow()
{
if (!connectionWindow)
{
connectionWindow = new ConnectionWindow();
connect(connectionWindow, SIGNAL(updateConnectionSettings(QString,QString,int,int)), this, SLOT(updateConnectionSettings(QString,QString,int,int)));
}
connectionWindow->show();
}
+8 -2
View File
@@ -19,6 +19,7 @@
#include "mainsettingsdialog.h"
#include "firmwareuploaderwindow.h"
#include "discretestatewindow.h"
#include "connectionwindow.h"
namespace Ui {
class MainWindow;
@@ -56,6 +57,7 @@ private slots:
void showComparisonWindow();
void showSettingsDialog();
void showFirmwareUploaderWindow();
void showConnectionSettingsWindow();
void exitApp();
void handleSaveDecoded();
void changeBaudRates();
@@ -78,6 +80,7 @@ public slots:
void gotFrames(int, int);
void updateSettings();
void gotCenterTimeID(int32_t ID, double timestamp);
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
signals:
void sendSerialPort(QSerialPortInfo *port);
@@ -98,8 +101,7 @@ private:
//canbus related data
CANFrameModel *model;
DBCHandler *dbcHandler;
QList<QSerialPortInfo> ports;
DBCHandler *dbcHandler;
QThread serialWorkerThread;
SerialWorker *worker;
QByteArray inputBuffer;
@@ -121,6 +123,7 @@ private:
MainSettingsDialog *settingsDialog;
DiscreteStateWindow *discreteStateWindow;
FirmwareUploaderWindow *firmwareUploaderWindow;
ConnectionWindow *connectionWindow;
//various private storage
QLabel lbStatusConnected;
@@ -128,6 +131,9 @@ private:
QLabel lbStatusDatabase;
int normalRowHeight;
bool isConnected;
QSerialPortInfo portInfo;
QString connType, portName;
int canSpeed0, canSpeed1;
//private methods
void saveDecodedTextFile(QString);
+19 -97
View File
@@ -46,102 +46,6 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Serial Port</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSerialPorts"/>
</item>
<item>
<widget class="QPushButton" name="btnConnect">
<property name="text">
<string>Connect To GVRET</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CANBus Speeds:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>First Bus:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSpeed1"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>7</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Second Bus:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSpeed2"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="btnBaudSet">
<property name="text">
<string>Set CANBUS Speeds</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="sizePolicy">
@@ -293,7 +197,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menu_RE_Tools">
@@ -336,9 +240,17 @@
<addaction name="separator"/>
<addaction name="actionExit_Application"/>
</widget>
<widget class="QMenu" name="menuConnection">
<property name="title">
<string>Connection</string>
</property>
<addaction name="actionSetup"/>
<addaction name="actionConnect"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menu_RE_Tools"/>
<addaction name="menuSend_Frames"/>
<addaction name="menuConnection"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="action_Playback">
@@ -446,6 +358,16 @@
<string>Firmware Uploader</string>
</property>
</action>
<action name="actionSetup">
<property name="text">
<string>Setup</string>
</property>
</action>
<action name="actionConnect">
<property name="text">
<string>Connect</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
+1 -1
View File
@@ -69,7 +69,7 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port)
delete serial;
}
serial = new QSerialPort(*port);
serial = new QSerialPort(*port);
qDebug() << "Serial port name is " << port->portName();
//serial->setBaudRate(10000000); //more speed! probably does nothing for USB serial