Remove some older junk code, add ability for main screen to show the number of connected buses
This commit is contained in:
@@ -40,6 +40,7 @@ void CANConManager::add(CANConnection* pConn_p)
|
|||||||
{
|
{
|
||||||
connect(pConn_p, SIGNAL(notify()), this, SLOT(refreshCanList()));
|
connect(pConn_p, SIGNAL(notify()), this, SLOT(refreshCanList()));
|
||||||
mConns.append(pConn_p);
|
mConns.append(pConn_p);
|
||||||
|
emit connectionStatusUpdated(getNumBuses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ void CANConManager::remove(CANConnection* pConn_p)
|
|||||||
{
|
{
|
||||||
disconnect(pConn_p, 0, this, 0);
|
disconnect(pConn_p, 0, this, 0);
|
||||||
mConns.removeOne(pConn_p);
|
mConns.removeOne(pConn_p);
|
||||||
|
emit connectionStatusUpdated(getNumBuses());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get total number of buses currently registered with the program
|
//Get total number of buses currently registered with the program
|
||||||
@@ -169,7 +171,6 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
|
|||||||
|
|
||||||
bool CANConManager::sendFrames(const QList<CANFrame>& pFrames)
|
bool CANConManager::sendFrames(const QList<CANFrame>& pFrames)
|
||||||
{
|
{
|
||||||
qDebug() << "CANConManager sendFrames #" << pFrames.count();
|
|
||||||
foreach(const CANFrame& frame, pFrames)
|
foreach(const CANFrame& frame, pFrames)
|
||||||
{
|
{
|
||||||
if(!sendFrame(frame))
|
if(!sendFrame(frame))
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void framesReceived(CANConnection* pConn_p, QVector<CANFrame>& pFrames);
|
void framesReceived(CANConnection* pConn_p, QVector<CANFrame>& pFrames);
|
||||||
|
void connectionStatusUpdated(int conns);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshCanList();
|
void refreshCanList();
|
||||||
|
|||||||
@@ -135,10 +135,8 @@ void CANConnectionModel::add(CANConnection* pConn_p)
|
|||||||
{
|
{
|
||||||
CANConManager* manager = CANConManager::getInstance();
|
CANConManager* manager = CANConManager::getInstance();
|
||||||
|
|
||||||
connect(pConn_p, SIGNAL(notify()), manager, SLOT(refreshCanList()));
|
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
manager->getConnections().append(pConn_p);
|
manager->add(pConn_p);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,10 +145,8 @@ void CANConnectionModel::remove(CANConnection* pConn_p)
|
|||||||
{
|
{
|
||||||
CANConManager* manager = CANConManager::getInstance();
|
CANConManager* manager = CANConManager::getInstance();
|
||||||
|
|
||||||
disconnect(pConn_p, 0, manager, 0);
|
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
manager->getConnections().removeOne(pConn_p);
|
manager->remove(pConn_p);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include "connectionwindow.h"
|
#include "connectionwindow.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "ui_connectionwindow.h"
|
#include "ui_connectionwindow.h"
|
||||||
#include "connections/canconfactory.h"
|
#include "connections/canconfactory.h"
|
||||||
#include "connections/canconmanager.h"
|
#include "connections/canconmanager.h"
|
||||||
|
|||||||
+7
-57
@@ -131,7 +131,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, model, &CANFrameModel::addFrames);
|
connect(CANConManager::getInstance(), &CANConManager::framesReceived, model, &CANFrameModel::addFrames);
|
||||||
|
|
||||||
lbStatusConnected.setText(tr("Not connected"));
|
lbStatusConnected.setText(tr("Connected to 0 buses"));
|
||||||
updateFileStatus();
|
updateFileStatus();
|
||||||
lbStatusDatabase.setText(tr("No DBC database loaded"));
|
lbStatusDatabase.setText(tr("No DBC database loaded"));
|
||||||
ui->statusBar->addWidget(&lbStatusConnected);
|
ui->statusBar->addWidget(&lbStatusConnected);
|
||||||
@@ -163,9 +163,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
qDebug() << "normal row height = " << normalRowHeight;
|
qDebug() << "normal row height = " << normalRowHeight;
|
||||||
model->clearFrames();
|
model->clearFrames();
|
||||||
|
|
||||||
|
//connect(CANConManager::getInstance(), CANConManager::connectionStatusUpdated, this, MainWindow::connectionStatusUpdated);
|
||||||
|
connect(CANConManager::getInstance(), SIGNAL(connectionStatusUpdated(int)), this, SLOT(connectionStatusUpdated(int)));
|
||||||
|
|
||||||
//Automatically create the connection window so it can be updated even if we never opened it.
|
//Automatically create the connection window so it can be updated even if we never opened it.
|
||||||
connectionWindow = new ConnectionWindow();
|
connectionWindow = new ConnectionWindow();
|
||||||
connect(this, SIGNAL(suspendCapturing(bool)), connectionWindow, SLOT(setSuspendAll(bool)));
|
connect(this, SIGNAL(suspendCapturing(bool)), connectionWindow, SLOT(setSuspendAll(bool)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -720,41 +724,9 @@ void MainWindow::toggleCapture()
|
|||||||
emit suspendCapturing(!allowCapture);
|
emit suspendCapturing(!allowCapture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::connectionSucceeded(int baud0, int baud1)
|
void MainWindow::connectionStatusUpdated(int conns)
|
||||||
{
|
{
|
||||||
lbStatusConnected.setText(tr("Connected to GVRET"));
|
lbStatusConnected.setText(tr("Connected to ") + QString::number(conns) + tr(" buses"));
|
||||||
//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
|
|
||||||
{
|
|
||||||
ui->cbSpeed1->addItem(QString::number(baud0));
|
|
||||||
ui->cbSpeed1->setCurrentIndex(ui->cbSpeed1->count() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
idx = ui->cbSpeed2->findText(QString::number(baud1));
|
|
||||||
if (idx > -1) ui->cbSpeed2->setCurrentIndex(idx);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->cbSpeed2->addItem(QString::number(baud1));
|
|
||||||
ui->cbSpeed2->setCurrentIndex(ui->cbSpeed2->count() - 1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (connectionWindow) connectionWindow->setSpeed(baud0);
|
|
||||||
//ui->btnConnect->setEnabled(false);
|
|
||||||
ui->actionConnect->setText(tr("Disconnect"));
|
|
||||||
isConnected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::connectionFailed()
|
|
||||||
{
|
|
||||||
lbStatusConnected.setText(tr("Failed to connect!"));
|
|
||||||
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText("Connection to the GVRET firmware failed.\nYou might have an old version of GVRET\nor may have chosen the wrong serial port.");
|
|
||||||
msgBox.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateFileStatus()
|
void MainWindow::updateFileStatus()
|
||||||
@@ -783,28 +755,6 @@ void MainWindow::updateFileStatus()
|
|||||||
lbStatusFilename.setText(output);
|
lbStatusFilename.setText(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::gotDeviceInfo(int build, int swCAN)
|
|
||||||
{
|
|
||||||
QString str = tr("Connected to GVRET ") + QString::number(build);
|
|
||||||
if (swCAN == 1) str += "(SW)";
|
|
||||||
lbStatusConnected.setText(str);
|
|
||||||
|
|
||||||
if (build < CURRENT_GVRET_VER)
|
|
||||||
{
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText("It appears that you are not running\nan up-to-date version of GVRET\n\nYour version: "
|
|
||||||
+ QString::number(build) +"\nCurrent Version: " + QString::number(CURRENT_GVRET_VER)
|
|
||||||
+ "\n\nPlease upgrade your firmware version.\nOtherwise, you may experience difficulties.");
|
|
||||||
msgBox.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connectionWindow)
|
|
||||||
{
|
|
||||||
if (swCAN == 1) connectionWindow->setSWMode(true);
|
|
||||||
else connectionWindow->setSWMode(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showSettingsDialog()
|
void MainWindow::showSettingsDialog()
|
||||||
{
|
{
|
||||||
if (!settingsDialog)
|
if (!settingsDialog)
|
||||||
|
|||||||
+1
-3
@@ -75,9 +75,7 @@ private slots:
|
|||||||
void showBisectWindow();
|
void showBisectWindow();
|
||||||
void exitApp();
|
void exitApp();
|
||||||
void handleSaveDecoded();
|
void handleSaveDecoded();
|
||||||
void connectionFailed();
|
void connectionStatusUpdated(int conns);
|
||||||
void gotDeviceInfo(int, int);
|
|
||||||
void connectionSucceeded(int, int);
|
|
||||||
void gridClicked(QModelIndex);
|
void gridClicked(QModelIndex);
|
||||||
void gridDoubleClicked(QModelIndex);
|
void gridDoubleClicked(QModelIndex);
|
||||||
void interpretToggled(bool);
|
void interpretToggled(bool);
|
||||||
|
|||||||
Reference in New Issue
Block a user