diff --git a/SavvyCAN.pro b/SavvyCAN.pro index 1967d8e..30a2789 100644 --- a/SavvyCAN.pro +++ b/SavvyCAN.pro @@ -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 diff --git a/SavvyCAN.pro.user b/SavvyCAN.pro.user index fda9d44..67f93d8 100644 --- a/SavvyCAN.pro.user +++ b/SavvyCAN.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp new file mode 100644 index 0000000..3a5e070 --- /dev/null +++ b/frameplaybackwindow.cpp @@ -0,0 +1,50 @@ +#include "frameplaybackwindow.h" +#include "ui_frameplaybackwindow.h" + +FramePlaybackWindow::FramePlaybackWindow(QList *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())); +} diff --git a/frameplaybackwindow.h b/frameplaybackwindow.h new file mode 100644 index 0000000..d18de00 --- /dev/null +++ b/frameplaybackwindow.h @@ -0,0 +1,30 @@ +#ifndef FRAMEPLAYBACKWINDOW_H +#define FRAMEPLAYBACKWINDOW_H + +#include +#include "can_structs.h" + +namespace Ui { +class FramePlaybackWindow; +} + +class FramePlaybackWindow : public QDialog +{ + Q_OBJECT + +public: + explicit FramePlaybackWindow(QList *frames, QWidget *parent = 0); + ~FramePlaybackWindow(); + +private: + Ui::FramePlaybackWindow *ui; + QList foundID; + QList frameCache; + QList *modelFrames; + int currentPosition; + + void refreshIDList(); + void updateFrameLabel(); +}; + +#endif // FRAMEPLAYBACKWINDOW_H diff --git a/frameplaybackwindow.ui b/frameplaybackwindow.ui new file mode 100644 index 0000000..745a428 --- /dev/null +++ b/frameplaybackwindow.ui @@ -0,0 +1,236 @@ + + + FramePlaybackWindow + + + + 0 + 0 + 257 + 606 + + + + Dialog + + + + + + + + + + + + :/icons/images/NavBack.png:/icons/images/NavBack.png + + + + + + + + + + + :/icons/images/PauseHS.png:/icons/images/PauseHS.png + + + + + + + + + + + :/icons/images/ReverseHS.png:/icons/images/ReverseHS.png + + + + + + + + + + + :/icons/images/StopHS.png:/icons/images/StopHS.png + + + + + + + + + + + :/icons/images/PlayHS.png:/icons/images/PlayHS.png + + + + + + + + + + + :/icons/images/NavForward.png:/icons/images/NavForward.png + + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 25 + + + + + + + + Playback speed (ms): + + + + + + + 1 + + + 1000 + + + 5 + + + + + + + Loop playback + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 10 + 20 + + + + + + + + Current frame: + + + + + + + x of y + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + Send to CANBus + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 40 + + + + + + + + ID Filtering: + + + + + + + + + + + + Select all IDs + + + + + + + Deselect all IDs + + + + + + + + + + + + diff --git a/icons.qrc b/icons.qrc new file mode 100644 index 0000000..cd68926 --- /dev/null +++ b/icons.qrc @@ -0,0 +1,10 @@ + + + images/NavBack.png + images/NavForward.png + images/PauseHS.png + images/PlayHS.png + images/ReverseHS.png + images/StopHS.png + + diff --git a/images/NavBack.png b/images/NavBack.png new file mode 100644 index 0000000..0a7da9a Binary files /dev/null and b/images/NavBack.png differ diff --git a/images/NavForward.png b/images/NavForward.png new file mode 100644 index 0000000..fa27d47 Binary files /dev/null and b/images/NavForward.png differ diff --git a/images/PauseHS.png b/images/PauseHS.png new file mode 100644 index 0000000..d83bf17 Binary files /dev/null and b/images/PauseHS.png differ diff --git a/images/PlayHS.png b/images/PlayHS.png new file mode 100644 index 0000000..96b050f Binary files /dev/null and b/images/PlayHS.png differ diff --git a/images/ReverseHS.png b/images/ReverseHS.png new file mode 100644 index 0000000..14804a9 Binary files /dev/null and b/images/ReverseHS.png differ diff --git a/images/StopHS.png b/images/StopHS.png new file mode 100644 index 0000000..5580fec Binary files /dev/null and b/images/StopHS.png differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 93d194e..9226edf 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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(); diff --git a/mainwindow.h b/mainwindow.h index ba4b110..69fc84b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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);