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 "value_descriptions.h"
16#include "multiplexing.h"
17#include <cstdint>
18#include <string>
19#include <unordered_map>
20#include <vector>
21
25enum class ByteOrder {
26 Intel,
27 Motorola
28};
29
33enum class ValueType {
34 Unsigned,
35 Signed
36};
37
42 Multiplexing multiplexing;
43 std::string name;
44 std::uint32_t startBit = 0U;
45 std::uint32_t length = 0U;
46 ByteOrder byteOrder = ByteOrder::Intel;
47 ValueType valueType = ValueType::Unsigned;
48 double factor = 1.0;
49 double offset = 0.0;
50 double minimum = 0.0;
51 double maximum = 0.0;
52 std::string unit;
53 std::vector<std::string> receivers;
54 ValueDescriptions valueDescriptions;
55 std::string comment;
57 DecodeSignal() = default;
58};
59
64 std::string name;
65 std::uint32_t canId = 0U;
66 bool isExtended = false;
67 std::uint8_t dlc = 0U;
68 std::uint32_t pgn = 0U;
69 bool hasPgn = false;
70 std::string transmitter;
71 std::string comment;
72 std::vector<DecodeSignal> signals;
74 DecodeFrame() = default;
75};
76
80struct FrameKey {
81 std::uint32_t canId = 0U;
82 bool isExtended = false;
83
84 FrameKey() = default;
85
86 FrameKey(std::uint32_t id, bool extended)
87 : canId(id), isExtended(extended) {
88 }
89
90 bool operator==(const FrameKey &other) const {
91 return (canId == other.canId) && (isExtended == other.isExtended);
92 }
93};
94
99 std::size_t operator()(const FrameKey &key) const {
100 const std::size_t a = static_cast<std::size_t>(key.canId);
101 const std::size_t b = key.isExtended ? 1U : 0U;
102 return (a * 1315423911U) ^ b;
103 }
104};
105
110 std::vector<DecodeFrame> frames;
111 std::unordered_map<FrameKey, std::size_t, FrameKeyHasher> frameIndexByKey;
112};
113
114#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
ValueDescriptions valueDescriptions
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.