mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-23 23:12:04 +08:00
cabana: show string value for val/desc (#27747)
This commit is contained in:
@@ -62,10 +62,21 @@ void SignalModel::updateState(const QHash<MessageId, CanData> *msgs) {
|
||||
auto &dat = can->lastMessage(msg_id).dat;
|
||||
int row = 0;
|
||||
for (auto item : root->children) {
|
||||
item->sig_val = QString::number(get_raw_value((uint8_t *)dat.constData(), dat.size(), *item->sig), 'f', item->sig->precision);
|
||||
double value = get_raw_value((uint8_t *)dat.constData(), dat.size(), *item->sig);
|
||||
item->sig_val = QString::number(value, 'f', item->sig->precision);
|
||||
|
||||
// Show unit
|
||||
if (!item->sig->unit.isEmpty()) {
|
||||
item->sig_val += " " + item->sig->unit;
|
||||
}
|
||||
|
||||
// Show enum string
|
||||
for (auto &[val, desc] : item->sig->val_desc) {
|
||||
if (std::abs(value - val.toInt()) < 1e-6) {
|
||||
item->sig_val = desc;
|
||||
}
|
||||
}
|
||||
|
||||
emit dataChanged(index(row, 1), index(row, 1), {Qt::DisplayRole});
|
||||
++row;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user