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 "definition_key.h"
16#include "multiplexing.h"
17#include "value_descriptions.h"
18#include <cstdint>
19#include <memory>
20#include <string>
21#include <unordered_map>
22#include <vector>
23
27enum class ByteOrder {
28 Intel,
29 Motorola
30};
31
35enum class ValueType {
36 Unsigned,
37 Signed
38};
39
44 Multiplexing multiplexing;
45 std::string name;
46 std::uint32_t startBit = 0U;
47 std::uint32_t length = 0U;
48 ByteOrder byteOrder = ByteOrder::Intel;
49 ValueType valueType = ValueType::Unsigned;
50 double factor = 1.0;
51 double offset = 0.0;
52 double minimum = 0.0;
53 double maximum = 0.0;
54 std::string unit;
55 std::vector<std::string> receivers;
56 ValueDescriptions valueDescriptions;
57 std::string comment;
59 DecodeSignal() = default;
60};
61
66 std::string name;
67 std::uint32_t canId = 0U;
68 bool isExtended = false;
69 std::uint8_t dlc = 0U;
70 std::uint32_t pgn = 0U;
71 bool hasPgn = false;
72 std::string transmitter;
73 std::string comment;
74 std::vector<DecodeSignal> signals;
76 DecodeFrame() = default;
77
78 FrameKey GetKey() const {
79 return FrameKey(canId, isExtended);
80 }
81};
82
88public:
89 DecodeDatabase() = default;
95 explicit DecodeDatabase(std::vector<DecodeFrame> frames);
96
98 const std::vector<DecodeFrame> &GetFrames() const;
100 std::shared_ptr<const DecodeFrame> FindFrame(const FrameKey &key) const;
101 std::shared_ptr<const DecodeSignal> FindSignal(const SignalKey &key) const;
102
103private:
104 struct Storage {
105 std::vector<DecodeFrame> frames;
106 std::unordered_map<FrameKey, std::size_t, FrameKeyHasher> frameIndexByKey;
107
108 explicit Storage(std::vector<DecodeFrame> definitions);
109 };
110
111 std::shared_ptr<const Storage> storage;
112};
113
114#endif /* DECODE_DATABASE_H */
Immutable runtime snapshot. Copies share storage; reload replaces a snapshot. Owning lookup handles a...
std::shared_ptr< const DecodeFrame > FindFrame(const FrameKey &key) const
const std::vector< DecodeFrame > & GetFrames() const
ByteOrder
Signal byte order used for runtime decoding.
ValueType
Signal numeric type.
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
Stable frame identifier: normalized CAN ID and frame type.