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
23
enum class
ByteOrder
{
24
Intel,
25
Motorola
26
};
27
31
enum class
ValueType
{
32
Unsigned,
33
Signed
34
};
35
39
struct
DecodeSignal
{
40
std::string
name
;
41
std::uint32_t
startBit
;
42
std::uint32_t
length
;
43
ByteOrder
byteOrder
;
44
ValueType
valueType
;
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
;
53
DecodeSignal
()
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
61
struct
DecodeFrame
{
62
std::string
name
;
63
std::uint32_t
canId
;
64
bool
isExtended
;
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;
72
DecodeFrame
()
73
:
name
(),
canId
(0U),
isExtended
(false),
dlc
(0U),
pgn
(0U),
hasPgn
(false),
transmitter
(),
comment
(), signals() {
74
}
75
};
76
80
struct
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
100
struct
FrameKeyHasher
{
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
111
struct
DecodeDatabase
{
112
std::vector<DecodeFrame> frames;
113
std::unordered_map<FrameKey, std::size_t, FrameKeyHasher> frameIndexByKey;
114
};
115
116
#endif
/* DECODE_DATABASE_H */
ByteOrder
ByteOrder
Signal byte order used for runtime decoding.
Definition
decode_database.h:23
ValueType
ValueType
Signal numeric type.
Definition
decode_database.h:31
DecodeDatabase
Runtime decode database with fast lookup by CAN ID.
Definition
decode_database.h:111
DecodeFrame
Runtime-ready frame definition.
Definition
decode_database.h:61
DecodeFrame::pgn
std::uint32_t pgn
Definition
decode_database.h:66
DecodeFrame::hasPgn
bool hasPgn
Definition
decode_database.h:67
DecodeFrame::comment
std::string comment
Definition
decode_database.h:69
DecodeFrame::isExtended
bool isExtended
Definition
decode_database.h:64
DecodeFrame::dlc
std::uint8_t dlc
Definition
decode_database.h:65
DecodeFrame::canId
std::uint32_t canId
Definition
decode_database.h:63
DecodeFrame::name
std::string name
Definition
decode_database.h:62
DecodeFrame::transmitter
std::string transmitter
Definition
decode_database.h:68
DecodeSignal
Runtime-ready signal definition.
Definition
decode_database.h:39
DecodeSignal::minimum
double minimum
Definition
decode_database.h:47
DecodeSignal::unit
std::string unit
Definition
decode_database.h:49
DecodeSignal::factor
double factor
Definition
decode_database.h:45
DecodeSignal::maximum
double maximum
Definition
decode_database.h:48
DecodeSignal::name
std::string name
Definition
decode_database.h:40
DecodeSignal::offset
double offset
Definition
decode_database.h:46
DecodeSignal::valueType
ValueType valueType
Definition
decode_database.h:44
DecodeSignal::startBit
std::uint32_t startBit
Definition
decode_database.h:41
DecodeSignal::receivers
std::vector< std::string > receivers
Definition
decode_database.h:50
DecodeSignal::byteOrder
ByteOrder byteOrder
Definition
decode_database.h:43
DecodeSignal::length
std::uint32_t length
Definition
decode_database.h:42
DecodeSignal::comment
std::string comment
Definition
decode_database.h:51
FrameKeyHasher
Hasher for frame key.
Definition
decode_database.h:100
FrameKey
Key for fast frame lookup.
Definition
decode_database.h:80
decode_database.h
Generated by
1.9.8