Addition of "System Time" mode where frames are timestamped by
absolute time from the PC clock.
This commit is contained in:
+16
-2
@@ -3,6 +3,7 @@
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QDateTime>
|
||||
#include "utility.h"
|
||||
|
||||
|
||||
@@ -91,6 +92,16 @@ void CANFrameModel::setSecondsMode(bool mode)
|
||||
}
|
||||
}
|
||||
|
||||
void CANFrameModel::setSysTimeMode(bool mode)
|
||||
{
|
||||
if (useSystemTime != mode)
|
||||
{
|
||||
this->beginResetModel();
|
||||
useSystemTime = mode;
|
||||
this->endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
void CANFrameModel::setInterpetMode(bool mode)
|
||||
{
|
||||
//if the state of interpretFrames changes then we need to reset the model
|
||||
@@ -237,8 +248,11 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
switch (index.column())
|
||||
{
|
||||
case 0: //timestamp
|
||||
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
||||
else return QString::number((double)thisFrame.timestamp / 1000000.0, 'f', 6);
|
||||
if (!useSystemTime) {
|
||||
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
||||
else return QString::number((double)thisFrame.timestamp / 1000000.0, 'f', 6);
|
||||
}
|
||||
else return QDateTime::fromMSecsSinceEpoch(thisFrame.timestamp / 1000).toString("MMM-dd HH:mm:ss.zzz");
|
||||
break;
|
||||
case 1: //id
|
||||
return Utility::formatNumber(thisFrame.ID);
|
||||
|
||||
+3
-1
@@ -23,7 +23,7 @@ public:
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
int columnCount(const QModelIndex &) const;
|
||||
int totalFrameCount();
|
||||
int totalFrameCount();
|
||||
|
||||
void sendRefresh();
|
||||
void sendRefresh(int);
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
void setInterpetMode(bool);
|
||||
void setOverwriteMode(bool);
|
||||
void setHexMode(bool);
|
||||
void setSysTimeMode(bool);
|
||||
void setFilterState(unsigned int ID, bool state);
|
||||
void setAllFilters(bool state);
|
||||
void setSecondsMode(bool);
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
||||
bool useHexMode;
|
||||
bool timeSeconds;
|
||||
bool useSystemTime;
|
||||
bool needFilterRefresh;
|
||||
uint64_t timeOffset;
|
||||
int lastUpdateNumFrames;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 169
|
||||
#define VERSION 170
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
|
||||
#include "canconmanager.h"
|
||||
|
||||
@@ -24,6 +25,14 @@ CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||
mNumActiveBuses = 0;
|
||||
|
||||
resetTimeBasis();
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("Main/TimeClock", false).toBool())
|
||||
{
|
||||
useSystemTime = true;
|
||||
}
|
||||
else useSystemTime = false;
|
||||
}
|
||||
|
||||
void CANConManager::resetTimeBasis()
|
||||
@@ -168,7 +177,8 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
|
||||
{
|
||||
workingFrame.bus -= busBase;
|
||||
workingFrame.isReceived = false;
|
||||
workingFrame.timestamp = ((QDateTime::currentMSecsSinceEpoch() * 1000) - mTimestampBasis);
|
||||
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000);
|
||||
if (!useSystemTime) workingFrame.timestamp -= mTimestampBasis;
|
||||
txFrame = conn->getQueue().get();
|
||||
*txFrame = workingFrame;
|
||||
conn->getQueue().queue();
|
||||
|
||||
@@ -74,6 +74,7 @@ private:
|
||||
QTimer mTimer;
|
||||
uint64_t mTimestampBasis;
|
||||
uint32_t mNumActiveBuses;
|
||||
bool useSystemTime;
|
||||
};
|
||||
|
||||
#endif // CANCONNECTIONMODEL_H
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <QSettings>
|
||||
#include <QThread>
|
||||
#include "canconnection.h"
|
||||
|
||||
@@ -79,6 +80,14 @@ void CANConnection::start()
|
||||
/* set started flag */
|
||||
mStarted = true;
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("Main/TimeClock", false).toBool())
|
||||
{
|
||||
useSystemTime = true;
|
||||
}
|
||||
else useSystemTime = false;
|
||||
|
||||
/* in multithread case, this will be called before entering thread event loop */
|
||||
return piStarted();
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ protected:
|
||||
void setCapSuspended(bool pIsSuspended);
|
||||
|
||||
protected:
|
||||
bool useSystemTime;
|
||||
|
||||
/**************************************************************/
|
||||
/*********** protected interface to implement *******/
|
||||
|
||||
@@ -400,6 +400,10 @@ void GVRetSerial::procRXChar(unsigned char c)
|
||||
buildFrame.timestamp |= (uint)c << 24;
|
||||
|
||||
buildFrame.timestamp += timeBasis;
|
||||
if (useSystemTime)
|
||||
{
|
||||
buildFrame.timestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
buildFrame.ID = c;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QCanBusFrame>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "socketcan.h"
|
||||
|
||||
@@ -189,7 +190,10 @@ void SocketCan::framesReceived()
|
||||
frame_p->extended = false;
|
||||
frame_p->ID = recFrame.frameId();
|
||||
frame_p->isReceived = true;
|
||||
frame_p->timestamp = (recFrame.timeStamp().seconds()*1000000 + recFrame.timeStamp().microSeconds()) - timeBasis;
|
||||
if (useSystemTime) {
|
||||
frame_p->timestamp = QDateTime::currentMSecsSinceEpoch() * 1000ul;
|
||||
}
|
||||
else frame_p->timestamp = (recFrame.timeStamp().seconds() * 1000000ul + recFrame.timeStamp().microSeconds()) - timeBasis;
|
||||
|
||||
checkTargettedFrame(*frame_p);
|
||||
|
||||
|
||||
+30
-3
@@ -26,7 +26,31 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
||||
ui->cbRestorePositions->setChecked(settings->value("Main/SaveRestorePositions", true).toBool());
|
||||
ui->cbValidate->setChecked(settings->value("Main/ValidateComm", true).toBool());
|
||||
ui->spinPlaybackSpeed->setValue(settings->value("Playback/DefSpeed", 5).toInt());
|
||||
ui->cbTimeSeconds->setChecked(settings->value("Main/TimeSeconds", false).toBool());
|
||||
|
||||
bool secondsMode = settings->value("Main/TimeSeconds", false).toBool();
|
||||
bool clockMode = settings->value("Main/TimeClock", false).toBool();
|
||||
if (clockMode)
|
||||
{
|
||||
ui->rbSeconds->setChecked(false);
|
||||
ui->rbMicros->setChecked(false);
|
||||
ui->rbSysClock->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (secondsMode)
|
||||
{
|
||||
ui->rbSeconds->setChecked(true);
|
||||
ui->rbMicros->setChecked(false);
|
||||
ui->rbSysClock->setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->rbSeconds->setChecked(false);
|
||||
ui->rbMicros->setChecked(true);
|
||||
ui->rbSysClock->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
ui->comboSendingBus->setCurrentIndex(settings->value("Playback/SendingBus", 4).toInt());
|
||||
ui->cbUseFiltered->setChecked(settings->value("Main/UseFiltered", false).toBool());
|
||||
|
||||
@@ -40,7 +64,9 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
||||
connect(ui->cbRestorePositions, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->cbValidate, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->spinPlaybackSpeed, SIGNAL(valueChanged(int)), this, SLOT(updateSettings()));
|
||||
connect(ui->cbTimeSeconds, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->rbSeconds, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->rbMicros, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->rbSysClock, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
|
||||
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
}
|
||||
@@ -68,7 +94,8 @@ void MainSettingsDialog::updateSettings()
|
||||
settings->setValue("Main/SaveRestorePositions", ui->cbRestorePositions->isChecked());
|
||||
settings->setValue("Main/ValidateComm", ui->cbValidate->isChecked());
|
||||
settings->setValue("Playback/DefSpeed", ui->spinPlaybackSpeed->value());
|
||||
settings->setValue("Main/TimeSeconds", ui->cbTimeSeconds->isChecked());
|
||||
settings->setValue("Main/TimeSeconds", ui->rbSeconds->isChecked());
|
||||
settings->setValue("Main/TimeClock", ui->rbSysClock->isChecked());
|
||||
settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
|
||||
settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
|
||||
|
||||
|
||||
+4
-15
@@ -52,13 +52,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
readSettings();
|
||||
|
||||
ui->canFramesView->setColumnWidth(0, 110);
|
||||
ui->canFramesView->setColumnWidth(0, 150);
|
||||
ui->canFramesView->setColumnWidth(1, 70);
|
||||
ui->canFramesView->setColumnWidth(2, 40);
|
||||
ui->canFramesView->setColumnWidth(3, 40);
|
||||
ui->canFramesView->setColumnWidth(4, 40);
|
||||
ui->canFramesView->setColumnWidth(5, 40);
|
||||
ui->canFramesView->setColumnWidth(6, 275);
|
||||
ui->canFramesView->setColumnWidth(6, 225);
|
||||
QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader();
|
||||
HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview
|
||||
|
||||
@@ -256,19 +256,6 @@ void MainWindow::readSettings()
|
||||
ui->cbAutoScroll->setChecked(true);
|
||||
}
|
||||
|
||||
/*
|
||||
int cType = settings.value("Main/DefaultConnectionType", 0).toInt();
|
||||
if (cType == 0) connType = "GVRET";
|
||||
if (cType == 1) connType = "KVASER";
|
||||
if (cType == 2) connType = "SOCKETCAN";
|
||||
portName = settings.value("Main/DefaultConnectionPort", "").toString();
|
||||
*/
|
||||
|
||||
//qDebug() << connType;
|
||||
//qDebug() << portName;
|
||||
|
||||
//"Main/SingleWireMode"
|
||||
|
||||
readUpdateableSettings();
|
||||
}
|
||||
|
||||
@@ -280,6 +267,8 @@ void MainWindow::readUpdateableSettings()
|
||||
Utility::decimalMode = !useHex;
|
||||
secondsMode = settings.value("Main/TimeSeconds", false).toBool();
|
||||
model->setSecondsMode(secondsMode);
|
||||
useSystemClock = settings.value("Main/TimeClock", false).toBool();
|
||||
model->setSysTimeMode(useSystemClock);
|
||||
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ private:
|
||||
bool useHex;
|
||||
bool allowCapture;
|
||||
bool secondsMode;
|
||||
bool useSystemClock;
|
||||
bool bDirty; //have frames been added or subtracted since the last save/load?
|
||||
bool useFiltered; //should sub-windows use the unfiltered or filtered frames list?
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>580</height>
|
||||
<height>687</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -42,10 +42,57 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbTimeSeconds">
|
||||
<property name="text">
|
||||
<string>Display time in seconds</string>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Time Keeping</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Seconds/Microseconds are dongle based</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbSeconds">
|
||||
<property name="text">
|
||||
<string>Seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbMicros">
|
||||
<property name="text">
|
||||
<string>Microseconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbSysClock">
|
||||
<property name="text">
|
||||
<string>System Clock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user