diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-30 09:52:21 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-31 09:58:54 +0300 |
commit | 27d42ad2794b7c678fa6235aa48cff83c5ad7487 (patch) | |
tree | 7dcb7ff300a0d6bb6e0b4e430342f6c9fd0e89ce /src/ObjectModel | |
parent | cef4926d6e6d004550e2dec20904de75886452ed (diff) |
Support reading array expressions for array-values command parameters
Diffstat (limited to 'src/ObjectModel')
-rw-r--r-- | src/ObjectModel/ObjectModel.cpp | 4 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 33 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp index 6a1dfd51..6328b1a6 100644 --- a/src/ObjectModel/ObjectModel.cpp +++ b/src/ObjectModel/ObjectModel.cpp @@ -84,7 +84,7 @@ void ExpressionValue::AppendAsString(const StringRef& str) const noexcept case TypeCode::DriverId: #if SUPPORT_CAN_EXPANSION - str.catf("%u.%u", (unsigned int)(uVal >> 8), (unsigned int)(uVal & 0xFF)); + str.catf("%u.%u", (unsigned int)param, (unsigned int)uVal); #else str.catf("%u", (unsigned int)uVal); #endif @@ -709,7 +709,7 @@ void ObjectModel::ReportItemAsJsonFull(OutputBuffer *buf, ObjectExplorationConte case TypeCode::DriverId: #if SUPPORT_CAN_EXPANSION - buf->catf("\"%u.%u\"", (unsigned int)(val.uVal >> 8), (unsigned int)(val.uVal & 0xFF)); + buf->catf("\"%u.%u\"", (unsigned int)val.param, (unsigned int)val.uVal); #else buf->catf("\"%u\"", (unsigned int)val.uVal); #endif diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 6a2858e0..af576473 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -123,7 +123,18 @@ struct ExpressionValue explicit constexpr ExpressionValue(IPAddress ip) noexcept : type((uint32_t)TypeCode::IPAddress), param(0), uVal(ip.GetV4LittleEndian()) { } explicit constexpr ExpressionValue(nullptr_t dummy) noexcept : type((uint32_t)TypeCode::None), param(0), uVal(0) { } explicit ExpressionValue(DateTime t) noexcept : type((t.tim == 0) ? (uint32_t)TypeCode::None : (uint32_t)TypeCode::DateTime) { Set56BitValue(t.tim); } - explicit ExpressionValue(DriverId id) noexcept : type((uint32_t)TypeCode::DriverId), param(0), uVal(id.AsU32()) { } + + explicit ExpressionValue(DriverId id) noexcept + : type((uint32_t)TypeCode::DriverId), +#if SUPPORT_CAN_EXPANSION + param(id.boardAddress), +#else + param(0), +#endif + uVal(id.localDriver) + { + } + explicit ExpressionValue(Bitmap<uint16_t> bm) noexcept : type((uint32_t)TypeCode::Bitmap16), param(0), uVal(bm.GetRaw()) { } explicit ExpressionValue(Bitmap<uint32_t> bm) noexcept : type((uint32_t)TypeCode::Bitmap32), param(0), uVal(bm.GetRaw()) { } explicit ExpressionValue(Bitmap<uint64_t> bm) noexcept : type((uint32_t)TypeCode::Bitmap64) { Set56BitValue(bm.GetRaw()); } @@ -150,6 +161,18 @@ struct ExpressionValue void Set(float f) noexcept { Release(); type = (uint32_t)TypeCode::Float; fVal = f; param = MaxFloatDigitsDisplayedAfterPoint; } void Set(float f, uint32_t digits) noexcept { Release(); type = (uint32_t)TypeCode::Float; fVal = f; param = digits; } void Set(const char *s) noexcept { Release(); type = (uint32_t)TypeCode::CString; sVal = s; } + void Set(DriverId did) noexcept + { + Release(); + type = (uint32_t)TypeCode::DriverId; +#if SUPPORT_CAN_EXPANSION + param = did.boardAddress; +#else + param = 0; +#endif + uVal = did.localDriver; + } + void Set(StringHandle sh) noexcept { Release(); type = (uint32_t)TypeCode::HeapString; shVal = sh; } void Set(nullptr_t dummy) noexcept { Release(); type = (uint32_t)TypeCode::None; } @@ -159,6 +182,14 @@ struct ExpressionValue // Extract a 56-bit value that we have stored. Used to retrieve date/times and large bitmaps. uint64_t Get56BitValue() const noexcept { return ((uint64_t)param << 32) | uVal; } + // Extract a driver ID value + DriverId GetDriverIdValue() const noexcept +#if SUPPORT_CAN_EXPANSION + { return DriverId(param, uVal); } +#else + { return DriverId(uVal); } +#endif + // Get the format string to use assuming this is a floating point number const char *GetFloatFormatString() const noexcept { return ::GetFloatFormatString(param); } |