Updated the entire program to work in either hex or decimal. Changing the mode in settings will change which is used in many places.
You can always still enter values in decimal, hex, or binary regardless of the mode you are in.
This commit is contained in:
+5
-7
@@ -1,6 +1,7 @@
|
|||||||
#include "canframemodel.h"
|
#include "canframemodel.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
int CANFrameModel::rowCount(const QModelIndex &parent) const
|
int CANFrameModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,7 @@ void CANFrameModel::setHexMode(bool mode)
|
|||||||
{
|
{
|
||||||
this->beginResetModel();
|
this->beginResetModel();
|
||||||
useHexMode = mode;
|
useHexMode = mode;
|
||||||
|
Utility::decimalMode = !useHexMode;
|
||||||
this->endResetModel();
|
this->endResetModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,11 +167,8 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
||||||
else return QString::number(thisFrame.timestamp / 1000000.0f);
|
else return QString::number(thisFrame.timestamp / 1000000.0f);
|
||||||
break;
|
break;
|
||||||
case 1: //id
|
case 1: //id
|
||||||
if (useHexMode)
|
return Utility::formatNumber(thisFrame.ID);
|
||||||
return QString::number(thisFrame.ID, 16).toUpper().rightJustified(2,'0');
|
|
||||||
else
|
|
||||||
return QString::number(thisFrame.ID).rightJustified(3,'0');
|
|
||||||
break;
|
break;
|
||||||
case 2: //ext
|
case 2: //ext
|
||||||
return QString::number(thisFrame.extended);
|
return QString::number(thisFrame.extended);
|
||||||
@@ -183,8 +182,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
case 5: //data
|
case 5: //data
|
||||||
for (int i = 0; i < thisFrame.len; i++)
|
for (int i = 0; i < thisFrame.len; i++)
|
||||||
{
|
{
|
||||||
if (useHexMode) tempString.append(QString::number(thisFrame.data[i], 16).toUpper().rightJustified(2,'0'));
|
tempString.append(Utility::formatNumber(thisFrame.data[i]));
|
||||||
else tempString.append(QString::number(thisFrame.data[i]).rightJustified(3,'0'));
|
|
||||||
tempString.append(" ");
|
tempString.append(" ");
|
||||||
}
|
}
|
||||||
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 130
|
#define VERSION 131
|
||||||
|
|
||||||
//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
|
||||||
|
|||||||
+4
-4
@@ -221,7 +221,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
|
|||||||
//dbcHandler->findNodeByIdx(0);
|
//dbcHandler->findNodeByIdx(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
msgID = ui->MessagesTable->item(row, 0)->text().toInt(NULL, 16);
|
msgID = Utility::ParseStringToNum(ui->MessagesTable->item(row, 0)->text());
|
||||||
qDebug() << "Msg ID of edited: " << msgID;
|
qDebug() << "Msg ID of edited: " << msgID;
|
||||||
msg = dbcHandler->findMsgByID(msgID);
|
msg = dbcHandler->findMsgByID(msgID);
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
|
|||||||
if (msg != NULL) msg->ID = msgID;
|
if (msg != NULL) msg->ID = msgID;
|
||||||
}
|
}
|
||||||
inhibitCellChanged = true;
|
inhibitCellChanged = true;
|
||||||
replacement = new QTableWidgetItem(QString::number(msgID, 16));
|
replacement = new QTableWidgetItem(Utility::formatNumber(msgID));
|
||||||
ui->MessagesTable->setItem(row, col, replacement);
|
ui->MessagesTable->setItem(row, col, replacement);
|
||||||
replacement = new QTableWidgetItem(QString::number(newMsg.len));
|
replacement = new QTableWidgetItem(QString::number(newMsg.len));
|
||||||
ui->MessagesTable->setItem(row, 2, replacement);
|
ui->MessagesTable->setItem(row, 2, replacement);
|
||||||
@@ -375,7 +375,7 @@ void DBCMainEditor::onCellClickedMessage(int row, int col)
|
|||||||
if (col == 3) //3 is the signals field. If clicked we go to the signals dialog
|
if (col == 3) //3 is the signals field. If clicked we go to the signals dialog
|
||||||
{
|
{
|
||||||
QString idString = ui->MessagesTable->item(row, 0)->text();
|
QString idString = ui->MessagesTable->item(row, 0)->text();
|
||||||
DBC_MESSAGE *message = dbcHandler->findMsgByID(idString.toInt(NULL, 16));
|
DBC_MESSAGE *message = dbcHandler->findMsgByID(Utility::ParseStringToNum(idString));
|
||||||
sigEditor->setMessageRef(message);
|
sigEditor->setMessageRef(message);
|
||||||
sigEditor->exec(); //blocks this window from being active until we're done
|
sigEditor->exec(); //blocks this window from being active until we're done
|
||||||
//now update the displayed # of signals
|
//now update the displayed # of signals
|
||||||
@@ -433,7 +433,7 @@ void DBCMainEditor::refreshMessagesTable(const DBC_NODE *node)
|
|||||||
if (msg.sender == node)
|
if (msg.sender == node)
|
||||||
{
|
{
|
||||||
//many of these are simplistic first versions just to test functionality.
|
//many of these are simplistic first versions just to test functionality.
|
||||||
QTableWidgetItem *msgID = new QTableWidgetItem(QString::number(msg.ID, 16));
|
QTableWidgetItem *msgID = new QTableWidgetItem(Utility::formatNumber(msg.ID));
|
||||||
QTableWidgetItem *msgName = new QTableWidgetItem(msg.name);
|
QTableWidgetItem *msgName = new QTableWidgetItem(msg.name);
|
||||||
QTableWidgetItem *msgLen = new QTableWidgetItem(QString::number(msg.len));
|
QTableWidgetItem *msgLen = new QTableWidgetItem(QString::number(msg.len));
|
||||||
QTableWidgetItem *msgSignals = new QTableWidgetItem(QString::number(msg.msgSignals.count()));
|
QTableWidgetItem *msgSignals = new QTableWidgetItem(QString::number(msg.msgSignals.count()));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "dbchandler.h"
|
#include "dbchandler.h"
|
||||||
#include "dbcsignaleditor.h"
|
#include "dbcsignaleditor.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DBCMainEditor;
|
class DBCMainEditor;
|
||||||
|
|||||||
+14
-5
@@ -50,6 +50,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->cbIntelFormat, &QCheckBox::toggled,
|
connect(ui->cbIntelFormat, &QCheckBox::toggled,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
currentSignal->intelByteOrder = ui->cbIntelFormat->isChecked();
|
currentSignal->intelByteOrder = ui->cbIntelFormat->isChecked();
|
||||||
fillSignalForm(currentSignal);
|
fillSignalForm(currentSignal);
|
||||||
});
|
});
|
||||||
@@ -57,11 +58,13 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->comboReceiver, &QComboBox::currentTextChanged,
|
connect(ui->comboReceiver, &QComboBox::currentTextChanged,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
currentSignal->receiver = dbcHandler->findNodeByName(ui->comboReceiver->currentText());
|
currentSignal->receiver = dbcHandler->findNodeByName(ui->comboReceiver->currentText());
|
||||||
});
|
});
|
||||||
connect(ui->comboType, &QComboBox::currentTextChanged,
|
connect(ui->comboType, &QComboBox::currentTextChanged,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
switch (ui->comboType->currentIndex())
|
switch (ui->comboType->currentIndex())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -84,6 +87,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtBias, &QLineEdit::editingFinished,
|
connect(ui->txtBias, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
double temp;
|
double temp;
|
||||||
bool result;
|
bool result;
|
||||||
temp = ui->txtBias->text().toDouble(&result);
|
temp = ui->txtBias->text().toDouble(&result);
|
||||||
@@ -93,6 +97,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtMaxVal, &QLineEdit::editingFinished,
|
connect(ui->txtMaxVal, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
double temp;
|
double temp;
|
||||||
bool result;
|
bool result;
|
||||||
temp = ui->txtMaxVal->text().toDouble(&result);
|
temp = ui->txtMaxVal->text().toDouble(&result);
|
||||||
@@ -102,6 +107,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtMinVal, &QLineEdit::editingFinished,
|
connect(ui->txtMinVal, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
double temp;
|
double temp;
|
||||||
bool result;
|
bool result;
|
||||||
temp = ui->txtMinVal->text().toDouble(&result);
|
temp = ui->txtMinVal->text().toDouble(&result);
|
||||||
@@ -110,6 +116,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtScale, &QLineEdit::editingFinished,
|
connect(ui->txtScale, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
double temp;
|
double temp;
|
||||||
bool result;
|
bool result;
|
||||||
temp = ui->txtScale->text().toDouble(&result);
|
temp = ui->txtScale->text().toDouble(&result);
|
||||||
@@ -118,19 +125,22 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtComment, &QLineEdit::editingFinished,
|
connect(ui->txtComment, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
currentSignal->comment = ui->txtComment->text();
|
currentSignal->comment = ui->txtComment->text();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->txtUnitName, &QLineEdit::editingFinished,
|
connect(ui->txtUnitName, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
currentSignal->unitName = ui->txtUnitName->text();
|
currentSignal->unitName = ui->txtUnitName->text();
|
||||||
});
|
});
|
||||||
connect(ui->txtBitLength, &QLineEdit::editingFinished,
|
connect(ui->txtBitLength, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
int temp;
|
int temp;
|
||||||
temp = ui->txtBitLength->text().toInt();
|
temp = Utility::ParseStringToNum(ui->txtBitLength->text());
|
||||||
if (temp < 0) return;
|
if (temp < 0) return;
|
||||||
if (temp > 63) return;
|
if (temp > 63) return;
|
||||||
currentSignal->signalSize = temp;
|
currentSignal->signalSize = temp;
|
||||||
@@ -139,12 +149,11 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtName, &QLineEdit::editingFinished,
|
connect(ui->txtName, &QLineEdit::editingFinished,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
if (currentSignal == NULL) return;
|
||||||
currentSignal->name = ui->txtName->text();
|
currentSignal->name = ui->txtName->text();
|
||||||
//need to update the list too.
|
//need to update the list too.
|
||||||
ui->signalsList->currentItem()->setText(currentSignal->name);
|
ui->signalsList->currentItem()->setText(currentSignal->name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBCSignalEditor::~DBCSignalEditor()
|
DBCSignalEditor::~DBCSignalEditor()
|
||||||
@@ -220,7 +229,7 @@ void DBCSignalEditor::onValuesCellChanged(int row,int col)
|
|||||||
|
|
||||||
if (col == 0)
|
if (col == 0)
|
||||||
{
|
{
|
||||||
currentSignal->valList[row].value = ui->valuesTable->item(row, col)->text().toInt();
|
currentSignal->valList[row].value = Utility::ParseStringToNum(ui->valuesTable->item(row, col)->text());
|
||||||
}
|
}
|
||||||
else if (col == 1)
|
else if (col == 1)
|
||||||
{
|
{
|
||||||
@@ -409,7 +418,7 @@ void DBCSignalEditor::fillValueTable(DBC_SIGNAL *sig)
|
|||||||
|
|
||||||
for (int i = 0; i < sig->valList.count(); i++)
|
for (int i = 0; i < sig->valList.count(); i++)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *val = new QTableWidgetItem(QString::number(sig->valList[i].value));
|
QTableWidgetItem *val = new QTableWidgetItem(Utility::formatNumber(sig->valList[i].value));
|
||||||
QTableWidgetItem *desc = new QTableWidgetItem(sig->valList[i].descript);
|
QTableWidgetItem *desc = new QTableWidgetItem(sig->valList[i].descript);
|
||||||
rowIdx = ui->valuesTable->rowCount();
|
rowIdx = ui->valuesTable->rowCount();
|
||||||
ui->valuesTable->insertRow(rowIdx);
|
ui->valuesTable->insertRow(rowIdx);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "dbchandler.h"
|
#include "dbchandler.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DBCSignalEditor;
|
class DBCSignalEditor;
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
bitmapBaseReference->setText(0, "Bits set only in reference frames");
|
bitmapBaseReference->setText(0, "Bits set only in reference frames");
|
||||||
}
|
}
|
||||||
sharedItem->addChild(bitmapBaseInterested);
|
sharedItem->addChild(bitmapBaseInterested);
|
||||||
sharedItem->addChild(bitmapBaseReference);
|
if (!uniqueInterested) sharedItem->addChild(bitmapBaseReference);
|
||||||
|
|
||||||
uint64_t interestedBits = interested.bitmap;
|
uint64_t interestedBits = interested.bitmap;
|
||||||
uint64_t referenceBits = reference.bitmap;
|
uint64_t referenceBits = reference.bitmap;
|
||||||
|
|||||||
+19
-18
@@ -303,7 +303,7 @@ void FlowViewWindow::refreshIDList()
|
|||||||
if (!foundID.contains(id))
|
if (!foundID.contains(id))
|
||||||
{
|
{
|
||||||
foundID.append(id);
|
foundID.append(id);
|
||||||
QListWidgetItem* item = new QListWidgetItem(QString::number(id, 16).toUpper().rightJustified(4,'0'), ui->listFrameID);
|
QListWidgetItem* item = new QListWidgetItem(Utility::formatNumber(id), ui->listFrameID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//default is to sort in ascending order
|
//default is to sort in ascending order
|
||||||
@@ -318,7 +318,7 @@ void FlowViewWindow::updateFrameLabel()
|
|||||||
void FlowViewWindow::changeID(QString newID)
|
void FlowViewWindow::changeID(QString newID)
|
||||||
{
|
{
|
||||||
//parse the ID and then load up the frame cache with just messages with that ID.
|
//parse the ID and then load up the frame cache with just messages with that ID.
|
||||||
int id = newID.toInt(NULL, 16);
|
int id = Utility::ParseStringToNum(newID);
|
||||||
frameCache.clear();
|
frameCache.clear();
|
||||||
|
|
||||||
if (modelFrames->count() == 0) return;
|
if (modelFrames->count() == 0) return;
|
||||||
@@ -440,23 +440,24 @@ void FlowViewWindow::timerTriggered()
|
|||||||
|
|
||||||
void FlowViewWindow::updateDataView()
|
void FlowViewWindow::updateDataView()
|
||||||
{
|
{
|
||||||
ui->txtCurr1->setText(QString::number(currBytes[0], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr2->setText(QString::number(currBytes[1], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr3->setText(QString::number(currBytes[2], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr4->setText(QString::number(currBytes[3], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr5->setText(QString::number(currBytes[4], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr6->setText(QString::number(currBytes[5], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr7->setText(QString::number(currBytes[6], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
ui->txtCurr8->setText(QString::number(currBytes[7], 16).toUpper().rightJustified(2, '0'));
|
|
||||||
|
|
||||||
ui->txtRef1->setText(QString::number(refBytes[0], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr1->setText(Utility::formatNumber(currBytes[0]));
|
||||||
ui->txtRef2->setText(QString::number(refBytes[1], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr2->setText(Utility::formatNumber(currBytes[1]));
|
||||||
ui->txtRef3->setText(QString::number(refBytes[2], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr3->setText(Utility::formatNumber(currBytes[2]));
|
||||||
ui->txtRef4->setText(QString::number(refBytes[3], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr4->setText(Utility::formatNumber(currBytes[3]));
|
||||||
ui->txtRef5->setText(QString::number(refBytes[4], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr5->setText(Utility::formatNumber(currBytes[4]));
|
||||||
ui->txtRef6->setText(QString::number(refBytes[5], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr6->setText(Utility::formatNumber(currBytes[5]));
|
||||||
ui->txtRef7->setText(QString::number(refBytes[6], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr7->setText(Utility::formatNumber(currBytes[6]));
|
||||||
ui->txtRef8->setText(QString::number(refBytes[7], 16).toUpper().rightJustified(2, '0'));
|
ui->txtCurr8->setText(Utility::formatNumber(currBytes[7]));
|
||||||
|
|
||||||
|
ui->txtRef1->setText(Utility::formatNumber(refBytes[0]));
|
||||||
|
ui->txtRef2->setText(Utility::formatNumber(refBytes[1]));
|
||||||
|
ui->txtRef3->setText(Utility::formatNumber(refBytes[2]));
|
||||||
|
ui->txtRef4->setText(Utility::formatNumber(refBytes[3]));
|
||||||
|
ui->txtRef5->setText(Utility::formatNumber(refBytes[4]));
|
||||||
|
ui->txtRef6->setText(Utility::formatNumber(refBytes[5]));
|
||||||
|
ui->txtRef7->setText(Utility::formatNumber(refBytes[6]));
|
||||||
|
ui->txtRef8->setText(Utility::formatNumber(refBytes[7]));
|
||||||
|
|
||||||
ui->flowView->setReference(refBytes, false);
|
ui->flowView->setReference(refBytes, false);
|
||||||
ui->flowView->updateData(currBytes, true);
|
ui->flowView->updateData(currBytes, true);
|
||||||
|
|||||||
+9
-9
@@ -114,7 +114,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
|||||||
int bitfieldHistogram[64];
|
int bitfieldHistogram[64];
|
||||||
QTreeWidgetItem *baseNode, *dataBase, *histBase, *numBase, *tempItem;
|
QTreeWidgetItem *baseNode, *dataBase, *histBase, *numBase, *tempItem;
|
||||||
|
|
||||||
targettedID = newID.toInt(NULL, 16);
|
targettedID = Utility::ParseStringToNum(newID);
|
||||||
|
|
||||||
if (modelFrames->count() == 0) return;
|
if (modelFrames->count() == 0) return;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
|||||||
if (frameCache.count() == 0) return;
|
if (frameCache.count() == 0) return;
|
||||||
|
|
||||||
baseNode = new QTreeWidgetItem();
|
baseNode = new QTreeWidgetItem();
|
||||||
baseNode->setText(0, QString("ID: 0x") + newID );
|
baseNode->setText(0, QString("ID: ") + newID );
|
||||||
|
|
||||||
if (frameCache[0].extended) //if these frames seem to be extended then try for J1939 decoding
|
if (frameCache[0].extended) //if these frames seem to be extended then try for J1939 decoding
|
||||||
{
|
{
|
||||||
@@ -160,23 +160,23 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
|||||||
{
|
{
|
||||||
jid.dest = jid.ps;
|
jid.dest = jid.ps;
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("Destination ID: 0x") + QString::number(jid.dest,16));
|
tempItem->setText(0, tr("Destination ID: ") + Utility::formatNumber(jid.dest));
|
||||||
baseNode->addChild(tempItem);
|
baseNode->addChild(tempItem);
|
||||||
}
|
}
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("SRC: 0x") + QString::number(jid.src,16));
|
tempItem->setText(0, tr("SRC: ") + Utility::formatNumber(jid.src));
|
||||||
baseNode->addChild(tempItem);
|
baseNode->addChild(tempItem);
|
||||||
|
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("PGN: ") + QString::number(jid.pgn,10));
|
tempItem->setText(0, tr("PGN: ") + Utility::formatNumber(jid.pgn));
|
||||||
baseNode->addChild(tempItem);
|
baseNode->addChild(tempItem);
|
||||||
|
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("PF: 0x") + QString::number(jid.pf,16));
|
tempItem->setText(0, tr("PF: ") + Utility::formatNumber(jid.pf));
|
||||||
baseNode->addChild(tempItem);
|
baseNode->addChild(tempItem);
|
||||||
|
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("PS: 0x") + QString::number(jid.ps,16));
|
tempItem->setText(0, tr("PS: ") + Utility::formatNumber(jid.ps));
|
||||||
baseNode->addChild(tempItem);
|
baseNode->addChild(tempItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
|||||||
dataBase->setText(0, tr("Data Byte ") + QString::number(c));
|
dataBase->setText(0, tr("Data Byte ") + QString::number(c));
|
||||||
baseNode->addChild(dataBase);
|
baseNode->addChild(dataBase);
|
||||||
tempItem = new QTreeWidgetItem();
|
tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, tr("Range: ") + QString::number(minData[c]) + tr(" to ") + QString::number(maxData[c]));
|
tempItem->setText(0, tr("Range: ") + Utility::formatNumber(minData[c]) + tr(" to ") + Utility::formatNumber(maxData[c]));
|
||||||
dataBase->addChild(tempItem);
|
dataBase->addChild(tempItem);
|
||||||
histBase->setText(0, tr("Histogram"));
|
histBase->setText(0, tr("Histogram"));
|
||||||
dataBase->addChild(histBase);
|
dataBase->addChild(histBase);
|
||||||
@@ -292,7 +292,7 @@ void FrameInfoWindow::refreshIDList()
|
|||||||
if (!foundID.contains(id))
|
if (!foundID.contains(id))
|
||||||
{
|
{
|
||||||
foundID.append(id);
|
foundID.append(id);
|
||||||
ui->listFrameID->addItem(QString::number(id, 16).toUpper().rightJustified(4,'0'));
|
ui->listFrameID->addItem(Utility::formatNumber(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//default is to sort in ascending order
|
//default is to sort in ascending order
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void FramePlaybackWindow::refreshIDList()
|
|||||||
QHash<int, bool>::Iterator filterIter;
|
QHash<int, bool>::Iterator filterIter;
|
||||||
for (filterIter = currentSeqItem->idFilters.begin(); filterIter != currentSeqItem->idFilters.end(); ++filterIter)
|
for (filterIter = currentSeqItem->idFilters.begin(); filterIter != currentSeqItem->idFilters.end(); ++filterIter)
|
||||||
{
|
{
|
||||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatHexNum(filterIter.key()), ui->listID);
|
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(filterIter.key()), ui->listID);
|
||||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||||
if (filterIter.value()) listItem->setCheckState(Qt::Checked);
|
if (filterIter.value()) listItem->setCheckState(Qt::Checked);
|
||||||
else listItem->setCheckState(Qt::Unchecked);
|
else listItem->setCheckState(Qt::Unchecked);
|
||||||
@@ -292,7 +292,7 @@ void FramePlaybackWindow::seqTableCellChanged(int row,int col)
|
|||||||
{
|
{
|
||||||
if (col == 1) //don't save any changes to the first column (0)
|
if (col == 1) //don't save any changes to the first column (0)
|
||||||
{
|
{
|
||||||
seqItems[row].maxLoops = ui->tblSequence->item(row, col)->text().toInt();
|
seqItems[row].maxLoops = Utility::ParseStringToNum(ui->tblSequence->item(row, col)->text());
|
||||||
if (seqItems[row].maxLoops < 1) seqItems[row].maxLoops = 1;
|
if (seqItems[row].maxLoops < 1) seqItems[row].maxLoops = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,7 +496,7 @@ void FramePlaybackWindow::changeSendingBus(int newIdx)
|
|||||||
void FramePlaybackWindow::changeIDFiltering(QListWidgetItem *item)
|
void FramePlaybackWindow::changeIDFiltering(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
qDebug() << "Changed ID filter";
|
qDebug() << "Changed ID filter";
|
||||||
int ID = item->text().toInt(NULL, 16);
|
int ID = Utility::ParseStringToNum(item->text());
|
||||||
currentSeqItem->idFilters[ID] = item->checkState();
|
currentSeqItem->idFilters[ID] = item->checkState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ void FramePlaybackWindow::btnSelectAllClick()
|
|||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listID->item(i);
|
QListWidgetItem *item = ui->listID->item(i);
|
||||||
item->setCheckState(Qt::Checked);
|
item->setCheckState(Qt::Checked);
|
||||||
currentSeqItem->idFilters[item->text().toInt(NULL, 16)] = true;
|
currentSeqItem->idFilters[Utility::ParseStringToNum(item->text())] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +516,7 @@ void FramePlaybackWindow::btnSelectNoneClick()
|
|||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listID->item(i);
|
QListWidgetItem *item = ui->listID->item(i);
|
||||||
item->setCheckState(Qt::Unchecked);
|
item->setCheckState(Qt::Unchecked);
|
||||||
currentSeqItem->idFilters[item->text().toInt(NULL, 16)] = false;
|
currentSeqItem->idFilters[Utility::ParseStringToNum(item->text())] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -270,6 +270,7 @@ void MainWindow::readUpdateableSettings()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
useHex = settings.value("Main/UseHex", true).toBool();
|
useHex = settings.value("Main/UseHex", true).toBool();
|
||||||
model->setHexMode(useHex);
|
model->setHexMode(useHex);
|
||||||
|
Utility::decimalMode = !useHex;
|
||||||
model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool());
|
model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool());
|
||||||
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
||||||
}
|
}
|
||||||
@@ -322,8 +323,7 @@ void MainWindow::updateFilterList()
|
|||||||
for (filterIter = filters->begin(); filterIter != filters->end(); ++filterIter)
|
for (filterIter = filters->begin(); filterIter != filters->end(); ++filterIter)
|
||||||
{
|
{
|
||||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||||
if (useHex) thisItem->setText(QString::number(filterIter.key(), 16).toUpper().rightJustified(4,'0'));
|
thisItem->setText(Utility::formatNumber(filterIter.key()));
|
||||||
else thisItem->setText(QString::number(filterIter.key()));
|
|
||||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||||
if (filterIter.value()) thisItem->setCheckState(Qt::Checked);
|
if (filterIter.value()) thisItem->setCheckState(Qt::Checked);
|
||||||
else thisItem->setCheckState(Qt::Unchecked);
|
else thisItem->setCheckState(Qt::Unchecked);
|
||||||
@@ -337,8 +337,7 @@ void MainWindow::filterListItemChanged(QListWidgetItem *item)
|
|||||||
//qDebug() << item->text();
|
//qDebug() << item->text();
|
||||||
int ID;
|
int ID;
|
||||||
bool isSet = false;
|
bool isSet = false;
|
||||||
if (useHex) ID = item->text().toInt(NULL, 16);
|
ID = Utility::ParseStringToNum(item->text());
|
||||||
else ID = item->text().toInt();
|
|
||||||
if (item->checkState() == Qt::Checked) isSet = true;
|
if (item->checkState() == Qt::Checked) isSet = true;
|
||||||
|
|
||||||
model->setFilterState(ID, isSet);
|
model->setFilterState(ID, isSet);
|
||||||
@@ -717,7 +716,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
|||||||
CANFrame thisFrame = frames->at(c);
|
CANFrame thisFrame = frames->at(c);
|
||||||
QString builderString;
|
QString builderString;
|
||||||
builderString += tr("Time: ") + QString::number((thisFrame.timestamp / 1000000.0), 'f', 6);
|
builderString += tr("Time: ") + QString::number((thisFrame.timestamp / 1000000.0), 'f', 6);
|
||||||
builderString += tr(" ID: 0x") + QString::number(thisFrame.ID, 16).toUpper().rightJustified(8, '0');
|
builderString += tr(" ID: ") + Utility::formatNumber(thisFrame.ID);
|
||||||
if (thisFrame.extended) builderString += tr(" Ext ");
|
if (thisFrame.extended) builderString += tr(" Ext ");
|
||||||
else builderString += tr(" Std ");
|
else builderString += tr(" Std ");
|
||||||
builderString += tr("Bus: ") + QString::number(thisFrame.bus);
|
builderString += tr("Bus: ") + QString::number(thisFrame.bus);
|
||||||
@@ -727,7 +726,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
|||||||
builderString = tr("Data Bytes: ");
|
builderString = tr("Data Bytes: ");
|
||||||
for (int temp = 0; temp < thisFrame.len; temp++)
|
for (int temp = 0; temp < thisFrame.len; temp++)
|
||||||
{
|
{
|
||||||
builderString += QString::number(thisFrame.data[temp], 16).toUpper().rightJustified(2, '0') + " ";
|
builderString += Utility::formatNumber(thisFrame.data[temp]) + " ";
|
||||||
}
|
}
|
||||||
builderString += "\n";
|
builderString += "\n";
|
||||||
outFile->write(builderString.toUtf8());
|
outFile->write(builderString.toUtf8());
|
||||||
|
|||||||
+2
-2
@@ -51,9 +51,9 @@ void NewGraphDialog::colorSwatchClick()
|
|||||||
|
|
||||||
void NewGraphDialog::setParams(GraphParams ¶ms)
|
void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||||
{
|
{
|
||||||
ui->txtID->setText("0x" + QString::number(params.ID, 16).toUpper());
|
ui->txtID->setText(Utility::formatNumber(params.ID));
|
||||||
ui->txtBias->setText(QString::number(params.bias));
|
ui->txtBias->setText(QString::number(params.bias));
|
||||||
ui->txtMask->setText("0x" + QString::number(params.mask, 16).toUpper().left(10));
|
ui->txtMask->setText(Utility::formatNumber(params.mask));
|
||||||
ui->txtScale->setText(QString::number(params.scale));
|
ui->txtScale->setText(QString::number(params.scale));
|
||||||
ui->txtStride->setText(QString::number(params.stride));
|
ui->txtStride->setText(QString::number(params.stride));
|
||||||
ui->cbSigned->setChecked(params.isSigned);
|
ui->cbSigned->setChecked(params.isSigned);
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
bool Utility::decimalMode = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef UTILITY_H
|
#ifndef UTILITY_H
|
||||||
#define UTILITY_H
|
#define UTILITY_H
|
||||||
|
|
||||||
|
#include <Qt>
|
||||||
|
#include <stdint.h>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
@@ -9,12 +11,15 @@
|
|||||||
class Utility
|
class Utility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static bool decimalMode;
|
||||||
|
|
||||||
static int ParseStringToNum(QByteArray input)
|
static int ParseStringToNum(QByteArray input)
|
||||||
{
|
{
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
|
|
||||||
input = input.toUpper();
|
input = input.toUpper();
|
||||||
if (input.startsWith("0X")) //hex number
|
if (input.startsWith("0X") || input.startsWith("X")) //hex number
|
||||||
{
|
{
|
||||||
temp = input.right(input.size() - 2).toInt(NULL, 16);
|
temp = input.right(input.size() - 2).toInt(NULL, 16);
|
||||||
}
|
}
|
||||||
@@ -47,14 +52,25 @@ public:
|
|||||||
|
|
||||||
//prints hex numbers in uppercase with 0's filling out the number depending
|
//prints hex numbers in uppercase with 0's filling out the number depending
|
||||||
//on the size needed. Promotes hex numbers to either 2, 4, or 8 digits
|
//on the size needed. Promotes hex numbers to either 2, 4, or 8 digits
|
||||||
static QString formatHexNum(int input)
|
static QString formatHexNum(uint64_t input)
|
||||||
{
|
{
|
||||||
if (input < 256)
|
if (input < 256)
|
||||||
return QString::number(input, 16).toUpper().rightJustified(2,'0');
|
return "0x" + QString::number(input, 16).toUpper().rightJustified(2,'0');
|
||||||
if (input < 65536)
|
if (input < 65536)
|
||||||
return QString::number(input, 16).toUpper().rightJustified(4,'0');
|
return "0x" + QString::number(input, 16).toUpper().rightJustified(4,'0');
|
||||||
|
if (input < 4294967296)
|
||||||
|
return "0x" + QString::number(input, 16).toUpper().rightJustified(8,'0');
|
||||||
|
return "0x" + QString::number(input, 16).toUpper().rightJustified(16,'0');
|
||||||
|
}
|
||||||
|
|
||||||
return QString::number(input, 16).toUpper().rightJustified(8,'0');
|
//uses decimalMode to see if it should show value as decimal or hex
|
||||||
|
static QString formatNumber(uint64_t value)
|
||||||
|
{
|
||||||
|
if (decimalMode)
|
||||||
|
{
|
||||||
|
return QString::number(value, 10);
|
||||||
|
}
|
||||||
|
else return formatHexNum(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user