diff --git a/SavvyCAN.pro b/SavvyCAN.pro index 6040390..07fc638 100644 --- a/SavvyCAN.pro +++ b/SavvyCAN.pro @@ -48,7 +48,9 @@ SOURCES += main.cpp\ udsscanwindow.cpp \ can_structs.cpp \ isotp_interpreterwindow.cpp \ - isotp_handler.cpp + isotp_handler.cpp \ + deltawindow.cpp \ + deltamodel.cpp HEADERS += mainwindow.h \ can_structs.h \ @@ -83,7 +85,9 @@ HEADERS += mainwindow.h \ fuzzingwindow.h \ udsscanwindow.h \ isotp_interpreterwindow.h \ - isotp_handler.h + isotp_handler.h \ + deltawindow.h \ + deltamodel.h FORMS += mainwindow.ui \ graphingwindow.ui \ @@ -105,7 +109,8 @@ FORMS += mainwindow.ui \ dbcloadsavewindow.ui \ fuzzingwindow.ui \ udsscanwindow.ui \ - isotp_interpreterwindow.ui + isotp_interpreterwindow.ui \ + deltawindow.ui DISTFILES += diff --git a/config.h b/config.h index 33378ea..12accfa 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 155 +#define VERSION 156 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/deltamodel.cpp b/deltamodel.cpp new file mode 100644 index 0000000..98f88fa --- /dev/null +++ b/deltamodel.cpp @@ -0,0 +1,36 @@ +#include "deltamodel.h" + +DeltaModel::DeltaModel(QObject *parent) + : QAbstractTableModel(parent) +{ +} + +QVariant DeltaModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + // FIXME: Implement me! +} + +int DeltaModel::rowCount(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return 0; + + // FIXME: Implement me! +} + +int DeltaModel::columnCount(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return 0; + + // FIXME: Implement me! +} + +QVariant DeltaModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + // FIXME: Implement me! + return QVariant(); +} diff --git a/deltamodel.h b/deltamodel.h new file mode 100644 index 0000000..c0444d8 --- /dev/null +++ b/deltamodel.h @@ -0,0 +1,25 @@ +#ifndef DELTAMODEL_H +#define DELTAMODEL_H + +#include + +class DeltaModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit DeltaModel(QObject *parent = 0); + + // Header: + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + + // Basic functionality: + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +private: +}; + +#endif // DELTAMODEL_H \ No newline at end of file diff --git a/deltawindow.cpp b/deltawindow.cpp new file mode 100644 index 0000000..8a1b3c0 --- /dev/null +++ b/deltawindow.cpp @@ -0,0 +1,14 @@ +#include "deltawindow.h" +#include "ui_deltawindow.h" + +DeltaWindow::DeltaWindow(QWidget *parent) : + QDialog(parent), + ui(new Ui::DeltaWindow) +{ + ui->setupUi(this); +} + +DeltaWindow::~DeltaWindow() +{ + delete ui; +} diff --git a/deltawindow.h b/deltawindow.h new file mode 100644 index 0000000..e9c30cf --- /dev/null +++ b/deltawindow.h @@ -0,0 +1,22 @@ +#ifndef DELTAWINDOW_H +#define DELTAWINDOW_H + +#include + +namespace Ui { +class DeltaWindow; +} + +class DeltaWindow : public QDialog +{ + Q_OBJECT + +public: + explicit DeltaWindow(QWidget *parent = 0); + ~DeltaWindow(); + +private: + Ui::DeltaWindow *ui; +}; + +#endif // DELTAWINDOW_H diff --git a/deltawindow.ui b/deltawindow.ui new file mode 100644 index 0000000..3a67a5e --- /dev/null +++ b/deltawindow.ui @@ -0,0 +1,24 @@ + + + DeltaWindow + + + + 0 + 0 + 978 + 654 + + + + Dialog + + + + + + + + + + diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp index 424925e..f443d49 100644 --- a/flowviewwindow.cpp +++ b/flowviewwindow.cpp @@ -158,9 +158,9 @@ void FlowViewWindow::writeSettings() /* * Keyboard shortcuts to allow for quick work without needing to move around a mouse. - * E = resume or pause playback - * Q = go back one frame - * W = go forward one frame + * R = resume or pause playback + * T = go back one frame + * Y = go forward one frame */ bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event) { @@ -371,27 +371,64 @@ void FlowViewWindow::updatedFrames(int numFrames) else //just got some new frames. See if they are relevant. { if (numFrames > modelFrames->count()) return; - int refID = frameCache[0].ID; + int refID; + if (frameCache.count() > 0) refID = frameCache[0].ID; + else refID = 0; bool needRefresh = false; for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) { thisFrame = modelFrames->at(i); + + if (!foundID.contains(thisFrame.ID)) + { + foundID.append(thisFrame.ID); + QListWidgetItem* item = new QListWidgetItem(Utility::formatNumber(thisFrame.ID), ui->listFrameID); + } + if (thisFrame.ID == refID) { frameCache.append(thisFrame); - if (ui->cbLiveMode->checkState() == Qt::Checked) + + for (int k = 0; k < 8; k++) { - currentPosition = frameCache.count() - 1; + if (ui->cbTimeGraph->isChecked()) + { + if (secondsMode){ + x[k].append((double)(thisFrame.timestamp) / 1000000.0); + } + else + { + x[k].append(thisFrame.timestamp); + } + } + else + { + x[k].append(x[k].count()); + } + y[k].append(thisFrame.data[k]); needRefresh = true; } - } + } + } + if (ui->cbLiveMode->checkState() == Qt::Checked) + { + currentPosition = frameCache.count() - 1; + memcpy(currBytes, frameCache.at(currentPosition).data, 8); + memcpy(refBytes, currBytes, 8); + } if (needRefresh) { - updateDataView(); + for (int k = 0; k < 8; k++) + { + graphRef[k]->setData(x[k], y[k]); + } + ui->graphView->replot(); + updateDataView(); if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0); } } + updateFrameLabel(); } void FlowViewWindow::removeAllGraphs() @@ -409,7 +446,10 @@ void FlowViewWindow::createGraph(int byteNum) int numEntries = frameCache.count(); - QVector x(numEntries), y(numEntries); + x[byteNum].clear(); + y[byteNum].clear(); + x[byteNum].resize(numEntries); + y[byteNum].resize(numEntries); for (int j = 0; j < numEntries; j++) { @@ -418,26 +458,26 @@ void FlowViewWindow::createGraph(int byteNum) if (graphByTime) { if (secondsMode){ - x[j] = (double)(frameCache[j].timestamp) / 1000000.0; + x[byteNum][j] = (double)(frameCache[j].timestamp) / 1000000.0; } else { - x[j] = frameCache[j].timestamp; + x[byteNum][j] = frameCache[j].timestamp; } } else { - x[j] = j; + x[byteNum][j] = j; } - y[j] = tempVal; - if (y[j] < minval) minval = y[j]; - if (y[j] > maxval) maxval = y[j]; + y[byteNum][j] = tempVal; + if (y[byteNum][j] < minval) minval = y[byteNum][j]; + if (y[byteNum][j] > maxval) maxval = y[byteNum][j]; } - ui->graphView->addGraph(); + graphRef[byteNum] = ui->graphView->addGraph(); ui->graphView->graph()->setName(QString("Graph %1").arg(ui->graphView->graphCount()-1)); - ui->graphView->graph()->setData(x,y); + ui->graphView->graph()->setData(x[byteNum],y[byteNum]); ui->graphView->graph()->setLineStyle(QCPGraph::lsLine); //connect points with lines QPen graphPen; graphPen.setColor(graphColors[byteNum]); diff --git a/flowviewwindow.h b/flowviewwindow.h index 78f5b71..165a13e 100644 --- a/flowviewwindow.h +++ b/flowviewwindow.h @@ -55,6 +55,8 @@ private: bool playbackForward; static const QColor graphColors[8]; bool secondsMode; + QVector x[8], y[8]; + QCPGraph *graphRef[8]; void refreshIDList(); void updateFrameLabel(); diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp index 765f482..be6dae7 100644 --- a/frameplaybackwindow.cpp +++ b/frameplaybackwindow.cpp @@ -400,10 +400,12 @@ void FramePlaybackWindow::btnLoadLive() void FramePlaybackWindow::btnBackOneClick() { + sendingBuffer.clear(); playbackTimer->stop(); //pushing this button halts automatic playback playbackActive = false; updatePosition(false); + emit sendFrameBatch(&sendingBuffer); } void FramePlaybackWindow::btnPauseClick() @@ -450,9 +452,11 @@ void FramePlaybackWindow::btnPlayClick() void FramePlaybackWindow::btnFwdOneClick() { + sendingBuffer.clear(); playbackTimer->stop(); playbackActive = false; updatePosition(true); + emit sendFrameBatch(&sendingBuffer); } void FramePlaybackWindow::changePlaybackSpeed(int newSpeed) diff --git a/graphingwindow.cpp b/graphingwindow.cpp index 0deecd5..6aff9ec 100644 --- a/graphingwindow.cpp +++ b/graphingwindow.cpp @@ -142,6 +142,7 @@ void GraphingWindow::updatedFrames(int numFrames) } else //just got some new frames. See if they are relevant. { + bool appendedToGraph = false; if (numFrames > modelFrames->count()) return; for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) { @@ -151,10 +152,17 @@ void GraphingWindow::updatedFrames(int numFrames) if (graphParams[j].ID == thisFrame.ID) { appendToGraph(graphParams[j], thisFrame); + appendedToGraph = true; } } } - ui->graphingView->replot(); + if (appendedToGraph) { + for (int j = 0; j < graphParams.count(); j++) + { + graphParams[j].ref->setData(graphParams[j].x, graphParams[j].y); + } + ui->graphingView->replot(); + } } } @@ -931,8 +939,6 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame) params.x.append(frame.timestamp - params.xbias); } params.y.append((tempVal * params.scale) + params.bias); - - params.ref->setData(params.x,params.y); } void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)