added data type HCD (for Ochsner)
This commit is contained in:
+13
-10
@@ -60,6 +60,7 @@ static const dataType_t dataTypes[] = {
|
||||
{"BCD", 16, bt_num, BCD|LST, 0xffff, 0, 0x9999, 1}, // unsigned decimal in BCD, 0 - 9999
|
||||
{"BCD", 24, bt_num, BCD|LST, 0xffffff, 0, 0x999999, 1}, // unsigned decimal in BCD, 0 - 999999
|
||||
{"BCD", 32, bt_num, BCD|LST, 0xffffffff, 0, 0x99999999, 1}, // unsigned decimal in BCD, 0 - 99999999
|
||||
{"HCD", 32, bt_num, HCD|BCD|REQ, 0, 0, 0x63636363, 1}, // unsigned decimal in HCD, 0 - 99999999
|
||||
pinDataType,
|
||||
uchDataType,
|
||||
{"SCH", 8, bt_num, SIG, 0x80, 0x81, 0x7f, 1}, // signed integer, -127 - +127
|
||||
@@ -826,14 +827,16 @@ result_t NumericDataField::readRawValue(SymbolString& input,
|
||||
value = m_dataType.replacement;
|
||||
return RESULT_OK;
|
||||
}
|
||||
if ((ch & 0xf0) > 0x90 || (ch & 0x0f) > 0x09)
|
||||
return RESULT_ERR_OUT_OF_RANGE; // invalid BCD
|
||||
if ((m_dataType.flags & HCD) == 0) {
|
||||
if ((ch & 0xf0) > 0x90 || (ch & 0x0f) > 0x09)
|
||||
return RESULT_ERR_OUT_OF_RANGE; // invalid BCD
|
||||
|
||||
ch = (unsigned char)((ch >> 4) * 10 + (ch & 0x0f));
|
||||
ch = (unsigned char)((ch >> 4) * 10 + (ch & 0x0f));
|
||||
} else if (ch > 0x63)
|
||||
return RESULT_ERR_OUT_OF_RANGE; // invalid HCD
|
||||
value += ch * exp;
|
||||
exp *= 100;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
value |= ch * exp;
|
||||
exp <<= 8;
|
||||
}
|
||||
@@ -872,13 +875,13 @@ result_t NumericDataField::writeRawValue(unsigned int value,
|
||||
ch = m_dataType.replacement & 0xff;
|
||||
else {
|
||||
ch = (unsigned char)((value / exp) % 100);
|
||||
ch = (unsigned char)(((ch / 10) << 4) | (ch % 10));
|
||||
if ((m_dataType.flags & HCD) == 0)
|
||||
ch = (unsigned char)(((ch / 10) << 4) | (ch % 10));
|
||||
}
|
||||
exp = exp * 100;
|
||||
}
|
||||
else {
|
||||
exp *= 100;
|
||||
} else {
|
||||
ch = (value / exp) & 0xff;
|
||||
exp = exp << 8;
|
||||
exp <<= 8;
|
||||
}
|
||||
if (offset == start && (m_bitCount % 8) != 0 && baseOffset + offset < output.size())
|
||||
output[baseOffset + offset] |= ch;
|
||||
|
||||
@@ -86,6 +86,7 @@ static const unsigned int DAY = 0x20; //!< forced value list defaulting to week
|
||||
static const unsigned int IGN = 0x40; //!< ignore value during read and write
|
||||
static const unsigned int FIX = 0x80; //!< fixed width formatting
|
||||
static const unsigned int REQ = 0x100;//!< value may not be NULL
|
||||
static const unsigned int HCD = 0x200; //!< binary representation is hex converted to decimal and interpreted as 2 digits (also requires @a BCD)
|
||||
|
||||
/** The structure for defining field types with their properties. */
|
||||
typedef struct {
|
||||
|
||||
@@ -119,6 +119,10 @@ int main()
|
||||
{"x,,bcd:4","99999999", "10feffff0199999999", "00", ""},
|
||||
{"x,,bcd:4","-", "10feffff01ffffffff", "00", ""},
|
||||
{"x,,bcd:4","", "10feffff0100009a00", "00", "rw"},
|
||||
{"x,,hcd","1234567", "10feffff01432d1701", "00", ""},
|
||||
{"x,,hcd","0", "10feffff0100000000", "00", ""},
|
||||
{"x,,hcd","99999999", "10feffff0163636363", "00", ""},
|
||||
{"x,,hcd","", "10feffff0100006400", "00", "rw"},
|
||||
{"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""},
|
||||
{"x,,uch:17", "", "10feffff00", "00", "c"},
|
||||
{"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"},
|
||||
@@ -301,8 +305,7 @@ int main()
|
||||
cout << "\"" << check[0] << "\": create OK" << endl;
|
||||
if (isTemplate) {
|
||||
// store new template
|
||||
string name = fields->getName();
|
||||
result = templates->add(fields, true);
|
||||
result = templates->add(fields, "", true);
|
||||
if (result == RESULT_OK) {
|
||||
fields = NULL;
|
||||
cout << " store template OK" << endl;
|
||||
|
||||
Reference in New Issue
Block a user