switch ";" and "," but keep ";" for values shown in/parsed from UI, added todos, removed "p" for poll (use 1-9 instead), formatting
This commit is contained in:
@@ -70,9 +70,6 @@ static const dataType_t dataTypes[] = {
|
||||
/** the week day names. */
|
||||
static const char* dayNames[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
#define VALUE_SEPARATOR ','
|
||||
#define LENGTH_SEPARATOR ':'
|
||||
#define NULL_VALUE "-"
|
||||
#define MAX_POS 16
|
||||
|
||||
unsigned int parseInt(const char* str, int base, const unsigned int minValue, const unsigned int maxValue, result_t& result, unsigned int* length) {
|
||||
@@ -96,7 +93,7 @@ unsigned int parseInt(const char* str, int base, const unsigned int minValue, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
void printErrorPos(vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos, char separator)
|
||||
void printErrorPos(vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos)
|
||||
{
|
||||
cout << "Erroneous item is here:" << endl;
|
||||
bool first = true;
|
||||
@@ -107,7 +104,7 @@ void printErrorPos(vector<string>::iterator begin, const vector<string>::iterato
|
||||
if (first == true)
|
||||
first = false;
|
||||
else {
|
||||
cout << separator;
|
||||
cout << FIELD_SEPARATOR;
|
||||
if (begin <= pos) {
|
||||
cnt++;
|
||||
}
|
||||
@@ -141,7 +138,7 @@ result_t DataField::create(vector<string>::iterator& it,
|
||||
const bool isTemplate = dstAddress == SYN;
|
||||
string token;
|
||||
|
||||
// name;part;type[:len][;[divisor|values][;[unit][;[comment]]]]
|
||||
// name,part,type[:len][,[divisor|values][,[unit][,[comment]]]]
|
||||
const string name = *it++;
|
||||
if (it == end)
|
||||
break;
|
||||
@@ -317,7 +314,7 @@ result_t DataField::create(vector<string>::iterator& it,
|
||||
result = RESULT_ERR_OUT_OF_RANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO add special field for fixed values (exactly one value in the list of values)
|
||||
add = new ValueListDataField(name, comment, unit, dataType, partType, useLength, bitCount, values);
|
||||
break;
|
||||
}
|
||||
|
||||
+21
-8
@@ -31,7 +31,20 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define FIELD_SEPARATOR ';'
|
||||
/** the separator character used between fields (in CSV only). */
|
||||
#define FIELD_SEPARATOR ','
|
||||
|
||||
/** the separator character used between multiple values (in CSV only). */
|
||||
#define VALUE_SEPARATOR ';'
|
||||
|
||||
/** the separator character used between base type name and length (in CSV only). */
|
||||
#define LENGTH_SEPARATOR ':'
|
||||
|
||||
/** the replacement string for undefined values (in UI and CSV). */
|
||||
#define NULL_VALUE "-"
|
||||
|
||||
/** the separator character used between fields (in UI only). */
|
||||
#define UI_FIELD_SEPARATOR ';'
|
||||
|
||||
/** the message part in which a data field is stored. */
|
||||
enum PartType {
|
||||
@@ -90,7 +103,7 @@ unsigned int parseInt(const char* str, int base, const unsigned int minValue, co
|
||||
* @param pos the iterator with the erroneous position.
|
||||
* @param separator the character to place between items.
|
||||
*/
|
||||
void printErrorPos(vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos, char separator=';');
|
||||
void printErrorPos(vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos);
|
||||
|
||||
|
||||
class DataFieldTemplates;
|
||||
@@ -178,7 +191,7 @@ public:
|
||||
virtual result_t read(const PartType partType,
|
||||
SymbolString& data, unsigned char offset,
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, char separator=';') = 0;
|
||||
bool verbose=false, char separator=UI_FIELD_SEPARATOR) = 0;
|
||||
/**
|
||||
* @brief Writes the value to the master or slave @a SymbolString.
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
@@ -190,7 +203,7 @@ public:
|
||||
*/
|
||||
virtual result_t write(istringstream& input,
|
||||
const PartType partType, SymbolString& data,
|
||||
unsigned char offset, char separator=';') = 0;
|
||||
unsigned char offset, char separator=UI_FIELD_SEPARATOR) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -259,11 +272,11 @@ public:
|
||||
virtual result_t read(const PartType partType,
|
||||
SymbolString& data, unsigned char offset,
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, char separator=';');
|
||||
bool verbose=false, char separator=UI_FIELD_SEPARATOR);
|
||||
// @copydoc
|
||||
virtual result_t write(istringstream& input,
|
||||
const PartType partType, SymbolString& data,
|
||||
unsigned char offset, char separator=';');//TODO replace
|
||||
unsigned char offset, char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -553,11 +566,11 @@ public:
|
||||
virtual result_t read(const PartType partType,
|
||||
SymbolString& data, unsigned char offset,
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, char separator=';');
|
||||
bool verbose=false, char separator=UI_FIELD_SEPARATOR);
|
||||
// @copydoc
|
||||
virtual result_t write(istringstream& input,
|
||||
const PartType partType, SymbolString& data,
|
||||
unsigned char offset, char separator=';');
|
||||
unsigned char offset, char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
+14
-32
@@ -59,19 +59,11 @@ Message::Message(const string clazz, const string name, const bool isSet,
|
||||
*/
|
||||
string getDefault(string value, vector<string>* defaults, size_t pos)
|
||||
{
|
||||
/*cout<<"getDefault("<<value<<",";
|
||||
if (defaults==NULL)
|
||||
cout<<"NULL";
|
||||
else
|
||||
cout<<static_cast<unsigned>(defaults->size());
|
||||
cout<<","<<static_cast<unsigned>(pos)<<"=";*/
|
||||
if (value.length() > 0 || defaults == NULL || pos > defaults->size()) {
|
||||
//cout<<value<<endl;
|
||||
return value;
|
||||
}
|
||||
|
||||
value = defaults->at(pos);
|
||||
//cout<<value<<endl;
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -79,7 +71,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
||||
vector< vector<string> >* defaultsRows,
|
||||
DataFieldTemplates* templates, Message*& returnValue)
|
||||
{
|
||||
// [type];[class];name;[comment];[QQ];ZZ;id;fields...
|
||||
// [type],[class],name,[comment],[QQ],ZZ,id,fields...
|
||||
result_t result;
|
||||
bool isSet = false, isPassive = false;
|
||||
char defaultsChar;
|
||||
@@ -96,33 +88,23 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
||||
} else if (strncasecmp(str, "W", 1) == 0) { // active set
|
||||
isSet = true;
|
||||
defaultsChar = 'w';
|
||||
} else if (strncasecmp(str, "P", 1) == 0) { // poll (=active get)
|
||||
if (str[1] == 0)
|
||||
pollPriority = 1;
|
||||
else {
|
||||
result_t result;
|
||||
pollPriority = parseInt(str+1, 10, 1, 9, result);
|
||||
if (result != RESULT_OK)
|
||||
return result;
|
||||
}
|
||||
defaultsChar = 'r';
|
||||
} else if (str[0] >= '0' && str[0] <= '9') { // poll priority (=active get)
|
||||
result_t result;
|
||||
pollPriority = parseInt(str, 10, 1, 9, result);
|
||||
pollPriority = parseInt(str, 10, 0, 9, result); // priority is the same as "r"
|
||||
if (result != RESULT_OK)
|
||||
return result;
|
||||
defaultsChar = 'r';
|
||||
} else { // any other: passive set/get
|
||||
isPassive = true;
|
||||
isSet = strncasecmp(str+1, "W", 1) == 0;
|
||||
defaultsChar = str[0];
|
||||
isSet = strcasecmp(str+strlen(str)-1, "W") == 0; // if type ends with "w" it is treated as passive set
|
||||
defaultsChar = str[0]; // TODO better not case sensitive, also in defaults definition
|
||||
}
|
||||
|
||||
vector<string>* defaults = NULL;
|
||||
if (defaultsRows != NULL && defaultsRows->size() > 0) {
|
||||
for (vector< vector<string> >::reverse_iterator it = defaultsRows->rbegin(); it != defaultsRows->rend(); it++) {
|
||||
string check = (*it)[0];
|
||||
if (check[0] == defaultsChar) {
|
||||
if (check[0] == defaultsChar) { // TODO better not case sensitive
|
||||
defaults = &(*it);
|
||||
break;
|
||||
}
|
||||
@@ -340,7 +322,7 @@ result_t MessageMap::add(Message* message)
|
||||
bool isSet = message->isSet();
|
||||
string clazz = message->getClass();
|
||||
string name = message->getName();
|
||||
string key = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + ";" + name;
|
||||
string key = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
|
||||
map<string, Message*>::iterator nameIt = m_messagesByName.find(key);
|
||||
if (nameIt != m_messagesByName.end()) {
|
||||
return RESULT_ERR_DUPLICATE; // duplicate key
|
||||
@@ -349,7 +331,7 @@ result_t MessageMap::add(Message* message)
|
||||
m_messagesByName[key] = message;
|
||||
m_messageCount++;
|
||||
|
||||
key = string(isPassive ? "-P;" : (isSet ? "-W;" : "-R;")) + name; // also store without class
|
||||
key = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + name; // also store without class
|
||||
m_messagesByName[key] = message; // last key without class overrides previous
|
||||
|
||||
if (message->isPassive() == true) {
|
||||
@@ -377,7 +359,7 @@ result_t MessageMap::addFromFile(vector<string>& row, DataFieldTemplates* arg, v
|
||||
|
||||
istringstream stream(types);
|
||||
string type;
|
||||
while (getline(stream, type, ',') != 0) {
|
||||
while (getline(stream, type, VALUE_SEPARATOR) != 0) {
|
||||
row[0] = type;
|
||||
vector<string>::iterator it = row.begin();
|
||||
result = Message::create(it, row.end(), defaults, arg, message);
|
||||
@@ -393,14 +375,14 @@ result_t MessageMap::addFromFile(vector<string>& row, DataFieldTemplates* arg, v
|
||||
return result;
|
||||
}
|
||||
|
||||
Message* MessageMap::find(const string& clazz, const string& name, const bool isSet,const bool isPassive)
|
||||
Message* MessageMap::find(const string& clazz, const string& name, const bool isSet, const bool isPassive)
|
||||
{
|
||||
for (int i=0; i<2; i++) {
|
||||
string key;
|
||||
if (i==0)
|
||||
key = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + ";" + name;
|
||||
key = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
|
||||
else
|
||||
key = string(isPassive ? "-P;" : (isSet ? "-W;" : "-R;")) + name; // second try: without class
|
||||
key = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + name; // second try: without class
|
||||
map<string, Message*>::iterator it = m_messagesByName.find(key);
|
||||
if (it != m_messagesByName.end())
|
||||
return it->second;
|
||||
@@ -422,7 +404,7 @@ Message* MessageMap::find(SymbolString& master)
|
||||
return NULL;
|
||||
|
||||
unsigned long long sourceMask = 0x1fLL << (8 * 7);
|
||||
for (int idLength=maxIdLength; idLength>=m_minIdLength; idLength--) {
|
||||
for (int idLength = maxIdLength; idLength >= m_minIdLength; idLength--) {
|
||||
int exp = 7;
|
||||
unsigned long long key = (unsigned long long)idLength << (8 * exp + 5);
|
||||
key |= (unsigned long long)getMasterNumber(master[0]) << (8 * exp--);
|
||||
@@ -455,8 +437,8 @@ void MessageMap::clear()
|
||||
m_pollMessages.pop();
|
||||
}
|
||||
// free message instances
|
||||
for (map<string, Message*>::iterator it=m_messagesByName.begin(); it!=m_messagesByName.end(); it++) {
|
||||
if (it->first[0] != '-') // avoid double free
|
||||
for (map<string, Message*>::iterator it = m_messagesByName.begin(); it != m_messagesByName.end(); it++) {
|
||||
if (it->first[0] != '-') // avoid double free: instances stored multiple times have a key starting with "-"
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t prepareMaster(const unsigned char srcAddress, SymbolString& masterData,
|
||||
istringstream& input, char separator=';');
|
||||
istringstream& input, char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
/**
|
||||
* @brief Prepare the slave @a SymbolString for sending an answer to the bus.
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t decode(const PartType partType, SymbolString& data,
|
||||
ostringstream& output, bool leadingSeparator=false, char separator=';');
|
||||
ostringstream& output, bool leadingSeparator=false, char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
/**
|
||||
* @brief Get the last decoded value.
|
||||
|
||||
+140
-140
@@ -44,145 +44,145 @@ int main()
|
||||
{
|
||||
string checks[][5] = {
|
||||
//name;[len];type[;[divisor|values][;[unit][;[comment]]]], decoded value, master, slave, flags
|
||||
{"x;;ign:10", "", "10fe07000a00000000000000000000", "00", ""},
|
||||
{"x;;str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x;;str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x;;str:10", "Hallo, Du ", "10fe07000a48616c6c6f2c20447520", "00", ""},
|
||||
{"x;;str:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
||||
{"x;;str:11", "", "10fe07000a20202020202020202020", "00", "rW"},
|
||||
{"x;;hex", "20", "10fe07000120", "00", ""},
|
||||
{"x;;hex:10", "48 61 6c 6c 6f 2c 20 44 75 21", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x;;hex:11", "", "10fe07000a48616c6c6f2c20447521", "00", "rW"},
|
||||
{"x;;bda", "26.10.2014","10fe07000426100614", "00", ""}, // Sunday
|
||||
{"x;;hda", "26.10.2014","10fe07000426100714", "00", ""}, // Sunday
|
||||
{"x;;bda", "01.01.2000","10fe07000401010500", "00", ""}, // Saturday
|
||||
{"x;;hda", "01.01.2000","10fe07000401010600", "00", ""}, // Saturday
|
||||
{"x;;bda", "31.12.2099","10fe07000431120399", "00", ""}, // Thursday
|
||||
{"x;;hda", "31.12.2099","10fe07000431120499", "00", ""}, // Thursday
|
||||
{"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", "", "10fe070003321299", "00", "rw"},
|
||||
{"x;;bti", "21:04:58", "10fe070003580421", "00", ""},
|
||||
{"x;;bti", "00:00:00", "10fe070003000000", "00", ""},
|
||||
{"x;;bti", "23:59:59", "10fe070003595923", "00", ""},
|
||||
{"x;;bti", "", "10fe070003605923", "00", "rw"},
|
||||
{"x;;hti", "21:04:58", "10fe07000315043a", "00", ""},
|
||||
{"x;;vti", "21:04:58", "10fe0700033a0415", "00", ""},
|
||||
{"x;;vti", "-:-:-", "10fe070003636363", "00", ""},
|
||||
{"x;;htm", "21:04", "10fe0700021504", "00", ""},
|
||||
{"x;;htm", "00:00", "10fe0700020000", "00", ""},
|
||||
{"x;;htm", "23:59", "10fe070002173b", "00", ""},
|
||||
{"x;;htm", "24:00", "10fe0700021800", "00", ""},
|
||||
{"x;;htm", "", "10fe070002183b", "00", "rw"},
|
||||
{"x;;htm", "24:01", "10fe0700021801", "00", "rw"},
|
||||
{"x;;ttm", "22:40", "10fe07000188", "00", ""},
|
||||
{"x;;ttm", "00:00", "10fe07000100", "00", ""},
|
||||
{"x;;ttm", "23:50", "10fe0700018f", "00", ""},
|
||||
{"x;;ttm", "-:-", "10fe07000190", "00", ""},
|
||||
{"x;;ttm", "", "10fe07000191", "00", "rw"},
|
||||
{"x;;bdy", "Mon", "10fe07000300", "00", ""},
|
||||
{"x;;bdy", "Sun", "10fe07000306", "00", ""},
|
||||
{"x;;bdy", "", "10fe07000308", "00", "rw"},
|
||||
{"x;;hdy", "Mon", "10fe07000301", "00", ""},
|
||||
{"x;;hdy", "Sun", "10fe07000307", "00", ""},
|
||||
{"x;;hdy", "", "10fe07000308", "00", "rw"},
|
||||
{"x;;bcd", "26", "10feffff0126", "00", ""},
|
||||
{"x;;bcd", "0", "10feffff0100", "00", ""},
|
||||
{"x;;bcd", "99", "10feffff0199", "00", ""},
|
||||
{"x;;bcd", "-", "10feffff01ff", "00", ""},
|
||||
{"x;;bcd", "", "10feffff019a", "00", "rw"},
|
||||
{"x;;str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""},
|
||||
{"x;;uch:17", "", "10feffff00", "00", "c"},
|
||||
{"x;s;uch", "0", "1025ffff0310111213", "0300010203", "W"},
|
||||
{"x;s;uch", "0", "1025ffff00", "0100", ""},
|
||||
{"x;s;uch;;;;y;m;uch", "3;2","1025ffff0103", "0102", ""},
|
||||
{"x;;uch", "38", "10feffff0126", "00", ""},
|
||||
{"x;;uch", "0", "10feffff0100", "00", ""},
|
||||
{"x;;uch", "254", "10feffff01fe", "00", ""},
|
||||
{"x;;uch", "-", "10feffff01ff", "00", ""},
|
||||
{"x;;sch", "-90", "10feffff01a6", "00", ""},
|
||||
{"x;;sch", "0", "10feffff0100", "00", ""},
|
||||
{"x;;sch", "-1", "10feffff01ff", "00", ""},
|
||||
{"x;;sch", "-", "10feffff0180", "00", ""},
|
||||
{"x;;sch", "-127", "10feffff0181", "00", ""},
|
||||
{"x;;sch", "127", "10feffff017f", "00", ""},
|
||||
{"x;;d1b", "-90", "10feffff01a6", "00", ""},
|
||||
{"x;;d1b", "0", "10feffff0100", "00", ""},
|
||||
{"x;;d1b", "-1", "10feffff01ff", "00", ""},
|
||||
{"x;;d1b", "-", "10feffff0180", "00", ""},
|
||||
{"x;;d1b", "-127", "10feffff0181", "00", ""},
|
||||
{"x;;d1b", "127", "10feffff017f", "00", ""},
|
||||
{"x;;d1c", "19.5", "10feffff0127", "00", ""},
|
||||
{"x;;d1c", "0.0", "10feffff0100", "00", ""},
|
||||
{"x;;d1c", "100.0", "10feffff01c8", "00", ""},
|
||||
{"x;;d1c", "-", "10feffff01ff", "00", ""},
|
||||
{"x;;uin", "38", "10feffff022600", "00", ""},
|
||||
{"x;;uin", "0", "10feffff020000", "00", ""},
|
||||
{"x;;uin", "65534", "10feffff02feff", "00", ""},
|
||||
{"x;;uin", "-", "10feffff02ffff", "00", ""},
|
||||
{"x;;sin", "-90", "10feffff02a6ff", "00", ""},
|
||||
{"x;;sin", "0", "10feffff020000", "00", ""},
|
||||
{"x;;sin", "-1", "10feffff02ffff", "00", ""},
|
||||
{"x;;sin", "-", "10feffff020080", "00", ""},
|
||||
{"x;;sin", "-32767", "10feffff020180", "00", ""},
|
||||
{"x;;sin", "32767", "10feffff02ff7f", "00", ""},
|
||||
{"x;;flt", "-0.090", "10feffff02a6ff", "00", ""},
|
||||
{"x;;flt", "0.000", "10feffff020000", "00", ""},
|
||||
{"x;;flt", "-0.001", "10feffff02ffff", "00", ""},
|
||||
{"x;;flt", "-", "10feffff020080", "00", ""},
|
||||
{"x;;flt","-32.767", "10feffff020180", "00", ""},
|
||||
{"x;;flt", "32.767", "10feffff02ff7f", "00", ""},
|
||||
{"x;;d2b", "18.004", "10fe0700090112", "00", ""},
|
||||
{"x;;d2b", "0.000", "10feffff020000", "00", ""},
|
||||
{"x;;d2b", "-0.004", "10feffff02ffff", "00", ""},
|
||||
{"x;;d2b", "-", "10feffff020080", "00", ""},
|
||||
{"x;;d2b","-127.996","10feffff020180", "00", ""},
|
||||
{"x;;d2b", "127.996","10feffff02ff7f", "00", ""},
|
||||
{"x;;d2c", "288.06", "10fe0700090112", "00", ""},
|
||||
{"x;;d2c", "0.00", "10feffff020000", "00", ""},
|
||||
{"x;;d2c", "-0.06", "10feffff02ffff", "00", ""},
|
||||
{"x;;d2c", "-", "10feffff020080", "00", ""},
|
||||
{"x;;d2c","-2047.94","10feffff020180", "00", ""},
|
||||
{"x;;d2c", "2047.94","10feffff02ff7f", "00", ""},
|
||||
{"x;;ulg", "38", "10feffff0426000000", "00", ""},
|
||||
{"x;;ulg", "0", "10feffff0400000000", "00", ""},
|
||||
{"x;;ulg", "4294967294", "10feffff04feffffff", "00", ""},
|
||||
{"x;;ulg", "-", "10feffff04ffffffff", "00", ""},
|
||||
{"x;;slg", "-90", "10feffff04a6ffffff", "00", ""},
|
||||
{"x;;slg", "0", "10feffff0400000000", "00", ""},
|
||||
{"x;;slg", "-1", "10feffff04ffffffff", "00", ""},
|
||||
{"x;;bi3", "1", "10feffff0108", "00", ""},
|
||||
{"x;;bi3", "-", "10feffff0100", "00", ""},
|
||||
{"x;;bi3;0=off,1=on","on", "10feffff0108", "00", ""},
|
||||
{"x;;bi3;0=off,1=on","off","10feffff0100", "00", ""},
|
||||
{"x;;bi3:2", "1", "10feffff0108", "00", ""},
|
||||
{"x;;bi3:2", "1", "10feffff01ef", "00", "W"},
|
||||
{"x;;bi3:2", "-", "10feffff0100", "00", ""},
|
||||
{"x;;bi3:2", "3", "10feffff0118", "00", ""},
|
||||
{"x;;bi3:2;1=on","on", "10feffff0108", "00", ""},
|
||||
{"x;;bi3:2;1=on","-", "10feffff0100", "00", ""},
|
||||
{"x;;bi3:2;0=off,1=on,2=auto,3=eco","auto", "10feffff0110", "00", ""},
|
||||
{"x;;bi3:2;0=off,1=on","on", "10feffff0108", "00", ""},
|
||||
{"x;;bi3:2;0=off,1=on","off","10feffff0100", "00", ""},
|
||||
{"x;;uch;1=test,2=high,3=off,4=on","on","10feffff0104", "00", ""},
|
||||
{"x;s;uch","3","1050ffff00", "0103", ""},
|
||||
{"x;;d2b;;�C;Aussentemperatur","x=18.004 �C [Aussentemperatur]","10fe0700090112", "00", "v"},
|
||||
{"x;;bti;;;;y;;bda;;;;z;;bdy", "21:04:58;26.10.2014;Sun","10fe0700085804212610061406", "00", ""}, // combination
|
||||
{"x;;bi3;;;;y;;bi5", "1;-", "10feffff0108", "00", ""}, // bit combination
|
||||
{"x;;bi3;;;;y;;bi5", "1;1", "10feffff0128", "00", ""}, // bit combination
|
||||
{"x;;bi3;;;;y;;bi5", "-;1", "10feffff0120", "00", ""}, // bit combination
|
||||
{"x;;bi3;;;;y;;bi5", "-;-", "10feffff0100", "00", ""}, // bit combination
|
||||
{"x;;bi3;;;;y;;bi7;;;;t;;uch", "-;-;9","10feffff020009", "00", ""}, // bit combination
|
||||
{"x;;bi6:2;;;;y;;bi0:2;;;;t;;uch", "2;1;9","10feffff03800109", "00", ""}, // bit combination
|
||||
{"temp;;d2b;;�C;Aussentemperatur","","", "", "t"}, // template with relative pos
|
||||
{"x;;temp","18.004","10fe0700020112", "00", ""}, // reference to template
|
||||
{"relrel;;d2b;;;;y;;d1c","","", "", "t"}, // template struct with relative pos
|
||||
{"x;;relrel","18.004;9.5","10fe070003011213", "00", ""}, // reference to template struct
|
||||
{"trelrel;;temp,temp","","", "", "t"}, // template struct with relative pos and ref to templates
|
||||
{"x;;trelrel","18.004;19.008","10fe07000401120213", "00", ""}, // reference to template struct
|
||||
{"x;;temp;;;;y;;d1c","18.004;9.5","10fe070003011213", "00", ""}, // reference to template, normal def
|
||||
{"x,,ign:10", "", "10fe07000a00000000000000000000", "00", ""},
|
||||
{"x,,str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x,,str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x,,str:10", "Hallo, Du ", "10fe07000a48616c6c6f2c20447520", "00", ""},
|
||||
{"x,,str:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
||||
{"x,,str:11", "", "10fe07000a20202020202020202020", "00", "rW"},
|
||||
{"x,,hex", "20", "10fe07000120", "00", ""},
|
||||
{"x,,hex:10", "48 61 6c 6c 6f 2c 20 44 75 21", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||
{"x,,hex:11", "", "10fe07000a48616c6c6f2c20447521", "00", "rW"},
|
||||
{"x,,bda", "26.10.2014","10fe07000426100614", "00", ""}, // Sunday
|
||||
{"x,,hda", "26.10.2014","10fe07000426100714", "00", ""}, // Sunday
|
||||
{"x,,bda", "01.01.2000","10fe07000401010500", "00", ""}, // Saturday
|
||||
{"x,,hda", "01.01.2000","10fe07000401010600", "00", ""}, // Saturday
|
||||
{"x,,bda", "31.12.2099","10fe07000431120399", "00", ""}, // Thursday
|
||||
{"x,,hda", "31.12.2099","10fe07000431120499", "00", ""}, // Thursday
|
||||
{"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", "", "10fe070003321299", "00", "rw"},
|
||||
{"x,,bti", "21:04:58", "10fe070003580421", "00", ""},
|
||||
{"x,,bti", "00:00:00", "10fe070003000000", "00", ""},
|
||||
{"x,,bti", "23:59:59", "10fe070003595923", "00", ""},
|
||||
{"x,,bti", "", "10fe070003605923", "00", "rw"},
|
||||
{"x,,hti", "21:04:58", "10fe07000315043a", "00", ""},
|
||||
{"x,,vti", "21:04:58", "10fe0700033a0415", "00", ""},
|
||||
{"x,,vti", "-:-:-", "10fe070003636363", "00", ""},
|
||||
{"x,,htm", "21:04", "10fe0700021504", "00", ""},
|
||||
{"x,,htm", "00:00", "10fe0700020000", "00", ""},
|
||||
{"x,,htm", "23:59", "10fe070002173b", "00", ""},
|
||||
{"x,,htm", "24:00", "10fe0700021800", "00", ""},
|
||||
{"x,,htm", "", "10fe070002183b", "00", "rw"},
|
||||
{"x,,htm", "24:01", "10fe0700021801", "00", "rw"},
|
||||
{"x,,ttm", "22:40", "10fe07000188", "00", ""},
|
||||
{"x,,ttm", "00:00", "10fe07000100", "00", ""},
|
||||
{"x,,ttm", "23:50", "10fe0700018f", "00", ""},
|
||||
{"x,,ttm", "-:-", "10fe07000190", "00", ""},
|
||||
{"x,,ttm", "", "10fe07000191", "00", "rw"},
|
||||
{"x,,bdy", "Mon", "10fe07000300", "00", ""},
|
||||
{"x,,bdy", "Sun", "10fe07000306", "00", ""},
|
||||
{"x,,bdy", "", "10fe07000308", "00", "rw"},
|
||||
{"x,,hdy", "Mon", "10fe07000301", "00", ""},
|
||||
{"x,,hdy", "Sun", "10fe07000307", "00", ""},
|
||||
{"x,,hdy", "", "10fe07000308", "00", "rw"},
|
||||
{"x,,bcd", "26", "10feffff0126", "00", ""},
|
||||
{"x,,bcd", "0", "10feffff0100", "00", ""},
|
||||
{"x,,bcd", "99", "10feffff0199", "00", ""},
|
||||
{"x,,bcd", "-", "10feffff01ff", "00", ""},
|
||||
{"x,,bcd", "", "10feffff019a", "00", "rw"},
|
||||
{"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""},
|
||||
{"x,,uch:17", "", "10feffff00", "00", "c"},
|
||||
{"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"},
|
||||
{"x,s,uch", "0", "1025ffff00", "0100", ""},
|
||||
{"x,s,uch,,,,y,m,uch", "3;2","1025ffff0103", "0102", ""},
|
||||
{"x,,uch", "38", "10feffff0126", "00", ""},
|
||||
{"x,,uch", "0", "10feffff0100", "00", ""},
|
||||
{"x,,uch", "254", "10feffff01fe", "00", ""},
|
||||
{"x,,uch", "-", "10feffff01ff", "00", ""},
|
||||
{"x,,sch", "-90", "10feffff01a6", "00", ""},
|
||||
{"x,,sch", "0", "10feffff0100", "00", ""},
|
||||
{"x,,sch", "-1", "10feffff01ff", "00", ""},
|
||||
{"x,,sch", "-", "10feffff0180", "00", ""},
|
||||
{"x,,sch", "-127", "10feffff0181", "00", ""},
|
||||
{"x,,sch", "127", "10feffff017f", "00", ""},
|
||||
{"x,,d1b", "-90", "10feffff01a6", "00", ""},
|
||||
{"x,,d1b", "0", "10feffff0100", "00", ""},
|
||||
{"x,,d1b", "-1", "10feffff01ff", "00", ""},
|
||||
{"x,,d1b", "-", "10feffff0180", "00", ""},
|
||||
{"x,,d1b", "-127", "10feffff0181", "00", ""},
|
||||
{"x,,d1b", "127", "10feffff017f", "00", ""},
|
||||
{"x,,d1c", "19.5", "10feffff0127", "00", ""},
|
||||
{"x,,d1c", "0.0", "10feffff0100", "00", ""},
|
||||
{"x,,d1c", "100.0", "10feffff01c8", "00", ""},
|
||||
{"x,,d1c", "-", "10feffff01ff", "00", ""},
|
||||
{"x,,uin", "38", "10feffff022600", "00", ""},
|
||||
{"x,,uin", "0", "10feffff020000", "00", ""},
|
||||
{"x,,uin", "65534", "10feffff02feff", "00", ""},
|
||||
{"x,,uin", "-", "10feffff02ffff", "00", ""},
|
||||
{"x,,sin", "-90", "10feffff02a6ff", "00", ""},
|
||||
{"x,,sin", "0", "10feffff020000", "00", ""},
|
||||
{"x,,sin", "-1", "10feffff02ffff", "00", ""},
|
||||
{"x,,sin", "-", "10feffff020080", "00", ""},
|
||||
{"x,,sin", "-32767", "10feffff020180", "00", ""},
|
||||
{"x,,sin", "32767", "10feffff02ff7f", "00", ""},
|
||||
{"x,,flt", "-0.090", "10feffff02a6ff", "00", ""},
|
||||
{"x,,flt", "0.000", "10feffff020000", "00", ""},
|
||||
{"x,,flt", "-0.001", "10feffff02ffff", "00", ""},
|
||||
{"x,,flt", "-", "10feffff020080", "00", ""},
|
||||
{"x,,flt","-32.767", "10feffff020180", "00", ""},
|
||||
{"x,,flt", "32.767", "10feffff02ff7f", "00", ""},
|
||||
{"x,,d2b", "18.004", "10fe0700090112", "00", ""},
|
||||
{"x,,d2b", "0.000", "10feffff020000", "00", ""},
|
||||
{"x,,d2b", "-0.004", "10feffff02ffff", "00", ""},
|
||||
{"x,,d2b", "-", "10feffff020080", "00", ""},
|
||||
{"x,,d2b","-127.996","10feffff020180", "00", ""},
|
||||
{"x,,d2b", "127.996","10feffff02ff7f", "00", ""},
|
||||
{"x,,d2c", "288.06", "10fe0700090112", "00", ""},
|
||||
{"x,,d2c", "0.00", "10feffff020000", "00", ""},
|
||||
{"x,,d2c", "-0.06", "10feffff02ffff", "00", ""},
|
||||
{"x,,d2c", "-", "10feffff020080", "00", ""},
|
||||
{"x,,d2c","-2047.94","10feffff020180", "00", ""},
|
||||
{"x,,d2c", "2047.94","10feffff02ff7f", "00", ""},
|
||||
{"x,,ulg", "38", "10feffff0426000000", "00", ""},
|
||||
{"x,,ulg", "0", "10feffff0400000000", "00", ""},
|
||||
{"x,,ulg", "4294967294", "10feffff04feffffff", "00", ""},
|
||||
{"x,,ulg", "-", "10feffff04ffffffff", "00", ""},
|
||||
{"x,,slg", "-90", "10feffff04a6ffffff", "00", ""},
|
||||
{"x,,slg", "0", "10feffff0400000000", "00", ""},
|
||||
{"x,,slg", "-1", "10feffff04ffffffff", "00", ""},
|
||||
{"x,,bi3", "1", "10feffff0108", "00", ""},
|
||||
{"x,,bi3", "-", "10feffff0100", "00", ""},
|
||||
{"x,,bi3,0=off;1=on","on", "10feffff0108", "00", ""},
|
||||
{"x,,bi3,0=off;1=on","off","10feffff0100", "00", ""},
|
||||
{"x,,bi3:2", "1", "10feffff0108", "00", ""},
|
||||
{"x,,bi3:2", "1", "10feffff01ef", "00", "W"},
|
||||
{"x,,bi3:2", "-", "10feffff0100", "00", ""},
|
||||
{"x,,bi3:2", "3", "10feffff0118", "00", ""},
|
||||
{"x,,bi3:2,1=on","on", "10feffff0108", "00", ""},
|
||||
{"x,,bi3:2,1=on","-", "10feffff0100", "00", ""},
|
||||
{"x,,bi3:2,0=off;1=on;2=auto;3=eco","auto", "10feffff0110", "00", ""},
|
||||
{"x,,bi3:2,0=off;1=on","on", "10feffff0108", "00", ""},
|
||||
{"x,,bi3:2,0=off;1=on","off","10feffff0100", "00", ""},
|
||||
{"x,,uch,1=test;2=high;3=off;4=on","on","10feffff0104", "00", ""},
|
||||
{"x,s,uch","3","1050ffff00", "0103", ""},
|
||||
{"x,,d2b,,°C,Aussentemperatur","x=18.004 °C [Aussentemperatur]","10fe0700090112", "00", "v"},
|
||||
{"x,,bti,,,,y,,bda,,,,z,,bdy", "21:04:58;26.10.2014;Sun","10fe0700085804212610061406", "00", ""}, // combination
|
||||
{"x,,bi3,,,,y,,bi5", "1;-", "10feffff0108", "00", ""}, // bit combination
|
||||
{"x,,bi3,,,,y,,bi5", "1;1", "10feffff0128", "00", ""}, // bit combination
|
||||
{"x,,bi3,,,,y,,bi5", "-;1", "10feffff0120", "00", ""}, // bit combination
|
||||
{"x,,bi3,,,,y,,bi5", "-;-", "10feffff0100", "00", ""}, // bit combination
|
||||
{"x,,bi3,,,,y,,bi7,,,,t,,uch", "-;-;9","10feffff020009", "00", ""}, // bit combination
|
||||
{"x,,bi6:2,,,,y,,bi0:2,,,,t,,uch", "2;1;9","10feffff03800109", "00", ""}, // bit combination
|
||||
{"temp,,d2b,,°C,Aussentemperatur","","", "", "t"}, // template with relative pos
|
||||
{"x,,temp","18.004","10fe0700020112", "00", ""}, // reference to template
|
||||
{"relrel,,d2b,,,,y,,d1c","","", "", "t"}, // template struct with relative pos
|
||||
{"x,,relrel","18.004;9.5","10fe070003011213", "00", ""}, // reference to template struct
|
||||
{"trelrel,,temp;temp","","", "", "t"}, // template struct with relative pos and ref to templates
|
||||
{"x,,trelrel","18.004;19.008","10fe07000401120213", "00", ""}, // reference to template struct
|
||||
{"x,,temp,,,,y,,d1c","18.004;9.5","10fe070003011213", "00", ""}, // reference to template, normal def
|
||||
};
|
||||
DataFieldTemplates* templates = new DataFieldTemplates();
|
||||
DataField* fields = NULL;
|
||||
@@ -204,7 +204,7 @@ int main()
|
||||
string item;
|
||||
vector<string> entries;
|
||||
|
||||
while (getline(isstr, item, ';') != 0)
|
||||
while (getline(isstr, item, FIELD_SEPARATOR) != 0)
|
||||
entries.push_back(item);
|
||||
|
||||
if (fields != NULL) {
|
||||
|
||||
@@ -47,14 +47,14 @@ int main()
|
||||
// field= name;[pos];type[;[divisor|values][;[unit][;[comment]]]]
|
||||
string checks[][5] = {
|
||||
// "message", "flags"
|
||||
{"u;;first;;;fe;0700;;x;;bda", "26.10.2014", "fffe07000426100614", "00", "p"},
|
||||
{"w;;first;;;15;b509;0400;date;;bda", "26.10.2014", "ff15b50906040026100614", "00", "m"},
|
||||
{"r;ehp;time;;;08;b509;0d2800;;;time", "15:00:17", "ff08b509030d2800", "0311000f", "m"},
|
||||
{"r;ehp;date;;;08;b509;0d2900;;;hda:3", "23.11.2014", "ff08b509030d2900", "03170b0e", "m"},
|
||||
{"u;ehp;ActualEnvironmentPower;Energiebezug;;08;B509;29BA00;;s;IGN:2;;;;;s;power", "8", "1008b5090329ba00", "03ba0008", "pm"},
|
||||
{"uw;ehp;test;Test;;08;B5de;ab;;;power;;;;;s;hex:1", "8;39", "1008b5de02ab08", "0139", "pm"},
|
||||
{"u,,first,,,fe,0700,,x,,bda", "26.10.2014", "fffe07000426100614", "00", "p"},
|
||||
{"w,,first,,,15,b509,0400,date,,bda", "26.10.2014", "ff15b50906040026100614", "00", "m"},
|
||||
{"r,ehp,time,,,08,b509,0d2800,,,time", "15:00:17", "ff08b509030d2800", "0311000f", "m"},
|
||||
{"r,ehp,date,,,08,b509,0d2900,,,hda:3", "23.11.2014", "ff08b509030d2900", "03170b0e", "m"},
|
||||
{"u,ehp,ActualEnvironmentPower,Energiebezug,,08,B509,29BA00,,s,IGN:2,,,,,s,power", "8", "1008b5090329ba00", "03ba0008", "pm"},
|
||||
{"uw,ehp,test,Test,,08,B5de,ab,,,power,,,,,s,hex:1", "8;39", "1008b5de02ab08", "0139", "pm"},
|
||||
{"","55.50;ok","1025b50903290000","050000780300",""},
|
||||
{"","no;25","10feb505042700190023","",""},
|
||||
//{"","no;25","10feb505042700190023","",""},
|
||||
};
|
||||
DataFieldTemplates* templates = new DataFieldTemplates();
|
||||
result_t result = templates->readFromFile("_types.csv");
|
||||
@@ -64,7 +64,7 @@ int main()
|
||||
cout << "read templates error: " << getResultCode(result) << endl;
|
||||
|
||||
MessageMap* messages = new MessageMap();
|
||||
result = messages->readFromFile("neu-ehp00.csv", templates);
|
||||
result = messages->readFromFile("ehp00.csv", templates);
|
||||
if (result == RESULT_OK)
|
||||
cout << "read messages OK" << endl;
|
||||
else
|
||||
@@ -86,7 +86,7 @@ int main()
|
||||
string item;
|
||||
vector<string> entries;
|
||||
|
||||
while (getline(isstr, item, ';') != 0)
|
||||
while (getline(isstr, item, FIELD_SEPARATOR) != 0)
|
||||
entries.push_back(item);
|
||||
|
||||
if (deleteMessage != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user