Incremented version number, added mode to playback window to make it

start playback only once traffic starts coming in
This commit is contained in:
Collin Kidder
2023-02-22 19:09:41 -05:00
parent 0938eb45c7
commit e0fe807c38
5 changed files with 76 additions and 6 deletions
+3
View File
@@ -66,6 +66,9 @@ CANFrameModel::CANFrameModel(QObject *parent)
//the goal is to prevent a reallocation from ever happening //the goal is to prevent a reallocation from ever happening
frames.reserve(preallocSize); frames.reserve(preallocSize);
//this is pretty wasteful. We're storing all frames twice. It may be better for filteredFrames to be a list of pointers.
//Pointers take up 8 bytes instead of 56 so this is quite a savings for RAM usage. But, then filteredFrames would
//work differently from frames above so the two could not be used interchangeably. Still think about what can be done.
filteredFrames.reserve(preallocSize); filteredFrames.reserve(preallocSize);
dbcHandler = DBCHandler::getReference(); dbcHandler = DBCHandler::getReference();
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CONFIG #ifndef CONFIG
#define CONFIG #define CONFIG
#define VERSION 211 #define VERSION 212
//try to keep this in sync. //try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision //SavvyCAN will complain if you connect a GVRET board with a revision
+62 -5
View File
@@ -1,4 +1,5 @@
#include "frameplaybackwindow.h" #include "frameplaybackwindow.h"
#include "mainwindow.h"
#include "ui_frameplaybackwindow.h" #include "ui_frameplaybackwindow.h"
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
@@ -48,6 +49,8 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
currentPosition = 0; currentPosition = 0;
forward = true; forward = true;
isPlaying = false; isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
updateFrameLabel(); updateFrameLabel();
@@ -72,6 +75,7 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
connect(ui->btnLoadFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::loadFilters); connect(ui->btnLoadFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::loadFilters);
connect(ui->btnSaveFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::saveFilters); connect(ui->btnSaveFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::saveFilters);
connect(ui->cbOriginalTiming, &QCheckBox::toggled, this, &FramePlaybackWindow::useOrigTimingClicked); connect(ui->cbOriginalTiming, &QCheckBox::toggled, this, &FramePlaybackWindow::useOrigTimingClicked);
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
connect(&playbackObject, &FramePlaybackObject::EndOfFrameCache, this, &FramePlaybackWindow::EndOfFrameCache); connect(&playbackObject, &FramePlaybackObject::EndOfFrameCache, this, &FramePlaybackWindow::EndOfFrameCache);
connect(&playbackObject, &FramePlaybackObject::statusUpdate, this, &FramePlaybackWindow::getStatusUpdate); connect(&playbackObject, &FramePlaybackObject::statusUpdate, this, &FramePlaybackWindow::getStatusUpdate);
@@ -101,6 +105,8 @@ void FramePlaybackWindow::showEvent(QShowEvent *)
{ {
readSettings(); readSettings();
installEventFilter(this); installEventFilter(this);
//any time the view is shown we'll go see how many buses are registered and redo the combobox to match
int numBuses = CANConManager::getInstance()->getNumBuses(); int numBuses = CANConManager::getInstance()->getNumBuses();
ui->comboCANBus->clear(); ui->comboCANBus->clear();
for (int n = 0; n < numBuses; n++) ui->comboCANBus->addItem(QString::number(n)); for (int n = 0; n < numBuses; n++) ui->comboCANBus->addItem(QString::number(n));
@@ -279,6 +285,32 @@ void FramePlaybackWindow::loadFilters()
} }
} }
void FramePlaybackWindow::updatedFrames(int numFrames)
{
CANFrame thisFrame;
if (numFrames == -1) //all frames deleted. Don't care
{
}
else if (numFrames == -2) //all new set of frames. Don't care
{
}
else //just got some new frames.
{
if (numFrames > 0)
{
haveIncomingTraffic = true;
if (wantPlaying && !isPlaying)
{
isPlaying = true;
updateFrameLabel();
if (forward) playbackObject.startPlaybackForward();
else playbackObject.startPlaybackBackward();
}
}
}
}
void FramePlaybackWindow::refreshIDList() void FramePlaybackWindow::refreshIDList()
{ {
if (currentSeqNum < 0 || currentSeqItem == nullptr) if (currentSeqNum < 0 || currentSeqItem == nullptr)
@@ -338,6 +370,8 @@ void FramePlaybackWindow::EndOfFrameCache()
else //not looping so stop playback entirely else //not looping so stop playback entirely
{ {
isPlaying = false; isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback(); playbackObject.stopPlayback();
} }
} }
@@ -361,6 +395,8 @@ void FramePlaybackWindow::EndOfFrameCache()
else //not looping so stop playback entirely else //not looping so stop playback entirely
{ {
isPlaying = false; isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback(); playbackObject.stopPlayback();
} }
} }
@@ -395,7 +431,10 @@ void FramePlaybackWindow::updateFrameLabel()
ui->lblCurrPlayback->setText(currentSeqItem->filename); ui->lblCurrPlayback->setText(currentSeqItem->filename);
ui->lblPosition->setText(QString::number(currentPosition) + tr(" of ") + QString::number(seqItems[row].data.count())); if (wantPlaying && !isPlaying)
ui->lblPosition->setText(QString::number(currentPosition) + tr(" of ") + QString::number(seqItems[row].data.count()) + " (WAITING)");
else
ui->lblPosition->setText(QString::number(currentPosition) + tr(" of ") + QString::number(seqItems[row].data.count()));
} }
void FramePlaybackWindow::seqTableCellClicked(int row, int col) void FramePlaybackWindow::seqTableCellClicked(int row, int col)
@@ -539,26 +578,36 @@ void FramePlaybackWindow::btnBackOneClick()
{ {
forward = false; forward = false;
isPlaying = false; isPlaying = false;
wantPlaying = false;
playbackObject.stepPlaybackBackward(); playbackObject.stepPlaybackBackward();
updateFrameLabel();
} }
void FramePlaybackWindow::btnPauseClick() void FramePlaybackWindow::btnPauseClick()
{ {
isPlaying = false; isPlaying = false;
wantPlaying = false;
playbackObject.pausePlayback(); playbackObject.pausePlayback();
updateFrameLabel();
} }
void FramePlaybackWindow::btnReverseClick() void FramePlaybackWindow::btnReverseClick()
{ {
forward = false; forward = false;
isPlaying = true; wantPlaying = true;
playbackObject.startPlaybackBackward(); if (!ui->ckWaitForTraffic->isChecked())
{
playbackObject.startPlaybackBackward();
isPlaying = true;
}
updateFrameLabel(); updateFrameLabel();
} }
void FramePlaybackWindow::btnStopClick() void FramePlaybackWindow::btnStopClick()
{ {
isPlaying = false; isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback(); playbackObject.stopPlayback();
if (seqItems.count() > 0) if (seqItems.count() > 0)
{ {
@@ -574,20 +623,28 @@ void FramePlaybackWindow::btnStopClick()
ui->tblSequence->setCurrentCell(0, 0); ui->tblSequence->setCurrentCell(0, 0);
refreshIDList(); refreshIDList();
} }
updateFrameLabel();
} }
void FramePlaybackWindow::btnPlayClick() void FramePlaybackWindow::btnPlayClick()
{ {
forward = true; forward = true;
isPlaying = true; wantPlaying = true;
playbackObject.startPlaybackForward(); if (!ui->ckWaitForTraffic->isChecked())
{
playbackObject.startPlaybackForward();
isPlaying = true;
}
updateFrameLabel();
} }
void FramePlaybackWindow::btnFwdOneClick() void FramePlaybackWindow::btnFwdOneClick()
{ {
forward = true; forward = true;
isPlaying = false; isPlaying = false;
wantPlaying = false;
playbackObject.stepPlaybackForward(); playbackObject.stepPlaybackForward();
updateFrameLabel();
} }
void FramePlaybackWindow::changePlaybackSpeed(int newSpeed) void FramePlaybackWindow::changePlaybackSpeed(int newSpeed)
+3
View File
@@ -44,6 +44,7 @@ private slots:
void useOrigTimingClicked(); void useOrigTimingClicked();
void getStatusUpdate(int frameNum); void getStatusUpdate(int frameNum);
void EndOfFrameCache(); void EndOfFrameCache();
void updatedFrames(int);
private: private:
Ui::FramePlaybackWindow *ui; Ui::FramePlaybackWindow *ui;
@@ -55,8 +56,10 @@ private:
int currentSeqNum; int currentSeqNum;
FramePlaybackObject playbackObject; FramePlaybackObject playbackObject;
bool forward; bool forward;
bool wantPlaying;
bool isPlaying; bool isPlaying;
int currentPosition; int currentPosition;
bool haveIncomingTraffic = false;
void refreshIDList(); void refreshIDList();
void updateFrameLabel(); void updateFrameLabel();
+7
View File
@@ -107,6 +107,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="ckWaitForTraffic">
<property name="text">
<string>Wait for traffic before starting playback</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>