DBC Framework
DBC parsing and CAN signal decoding framework
Loading...
Searching...
No Matches
decode_database.h
Go to the documentation of this file.
1
12#ifndef DECODE_DATABASE_H
13#define DECODE_DATABASE_H
14
15#include <cstdint>
16#include <string>
17#include <unordered_map>
18#include <vector>
19
23enum class ByteOrder {
24 Intel,
25 Motorola
26};
27
31enum class ValueType {
32 Unsigned,
33 Signed
34};
35
40 std::string name;
41 std::uint32_t startBit;
42 std::uint32_t length;
45 double factor;
46 double offset;
47 double minimum;
48 double maximum;
49 std::string unit;
50 std::vector<std::string> receivers;
51 std::string comment;
54 : name(), startBit(0U), length(0U), byteOrder(ByteOrder::Intel), valueType(ValueType::Unsigned), factor(1.0), offset(0.0), minimum(0.0), maximum(0.0), unit(), receivers(), comment() {
55 }
56};
57
62 std::string name;
63 std::uint32_t canId;
65 std::uint8_t dlc;
66 std::uint32_t pgn;
67 bool hasPgn;
68 std::string transmitter;
69 std::string comment;
70 std::vector<DecodeSignal> signals;
73 : name(), canId(0U), isExtended(false), dlc(0U), pgn(0U), hasPgn(false), transmitter(), comment(), signals() {
74 }
75};
76
80struct FrameKey {
81 std::uint32_t canId;
82 bool isExtended;
83
84 FrameKey()
85 : canId(0U), isExtended(false) {
86 }
87
88 FrameKey(std::uint32_t id, bool extended)
89 : canId(id), isExtended(extended) {
90 }
91
92 bool operator==(const FrameKey &other) const {
93 return (canId == other.canId) && (isExtended == other.isExtended);
94 }
95};
96
101 std::size_t operator()(const FrameKey &key) const {
102 const std::size_t a = static_cast<std::size_t>(key.canId);
103 const std::size_t b = key.isExtended ? 1U : 0U;
104 return (a * 1315423911U) ^ b;
105 }
106};
107
112 std::vector<DecodeFrame> frames;
113 std::unordered_map<FrameKey, std::size_t, FrameKeyHasher> frameIndexByKey;
114};
115
116#endif /* DECODE_DATABASE_H */
ByteOrder
Signal byte order used for runtime decoding.
ValueType
Signal numeric type.
Runtime decode database with fast lookup by CAN ID.
Runtime-ready frame definition.
std::uint32_t pgn
std::string comment
std::uint8_t dlc
std::uint32_t canId
std::string name
std::string transmitter
Runtime-ready signal definition.
std::string unit
std::string name
ValueType valueType
std::uint32_t startBit
std::vector< std::string > receivers
ByteOrder byteOrder
std::uint32_t length
std::string comment
Hasher for frame key.
Key for fast frame lookup.