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
25
enum class
ByteOrder
{
26
Intel,
27
Motorola
28
};
29
33
enum class
ValueType
{
34
Unsigned,
35
Signed
36
};
37
41
struct
DecodeSignal
{
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
63
struct
DecodeFrame
{
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
80
struct
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
98
struct
FrameKeyHasher
{
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
109
struct
DecodeDatabase
{
110
std::vector<DecodeFrame> frames;
111
std::unordered_map<FrameKey, std::size_t, FrameKeyHasher> frameIndexByKey;
112
};
113
114
#endif
/* DECODE_DATABASE_H */
ByteOrder
ByteOrder
Signal byte order used for runtime decoding.
Definition
decode_database.h:25
ValueType
ValueType
Signal numeric type.
Definition
decode_database.h:33
DecodeDatabase
Runtime decode database with fast lookup by CAN ID.
Definition
decode_database.h:109
DecodeFrame
Runtime-ready frame definition.
Definition
decode_database.h:63
DecodeFrame::pgn
std::uint32_t pgn
Definition
decode_database.h:68
DecodeFrame::hasPgn
bool hasPgn
Definition
decode_database.h:69
DecodeFrame::comment
std::string comment
Definition
decode_database.h:71
DecodeFrame::isExtended
bool isExtended
Definition
decode_database.h:66
DecodeFrame::dlc
std::uint8_t dlc
Definition
decode_database.h:67
DecodeFrame::canId
std::uint32_t canId
Definition
decode_database.h:65
DecodeFrame::name
std::string name
Definition
decode_database.h:64
DecodeFrame::transmitter
std::string transmitter
Definition
decode_database.h:70
DecodeSignal
Runtime-ready signal definition.
Definition
decode_database.h:41
DecodeSignal::minimum
double minimum
Definition
decode_database.h:50
DecodeSignal::unit
std::string unit
Definition
decode_database.h:52
DecodeSignal::factor
double factor
Definition
decode_database.h:48
DecodeSignal::maximum
double maximum
Definition
decode_database.h:51
DecodeSignal::name
std::string name
Definition
decode_database.h:43
DecodeSignal::valueDescriptions
ValueDescriptions valueDescriptions
Definition
decode_database.h:54
DecodeSignal::offset
double offset
Definition
decode_database.h:49
DecodeSignal::valueType
ValueType valueType
Definition
decode_database.h:47
DecodeSignal::startBit
std::uint32_t startBit
Definition
decode_database.h:44
DecodeSignal::receivers
std::vector< std::string > receivers
Definition
decode_database.h:53
DecodeSignal::byteOrder
ByteOrder byteOrder
Definition
decode_database.h:46
DecodeSignal::length
std::uint32_t length
Definition
decode_database.h:45
DecodeSignal::comment
std::string comment
Definition
decode_database.h:55
FrameKeyHasher
Hasher for frame key.
Definition
decode_database.h:98
FrameKey
Key for fast frame lookup.
Definition
decode_database.h:80
Multiplexing
Definition
multiplexing.h:14
core
decode_database.h
Generated by
1.9.8