Addition of a playback form - used to play back a log file onto one or both canbuses. However, not yet completed (but it won't crash)

This commit is contained in:
Collin Kidder
2015-05-05 23:04:48 -04:00
parent eebcbacfa5
commit fcfdb76225
14 changed files with 349 additions and 6 deletions
+11 -3
View File
@@ -19,7 +19,8 @@ SOURCES += main.cpp\
qcustomplot.cpp \
graphingwindow.cpp \
frameinfowindow.cpp \
newgraphdialog.cpp
newgraphdialog.cpp \
frameplaybackwindow.cpp
HEADERS += mainwindow.h \
can_structs.h \
@@ -28,9 +29,16 @@ HEADERS += mainwindow.h \
qcustomplot.h \
graphingwindow.h \
frameinfowindow.h \
newgraphdialog.h
newgraphdialog.h \
frameplaybackwindow.h
FORMS += mainwindow.ui \
graphingwindow.ui \
frameinfowindow.ui \
newgraphdialog.ui
newgraphdialog.ui \
frameplaybackwindow.ui
DISTFILES +=
RESOURCES += \
icons.qrc
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.4.0, 2015-05-04T22:19:29. -->
<!-- Written by QtCreator 3.4.0, 2015-05-05T23:03:39. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+50
View File
@@ -0,0 +1,50 @@
#include "frameplaybackwindow.h"
#include "ui_frameplaybackwindow.h"
FramePlaybackWindow::FramePlaybackWindow(QList<CANFrame> *frames, QWidget *parent) :
QDialog(parent),
ui(new Ui::FramePlaybackWindow)
{
ui->setupUi(this);
modelFrames = frames;
currentPosition = 0;
refreshIDList();
ui->comboCANBus->addItem(tr("None"));
ui->comboCANBus->addItem(tr("0"));
ui->comboCANBus->addItem(tr("1"));
ui->comboCANBus->addItem(tr("From File"));
updateFrameLabel();
}
FramePlaybackWindow::~FramePlaybackWindow()
{
delete ui;
}
void FramePlaybackWindow::refreshIDList()
{
int id;
for (int i = 0; i < modelFrames->count(); i++)
{
id = modelFrames->at(i).ID;
if (!foundID.contains(id))
{
foundID.append(id);
QListWidgetItem* item = new QListWidgetItem(QString::number(id, 16).toUpper().rightJustified(4,'0'), ui->listID);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Checked);
}
}
//default is to sort in ascending order
ui->listID->sortItems();
}
void FramePlaybackWindow::updateFrameLabel()
{
ui->lblPosition->setText(QString::number(currentPosition) + tr(" of ") + QString::number(modelFrames->count()));
}
+30
View File
@@ -0,0 +1,30 @@
#ifndef FRAMEPLAYBACKWINDOW_H
#define FRAMEPLAYBACKWINDOW_H
#include <QDialog>
#include "can_structs.h"
namespace Ui {
class FramePlaybackWindow;
}
class FramePlaybackWindow : public QDialog
{
Q_OBJECT
public:
explicit FramePlaybackWindow(QList<CANFrame> *frames, QWidget *parent = 0);
~FramePlaybackWindow();
private:
Ui::FramePlaybackWindow *ui;
QList<int> foundID;
QList<CANFrame> frameCache;
QList<CANFrame> *modelFrames;
int currentPosition;
void refreshIDList();
void updateFrameLabel();
};
#endif // FRAMEPLAYBACKWINDOW_H
+236
View File
@@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FramePlaybackWindow</class>
<widget class="QDialog" name="FramePlaybackWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>606</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnStepBack">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/NavBack.png</normaloff>:/icons/images/NavBack.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPause">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/PauseHS.png</normaloff>:/icons/images/PauseHS.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPlayReverse">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/ReverseHS.png</normaloff>:/icons/images/ReverseHS.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStop">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/StopHS.png</normaloff>:/icons/images/StopHS.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPlay">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/PlayHS.png</normaloff>:/icons/images/PlayHS.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStepForward">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/NavForward.png</normaloff>:/icons/images/NavForward.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="text">
<string>Playback speed (ms):</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinPlaySpeed">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="cbLoop">
<property name="text">
<string>Loop playback</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Current frame:</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lblPosition">
<property name="text">
<string>x of y</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Send to CANBus</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboCANBus"/>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_5">
<property name="text">
<string>ID Filtering:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listID"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="btnSelectAll">
<property name="text">
<string>Select all IDs</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSelectNone">
<property name="text">
<string>Deselect all IDs</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="icons.qrc"/>
</resources>
<connections/>
</ui>
+10
View File
@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/icons">
<file>images/NavBack.png</file>
<file>images/NavForward.png</file>
<file>images/PauseHS.png</file>
<file>images/PlayHS.png</file>
<file>images/ReverseHS.png</file>
<file>images/StopHS.png</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

+8 -2
View File
@@ -12,11 +12,9 @@ This first order of business is to attempt to gain feature parity (roughly) with
can replace it as a cross platform solution.
Here are things yet to do
- Support saving frames
- Add flow view - ability to see bits change over time
- Ability to send frames via playback mechanism (people use this so get it working!)
- Ability to use programmatic frame sending interface (only I use it and it's complicated but helpful)
*/
@@ -32,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->actionFrame_Data_Analysis, SIGNAL(triggered(bool)), this, SLOT(showFrameDataAnalysis()));
connect(ui->btnClearFrames, SIGNAL(clicked(bool)), this, SLOT(clearFrames()));
connect(ui->actionSave_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleSaveFile()));
connect(ui->action_Playback, SIGNAL(triggered(bool)), this, SLOT(showPlaybackWindow()));
model = new CANFrameModel();
ui->canFramesView->setModel(model);
@@ -60,6 +59,7 @@ MainWindow::MainWindow(QWidget *parent) :
graphingWindow = NULL;
frameInfoWindow = NULL;
playbackWindow = NULL;
}
MainWindow::~MainWindow()
@@ -539,6 +539,12 @@ void MainWindow::showFrameDataAnalysis()
frameInfoWindow->show();
}
void MainWindow::showPlaybackWindow()
{
if (!playbackWindow) playbackWindow = new FramePlaybackWindow(model->getListReference());
playbackWindow->show();
}
void MainWindow::readSerialData()
{
QByteArray data = port->readAll();
+3
View File
@@ -7,6 +7,7 @@
#include "can_structs.h"
#include "graphingwindow.h"
#include "frameinfowindow.h"
#include "frameplaybackwindow.h"
namespace Ui {
class MainWindow;
@@ -40,6 +41,7 @@ private slots:
void showGraphingWindow();
void showFrameDataAnalysis();
void clearFrames();
void showPlaybackWindow();
private:
Ui::MainWindow *ui;
@@ -51,6 +53,7 @@ private:
CANFrame buildFrame;
GraphingWindow *graphingWindow;
FrameInfoWindow *frameInfoWindow;
FramePlaybackWindow *playbackWindow;
void loadCRTDFile(QString);
void loadNativeCSVFile(QString);
void loadGenericCSVFile(QString);