Switched up the way time stamp formatting is done. Now tracked by an
enum for easier determination. Also changed graphing window to respect "system clock" style timestamps and display them properly.
This commit is contained in:
+6
-25
@@ -76,7 +76,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
|||||||
overwriteDups = false;
|
overwriteDups = false;
|
||||||
filtersPersistDuringClear = false;
|
filtersPersistDuringClear = false;
|
||||||
useHexMode = true;
|
useHexMode = true;
|
||||||
timeSeconds = false;
|
timeStyle = TS_MICROS;
|
||||||
timeOffset = 0;
|
timeOffset = 0;
|
||||||
needFilterRefresh = false;
|
needFilterRefresh = false;
|
||||||
lastUpdateNumFrames = 0;
|
lastUpdateNumFrames = 0;
|
||||||
@@ -101,32 +101,13 @@ void CANFrameModel::setHexMode(bool mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANFrameModel::setSecondsMode(bool mode)
|
void CANFrameModel::setTimeStyle(TimeStyle newStyle)
|
||||||
{
|
{
|
||||||
if (Utility::secondsMode != mode)
|
if (timeStyle != newStyle)
|
||||||
{
|
{
|
||||||
this->beginResetModel();
|
this->beginResetModel();
|
||||||
Utility::secondsMode = mode;
|
timeStyle = newStyle;
|
||||||
this->endResetModel();
|
Utility::timeStyle = newStyle;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CANFrameModel::setSysTimeMode(bool mode)
|
|
||||||
{
|
|
||||||
if (Utility::sysTimeMode != mode)
|
|
||||||
{
|
|
||||||
this->beginResetModel();
|
|
||||||
Utility::sysTimeMode = mode;
|
|
||||||
this->endResetModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CANFrameModel::setMillisMode(bool mode)
|
|
||||||
{
|
|
||||||
if (Utility::millisMode != mode)
|
|
||||||
{
|
|
||||||
this->beginResetModel();
|
|
||||||
Utility::millisMode = mode;
|
|
||||||
this->endResetModel();
|
this->endResetModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,7 +468,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
//Reformatting the output a bit with custom code
|
//Reformatting the output a bit with custom code
|
||||||
if (overwriteDups)
|
if (overwriteDups)
|
||||||
{
|
{
|
||||||
if (timeSeconds) return QString::number(thisFrame.timedelta / 1000000.0, 'f', 5);
|
if (timeStyle == TS_SECONDS) return QString::number(thisFrame.timedelta / 1000000.0, 'f', 5);
|
||||||
return QString::number(thisFrame.timedelta);
|
return QString::number(thisFrame.timedelta);
|
||||||
}
|
}
|
||||||
else ts = Utility::formatTimestamp(thisFrame.timeStamp().microSeconds());
|
else ts = Utility::formatTimestamp(thisFrame.timeStamp().microSeconds());
|
||||||
|
|||||||
+3
-5
@@ -9,6 +9,7 @@
|
|||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
#include "dbc/dbchandler.h"
|
#include "dbc/dbchandler.h"
|
||||||
#include "connections/canconnection.h"
|
#include "connections/canconnection.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
enum class Column {
|
enum class Column {
|
||||||
TimeStamp = 0, ///< The timestamp when the frame was transmitted or received
|
TimeStamp = 0, ///< The timestamp when the frame was transmitted or received
|
||||||
@@ -47,13 +48,11 @@ public:
|
|||||||
void setOverwriteMode(bool);
|
void setOverwriteMode(bool);
|
||||||
void setHexMode(bool);
|
void setHexMode(bool);
|
||||||
void setClearMode(bool mode);
|
void setClearMode(bool mode);
|
||||||
void setSysTimeMode(bool);
|
void setTimeStyle(TimeStyle newStyle);
|
||||||
void setMillisMode(bool mode);
|
|
||||||
void setIgnoreDBCColors(bool mode);
|
void setIgnoreDBCColors(bool mode);
|
||||||
void setFilterState(unsigned int ID, bool state);
|
void setFilterState(unsigned int ID, bool state);
|
||||||
void setBusFilterState(unsigned int BusID, bool state);
|
void setBusFilterState(unsigned int BusID, bool state);
|
||||||
void setAllFilters(bool state);
|
void setAllFilters(bool state);
|
||||||
void setSecondsMode(bool);
|
|
||||||
void setTimeFormat(QString);
|
void setTimeFormat(QString);
|
||||||
void setBytesPerLine(int bpl);
|
void setBytesPerLine(int bpl);
|
||||||
void loadFilterFile(QString filename);
|
void loadFilterFile(QString filename);
|
||||||
@@ -93,9 +92,8 @@ private:
|
|||||||
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
||||||
bool filtersPersistDuringClear;
|
bool filtersPersistDuringClear;
|
||||||
QString timeFormat;
|
QString timeFormat;
|
||||||
|
TimeStyle timeStyle;
|
||||||
bool useHexMode;
|
bool useHexMode;
|
||||||
bool timeSeconds;
|
|
||||||
bool useSystemTime;
|
|
||||||
bool needFilterRefresh;
|
bool needFilterRefresh;
|
||||||
bool ignoreDBCColors;
|
bool ignoreDBCColors;
|
||||||
int64_t timeOffset;
|
int64_t timeOffset;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 212
|
#define VERSION 213
|
||||||
|
|
||||||
//try to keep this in sync.
|
//try to keep this in sync.
|
||||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||||
|
|||||||
+11
-6
@@ -387,12 +387,17 @@ void MainWindow::readUpdateableSettings()
|
|||||||
useHex = settings.value("Main/UseHex", true).toBool();
|
useHex = settings.value("Main/UseHex", true).toBool();
|
||||||
model->setHexMode(useHex);
|
model->setHexMode(useHex);
|
||||||
Utility::decimalMode = !useHex;
|
Utility::decimalMode = !useHex;
|
||||||
secondsMode = settings.value("Main/TimeSeconds", false).toBool();
|
|
||||||
model->setSecondsMode(secondsMode);
|
bool tempBool;
|
||||||
useSystemClock = settings.value("Main/TimeClock", false).toBool();
|
TimeStyle ts = TS_MICROS;
|
||||||
model->setSysTimeMode(useSystemClock);
|
tempBool = settings.value("Main/TimeSeconds", false).toBool();
|
||||||
millisMode = settings.value("Main/TimeMillis", false).toBool();
|
if (tempBool) ts = TS_SECONDS;
|
||||||
model->setMillisMode(millisMode);
|
tempBool = settings.value("Main/TimeClock", false).toBool();
|
||||||
|
if (tempBool) ts = TS_CLOCK;
|
||||||
|
tempBool = settings.value("Main/TimeMillis", false).toBool();
|
||||||
|
if (tempBool) ts = TS_MILLIS;
|
||||||
|
model->setTimeStyle(ts);
|
||||||
|
|
||||||
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
||||||
model->setTimeFormat(settings.value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
|
model->setTimeFormat(settings.value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
|
||||||
ignoreDBCColors = settings.value("Main/IgnoreDBCColors", false).toBool();
|
ignoreDBCColors = settings.value("Main/IgnoreDBCColors", false).toBool();
|
||||||
|
|||||||
@@ -147,9 +147,6 @@ private:
|
|||||||
bool inhibitFilterUpdate;
|
bool inhibitFilterUpdate;
|
||||||
bool useHex;
|
bool useHex;
|
||||||
bool allowCapture;
|
bool allowCapture;
|
||||||
bool secondsMode;
|
|
||||||
bool millisMode;
|
|
||||||
bool useSystemClock;
|
|
||||||
bool ignoreDBCColors;
|
bool ignoreDBCColors;
|
||||||
bool bDirty; //have frames been added or subtracted since the last save/load?
|
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?
|
bool useFiltered; //should sub-windows use the unfiltered or filtered frames list?
|
||||||
|
|||||||
+24
-6
@@ -3,6 +3,7 @@
|
|||||||
#include "newgraphdialog.h"
|
#include "newgraphdialog.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "helpwindow.h"
|
#include "helpwindow.h"
|
||||||
|
#include "utility.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -33,9 +34,16 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
|
|||||||
ui->graphingView->xAxis->setLabel("Time Axis");
|
ui->graphingView->xAxis->setLabel("Time Axis");
|
||||||
ui->graphingView->yAxis->setLabel("Value Axis");
|
ui->graphingView->yAxis->setLabel("Value Axis");
|
||||||
ui->graphingView->xAxis->setNumberFormat("f");
|
ui->graphingView->xAxis->setNumberFormat("f");
|
||||||
if (secondsMode) ui->graphingView->xAxis->setNumberPrecision(6);
|
if (Utility::timeStyle == TS_SECONDS) ui->graphingView->xAxis->setNumberPrecision(6);
|
||||||
else ui->graphingView->xAxis->setNumberPrecision(0);
|
else ui->graphingView->xAxis->setNumberPrecision(0);
|
||||||
|
|
||||||
|
if (Utility::timeStyle == TS_CLOCK)
|
||||||
|
{
|
||||||
|
QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
|
||||||
|
timeTicker->setTimeFormat("%h:%m:%s.%z");
|
||||||
|
ui->graphingView->xAxis->setTicker(timeTicker);
|
||||||
|
}
|
||||||
|
|
||||||
ui->graphingView->legend->setVisible(true);
|
ui->graphingView->legend->setVisible(true);
|
||||||
QFont legendFont = font();
|
QFont legendFont = font();
|
||||||
legendFont.setPointSize(10);
|
legendFont.setPointSize(10);
|
||||||
@@ -154,7 +162,7 @@ void GraphingWindow::readSettings()
|
|||||||
resize(settings.value("Graphing/WindowSize", QSize(800, 600)).toSize());
|
resize(settings.value("Graphing/WindowSize", QSize(800, 600)).toSize());
|
||||||
move(Utility::constrainedWindowPos(settings.value("Graphing/WindowPos", QPoint(50, 50)).toPoint()));
|
move(Utility::constrainedWindowPos(settings.value("Graphing/WindowPos", QPoint(50, 50)).toPoint()));
|
||||||
}
|
}
|
||||||
secondsMode = settings.value("Main/TimeSeconds", false).toBool();
|
|
||||||
useOpenGL = settings.value("Main/UseOpenGL", false).toBool();
|
useOpenGL = settings.value("Main/UseOpenGL", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +275,7 @@ void GraphingWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, int d
|
|||||||
//apply transforms to get the X axis value where we double clicked
|
//apply transforms to get the X axis value where we double clicked
|
||||||
double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x());
|
double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x());
|
||||||
id = plottable->property("id").toInt();
|
id = plottable->property("id").toInt();
|
||||||
if (secondsMode) emit sendCenterTimeID(id, coord);
|
if (Utility::timeStyle == TS_SECONDS) emit sendCenterTimeID(id, coord);
|
||||||
else emit sendCenterTimeID(id, coord / 1000000.0);
|
else emit sendCenterTimeID(id, coord / 1000000.0);
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
@@ -298,7 +306,7 @@ void GraphingWindow::gotCenterTimeID(uint32_t ID, double timestamp)
|
|||||||
|
|
||||||
QCPRange range = ui->graphingView->xAxis->range();
|
QCPRange range = ui->graphingView->xAxis->range();
|
||||||
double offset = range.size() / 2.0;
|
double offset = range.size() / 2.0;
|
||||||
if (!secondsMode) timestamp *= 1000000.0; //timestamp is always in seconds when being passed so convert if necessary
|
if (Utility::timeStyle != TS_SECONDS) timestamp *= 1000000.0; //timestamp is always in seconds when being passed so convert if necessary
|
||||||
ui->graphingView->xAxis->setRange(timestamp - offset, timestamp + offset);
|
ui->graphingView->xAxis->setRange(timestamp - offset, timestamp + offset);
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
@@ -1242,10 +1250,15 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector
|
|||||||
int64_t tempVal; //64 bit temp value.
|
int64_t tempVal; //64 bit temp value.
|
||||||
tempVal = Utility::processIntegerSignal(frame.payload(), params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
|
tempVal = Utility::processIntegerSignal(frame.payload(), params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
|
||||||
double xVal, yVal;
|
double xVal, yVal;
|
||||||
if (secondsMode)
|
if (Utility::timeStyle == TS_SECONDS)
|
||||||
{
|
{
|
||||||
xVal = ((double)(frame.timeStamp().microSeconds()) / 1000000.0 - params.xbias);
|
xVal = ((double)(frame.timeStamp().microSeconds()) / 1000000.0 - params.xbias);
|
||||||
}
|
}
|
||||||
|
else if (Utility::timeStyle == TS_CLOCK)
|
||||||
|
{
|
||||||
|
QDateTime dt = QDateTime::fromMSecsSinceEpoch((frame.timeStamp().microSeconds() / 1000) - params.xbias);
|
||||||
|
xVal = (dt.time().second() + dt.time().minute() * 60 + dt.time().hour() * 3600);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xVal = (frame.timeStamp().microSeconds() - params.xbias);
|
xVal = (frame.timeStamp().microSeconds() - params.xbias);
|
||||||
@@ -1375,10 +1388,15 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
|||||||
y = (tempVal * params.scale) + params.bias;
|
y = (tempVal * params.scale) + params.bias;
|
||||||
params.y.append( y );
|
params.y.append( y );
|
||||||
|
|
||||||
if (secondsMode)
|
if (Utility::timeStyle == TS_SECONDS)
|
||||||
{
|
{
|
||||||
x = (frameCache[k].timeStamp().microSeconds()) / 1000000.0;
|
x = (frameCache[k].timeStamp().microSeconds()) / 1000000.0;
|
||||||
}
|
}
|
||||||
|
else if (Utility::timeStyle == TS_CLOCK)
|
||||||
|
{
|
||||||
|
QDateTime dt = QDateTime::fromMSecsSinceEpoch((frameCache[k].timeStamp().microSeconds() / 1000) - params.xbias);
|
||||||
|
x = (dt.time().msecsSinceStartOfDay() / 1000.0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = frameCache[k].timeStamp().microSeconds();
|
x = frameCache[k].timeStamp().microSeconds();
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ private:
|
|||||||
QCPItemText *locationText;
|
QCPItemText *locationText;
|
||||||
QCPItemTracer *itemTracer;
|
QCPItemTracer *itemTracer;
|
||||||
bool needScaleSetup; //do we need to set x,y graphing extents?
|
bool needScaleSetup; //do we need to set x,y graphing extents?
|
||||||
bool secondsMode;
|
|
||||||
bool useOpenGL;
|
bool useOpenGL;
|
||||||
bool followGraphEnd;
|
bool followGraphEnd;
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
bool Utility::decimalMode = false;
|
bool Utility::decimalMode = false;
|
||||||
bool Utility::secondsMode = true;
|
|
||||||
bool Utility::sysTimeMode = false;
|
|
||||||
bool Utility::millisMode = false;
|
|
||||||
QString Utility::timeFormat = "MMM-dd HH:mm:ss.zzz";
|
QString Utility::timeFormat = "MMM-dd HH:mm:ss.zzz";
|
||||||
|
TimeStyle Utility::timeStyle = TS_MICROS;
|
||||||
|
|||||||
@@ -10,14 +10,20 @@
|
|||||||
#include <QRect>
|
#include <QRect>
|
||||||
//#include <QDesktopWidget>
|
//#include <QDesktopWidget>
|
||||||
|
|
||||||
|
enum TimeStyle
|
||||||
|
{
|
||||||
|
TS_SECONDS,
|
||||||
|
TS_MICROS,
|
||||||
|
TS_MILLIS,
|
||||||
|
TS_CLOCK
|
||||||
|
};
|
||||||
|
|
||||||
class Utility
|
class Utility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static bool decimalMode;
|
static bool decimalMode;
|
||||||
static bool secondsMode;
|
static TimeStyle timeStyle;
|
||||||
static bool millisMode;
|
|
||||||
static bool sysTimeMode;
|
|
||||||
static QString timeFormat;
|
static QString timeFormat;
|
||||||
|
|
||||||
//determines whether the window position is within any available screens. If it is not we default
|
//determines whether the window position is within any available screens. If it is not we default
|
||||||
@@ -153,16 +159,22 @@ public:
|
|||||||
|
|
||||||
static QVariant formatTimestamp(uint64_t timestamp)
|
static QVariant formatTimestamp(uint64_t timestamp)
|
||||||
{
|
{
|
||||||
if (!sysTimeMode) {
|
switch (timeStyle)
|
||||||
if (millisMode) return (double)timestamp / 1000.0;
|
|
||||||
if (!secondsMode) return (unsigned long long)(timestamp);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case TS_CLOCK:
|
||||||
|
return QDateTime::fromMSecsSinceEpoch(timestamp / 1000);
|
||||||
|
break;
|
||||||
|
case TS_MILLIS:
|
||||||
|
return (double)timestamp / 1000.0;
|
||||||
|
break;
|
||||||
|
case TS_MICROS:
|
||||||
|
return (unsigned long long)(timestamp);
|
||||||
|
break;
|
||||||
|
case TS_SECONDS:
|
||||||
return (double)timestamp / 1000000.0;
|
return (double)timestamp / 1000000.0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return QDateTime::fromMSecsSinceEpoch(timestamp / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
//parses the input string to grab as much of it as possible while staying alpha numeric
|
//parses the input string to grab as much of it as possible while staying alpha numeric
|
||||||
static QString grabAlphaNumeric(QString &input)
|
static QString grabAlphaNumeric(QString &input)
|
||||||
|
|||||||
Reference in New Issue
Block a user