Closes #15
This commit is contained in:
1 parent
0708316a37
commit
7022c84941
69 files changed
+2696
-1912
No files matched your search
+16
-2
@@ -34,6 +34,15 @@ enum class SignalDecodeStatus {
|
||||
InsufficientPayload,
|
||||
SelectorUnavailable,
|
||||
Inactive,
|
||||
Valid,
|
||||
PhysicalConversionFailed
|
||||
};
|
||||
|
||||
/** Frame summary: short payload takes precedence over individual signal errors. */
|
||||
enum class FrameDecodeStatus {
|
||||
UnknownFrame,
|
||||
InsufficientPayload,
|
||||
SignalErrors,
|
||||
Valid
|
||||
};
|
||||
|
||||
@@ -43,8 +52,8 @@ enum class SignalDecodeStatus {
|
||||
struct DecodedSignalValue {
|
||||
std::shared_ptr<const DecodeSignal> definition; /**< Owning immutable definition. */
|
||||
SignalKey key; /**< Stable application identifier. */
|
||||
RawSignalValue rawValue = std::uint64_t(0U); /**< Exact signed or unsigned raw value. */
|
||||
double physicalValue = 0.0; /**< Converted physical value. */
|
||||
RawSignalValue rawValue = std::uint64_t(0U); /**< Exact raw value for Valid or PhysicalConversionFailed. */
|
||||
double physicalValue = 0.0; /**< Conversion result, possibly NaN/Inf on failure. */
|
||||
bool valid = false; /**< true if decoding succeeded. */
|
||||
SignalDecodeStatus status = SignalDecodeStatus::InvalidDefinition;
|
||||
|
||||
@@ -64,6 +73,7 @@ struct DecodedFrameValue {
|
||||
FrameKey key; /**< Stable application identifier. */
|
||||
std::vector<DecodedSignalValue> signals; /**< Decoded signal values. */
|
||||
bool valid = false; /**< true if frame was matched. */
|
||||
FrameDecodeStatus status = FrameDecodeStatus::UnknownFrame; /**< Inspect signals for individual failures. */
|
||||
|
||||
DecodedFrameValue() = default;
|
||||
};
|
||||
@@ -88,12 +98,15 @@ public:
|
||||
* @brief Decode one raw CAN frame.
|
||||
* @param database Runtime decode database.
|
||||
* @param frame Raw CAN frame.
|
||||
* Short payloads decode available signals; bytes beyond declared DLC are ignored.
|
||||
* @return Decoded frame value.
|
||||
*/
|
||||
DecodedFrameValue Decode(const DecodeDatabase &database,
|
||||
const RawCanFrame &frame) const;
|
||||
|
||||
private:
|
||||
static bool IsValidDefinition(const DecodeSignal &signal, std::uint8_t dlc);
|
||||
|
||||
struct SelectorState {
|
||||
const DecodeSignal *definition = nullptr;
|
||||
bool valid = false;
|
||||
@@ -103,6 +116,7 @@ private:
|
||||
|
||||
static SelectorState ReadSelector(const DecodeFrame &definition, const RawCanFrame &frame);
|
||||
static DecodedSignalValue DecodeOneSignal(const DecodeSignal &signal,
|
||||
std::uint8_t dlc,
|
||||
const RawCanFrame &frame,
|
||||
const SelectorState &selector);
|
||||
|
||||
|
||||
Reference in new issue
Block a user