Addition of time normalization. Will reset the timing to start at zero and work up from there.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -58,6 +58,7 @@ private slots:
|
||||
void overwriteToggled(bool);
|
||||
void showDBCEditor();
|
||||
void toggleCapture();
|
||||
void normalizeTiming();
|
||||
|
||||
public slots:
|
||||
void gotFrames(int, int);
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user