Addition of time normalization. Will reset the timing to start at zero and work up from there.

This commit is contained in:
Collin Kidder
2015-06-23 22:14:48 -04:00
parent 37f30116e7
commit 7f17aa8495
5 changed files with 30 additions and 0 deletions
+14
View File
@@ -17,6 +17,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
dbcHandler = NULL;
interpretFrames = false;
overwriteDups = false;
timeOffset = 0;
}
void CANFrameModel::setDBCHandler(DBCHandler *handler)
@@ -36,6 +37,18 @@ void CANFrameModel::setInterpetMode(bool mode)
}
}
void CANFrameModel::normalizeTiming()
{
if (frames.count() == 0) return;
this->beginResetModel();
timeOffset = frames[0].timestamp;
for (int i = 0; i < frames.count(); i++)
{
frames[i].timestamp -= timeOffset;
}
this->endResetModel();
}
void CANFrameModel::setOverwriteMode(bool mode)
{
overwriteDups = mode;
@@ -140,6 +153,7 @@ void CANFrameModel::addFrame(CANFrame &frame, bool autoRefresh = false)
{
mutex.lock();
if (autoRefresh) beginInsertRows(QModelIndex(), frames.count() + 1, frames.count() + 1);
frame.timestamp -= timeOffset;
frames.append(frame);
if (autoRefresh) endInsertRows();
mutex.unlock();
+2
View File
@@ -29,6 +29,7 @@ public:
void setDBCHandler(DBCHandler *);
void setInterpetMode(bool);
void setOverwriteMode(bool);
void normalizeTiming();
QVector<CANFrame> *getListReference();
@@ -38,6 +39,7 @@ private:
QMutex mutex;
bool interpretFrames; //should we use the dbcHandler?
bool overwriteDups; //should we display all frames or only the newest for each ID?
uint64_t timeOffset;
};
+6
View File
@@ -130,6 +130,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->actionSave_Decoded_Frames, SIGNAL(triggered(bool)), this, SLOT(handleSaveDecoded()));
connect(ui->actionSingle_Multi_State, SIGNAL(triggered(bool)), this, SLOT(showSingleMultiWindow()));
connect(ui->actionFile_Comparison, SIGNAL(triggered(bool)), this, SLOT(showComparisonWindow()));
connect(ui->btnNormalize, SIGNAL(clicked(bool)), this, SLOT(normalizeTiming()));
lbStatusConnected.setText(tr("Not connected"));
updateFileStatus();
@@ -268,6 +269,11 @@ void MainWindow::clearFrames()
emit framesUpdated(-1);
}
void MainWindow::normalizeTiming()
{
model->normalizeTiming();
}
void MainWindow::changeBaudRates()
{
int Speed1 = 0, Speed2 = 0;
+1
View File
@@ -58,6 +58,7 @@ private slots:
void overwriteToggled(bool);
void showDBCEditor();
void toggleCapture();
void normalizeTiming();
public slots:
void gotFrames(int, int);
+7
View File
@@ -201,6 +201,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnNormalize">
<property name="text">
<string>Normalize Frame Timing</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClearFrames">
<property name="text">