Closes #28
This commit is contained in:
1 parent
a0938cb29c
commit
3dd9230fca
21 files changed
+491
-450
No files matched your search
+25
-19
@@ -22,13 +22,11 @@
|
||||
* @brief Raw CAN frame used for runtime or trace decoding.
|
||||
*/
|
||||
struct RawCanFrame {
|
||||
std::uint32_t canId; /**< Normalized CAN ID. */
|
||||
bool isExtended; /**< true for extended frame. */
|
||||
std::vector<std::uint8_t> data; /**< Payload bytes. */
|
||||
std::uint32_t canId = 0U; /**< Normalized CAN ID. */
|
||||
bool isExtended = false; /**< true for extended frame. */
|
||||
std::vector<std::uint8_t> data; /**< Payload bytes. */
|
||||
|
||||
RawCanFrame()
|
||||
: canId(0U), isExtended(false), data() {
|
||||
}
|
||||
RawCanFrame() = default;
|
||||
};
|
||||
|
||||
enum class SignalDecodeStatus {
|
||||
@@ -43,10 +41,10 @@ enum class SignalDecodeStatus {
|
||||
* @brief One decoded signal value.
|
||||
*/
|
||||
struct DecodedSignalValue {
|
||||
const DecodeSignal *definition; /**< Signal definition. */
|
||||
RawSignalValue rawValue; /**< Exact signed or unsigned raw value. */
|
||||
double physicalValue; /**< Converted physical value. */
|
||||
bool valid; /**< true if decoding succeeded. */
|
||||
const DecodeSignal *definition = nullptr; /**< Signal definition. */
|
||||
RawSignalValue rawValue = std::uint64_t(0U); /**< Exact signed or unsigned raw value. */
|
||||
double physicalValue = 0.0; /**< Converted physical value. */
|
||||
bool valid = false; /**< true if decoding succeeded. */
|
||||
SignalDecodeStatus status = SignalDecodeStatus::InvalidDefinition;
|
||||
|
||||
/** Lookup using the raw integer; nullptr for invalid or unmapped values. */
|
||||
@@ -54,22 +52,18 @@ struct DecodedSignalValue {
|
||||
return valid && definition ? FindValueDescription(definition->valueDescriptions, rawValue) : nullptr;
|
||||
}
|
||||
|
||||
DecodedSignalValue()
|
||||
: definition(nullptr), rawValue(std::uint64_t(0U)), physicalValue(0.0), valid(false) {
|
||||
}
|
||||
DecodedSignalValue() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Fully decoded frame.
|
||||
*/
|
||||
struct DecodedFrameValue {
|
||||
const DecodeFrame *definition; /**< Frame definition. */
|
||||
std::vector<DecodedSignalValue> signals; /**< Decoded signal values. */
|
||||
bool valid; /**< true if frame was matched. */
|
||||
const DecodeFrame *definition = nullptr; /**< Frame definition. */
|
||||
std::vector<DecodedSignalValue> signals; /**< Decoded signal values. */
|
||||
bool valid = false; /**< true if frame was matched. */
|
||||
|
||||
DecodedFrameValue()
|
||||
: definition(nullptr), signals(), valid(false) {
|
||||
}
|
||||
DecodedFrameValue() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -98,6 +92,18 @@ public:
|
||||
const RawCanFrame &frame) const;
|
||||
|
||||
private:
|
||||
struct SelectorState {
|
||||
const DecodeSignal *definition = nullptr;
|
||||
bool valid = false;
|
||||
bool available = false;
|
||||
std::uint64_t value = 0U;
|
||||
};
|
||||
|
||||
static SelectorState ReadSelector(const DecodeFrame &definition, const RawCanFrame &frame);
|
||||
static DecodedSignalValue DecodeOneSignal(const DecodeSignal &signal,
|
||||
const RawCanFrame &frame,
|
||||
const SelectorState &selector);
|
||||
|
||||
static bool ExtractUnsigned(const std::vector<std::uint8_t> &data,
|
||||
const DecodeSignal &signal,
|
||||
std::uint64_t &value);
|
||||
|
||||
Reference in new issue
Block a user