added list values, use list of predefined data types instead of coding each one separately
This commit is contained in:
Regular → Executable
+22
-20
@@ -25,7 +25,6 @@ using namespace libebus;
|
||||
|
||||
int main ()
|
||||
{
|
||||
//TODO dt_float,
|
||||
//TODO dt_d1b,
|
||||
//TODO dt_d1c,
|
||||
//TODO dt_d2c,
|
||||
@@ -33,23 +32,26 @@ int main ()
|
||||
//name;position(s);type;factor;unit;comment
|
||||
// {"temp;1;d2b;;°C;Aussentemperatur","temp=18.004 °C [Aussentemperatur]","10fe070009019258042126100714cc", "00"},
|
||||
// {"zeit;1;ttm;2;Uhr;","zeit=22:40 Uhr","10feffff0188", "00"},
|
||||
{"hex;1-10;hex","53 70 65 69 63 68 65 72 20 20", "10fe07000a53706569636865722020", "00"},
|
||||
{"zeit;1;bti","21:04:58","10fe070009580421", "00"},
|
||||
{"datum;1;bda","26.10.2014","10fe07000926100714", "00"},
|
||||
{"datum;1-3;bda","26.10.2014","10fe070003261014", "00"},
|
||||
{"tag;1;bdy","Sun","10fe07000307", "00"},
|
||||
{"temp;1;d2b","18.004","10fe0700090112", "00"},
|
||||
{"zeit;1;ttm","22:40","10feffff0188", "00"},
|
||||
{"bcd;1;bcd","26","10feffff0126", "00"},
|
||||
{"bcd;1;bcd","-","10feffff01ff", "00"},
|
||||
{"uch;1;uch","38","10feffff0126", "00"},
|
||||
{"sch;1;sch","-90","10feffff01a6", "00"},
|
||||
{"uin;1;uin","38","10feffff022600", "00"},
|
||||
{"sin;1;sin","-90","10feffff02a6ff", "00"},
|
||||
{"ulg;1;ulg","38","10feffff0426000000", "00"},
|
||||
{"slg;1;slg","-90","10feffff04a6ffffff", "00"},
|
||||
{"str;1-9;str","hallo Du!","10feffff0868616c6c6f20447521", "00"},
|
||||
{"str;1-9;str","hallo Du ","10feffff0868616c6c6f20447500", "00"},
|
||||
{"x;1-10;hex","53 70 65 69 63 68 65 72 20 20", "10fe07000a53706569636865722020", "00"},
|
||||
{"x;1;bti","21:04:58","10fe070009580421", "00"},
|
||||
{"x;1;bda","26.10.2014","10fe07000926100714", "00"},
|
||||
{"x;1-3;bda","26.10.2014","10fe070003261014", "00"},
|
||||
{"x;1;hdy","Sun","10fe07000307", "00"},
|
||||
{"x;1;bdy","Sun","10fe07000306", "00"},
|
||||
{"x;1;d2b","18.004","10fe0700090112", "00"},
|
||||
{"x;1;ttm","22:40","10feffff0188", "00"},
|
||||
{"x;1;bcd","26","10feffff0126", "00"},
|
||||
{"x;1;bcd","-","10feffff01ff", "00"},
|
||||
{"x;1;uch","38","10feffff0126", "00"},
|
||||
{"x;1;sch","-90","10feffff01a6", "00"},
|
||||
{"x;1;d1b","-90","10feffff01a6", "00"},
|
||||
{"x;1;uin","38","10feffff022600", "00"},
|
||||
{"x;1;sin","-90","10feffff02a6ff", "00"},
|
||||
{"x;1;ulg","38","10feffff0426000000", "00"},
|
||||
{"x;1;slg","-90","10feffff04a6ffffff", "00"},
|
||||
{"x;1;flt","-0.090","10feffff02a6ff", "00"},
|
||||
{"x;1-9;str","hallo Du!","10feffff0868616c6c6f20447521", "00"},
|
||||
{"x;1-9;str","hallo Du ","10feffff0868616c6c6f20447520", "00"},
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(checks)/sizeof(checks[0]); i++) {
|
||||
std::istringstream isstr(checks[i][0]);
|
||||
@@ -72,7 +74,7 @@ int main ()
|
||||
std::cout << "create \"" << checks[i][0] << "\" successful" << std::endl;
|
||||
|
||||
|
||||
std::string gotStr = field->parseSymbols(mstr, sstr);
|
||||
std::string gotStr = field->read(mstr, sstr);
|
||||
|
||||
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
|
||||
std::cout << "parse successful: " << gotStr << std::endl;
|
||||
@@ -82,7 +84,7 @@ int main ()
|
||||
|
||||
SymbolString writeMstr = SymbolString(mstr.getDataStr().substr(0, 10), false);
|
||||
SymbolString writeSstr = SymbolString(sstr.getDataStr().substr(0, 2), false);
|
||||
if (field->formatSymbols(gotStr, writeMstr, writeSstr) == false)
|
||||
if (field->write(gotStr, writeMstr, writeSstr) == false)
|
||||
std::cout << "format failed" << std::endl;
|
||||
else {
|
||||
if (mstr == writeMstr && sstr == writeSstr)
|
||||
|
||||
Reference in New Issue
Block a user