diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index 01c74c05..6d137560 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -264,6 +264,13 @@ void DataField::dumpString(ostream& output, const string str, const bool prepend } } +string DataField::getDayName(int day) { + if (day < 0 || day > 6) { + return ""; + } + return dayNames[day]; +} + result_t SingleDataField::create(const string id, const unsigned char length, const string name, const string comment, const string unit, const PartType partType, int divisor, map values, @@ -300,8 +307,9 @@ result_t SingleDataField::create(const string id, const unsigned char length, if (dataType->isNumeric()) { NumberDataType* numType = reinterpret_cast(dataType); if (values.empty() && numType->hasFlag(DAY)) { - for (unsigned int i = 0; i < sizeof(dayNames) / sizeof(dayNames[0]); i++) + for (unsigned int i = 0; i < sizeof(dayNames) / sizeof(dayNames[0]); i++) { values[numType->getMinValue() + i] = dayNames[i]; + } } result_t result = numType->derive(divisor, bitCount, numType); if (result != RESULT_OK) { diff --git a/src/lib/ebus/data.h b/src/lib/ebus/data.h index fe216a0a..720a8e48 100644 --- a/src/lib/ebus/data.h +++ b/src/lib/ebus/data.h @@ -102,6 +102,12 @@ class DataField { */ static void dumpString(ostream& output, const string str, const bool prependFieldSeparator = true); + /** + * Return the name of the specified day. + * @return the name of the specified day. + */ + static string getDayName(int day); + /** * Returns the length of this field (or contained fields) in bytes. * @param partType the message part of the contained fields to limit the length calculation to.