* @brief Emits one signal's spec line; default-valued fields are omitted so the spec stays * scannable, and the DBC signal comment rides along as a Lua comment. */
| 650 | * scannable, and the DBC signal comment rides along as a Lua comment. |
| 651 | */ |
| 652 | QString DataModel::DBCImporter::signalSpecLine(const QCanSignalDescription& signal, |
| 653 | MuxRole role, |
| 654 | qint64 muxValue) const |
| 655 | { |
| 656 | QString line = QStringLiteral(" { name = %1, start = %2, len = %3") |
| 657 | .arg(luaQuote(signal.name()), |
| 658 | QString::number(signal.startBit()), |
| 659 | QString::number(signal.bitLength())); |
| 660 | |
| 661 | if (signal.dataEndian() == QSysInfo::BigEndian) |
| 662 | line += QStringLiteral(", be = true"); |
| 663 | |
| 664 | if (signal.dataFormat() == QtCanBus::DataFormat::SignedInteger) |
| 665 | line += QStringLiteral(", signed = true"); |
| 666 | |
| 667 | if (std::isfinite(signal.factor()) && signal.factor() != 1.0) |
| 668 | line += QStringLiteral(", factor = %1").arg(luaNumber(signal.factor())); |
| 669 | |
| 670 | if (std::isfinite(signal.offset()) && signal.offset() != 0.0) |
| 671 | line += QStringLiteral(", offset = %1").arg(luaNumber(signal.offset())); |
| 672 | |
| 673 | if (role == MuxRole::Selector) |
| 674 | line += QStringLiteral(", selector = true"); |
| 675 | else if (role == MuxRole::SimpleMuxed) |
| 676 | line += QStringLiteral(", mux = %1").arg(muxValue); |
| 677 | |
| 678 | line += QStringLiteral(" },"); |
| 679 | |
| 680 | const auto comment = signal.comment().simplified(); |
| 681 | if (!comment.isEmpty()) |
| 682 | line += QStringLiteral(" -- %1").arg(comment); |
| 683 | |
| 684 | return line + QLatin1Char('\n'); |
| 685 | } |
| 686 | |
| 687 | /** |
| 688 | * @brief Builds the Lua transform that maps a VAL_ enum signal's raw value to its DBC label, |