Skip to content

Commit

Permalink
Added two modes - millisecond timestamps for frames and a way to
Browse files Browse the repository at this point in the history
ignore colors set in DBC files
  • Loading branch information
collin80 committed Jan 20, 2022
1 parent 3dadb6c commit 37e8ad5
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 13 deletions.
24 changes: 22 additions & 2 deletions canframemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ void CANFrameModel::setSysTimeMode(bool mode)
}
}

void CANFrameModel::setMillisMode(bool mode)
{
if (Utility::millisMode != mode)
{
this->beginResetModel();
Utility::millisMode = mode;
this->endResetModel();
}
}

void CANFrameModel::setInterpretMode(bool mode)
{
//if the state of interpretFrames changes then we need to reset the model
Expand All @@ -127,6 +137,16 @@ void CANFrameModel::setTimeFormat(QString format)
endResetModel();
}

void CANFrameModel::setIgnoreDBCColors(bool mode)
{
if(ignoreDBCColors != mode)
{
beginResetModel(); //reset model to update the view
ignoreDBCColors = mode;
endResetModel();
}
}

/*
* Scan all frames for the smallest timestamp and offset all timestamps so that smallest one is at 0
*/
Expand Down Expand Up @@ -385,7 +405,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const

if (role == Qt::BackgroundColorRole)
{
if (dbcHandler != nullptr && interpretFrames)
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
{
DBC_MESSAGE *msg = dbcHandler->findMessage(thisFrame);
if (msg != nullptr)
Expand Down Expand Up @@ -418,7 +438,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const

if (role == Qt::TextColorRole)
{
if (dbcHandler != nullptr && interpretFrames)
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
{
DBC_MESSAGE *msg = dbcHandler->findMessage(thisFrame);
if (msg != nullptr)
Expand Down
3 changes: 3 additions & 0 deletions canframemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class CANFrameModel: public QAbstractTableModel
void setOverwriteMode(bool);
void setHexMode(bool);
void setSysTimeMode(bool);
void setMillisMode(bool mode);
void setIgnoreDBCColors(bool mode);
void setFilterState(unsigned int ID, bool state);
void setBusFilterState(unsigned int BusID, bool state);
void setAllFilters(bool state);
Expand Down Expand Up @@ -92,6 +94,7 @@ public slots:
bool timeSeconds;
bool useSystemTime;
bool needFilterRefresh;
bool ignoreDBCColors;
int64_t timeOffset;
int lastUpdateNumFrames;
uint32_t preallocSize;
Expand Down
18 changes: 17 additions & 1 deletion mainsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
QSettings settings;
ui->setupUi(this);

//TODO: This is still hard coded to support only two buses. Sometimes there is none, sometimes 1, sometimes much more than 2. Fix this.
//TODO: This is still hard coded to support only two buses. Sometimes there is none, sometimes 1, sometimes much more than 2. Fix this.
ui->comboSendingBus->addItem(tr("None"));
ui->comboSendingBus->addItem(tr("0"));
ui->comboSendingBus->addItem(tr("1"));
Expand Down Expand Up @@ -51,11 +51,13 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :

bool secondsMode = settings.value("Main/TimeSeconds", false).toBool();
bool clockMode = settings.value("Main/TimeClock", false).toBool();
bool milliMode = settings.value("Main/TimeMillis", false).toBool();
if (clockMode)
{
ui->rbSeconds->setChecked(false);
ui->rbMicros->setChecked(false);
ui->rbSysClock->setChecked(true);
ui->rbMillis->setChecked(false);
}
else
{
Expand All @@ -64,19 +66,29 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
ui->rbSeconds->setChecked(true);
ui->rbMicros->setChecked(false);
ui->rbSysClock->setChecked(false);
ui->rbMillis->setChecked(false);
}
else if (milliMode)
{
ui->rbSeconds->setChecked(false);
ui->rbMicros->setChecked(false);
ui->rbSysClock->setChecked(false);
ui->rbMillis->setChecked(true);
}
else
{
ui->rbSeconds->setChecked(false);
ui->rbMicros->setChecked(true);
ui->rbSysClock->setChecked(false);
ui->rbMillis->setChecked(false);
}
}

ui->comboSendingBus->setCurrentIndex(settings.value("Playback/SendingBus", 4).toInt());
ui->cbUseFiltered->setChecked(settings.value("Main/UseFiltered", false).toBool());
ui->cbUseOpenGL->setChecked(settings.value("Main/UseOpenGL", false).toBool());
ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool());
ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool());

//just for simplicity they all call the same function and that function updates all settings at once
connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
Expand All @@ -91,6 +103,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
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->rbMillis, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->lineClockFormat, SIGNAL(editingFinished()), this, SLOT(updateSettings()));
Expand All @@ -103,6 +116,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
connect(ui->cbFilterLabeling, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));

