added getDayName(), formatting
This commit is contained in:
@@ -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,
|
result_t SingleDataField::create(const string id, const unsigned char length,
|
||||||
const string name, const string comment, const string unit,
|
const string name, const string comment, const string unit,
|
||||||
const PartType partType, int divisor, map<unsigned int, string> values,
|
const PartType partType, int divisor, map<unsigned int, string> values,
|
||||||
@@ -300,8 +307,9 @@ result_t SingleDataField::create(const string id, const unsigned char length,
|
|||||||
if (dataType->isNumeric()) {
|
if (dataType->isNumeric()) {
|
||||||
NumberDataType* numType = reinterpret_cast<NumberDataType*>(dataType);
|
NumberDataType* numType = reinterpret_cast<NumberDataType*>(dataType);
|
||||||
if (values.empty() && numType->hasFlag(DAY)) {
|
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];
|
values[numType->getMinValue() + i] = dayNames[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result_t result = numType->derive(divisor, bitCount, numType);
|
result_t result = numType->derive(divisor, bitCount, numType);
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
|
|||||||
@@ -102,6 +102,12 @@ class DataField {
|
|||||||
*/
|
*/
|
||||||
static void dumpString(ostream& output, const string str, const bool prependFieldSeparator = true);
|
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.
|
* 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.
|
* @param partType the message part of the contained fields to limit the length calculation to.
|
||||||
|
|||||||
Reference in New Issue
Block a user