Allow for decoded DBC signal output without attaching the name to the
resulting string. Used by CSV output.
This commit is contained in:
+7
-5
@@ -118,7 +118,7 @@ s 5 47 46 45 44 43 42 41 40
|
|||||||
So, the bits are 12, 11, 10, 9, 8, 23, 22, 21. Yes, that's confusing. They now go in reverse value order too.
|
So, the bits are 12, 11, 10, 9, 8, 23, 22, 21. Yes, that's confusing. They now go in reverse value order too.
|
||||||
Bit 12 is worth 128, 11 is worth 64, etc until bit 21 is worth 1.
|
Bit 12 is worth 128, 11 is worth 64, etc until bit 21 is worth 1.
|
||||||
*/
|
*/
|
||||||
bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool outputName)
|
bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool outputName, bool outputUnit)
|
||||||
{
|
{
|
||||||
int64_t result = 0;
|
int64_t result = 0;
|
||||||
bool isSigned = false;
|
bool isSigned = false;
|
||||||
@@ -170,7 +170,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
|||||||
endResult = (*((double *)(&result)) * factor) + bias;
|
endResult = (*((double *)(&result)) * factor) + bias;
|
||||||
}
|
}
|
||||||
|
|
||||||
outString = makePrettyOutput(endResult, result, outputName, isInteger);
|
outString = makePrettyOutput(endResult, result, outputName, isInteger, outputUnit);
|
||||||
cachedValue = endResult;
|
cachedValue = endResult;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ bool DBC_SIGNAL::getValueString(int64_t intVal, QString &outString)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outputName, bool isInteger)
|
QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outputName, bool isInteger, bool outputUnit)
|
||||||
{
|
{
|
||||||
QString outputString;
|
QString outputString;
|
||||||
|
|
||||||
@@ -209,11 +209,13 @@ QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outpu
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundVal) outputString += QString::number(intVal) + unitName;
|
if (!foundVal) outputString += QString::number(intVal);
|
||||||
|
if (outputUnit) outputString += unitName;
|
||||||
}
|
}
|
||||||
else //otherwise display the actual number and unit (if it exists)
|
else //otherwise display the actual number and unit (if it exists)
|
||||||
{
|
{
|
||||||
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal)) + unitName;
|
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal));
|
||||||
|
if (outputUnit) outputString += unitName;
|
||||||
}
|
}
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -114,11 +114,11 @@ public: //TODO: this is sloppy. It shouldn't all be public!
|
|||||||
DBC_SIGNAL *self;
|
DBC_SIGNAL *self;
|
||||||
|
|
||||||
DBC_SIGNAL();
|
DBC_SIGNAL();
|
||||||
bool processAsText(const CANFrame &frame, QString &outString, bool outputName = true);
|
bool processAsText(const CANFrame &frame, QString &outString, bool outputName = true, bool outputUnit = true);
|
||||||
bool processAsInt(const CANFrame &frame, int32_t &outValue);
|
bool processAsInt(const CANFrame &frame, int32_t &outValue);
|
||||||
bool processAsDouble(const CANFrame &frame, double &outValue);
|
bool processAsDouble(const CANFrame &frame, double &outValue);
|
||||||
bool getValueString(int64_t intVal, QString &outString);
|
bool getValueString(int64_t intVal, QString &outString);
|
||||||
QString makePrettyOutput(double floatVal, int64_t intVal, bool outputName = true, bool isInteger = false);
|
QString makePrettyOutput(double floatVal, int64_t intVal, bool outputName = true, bool isInteger = false, bool outputUnit = true);
|
||||||
QString processSignalTree(const CANFrame &frame);
|
QString processSignalTree(const CANFrame &frame);
|
||||||
DBC_ATTRIBUTE_VALUE *findAttrValByName(QString name);
|
DBC_ATTRIBUTE_VALUE *findAttrValByName(QString name);
|
||||||
DBC_ATTRIBUTE_VALUE *findAttrValByIdx(int idx);
|
DBC_ATTRIBUTE_VALUE *findAttrValByIdx(int idx);
|
||||||
|
|||||||
+9
-4
@@ -681,7 +681,7 @@ void MainWindow::updateFilterList()
|
|||||||
if (model == nullptr) return;
|
if (model == nullptr) return;
|
||||||
const QMap<int, bool> *filters = model->getFiltersReference();
|
const QMap<int, bool> *filters = model->getFiltersReference();
|
||||||
const QMap<int, bool> *busFilters = model->getBusFiltersReference();
|
const QMap<int, bool> *busFilters = model->getBusFiltersReference();
|
||||||
if (filters == nullptr && busFilters == nullptr) return;
|
if (filters == nullptr || busFilters == nullptr) return;
|
||||||
|
|
||||||
qDebug() << "updateFilterList called on MainWindow";
|
qDebug() << "updateFilterList called on MainWindow";
|
||||||
|
|
||||||
@@ -1054,7 +1054,8 @@ void MainWindow::handleSaveDecodedMethod(bool csv)
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters.append(QString(tr("Text File (*.txt)")));
|
if (!csv) filters.append(QString(tr("Text File (*.txt *.TXT)")));
|
||||||
|
else filters.append(QString(tr("CSV File (*.csv *.CSV)")));
|
||||||
|
|
||||||
dialog.setDirectory(settings.value("FileIO/LoadSaveDirectory", dialog.directory().path()).toString());
|
dialog.setDirectory(settings.value("FileIO/LoadSaveDirectory", dialog.directory().path()).toString());
|
||||||
dialog.setFileMode(QFileDialog::AnyFile);
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
@@ -1065,7 +1066,11 @@ void MainWindow::handleSaveDecodedMethod(bool csv)
|
|||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
filename = dialog.selectedFiles()[0];
|
filename = dialog.selectedFiles()[0];
|
||||||
if (!filename.contains('.')) filename += ".txt";
|
if (!filename.contains('.'))
|
||||||
|
{
|
||||||
|
if (!csv) filename += ".txt";
|
||||||
|
else filename += ".csv";
|
||||||
|
}
|
||||||
|
|
||||||
if(csv)
|
if(csv)
|
||||||
saveDecodedTextFileAsColumns(filename);
|
saveDecodedTextFileAsColumns(filename);
|
||||||
@@ -1217,7 +1222,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString temp;
|
QString temp;
|
||||||
if (msg->sigHandler->findSignalByIdx(j)->processAsText(*frame, temp, false))
|
if (msg->sigHandler->findSignalByIdx(j)->processAsText(*frame, temp, false, false))
|
||||||
{
|
{
|
||||||
builderString.append(temp);
|
builderString.append(temp);
|
||||||
builderString.append(",");
|
builderString.append(",");
|
||||||
|
|||||||
Reference in New Issue
Block a user