installEventFilter(this);
}
Expand Down Expand Up @@ -155,6 +169,7 @@ void MainSettingsDialog::updateSettings()
settings.setValue("Main/ValidateComm", ui->cbValidate->isChecked());
settings.setValue("Playback/DefSpeed", ui->spinPlaybackSpeed->value());
settings.setValue("Main/TimeSeconds", ui->rbSeconds->isChecked());
settings.setValue("Main/TimeMillis", ui->rbMillis->isChecked());
settings.setValue("Main/TimeClock", ui->rbSysClock->isChecked());
settings.setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
settings.setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
Expand All @@ -167,6 +182,7 @@ void MainSettingsDialog::updateSettings()
QByteArray encPass = crypto.encryptToByteArray(ui->lineRemotePassword->text());
settings.setValue("Remote/Pass", encPass);
settings.setValue("Main/FilterLabeling", ui->cbFilterLabeling->isChecked());
settings.setValue("Main/IgnoreDBCColors", ui->cbIgnoreDBCColors->isChecked());

settings.sync();
emit updatedSettings();
Expand Down
9 changes: 9 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ void MainWindow::readSettings()
readUpdateableSettings();
}


/*
* TODO: The way the frame timing mode is specified is DEAD STUPID. There shouldn't be three boolean values
* for this. Instead switch it all to an ENUM or something sane.
*/
void MainWindow::readUpdateableSettings()
{
QSettings settings;
Expand All @@ -371,8 +376,12 @@ void MainWindow::readUpdateableSettings()
model->setSecondsMode(secondsMode);
useSystemClock = settings.value("Main/TimeClock", false).toBool();
model->setSysTimeMode(useSystemClock);
millisMode = settings.value("Main/TimeMillis", false).toBool();
model->setMillisMode(millisMode);
useFiltered = settings.value("Main/UseFiltered", false).toBool();
model->setTimeFormat(settings.value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
ignoreDBCColors = settings.value("Main/IgnoreDBCColors", false).toBool();
model->setIgnoreDBCColors(ignoreDBCColors);

if (settings.value("Main/FilterLabeling", false).toBool())
ui->listFilters->setMaximumWidth(250);
Expand Down
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public slots:
bool useHex;
bool allowCapture;
bool secondsMode;
bool millisMode;
bool useSystemClock;
bool ignoreDBCColors;
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?

Expand Down
41 changes: 32 additions & 9 deletions ui/mainsettingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>965</width>
<height>668</height>
<height>678</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -73,13 +73,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbFilterLabeling">
<property name="text">
<string>Label filters using messages from DBC files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbUseOpenGL">
<property name="text">
Expand All @@ -96,7 +89,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Seconds/Microseconds are dongle based</string>
<string>Seconds/Milli/Micro are dongle based</string>
</property>
</widget>
</item>
Expand All @@ -116,6 +109,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbMillis">
<property name="text">
<string>Milliseconds</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -275,6 +275,29 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>DBC Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="cbFilterLabeling">
<property name="text">
<string>Label DBC Signals by default</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbIgnoreDBCColors">
<property name="text">
<string>Ignore DBC signal colors</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
Expand Down
1 change: 1 addition & 0 deletions utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
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";
7 changes: 6 additions & 1 deletion utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Utility

static bool decimalMode;
static bool secondsMode;
static bool millisMode;
static bool sysTimeMode;
static QString timeFormat;

Expand Down Expand Up @@ -148,8 +149,12 @@ class Utility
static QVariant formatTimestamp(uint64_t timestamp)
{
if (!sysTimeMode) {
if (millisMode) return (double)timestamp / 1000.0;
if (!secondsMode) return (unsigned long long)(timestamp);
else return (double)timestamp / 1000000.0;
else
{
return (double)timestamp / 1000000.0;
}
}
else return QDateTime::fromMSecsSinceEpoch(timestamp / 1000);
}
Expand Down

0 comments on commit 37e8ad5

Please sign in to comment.