ADU histogram: Save
This commit is contained in:
@@ -108,26 +108,6 @@ inline std::pair<uint64_t, uint64_t> GetRational(CborValue &value) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline void GetCBORFloatArray(CborValue &value, std::vector<float> &v) {
|
||||
if (GetCBORTag(value) != TagFloatLE)
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
|
||||
auto len = GetCBORArrayLen(value);
|
||||
if (len > 0) {
|
||||
CborValue array_value;
|
||||
|
||||
v.resize(len);
|
||||
|
||||
cborErr(cbor_value_enter_container(&value, &array_value));
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
v[i] = GetCBORFloat(array_value);
|
||||
|
||||
cborErr(cbor_value_leave_container(&value, &array_value));
|
||||
} else
|
||||
cbor_value_advance(&value);
|
||||
}
|
||||
|
||||
|
||||
inline std::pair<uint64_t, uint64_t> GetCBORDimension2DArray(CborValue &value) {
|
||||
std::pair<uint64_t, uint64_t> ret;
|
||||
|
||||
@@ -179,6 +159,32 @@ inline std::pair<const uint8_t *, size_t> GetCBORByteString(CborValue &value) {
|
||||
return {ptr, len};
|
||||
}
|
||||
|
||||
inline void GetCBORFloatArray(CborValue &value, std::vector<float> &v) {
|
||||
if (GetCBORTag(value) != TagFloatLE)
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
|
||||
|
||||
auto [ptr, len] = GetCBORByteString(value);
|
||||
|
||||
if (len % sizeof(float))
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Size mismatch");
|
||||
|
||||
v.resize(len / sizeof(float));
|
||||
memcpy(v.data(), ptr, len);
|
||||
}
|
||||
|
||||
inline void GetCBORUInt64Array(CborValue &value, std::vector<uint64_t> &v) {
|
||||
if (GetCBORTag(value) != TagUnsignedInt64BitLE)
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
|
||||
|
||||
auto [ptr, len] = GetCBORByteString(value);
|
||||
|
||||
if (len % sizeof(uint64_t))
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Size mismatch");
|
||||
|
||||
v.resize(len / sizeof(uint64_t));
|
||||
memcpy(v.data(), ptr, len);
|
||||
}
|
||||
|
||||
inline void GetCBORTypedArray(CBORImage &v, CborValue &value) {
|
||||
CborTag tag = GetCBORTag(value);
|
||||
|
||||
@@ -401,6 +407,8 @@ void JFJochFrameDeserializer::ProcessImageMessageUserDataElement(CborValue &valu
|
||||
data_message.storage_cell = GetCBORUInt(map_value) & UINT32_MAX;
|
||||
else if (key == "bunch_id")
|
||||
data_message.bunch_id = GetCBORUInt(map_value);
|
||||
else if (key == "adu_histogram")
|
||||
GetCBORUInt64Array(map_value, data_message.adu_histogram);
|
||||
else
|
||||
cbor_value_advance(&map_value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user