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
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);
dbcHandler = DBCHandler::getReference();
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CONFIG
#define CONFIG
#define VERSION 211
#define VERSION 212
//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
+62 -5
View File
@@ -1,4 +1,5 @@
#include "frameplaybackwindow.h"
#include "mainwindow.h"
#include "ui_frameplaybackwindow.h"
#include <QDebug>
#include <QFileDialog>
@@ -48,6 +49,8 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
currentPosition = 0;
forward = true;
isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
updateFrameLabel();
@@ -72,6 +75,7 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidge
connect(ui->btnLoadFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::loadFilters);
connect(ui->btnSaveFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::saveFilters);
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::statusUpdate, this, &FramePlaybackWindow::getStatusUpdate);
@@ -101,6 +105,8 @@ void FramePlaybackWindow::showEvent(QShowEvent *)
{
readSettings();
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();
ui->comboCANBus->clear();
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()
{
if (currentSeqNum < 0 || currentSeqItem == nullptr)
@@ -338,6 +370,8 @@ void FramePlaybackWindow::EndOfFrameCache()
else //not looping so stop playback entirely
{
isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback();
}
}
@@ -361,6 +395,8 @@ void FramePlaybackWindow::EndOfFrameCache()
else //not looping so stop playback entirely
{
isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback();
}
}
@@ -395,7 +431,10 @@ void FramePlaybackWindow::updateFrameLabel()
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)
@@ -539,26 +578,36 @@ void FramePlaybackWindow::btnBackOneClick()
{
forward = false;
isPlaying = false;
wantPlaying = false;
playbackObject.stepPlaybackBackward();
updateFrameLabel();
}
void FramePlaybackWindow::btnPauseClick()
{
isPlaying = false;
wantPlaying = false;
playbackObject.pausePlayback();
updateFrameLabel();
}
void FramePlaybackWindow::btnReverseClick()
{
forward = false;
isPlaying = true;
playbackObject.startPlaybackBackward();
wantPlaying = true;
if (!ui->ckWaitForTraffic->isChecked())
{
playbackObject.startPlaybackBackward();
isPlaying = true;
}
updateFrameLabel();
}
void FramePlaybackWindow::btnStopClick()
{
isPlaying = false;
wantPlaying = false;
haveIncomingTraffic = false;
playbackObject.stopPlayback();
if (seqItems.count() > 0)
{
@@ -574,20 +623,28 @@ void FramePlaybackWindow::btnStopClick()
ui->tblSequence->setCurrentCell(0, 0);
refreshIDList();
}
updateFrameLabel();
}
void FramePlaybackWindow::btnPlayClick()
{
forward = true;
isPlaying = true;
playbackObject.startPlaybackForward();
wantPlaying = true;
if (!ui->ckWaitForTraffic->isChecked())
{
playbackObject.startPlaybackForward();
isPlaying = true;
}
updateFrameLabel();
}
void FramePlaybackWindow::btnFwdOneClick()
{
forward = true;
isPlaying = false;
wantPlaying = false;
playbackObject.stepPlaybackForward();
updateFrameLabel();
}
void FramePlaybackWindow::changePlaybackSpeed(int newSpeed)
+3
View File
@@ -44,6 +44,7 @@ private slots:
void useOrigTimingClicked();
void getStatusUpdate(int frameNum);
void EndOfFrameCache();
void updatedFrames(int);
private:
Ui::FramePlaybackWindow *ui;
@@ -55,8 +56,10 @@ private:
int currentSeqNum;
FramePlaybackObject playbackObject;
bool forward;
bool wantPlaying;
bool isPlaying;
int currentPosition;
bool haveIncomingTraffic = false;
void refreshIDList();
void updateFrameLabel();
+7
View File
@@ -107,6 +107,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ckWaitForTraffic">
<property name="text">
<string>Wait for traffic before starting playback</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>