Changed sending windows to use new system where there are arbitrary number of buses

This commit is contained in:
Collin Kidder
2016-12-08 20:21:42 -05:00
parent 2cfacc6519
commit ddfac100d2
9 changed files with 49 additions and 62 deletions
+23 -22
View File
@@ -4,6 +4,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMenu> #include <QMenu>
#include <QSettings> #include <QSettings>
#include "connections/canconmanager.h"
/* /*
* Notes about new functionality: * Notes about new functionality:
@@ -24,10 +25,10 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
{ {
ui->setupUi(this); ui->setupUi(this);
ui->comboCANBus->addItem(tr("None"));
ui->comboCANBus->addItem(tr("0")); int numBuses = CANConManager::getInstance()->getNumBuses();
ui->comboCANBus->addItem(tr("1")); for (int n = 0; n < numBuses; n++) ui->comboCANBus->addItem(QString::number(n));
ui->comboCANBus->addItem(tr("Both")); ui->comboCANBus->addItem(tr("All"));
ui->comboCANBus->addItem(tr("From File")); ui->comboCANBus->addItem(tr("From File"));
readSettings(); readSettings();
@@ -399,7 +400,7 @@ void FramePlaybackWindow::btnBackOneClick()
playbackActive = false; playbackActive = false;
updatePosition(false); updatePosition(false);
emit sendFrameBatch(&sendingBuffer); CANConManager::getInstance()->sendFrames(sendingBuffer);
} }
void FramePlaybackWindow::btnPauseClick() void FramePlaybackWindow::btnPauseClick()
@@ -450,7 +451,7 @@ void FramePlaybackWindow::btnFwdOneClick()
playbackTimer->stop(); playbackTimer->stop();
playbackActive = false; playbackActive = false;
updatePosition(true); updatePosition(true);
emit sendFrameBatch(&sendingBuffer); CANConManager::getInstance()->sendFrames(sendingBuffer);
} }
void FramePlaybackWindow::changePlaybackSpeed(int newSpeed) void FramePlaybackWindow::changePlaybackSpeed(int newSpeed)
@@ -465,8 +466,6 @@ void FramePlaybackWindow::changeLooping(bool check)
void FramePlaybackWindow::changeSendingBus(int newIdx) void FramePlaybackWindow::changeSendingBus(int newIdx)
{ {
//falls out neatly this way. 0 = no sending, 1 = bus 0, 2 = bus 1, 3 = both, 4 = from file
//the index is exactly the same as the whichSendBus bitfield.
whichBusSend = newIdx; whichBusSend = newIdx;
} }
@@ -516,7 +515,7 @@ void FramePlaybackWindow::timerTriggered()
updatePosition(false); updatePosition(false);
} }
} }
emit sendFrameBatch(&sendingBuffer); CANConManager::getInstance()->sendFrames(sendingBuffer);
} }
void FramePlaybackWindow::updatePosition(bool forward) void FramePlaybackWindow::updatePosition(bool forward)
@@ -590,23 +589,25 @@ void FramePlaybackWindow::updatePosition(bool forward)
int originalBus = thisFrame->bus; int originalBus = thisFrame->bus;
if (currentSeqItem->idFilters.find(thisFrame->ID).value()) if (currentSeqItem->idFilters.find(thisFrame->ID).value())
{ {
//index 0 is none, 1 is Bus 0, 2 is bus 1, 3 is both, 4 is from file if (whichBusSend < ui->comboCANBus->count() - 2)
if (whichBusSend & 4) {
thisFrame->bus = whichBusSend;
sendingBuffer.append(*thisFrame);
}
else if (whichBusSend = ui->comboCANBus->count() - 2) //all
{
for (int c = 0; c < ui->comboCANBus->count() - 2; c++)
{
thisFrame->bus = c;
sendingBuffer.append(*thisFrame);
}
}
else //from file so retain original bus and send as-is
{ {
sendingBuffer.append(*thisFrame); sendingBuffer.append(*thisFrame);
} }
if (whichBusSend & 1)
{
thisFrame->bus = 0;
sendingBuffer.append(*thisFrame);
}
if (whichBusSend & 2)
{
thisFrame->bus = 1;
sendingBuffer.append(*thisFrame);
}
thisFrame->bus = originalBus; thisFrame->bus = originalBus;
updateFrameLabel(); updateFrameLabel();
} }
} }
-4
View File
@@ -53,10 +53,6 @@ private slots:
void saveFilters(); void saveFilters();
void loadFilters(); void loadFilters();
signals:
void sendCANFrame(const CANFrame *);
void sendFrameBatch(const QList<CANFrame> *);
private: private:
Ui::FramePlaybackWindow *ui; Ui::FramePlaybackWindow *ui;
QList<int> foundID; QList<int> foundID;
+3 -2
View File
@@ -5,6 +5,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QDebug> #include <QDebug>
#include "mainwindow.h" #include "mainwindow.h"
#include "connections/canconmanager.h"
/* /*
* notes: need to ensure that you grab pointers when modifying data structures and dont * notes: need to ensure that you grab pointers when modifying data structures and dont
@@ -151,7 +152,7 @@ void FrameSenderWindow::processIncomingFrame(CANFrame *frame)
sendingData[sd].count++; sendingData[sd].count++;
doModifiers(sd); doModifiers(sd);
updateGridRow(sd); updateGridRow(sd);
sendCANFrame(&sendingData[sd]); CANConManager::getInstance()->sendFrame(sendingData[sd]);
} }
else //delayed sending frame else //delayed sending frame
{ {
@@ -354,7 +355,7 @@ void FrameSenderWindow::handleTick()
doModifiers(i); doModifiers(i);
updateGridRow(i); updateGridRow(i);
qDebug() << "About to try to send a frame"; qDebug() << "About to try to send a frame";
emit sendCANFrame(&sendingData[i]); CANConManager::getInstance()->sendFrame(sendingData[i]);
if (trigger->ID > 0) trigger->readyCount = false; //reset flag if this is a timed ID trigger if (trigger->ID > 0) trigger->readyCount = false; //reset flag if this is a timed ID trigger
} }
} }
-3
View File
@@ -30,9 +30,6 @@ private slots:
void loadGrid(); void loadGrid();
void updatedFrames(int); void updatedFrames(int);
signals:
void sendCANFrame(const CANFrame *);
private: private:
Ui::FrameSenderWindow *ui; Ui::FrameSenderWindow *ui;
QList<FrameSendData> sendingData; QList<FrameSendData> sendingData;
-6
View File
@@ -863,8 +863,6 @@ void MainWindow::showFrameSenderWindow()
frameSenderWindow = new FrameSenderWindow(model->getListReference()); frameSenderWindow = new FrameSenderWindow(model->getListReference());
else else
frameSenderWindow = new FrameSenderWindow(model->getFilteredListReference()); frameSenderWindow = new FrameSenderWindow(model->getFilteredListReference());
//connect(frameSenderWindow, &FrameSenderWindow::sendCANFrame, connectionWindow, &ConnectionWindow::sendFrame);
} }
frameSenderWindow->show(); frameSenderWindow->show();
} }
@@ -877,9 +875,6 @@ void MainWindow::showPlaybackWindow()
playbackWindow = new FramePlaybackWindow(model->getListReference()); playbackWindow = new FramePlaybackWindow(model->getListReference());
else else
playbackWindow = new FramePlaybackWindow(model->getFilteredListReference()); playbackWindow = new FramePlaybackWindow(model->getFilteredListReference());
//connect(playbackWindow, SIGNAL(sendCANFrame(const CANFrame*)), connectionWindow, SLOT(sendFrame(const CANFrame*)), Qt::QueuedConnection);
//connect(playbackWindow, SIGNAL(sendFrameBatch(const QList<CANFrame>*)), connectionWindow, SLOT(sendFrameBatch(const QList<CANFrame>*)), Qt::QueuedConnection);
} }
playbackWindow->show(); playbackWindow->show();
} }
@@ -927,7 +922,6 @@ void MainWindow::showUDSScanWindow()
if (!udsScanWindow) if (!udsScanWindow)
{ {
udsScanWindow = new UDSScanWindow(model->getListReference()); udsScanWindow = new UDSScanWindow(model->getListReference());
//connect(udsScanWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), connectionWindow, SLOT(sendFrame(const CANFrame*)));
} }
udsScanWindow->show(); udsScanWindow->show();
} }
-3
View File
@@ -32,9 +32,6 @@ public slots:
private slots: private slots:
void tick(); void tick();
signals:
void sendCANFrame(const CANFrame *);
private: private:
QJSEngine scriptEngine; QJSEngine scriptEngine;
QJSValue compiledScript; QJSValue compiledScript;
-2
View File
@@ -40,8 +40,6 @@ private:
QList<ScriptContainer *> scripts; QList<ScriptContainer *> scripts;
ScriptContainer *currentScript; ScriptContainer *currentScript;
const QVector<CANFrame> *modelFrames; const QVector<CANFrame> *modelFrames;
}; };
#endif // SCRIPTINGWINDOW_H #endif // SCRIPTINGWINDOW_H
+23 -17
View File
@@ -1,6 +1,7 @@
#include "udsscanwindow.h" #include "udsscanwindow.h"
#include "ui_udsscanwindow.h" #include "ui_udsscanwindow.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "connections/canconmanager.h"
UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) : UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
QDialog(parent), QDialog(parent),
@@ -20,10 +21,9 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS); connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut); connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
ui->cbBuses->addItem("0"); int numBuses = CANConManager::getInstance()->getNumBuses();
ui->cbBuses->addItem("1"); for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n));
ui->cbBuses->addItem("Both"); ui->cbBuses->addItem(tr("All"));
} }
UDSScanWindow::~UDSScanWindow() UDSScanWindow::~UDSScanWindow()
@@ -53,8 +53,6 @@ void UDSScanWindow::scanUDS()
endID = Utility::ParseStringToNum(ui->txtEndID->text()); endID = Utility::ParseStringToNum(ui->txtEndID->text());
int buses = ui->cbBuses->currentIndex(); int buses = ui->cbBuses->currentIndex();
buses++;
if (buses < 1) buses = 1;
//start out by sending tester present to every address to see if anyone replies //start out by sending tester present to every address to see if anyone replies
for (id = startID; id <= endID; id++) for (id = startID; id <= endID; id++)
@@ -68,16 +66,20 @@ void UDSScanWindow::scanUDS()
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0; frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
frame.data[6] = 0;frame.data[7] = 0; frame.data[6] = 0;frame.data[7] = 0;
if (buses & 1) if (buses < ui->cbBuses->count()- 1)
{ {
frame.bus = 0; frame.bus = buses;
sendingFrames.append(frame); sendingFrames.append(frame);
} }
if (buses & 2) else
{ {
frame.bus = 1; for (int c = 0; c < ui->cbBuses->count() - 1; c++)
sendingFrames.append(frame); {
frame.bus = c;
sendingFrames.append(frame);
}
} }
} }
//then try asking for the various diagnostic session types //then try asking for the various diagnostic session types
@@ -94,15 +96,18 @@ void UDSScanWindow::scanUDS()
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0; frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
frame.data[6] = 0;frame.data[7] = 0; frame.data[6] = 0;frame.data[7] = 0;
if (buses & 1) if (buses < ui->cbBuses->count()- 1)
{ {
frame.bus = 0; frame.bus = buses;
sendingFrames.append(frame); sendingFrames.append(frame);
} }
if (buses & 2) else
{ {
frame.bus = 1; for (int c = 0; c < ui->cbBuses->count() - 1; c++)
sendingFrames.append(frame); {
frame.bus = c;
sendingFrames.append(frame);
}
} }
} }
} }
@@ -129,6 +134,7 @@ void UDSScanWindow::updatedFrames(int numFrames)
} }
//Updates here are nearly once per millisecond if there is heavy traffic. That's more like it! //Updates here are nearly once per millisecond if there is heavy traffic. That's more like it!
//TODO: I really doubt this works anymore with the new connection system. This breaks the UDS scanner for now! ;(
void UDSScanWindow::rapidFrames(int numFrames) void UDSScanWindow::rapidFrames(int numFrames)
{ {
CANFrame thisFrame; CANFrame thisFrame;
@@ -210,7 +216,7 @@ void UDSScanWindow::sendNextMsg()
currIdx++; currIdx++;
if (currIdx < sendingFrames.count()) if (currIdx < sendingFrames.count())
{ {
emit sendCANFrame(&sendingFrames[currIdx]); CANConManager::getInstance()->sendFrame(sendingFrames[currIdx]);
waitTimer->start(); waitTimer->start();
} }
else else
-3
View File
@@ -17,9 +17,6 @@ public:
explicit UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent = 0); explicit UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
~UDSScanWindow(); ~UDSScanWindow();
signals:
void sendCANFrame(const CANFrame *);
private slots: private slots:
void updatedFrames(int numFrames); void updatedFrames(int numFrames);
void rapidFrames(int numFrames); void rapidFrames(int numFrames);