Skip to content
Permalink
Browse files

read candb signal unit name from dbc an show in trace windows

  • Loading branch information...
HubertD committed Jun 30, 2016
1 parent 5bb293b commit 660fbb2cec5336ae12c3b770ba34af6425d6835e
@@ -147,6 +147,16 @@ void CanDbSignal::setMaximumValue(double max)
_max = max;
}

QString CanDbSignal::getUnit() const
{
return _unit;
}

void CanDbSignal::setUnit(const QString &unit)
{
_unit = unit;
}

bool CanDbSignal::isUnsigned() const
{
return _isUnsigned;
@@ -61,6 +61,9 @@ class CanDbSignal
double getMaximumValue() const;
void setMaximumValue(double max);

QString getUnit() const;
void setUnit(const QString &unit);

bool isUnsigned() const;
void setUnsigned(bool isUnsigned);

@@ -94,6 +97,7 @@ class CanDbSignal
double _offset;
double _min;
double _max;
QString _unit;
bool _isMuxer;
bool _isMuxed;
uint32_t _muxValue;
@@ -578,6 +578,7 @@ bool DbcParser::parseSectionBoSg(CanDb &candb, CanDbMessage *msg, DbcTokenList &
if (!expectAndSkipToken(tokens, dbc_tok_bracket_close)) { return false; }

if (!expectString(tokens, &unit)) { return false; }
signal->setUnit(unit);

if (!expectIdentifier(tokens, &receiver)) { return false; }
receivers.append(receiver);
@@ -180,6 +180,7 @@ QVariant BaseTraceViewModel::data_DisplayRole_Signal(const QModelIndex &index, i
(void) role;
uint32_t raw_data;
QString value_name;
QString unit;

CanDbMessage *dbmsg = backend()->findDbMessage(msg);
if (!dbmsg) { return QVariant(); }
@@ -204,7 +205,12 @@ QVariant BaseTraceViewModel::data_DisplayRole_Signal(const QModelIndex &index, i

value_name = dbsignal->getValueName(raw_data);
if (value_name.isEmpty()) {
return dbsignal->convertRawValueToPhysical(raw_data);
unit = dbsignal->getUnit();
if (unit.isEmpty()) {
return dbsignal->convertRawValueToPhysical(raw_data);
} else {
return QString("%1 %2").arg(dbsignal->convertRawValueToPhysical(raw_data)).arg(unit);
}
} else {
return QString("%1 - %2").arg(raw_data).arg(value_name);
}

0 comments on commit 660fbb2

Please sign in to comment.
You can’t perform that action at this time.