Skip to content

Commit

Permalink
add secondary replacement value 0 for date types (closes #1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Dec 31, 2024
1 parent 3eb51e7 commit edcb019
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/ebus/datatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ result_t DateTimeDataType::readSymbols(size_t offset, size_t length, const Symbo
}
switch (type) {
case 2: // date only
if (!hasFlag(REQ) && symbol == m_replacement) {
if (!hasFlag(REQ) && (symbol == m_replacement || (!hasFlag(REZ) && symbol == 0))) {
if (i + 1 != length) {
*output << NULL_VALUE << ".";
break;
} else if (last == m_replacement) {
} else if (last == m_replacement || (!hasFlag(REZ) && last == 0)) {
if (length == 2) { // number of days since 01.01.1900
*output << NULL_VALUE << ".";
}
Expand Down Expand Up @@ -1228,7 +1228,7 @@ DataTypeList::DataTypeList() {
// date, 01.01.2000 - 31.12.2099 (0x01,0x01,0x00 - 0x1f,0x0c,0x63, replacement 0xff)
add(new DateTimeDataType("HDA:3", 24, 0, 0xff, true, false, 0));
// date, days since 01.01.1900, 01.01.1900 - 06.06.2079 (0x00,0x00 - 0xff,0xff)
add(new DateTimeDataType("DAY", 16, 0, 0xff, true, false, 0));
add(new DateTimeDataType("DAY", 16, REZ, 0xff, true, false, 0));
// date+time in minutes since 01.01.2009, 01.01.2009 - 31.12.2099 (0x00,0x00,0x00,0x00 - 0x02,0xda,0x4e,0x1f)
add(new DateTimeDataType("DTM", 32, REQ, 0x100, true, true, 0));
// time in BCD, 00:00:00 - 23:59:59 (0x00,0x00,0x00 - 0x59,0x59,0x23)
Expand Down
3 changes: 3 additions & 0 deletions src/lib/ebus/datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ enum PartType {
/** bit flag for @a DataType: stored duplicate for backwards compatibility, not to be traversed in lists any more. */
#define DUP 0x2000

/** bit flag for @a DataType: special marker for non-tolerated secondary replacement value of zero (date only). */
#define REZ 0x4000

/**
* Parse a float value from the 32 bit representation (IEEE 754).
* @param value the 32 bit representation of the float value.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/ebus/test/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,33 @@ int main() {
{"x,,bda", "20.02.2021", "10fe07000420020621", "00", ""}, // Saturday
{"x,,bda", "31.12.2099", "10fe07000431120499", "00", ""}, // Thursday
{"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"x,,bda", "-.-.-", "10fe07000400000000", "00", "W"},
{"x,,bda", "", "10fe07000432100014", "00", "rw"},
{"x,,bda:3", "26.10.2014", "10fe070003261014", "00", ""},
{"x,,bda:3", "01.01.2000", "10fe070003010100", "00", ""},
{"x,,bda:3", "31.12.2099", "10fe070003311299", "00", ""},
{"x,,bda:3", "-.-.-", "10fe070003ffffff", "00", ""},
{"x,,bda:3", "-.-.-", "10fe070003000000", "00", "W"},
{"x,,bda:3", "", "10fe070003321299", "00", "rw"},
{"x,,bda,2", "", "", "", "c"},
{"x,,bdz", "26.10.2014", "10fe07000426100614", "00", ""}, // Sunday
{"x,,bdz", "01.01.2000", "10fe07000401010500", "00", ""}, // Saturday
{"x,,bdz", "20.02.2021", "10fe07000420020521", "00", ""}, // Saturday
{"x,,bdz", "31.12.2099", "10fe07000431120399", "00", ""}, // Thursday
{"x,,bdz", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"x,,bdz", "-.-.-", "10fe07000400000000", "00", "W"},
{"x,,bdz", "", "10fe07000432100014", "00", "rw"},
{"x,,hda", "26.10.2014", "10fe0700041a0a070e", "00", ""}, // Sunday
{"x,,hda", "01.01.2000", "10fe07000401010600", "00", ""}, // Saturday
{"x,,hda", "31.12.2099", "10fe0700041f0c0463", "00", ""}, // Thursday
{"x,,hda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"x,,hda", "-.-.-", "10fe07000400000000", "00", "W"},
{"x,,hda", "", "10fe070004200c0463", "00", "rw"},
{"x,,hda:3", "26.10.2014", "10fe0700031a0a0e", "00", ""},
{"x,,hda:3", "01.01.2000", "10fe070003010100", "00", ""},
{"x,,hda:3", "31.12.2099", "10fe0700031f0c63", "00", ""},
{"x,,hda:3", "-.-.-", "10fe070003ffffff", "00", ""},
{"x,,hda:3", "-.-.-", "10fe070003000000", "00", "W"},
{"x,,hda:3", "", "10fe070003200c63", "00", "rw"},
{"x,,hda,2", "", "", "", "c"},
{"x,,day", "26.10.2014", "10fe070002d0a3", "00", ""},
Expand Down

0 comments on commit edcb019

Please sign in to comment.