Changed sending windows to use new system where there are arbitrary number of buses
This commit is contained in:
+23
-22
@@ -4,6 +4,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMenu>
|
||||
#include <QSettings>
|
||||
#include "connections/canconmanager.h"
|
||||
|
||||
/*
|
||||
* Notes about new functionality:
|
||||
@@ -24,10 +25,10 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->comboCANBus->addItem(tr("None"));
|
||||
ui->comboCANBus->addItem(tr("0"));
|
||||
ui->comboCANBus->addItem(tr("1"));
|
||||
ui->comboCANBus->addItem(tr("Both"));
|
||||
|
||||
int numBuses = CANConManager::getInstance()->getNumBuses();
|
||||
for (int n = 0; n < numBuses; n++) ui->comboCANBus->addItem(QString::number(n));
|
||||
ui->comboCANBus->addItem(tr("All"));
|
||||
ui->comboCANBus->addItem(tr("From File"));
|
||||
|
||||
readSettings();
|
||||
@@ -399,7 +400,7 @@ void FramePlaybackWindow::btnBackOneClick()
|
||||
playbackActive = false;
|
||||
|
||||
updatePosition(false);
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
CANConManager::getInstance()->sendFrames(sendingBuffer);
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::btnPauseClick()
|
||||
@@ -450,7 +451,7 @@ void FramePlaybackWindow::btnFwdOneClick()
|
||||
playbackTimer->stop();
|
||||
playbackActive = false;
|
||||
updatePosition(true);
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
CANConManager::getInstance()->sendFrames(sendingBuffer);
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::changePlaybackSpeed(int newSpeed)
|
||||
@@ -465,8 +466,6 @@ void FramePlaybackWindow::changeLooping(bool check)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -516,7 +515,7 @@ void FramePlaybackWindow::timerTriggered()
|
||||
updatePosition(false);
|
||||
}
|
||||
}
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
CANConManager::getInstance()->sendFrames(sendingBuffer);
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::updatePosition(bool forward)
|
||||
@@ -590,23 +589,25 @@ void FramePlaybackWindow::updatePosition(bool forward)
|
||||
int originalBus = thisFrame->bus;
|
||||
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 & 4)
|
||||
if (whichBusSend < ui->comboCANBus->count() - 2)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (whichBusSend & 1)
|
||||
{
|
||||
thisFrame->bus = 0;
|
||||
sendingBuffer.append(*thisFrame);
|
||||
}
|
||||
if (whichBusSend & 2)
|
||||
{
|
||||
thisFrame->bus = 1;
|
||||
sendingBuffer.append(*thisFrame);
|
||||
}
|
||||
|
||||
thisFrame->bus = originalBus;
|
||||
updateFrameLabel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,10 +53,6 @@ private slots:
|
||||
void saveFilters();
|
||||
void loadFilters();
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *);
|
||||
void sendFrameBatch(const QList<CANFrame> *);
|
||||
|
||||
private:
|
||||
Ui::FramePlaybackWindow *ui;
|
||||
QList<int> foundID;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include "mainwindow.h"
|
||||
#include "connections/canconmanager.h"
|
||||
|
||||
/*
|
||||
* 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++;
|
||||
doModifiers(sd);
|
||||
updateGridRow(sd);
|
||||
sendCANFrame(&sendingData[sd]);
|
||||
CANConManager::getInstance()->sendFrame(sendingData[sd]);
|
||||
}
|
||||
else //delayed sending frame
|
||||
{
|
||||
@@ -354,7 +355,7 @@ void FrameSenderWindow::handleTick()
|
||||
doModifiers(i);
|
||||
updateGridRow(i);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,6 @@ private slots:
|
||||
void loadGrid();
|
||||
void updatedFrames(int);
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *);
|
||||
|
||||
private:
|
||||
Ui::FrameSenderWindow *ui;
|
||||
QList<FrameSendData> sendingData;
|
||||
|
||||
@@ -863,8 +863,6 @@ void MainWindow::showFrameSenderWindow()
|
||||
frameSenderWindow = new FrameSenderWindow(model->getListReference());
|
||||
else
|
||||
frameSenderWindow = new FrameSenderWindow(model->getFilteredListReference());
|
||||
|
||||
//connect(frameSenderWindow, &FrameSenderWindow::sendCANFrame, connectionWindow, &ConnectionWindow::sendFrame);
|
||||
}
|
||||
frameSenderWindow->show();
|
||||
}
|
||||
@@ -877,9 +875,6 @@ void MainWindow::showPlaybackWindow()
|
||||
playbackWindow = new FramePlaybackWindow(model->getListReference());
|
||||
else
|
||||
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();
|
||||
}
|
||||
@@ -927,7 +922,6 @@ void MainWindow::showUDSScanWindow()
|
||||
if (!udsScanWindow)
|
||||
{
|
||||
udsScanWindow = new UDSScanWindow(model->getListReference());
|
||||
//connect(udsScanWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), connectionWindow, SLOT(sendFrame(const CANFrame*)));
|
||||
}
|
||||
udsScanWindow->show();
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ public slots:
|
||||
private slots:
|
||||
void tick();
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *);
|
||||
|
||||
private:
|
||||
QJSEngine scriptEngine;
|
||||
QJSValue compiledScript;
|
||||
|
||||
@@ -40,8 +40,6 @@ private:
|
||||
QList<ScriptContainer *> scripts;
|
||||
ScriptContainer *currentScript;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SCRIPTINGWINDOW_H
|
||||
|
||||
+21
-15
@@ -1,6 +1,7 @@
|
||||
#include "udsscanwindow.h"
|
||||
#include "ui_udsscanwindow.h"
|
||||
#include "mainwindow.h"
|
||||
#include "connections/canconmanager.h"
|
||||
|
||||
UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -20,10 +21,9 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
||||
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
||||
|
||||
ui->cbBuses->addItem("0");
|
||||
ui->cbBuses->addItem("1");
|
||||
ui->cbBuses->addItem("Both");
|
||||
|
||||
int numBuses = CANConManager::getInstance()->getNumBuses();
|
||||
for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n));
|
||||
ui->cbBuses->addItem(tr("All"));
|
||||
}
|
||||
|
||||
UDSScanWindow::~UDSScanWindow()
|
||||
@@ -53,8 +53,6 @@ void UDSScanWindow::scanUDS()
|
||||
endID = Utility::ParseStringToNum(ui->txtEndID->text());
|
||||
|
||||
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
|
||||
for (id = startID; id <= endID; id++)
|
||||
@@ -68,18 +66,22 @@ void UDSScanWindow::scanUDS()
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 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);
|
||||
}
|
||||
if (buses & 2)
|
||||
else
|
||||
{
|
||||
frame.bus = 1;
|
||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
||||
{
|
||||
frame.bus = c;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//then try asking for the various diagnostic session types
|
||||
for (typ = 1; typ < 5; typ++)
|
||||
{
|
||||
@@ -94,18 +96,21 @@ void UDSScanWindow::scanUDS()
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 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);
|
||||
}
|
||||
if (buses & 2)
|
||||
else
|
||||
{
|
||||
frame.bus = 1;
|
||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
||||
{
|
||||
frame.bus = c;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waitTimer->start();
|
||||
currIdx = -1;
|
||||
@@ -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!
|
||||
//TODO: I really doubt this works anymore with the new connection system. This breaks the UDS scanner for now! ;(
|
||||
void UDSScanWindow::rapidFrames(int numFrames)
|
||||
{
|
||||
CANFrame thisFrame;
|
||||
@@ -210,7 +216,7 @@ void UDSScanWindow::sendNextMsg()
|
||||
currIdx++;
|
||||
if (currIdx < sendingFrames.count())
|
||||
{
|
||||
emit sendCANFrame(&sendingFrames[currIdx]);
|
||||
CANConManager::getInstance()->sendFrame(sendingFrames[currIdx]);
|
||||
waitTimer->start();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -17,9 +17,6 @@ public:
|
||||
explicit UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
||||
~UDSScanWindow();
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *);
|
||||
|
||||
private slots:
|
||||
void updatedFrames(int numFrames);
|
||||
void rapidFrames(int numFrames);
|
||||
|
||||
Reference in New Issue
Block a user