code style

This commit is contained in:
john30
2017-01-14 15:02:10 +01:00
parent b3bb2e08ac
commit 54a6c0f673
32 changed files with 484 additions and 665 deletions
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIB_EBUS_CONTRIB_H_
#define LIB_EBUS_CONTRIB_H_
#ifndef LIB_EBUS_CONTRIB_CONTRIB_H_
#define LIB_EBUS_CONTRIB_CONTRIB_H_
/** @file contrib.h
* Contributed sources that may be excluded from regular builds.
@@ -32,4 +32,4 @@ using namespace std;
*/
bool libebus_contrib_register();
#endif // LIB_EBUS_CONTRIB_H_
#endif // LIB_EBUS_CONTRIB_CONTRIB_H_
+2 -5
View File
@@ -40,10 +40,8 @@ using namespace std;
* A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave
* data.
*/
class TemParamDataType : public NumberDataType
{
public:
class TemParamDataType : public NumberDataType {
public:
/**
* Constructs a new instance.
* @param id the type identifier.
@@ -63,7 +61,6 @@ public:
virtual result_t writeSymbols(istringstream& input,
const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
};
/**
+3 -6
View File
@@ -340,8 +340,7 @@ result_t SingleDataField::read(const PartType partType,
if (partType != m_partType) {
return RESULT_EMPTY;
}
switch (m_partType)
{
switch (m_partType) {
case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break;
@@ -368,8 +367,7 @@ result_t SingleDataField::read(const PartType partType,
if (partType != m_partType) {
return RESULT_OK;
}
switch (m_partType)
{
switch (m_partType) {
case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break;
@@ -435,8 +433,7 @@ result_t SingleDataField::write(istringstream& input,
if (partType != m_partType) {
return RESULT_OK;
}
switch (m_partType)
{
switch (m_partType) {
case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break;
+21 -42
View File
@@ -53,10 +53,8 @@ class SingleDataField;
/**
* Base class for all kinds of data fields.
*/
class DataField
{
public:
class DataField {
public:
/**
* Constructs a new instance.
* @param name the field name.
@@ -205,24 +203,21 @@ public:
const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL) = 0;
protected:
protected:
/** the field name. */
const string m_name;
/** the field comment. */
const string m_comment;
};
/**
* A single @a DataField holding a value.
*/
class SingleDataField : public DataField
{
public:
class SingleDataField : public DataField {
public:
/**
* Constructs a new instance.
* @param name the field name.
@@ -325,8 +320,8 @@ public:
const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL);
protected:
protected:
/**
* Internal method for reading the field from a @a SymbolString.
* @param input the unescaped @a SymbolString to read the binary value from.
@@ -353,8 +348,6 @@ protected:
const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
protected:
/** the value unit. */
const string m_unit;
@@ -366,17 +359,14 @@ protected:
/** the number of symbols in the message part in which the field is stored. */
const unsigned char m_length;
};
/**
* A numeric data field with a list of value=text assignments and a string representation.
*/
class ValueListDataField : public SingleDataField
{
public:
class ValueListDataField : public SingleDataField {
public:
/**
* Constructs a new instance.
* @param name the field name.
@@ -410,8 +400,8 @@ public:
// @copydoc
virtual void dump(ostream& output);
protected:
protected:
// @copydoc
virtual result_t readSymbols(SymbolString& input, const bool isMaster,
const unsigned char offset,
@@ -422,21 +412,18 @@ protected:
const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the value=text assignments. */
map<unsigned int, string> m_values;
};
/**
* A data field with a constant value.
*/
class ConstantDataField : public SingleDataField
{
public:
class ConstantDataField : public SingleDataField {
public:
/**
* Constructs a new instance.
* @param name the field name.
@@ -471,8 +458,8 @@ public:
// @copydoc
virtual void dump(ostream& output);
protected:
protected:
// @copydoc
virtual result_t readSymbols(SymbolString& input, const bool isMaster,
const unsigned char offset,
@@ -483,24 +470,21 @@ protected:
const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the constant value. */
const string m_value;
/** whether to verify the read value against the constant value. */
const bool m_verify;
};
/**
* A set of @a DataField instances.
*/
class DataFieldSet : public DataField
{
public:
class DataFieldSet : public DataField {
public:
/**
* Get the @a DataFieldSet for parsing the identification message (service 0x07 0x04).
* @return the @a DataFieldSet for parsing the identification message. This is:<ul>
@@ -522,8 +506,7 @@ public:
DataFieldSet(const string name, const string comment,
const vector<SingleDataField*> fields)
: DataField(name, comment),
m_fields(fields)
{
m_fields(fields) {
bool uniqueNames = true;
map<string, string> names;
for (vector<SingleDataField*>::const_iterator it = fields.begin(); it != fields.end(); it++) {
@@ -603,8 +586,8 @@ public:
const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL);
private:
private:
/** the @a DataFieldSet containing the ident message @a SingleDataField instances, or NULL. */
static DataFieldSet* s_identFields;
@@ -613,17 +596,14 @@ private:
/** whether all fields have a unique name. */
bool m_uniqueNames;
};
/**
* A map of template @a DataField instances.
*/
class DataFieldTemplates : public FileReader
{
public:
class DataFieldTemplates : public FileReader {
public:
/**
* Constructs a new instance.
*/
@@ -670,11 +650,10 @@ public:
*/
DataField* get(string name);
private:
private:
/** the known template @a DataField instances by name. */
map<string, DataField*> m_fieldsByName;
};
#endif // LIB_EBUS_DATA_H_
+5 -9
View File
@@ -123,8 +123,7 @@ void printErrorPos(ostream& out, vector<string>::iterator begin, const vector<st
}
bool DataType::dump(ostream& output, const unsigned char length) const
{
bool DataType::dump(ostream& output, const unsigned char length) const {
output << m_id;
if (isAdjustableLength()) {
if (length == REMAIN_LEN) {
@@ -312,8 +311,7 @@ result_t DateTimeDataType::readSymbols(SymbolString& input, const bool isMaster,
}
ch = (unsigned char)((ch >> 4) * 10 + (ch & 0x0f));
}
switch (type)
{
switch (type) {
case 2: // date only
if (!hasFlag(REQ) && ch == m_replacement) {
if (i + 1 != length) {
@@ -440,10 +438,9 @@ result_t DateTimeDataType::writeSymbols(istringstream& input,
size_t i = 0, offset;
int type = (m_hasDate?2:0) | (m_hasTime?1:0);
bool skip = false;
for (offset = start; i < count; offset += skip?0:incr, i++) {
for (offset = start; i < count; offset += skip ? 0 : incr, i++) {
skip = false;
switch (type)
{
switch (type) {
case 2: // date only
if (length == 4 && i == 2) {
continue; // skip weekday in between
@@ -584,8 +581,7 @@ unsigned char NumberDataType::calcPrecision(const int divisor) {
return precision;
}
bool NumberDataType::dump(ostream& output, unsigned char length) const
{
bool NumberDataType::dump(ostream& output, unsigned char length) const {
if (m_bitCount < 8) {
DataType::dump(output, m_bitCount);
} else {
+15 -30
View File
@@ -146,10 +146,8 @@ void printErrorPos(ostream& out, vector<string>::iterator begin, const vector<st
/**
* Base class for all kinds of data types.
*/
class DataType
{
public:
class DataType {
public:
/**
* Constructs a new instance.
* @param id the type identifier.
@@ -251,8 +249,8 @@ public:
const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength) = 0;
protected:
protected:
/** the type identifier. */
const string m_id;
@@ -264,17 +262,14 @@ protected:
/** the replacement value (fill-up value for @a StringDataType, no replacement if equal to @a NumberDataType#minValue). */
const unsigned int m_replacement;
};
/**
* A string based @a DataType.
*/
class StringDataType : public DataType
{
public:
class StringDataType : public DataType {
public:
/**
* Constructs a new instance.
* @param id the type identifier.
@@ -307,21 +302,18 @@ public:
const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** true for hex digits instead of characters. */
const bool m_isHex;
};
/**
* A date/time based @a DataType.
*/
class DateTimeDataType : public DataType
{
public:
class DateTimeDataType : public DataType {
public:
/**
* Constructs a new instance.
* @param id the type identifier.
@@ -371,8 +363,8 @@ public:
const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** true if date part is present. */
const bool m_hasDate;
@@ -381,17 +373,14 @@ private:
/** the resolution in minutes for time types, or 1. */
const short m_resolution;
};
/**
* A number based @a DataType.
*/
class NumberDataType : public DataType
{
public:
class NumberDataType : public DataType {
public:
/**
* Constructs a new instance for multiple of 8 bits.
* @param id the type identifier.
@@ -501,8 +490,8 @@ public:
const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the minimum raw value. */
const unsigned int m_minValue;
@@ -520,17 +509,14 @@ private:
/** the base @a NumberDataType for derived instances. */
NumberDataType* m_baseType;
};
/**
* A map of base @a DataType instances.
*/
class DataTypeList
{
public:
class DataTypeList {
public:
/**
* Constructs a new instance and registers the known base data types.
*/
@@ -577,8 +563,8 @@ public:
*/
DataType* get(const string id, const unsigned char length = 0);
private:
private:
/** the known @a DataType instances by ID only. */
map<string, DataType*> m_typesById;
@@ -596,7 +582,6 @@ private:
/** true when contributed datatypes were successfully initialized. */
static bool s_contrib_initialized;
#endif
};
#endif // LIB_EBUS_DATATYPE_H_
+3 -2
View File
@@ -258,7 +258,7 @@ result_t NetworkDevice::open() {
value = 1;
setsockopt(m_fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&value, sizeof(value));
}
if (ret == 0) {
if (ret == 0) {
ret = connect(m_fd, (struct sockaddr*)&m_address, sizeof(m_address));
}
if (ret < 0) {
@@ -269,7 +269,8 @@ result_t NetworkDevice::open() {
if (ioctl(m_fd, FIONREAD, &cnt) >= 0 && cnt > 1) {
// skip buffered input
unsigned char buf[256];
while (::read(m_fd, &buf, 256) > 0);
while (::read(m_fd, &buf, 256) > 0) {
}
}
if (m_bufSize == 0) {
m_bufSize = MAX_LEN+1;
+19 -25
View File
@@ -41,10 +41,8 @@ using namespace std;
/**
* Interface for listening to data received on/sent to a device.
*/
class DeviceListener
{
public:
class DeviceListener {
public:
/**
* Destructor.
*/
@@ -56,17 +54,14 @@ public:
* @param received @a true on reception, @a false on sending.
*/
virtual void notifyDeviceData(const unsigned char byte, bool received) = 0; // abstract
};
/**
* The base class for accessing an eBUS.
*/
class Device
{
public:
class Device {
public:
/**
* Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network).
@@ -150,7 +145,8 @@ public:
*/
void setListener(DeviceListener* listener) { m_listener = listener; }
protected:
protected:
/**
* Check if the device is still available and close it if not.
*/
@@ -176,7 +172,6 @@ protected:
*/
virtual ssize_t read(unsigned char& value) { return ::read(m_fd, &value, 1); }
protected:
/** the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). */
const char* m_name;
@@ -192,19 +187,17 @@ protected:
/** the opened file descriptor, or -1. */
int m_fd;
private:
private:
/** the @a DeviceListener, or NULL. */
DeviceListener* m_listener;
};
/**
* The @a Device for directly connected serial interfaces (tty).
*/
class SerialDevice : public Device
{
public:
class SerialDevice : public Device {
public:
/**
* Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network).
@@ -221,22 +214,22 @@ public:
// @copydoc
virtual void close();
protected:
protected:
// @copydoc
virtual void checkDevice();
private:
private:
/** the previous settings of the device for restoring. */
termios m_oldSettings;
};
/**
* The @a Device for remote network interfaces.
*/
class NetworkDevice : public Device
{
public:
class NetworkDevice : public Device {
public:
/**
* Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network).
@@ -256,7 +249,8 @@ public:
// @copydoc
virtual result_t open();
protected:
protected:
// @copydoc
virtual void checkDevice();
@@ -269,7 +263,8 @@ protected:
// @copydoc
virtual ssize_t read(unsigned char& value);
private:
private:
/** the socket address of the device. */
const struct sockaddr_in m_address;
@@ -287,7 +282,6 @@ private:
/** the buffer read position. */
unsigned char m_bufPos;
};
#endif // LIB_EBUS_DEVICE_H_
+11 -21
View File
@@ -60,10 +60,8 @@ extern unsigned int parseInt(const char* str, int base, const unsigned int minVa
/**
* An abstract class that support reading definitions from a file.
*/
class FileReader
{
public:
class FileReader {
public:
/**
* Construct a new instance.
*/
@@ -85,8 +83,7 @@ public:
* @return @a RESULT_OK on success, or an error code.
*/
virtual result_t readFromFile(const string filename, bool verbose = false,
string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "")
{
string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "") {
ifstream ifs;
ifs.open(filename.c_str(), ifstream::in);
if (!ifs.is_open()) {
@@ -177,8 +174,7 @@ public:
*/
virtual result_t addDefaultFromFile(vector< vector<string> >& defaults, vector<string>& row,
vector<string>::iterator& begin, string defaultDest, string defaultCircuit, string defaultSuffix,
const string& filename, unsigned int lineNo)
{
const string& filename, unsigned int lineNo) {
defaults.push_back(row);
begin = row.end();
return RESULT_OK;
@@ -204,8 +200,7 @@ public:
* Left and right trim the string.
* @param str the @a string to trim.
*/
static void trim(string& str)
{
static void trim(string& str) {
size_t pos = str.find_first_not_of(" \t");
if (pos != string::npos) {
str.erase(0, pos);
@@ -220,8 +215,7 @@ public:
* Convert all upper case characters in the string to lower case.
* @param str the @a string to convert.
*/
static void tolower(string& str)
{
static void tolower(string& str) {
transform(str.begin(), str.end(), str.begin(), ::tolower);
}
@@ -232,8 +226,7 @@ public:
* @param lineNo the current line number (incremented with each line read).
* @return true if there are more lines to read, false when there are no more lines left.
*/
static bool splitFields(istream& ifs, vector<string>& row, unsigned int& lineNo)
{
static bool splitFields(istream& ifs, vector<string>& row, unsigned int& lineNo) {
row.clear();
string line;
bool quotedText = false, wasQuoted = false;
@@ -251,8 +244,7 @@ public:
}
for (size_t pos = 0; pos < length; pos++) {
char ch = line[pos];
switch (ch)
{
switch (ch) {
case FIELD_SEPARATOR:
if (quotedText) {
field << ch;
@@ -317,8 +309,7 @@ public:
* @return true if at least the address and the identification part were extracted, false otherwise.
*/
static bool extractDefaultsFromFilename(string name, unsigned char& dest, string& ident, string& circuit,
string& suffix, unsigned int& software, unsigned int& hardware)
{
string& suffix, unsigned int& software, unsigned int& hardware) {
ident = circuit = suffix = "";
software = hardware = UINT_MAX;
if (name.length() > 4 && name.substr(name.length()-4) == ".csv") {
@@ -374,16 +365,15 @@ public:
return true;
}
private:
private:
/** whether this instance supports rows with defaults (starting with a star). */
bool m_supportsDefaults;
protected:
protected:
/** a @a string describing the last error position. */
string m_lastError;
};
#endif // LIB_EBUS_FILEREADER_H_
+2 -3
View File
@@ -834,8 +834,7 @@ ChainedMessage::ChainedMessage(const string circuit, const string name,
srcAddress, dstAddress, id,
data, deleteData, pollPriority, condition),
m_ids(ids), m_lengths(lengths),
m_maxTimeDiff(m_ids.size()*15) // 15 seconds per message
{
m_maxTimeDiff(m_ids.size()*15) { // 15 seconds per message
size_t cnt = ids.size();
m_lastMasterDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*));
m_lastSlaveDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*));
@@ -1334,7 +1333,7 @@ result_t SimpleCondition::resolve(MessageMap* messages, ostringstream& errorMess
} else {
Message* first = getFirstAvailable(*derived, message);
if (first == NULL) {
errorMessage << ": conditional derived message " << message->getCircuit() << "." << message->getName() << " for " << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_dstAddress) << " not found" ;
errorMessage << ": conditional derived message " << message->getCircuit() << "." << message->getName() << " for " << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_dstAddress) << " not found";
return RESULT_ERR_INVALID_ARG;
}
message = first;
+50 -81
View File
@@ -93,11 +93,9 @@ class MessageMap;
/**
* Defines parameters of a message sent or received on the bus.
*/
class Message
{
class Message {
friend class MessageMap;
public:
public:
/**
* Construct a new instance.
* @param circuit the optional circuit name.
@@ -122,7 +120,8 @@ public:
const unsigned char pollPriority = 0,
Condition* condition = NULL);
private:
private:
/**
* Construct a new scan @a Message instance.
* @param circuit the circuit name, or empty for not storing by name.
@@ -140,7 +139,8 @@ private:
const unsigned char pb, const unsigned char sb,
DataField* data, const bool deleteData);
public:
public:
/**
* Destructor.
*/
@@ -394,8 +394,8 @@ public:
istringstream& input, char separator = UI_FIELD_SEPARATOR,
const unsigned char dstAddress = SYN, unsigned char index = 0);
protected:
protected:
/**
* Prepare a part of the master data @a SymbolString for sending (everything including NN).
* @param master the master data @a SymbolString for writing symbols to.
@@ -406,8 +406,8 @@ protected:
*/
virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index);
public:
public:
/**
* Prepare the slave @a SymbolString for sending an answer to the bus.
* @param input the @a istringstream to parse the formatted value(s) from.
@@ -521,8 +521,8 @@ public:
*/
virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false);
protected:
protected:
/** the optional circuit name. */
const string m_circuit;
@@ -606,17 +606,14 @@ protected:
/** the system time when this message was last polled for, 0 for never. */
time_t m_lastPollTime;
};
/**
* A chained @a Message that needs more than one read/write on the bus to collect/send the data.
*/
class ChainedMessage : public Message
{
public:
class ChainedMessage : public Message {
public:
/**
* Construct a new instance.
* @param circuit the optional circuit name.
@@ -659,26 +656,26 @@ public:
// @copydoc
virtual unsigned char getCount() { return (unsigned char)m_ids.size(); }
protected:
protected:
// @copydoc
virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index);
public:
public:
// @copydoc
virtual result_t storeLastData(SymbolString& master, SymbolString& slave);
// @copydoc
virtual result_t storeLastData(const PartType partType, SymbolString& data, unsigned char index);
protected:
protected:
// @copydoc
virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false);
private:
private:
/** the primary, secondary, and optional further ID bytes for each part of the chain. */
const vector< vector<unsigned char> > m_ids;
@@ -699,21 +696,20 @@ private:
/** array of the system times when the corresponding slave data was last updated, 0 for never. */
time_t* m_lastSlaveUpdateTimes;
};
/**
* A function that compares the weighted poll priority of two @a Message instances.
*/
struct compareMessagePriority : binary_function <Message*,Message*,bool> {
struct compareMessagePriority : binary_function <Message*, Message*, bool> {
/**
* Compare the weighted poll priority of the two @a Message instances.
* @param x the first @a Message.
* @param y the second @a Message.
* @return whether @a x is smaller than @a y with regard to their weighted poll priority.
*/
bool operator() (Message* x, Message* y) const { return x->isLessPollWeight(y); };
bool operator() (Message* x, Message* y) const { return x->isLessPollWeight(y); }
};
@@ -721,15 +717,13 @@ struct compareMessagePriority : binary_function <Message*,Message*,bool> {
* Helper class extending @a priority_queue to hold distinct values only.
*/
class MessagePriorityQueue
: public priority_queue<Message*, vector<Message*>, compareMessagePriority>
{
public:
: public priority_queue<Message*, vector<Message*>, compareMessagePriority> {
public:
/**
* Add data to the queue and ensure it is contained only once.
* @param __x the element to add.
*/
void push(const value_type& __x)
{
void push(const value_type& __x) {
for (vector<Message*>::iterator it = c.begin(); it != c.end(); it++) {
if (*it == __x) {
c.erase(it);
@@ -744,10 +738,8 @@ public:
/**
* An abstract condition based on the value of one or more @a Message instances.
*/
class Condition
{
public:
class Condition {
public:
/**
* Construct a new instance.
*/
@@ -776,7 +768,7 @@ public:
* @param valueList the @a string with the new list of values.
* @return the derived @a SimpleCondition instance, or NULL if the value list is invalid.
*/
virtual SimpleCondition* derive(string valueList) { return NULL; };
virtual SimpleCondition* derive(string valueList) { return NULL; }
/**
* Write the condition definition or resolved expression to the @a ostream.
@@ -807,24 +799,21 @@ public:
*/
virtual bool isTrue() = 0;
protected:
protected:
/** the system time when the condition was last checked, 0 for never. */
time_t m_lastCheckTime;
/** whether the condition was @a true during the last check. */
bool m_isTrue;
};
/**
* A simple @a Condition based on the value of one @a Message.
*/
class SimpleCondition : public Condition
{
public:
class SimpleCondition : public Condition {
public:
/**
* Construct a new instance.
* @param condName the name of the condition.
@@ -865,8 +854,8 @@ public:
*/
virtual bool isNumeric() { return true; }
protected:
protected:
/**
* Check the values against the field in the @a Message.
* @param message the @a Message to check against.
@@ -878,8 +867,8 @@ protected:
/** the value that matched in @a checkValue. */
string m_matchedValue;
private:
private:
/** the condition name. */
const string m_condName;
@@ -903,17 +892,14 @@ private:
/** the resolved @a Message instance, or NULL. */
Message* m_message;
};
/**
* A simple @a Condition based on the numeric value of one @a Message.
*/
class SimpleNumericCondition : public SimpleCondition
{
public:
class SimpleNumericCondition : public SimpleCondition {
public:
/**
* Construct a new instance.
* @param condName the name of the condition.
@@ -933,26 +919,23 @@ public:
*/
virtual ~SimpleNumericCondition() {}
protected:
protected:
// @copydoc
virtual bool checkValue(Message* message, const string field);
private:
private:
/** the valid value ranges (pairs of from/to inclusive), empty for @a m_message seen check. */
const vector<unsigned int> m_valueRanges;
};
/**
* A simple @a Condition based on the string value of one @a Message.
*/
class SimpleStringCondition : public SimpleCondition
{
public:
class SimpleStringCondition : public SimpleCondition {
public:
/**
* Construct a new instance.
* @param condName the name of the condition.
@@ -975,26 +958,23 @@ public:
// @copydoc
virtual bool isNumeric() { return false; }
protected:
protected:
// @copydoc
virtual bool checkValue(Message* message, const string field);
private:
private:
/** the valid values. */
const vector<string> m_values;
};
/**
* A @a Condition combining two or more @a SimpleCondition instances with a logical and.
*/
class CombinedCondition : public Condition
{
public:
class CombinedCondition : public Condition {
public:
/**
* Construct a new instance.
*/
@@ -1018,21 +998,18 @@ public:
// @copydoc
virtual bool isTrue();
private:
private:
/** the @a Condition instances used. */
vector<Condition*> m_conditions;
};
/**
* An abstract instruction based on the value of one or more @a Message instances.
*/
class Instruction
{
public:
class Instruction {
public:
/**
* Construct a new instance.
* @param condition the @a Condition this instruction requires, or null.
@@ -1092,16 +1069,16 @@ public:
*/
virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition) = 0;
private:
private:
/** the @a Condition this instruction requires, or null. */
Condition* m_condition;
/** whether this @a Instruction belongs to a set of instructions of which only the first one may be executed for the same source file. */
bool m_singleton;
protected:
protected:
/** the default destination address, or empty. */
const string m_defaultDest;
@@ -1110,17 +1087,14 @@ protected:
/** the default circuit name suffix (starting with a "."), or empty. */
const string m_defaultSuffix;
};
/**
* An @a Instruction allowing to load another file.
*/
class LoadInstruction : public Instruction
{
public:
class LoadInstruction : public Instruction {
public:
/**
* Construct a new instance.
* @param condition the @a Condition this instruction requires, or null.
@@ -1141,28 +1115,24 @@ public:
// @copydoc
virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition);
private:
private:
/** the name of the file to load. */
const string m_filename;
};
/**
* Holds a map of all known @a Message instances.
*/
class MessageMap : public FileReader
{
public:
class MessageMap : public FileReader {
public:
/**
* Construct a new instance.
* @param addAll whether to add all messages, even if duplicate.
*/
MessageMap(const bool addAll = false) : FileReader::FileReader(true),
m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0)
{
m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0) {
m_scanMessage = Message::createScanMessage();
}
@@ -1368,8 +1338,8 @@ public:
*/
void dump(ostream& output, bool withConditions = false);
private:
private:
/** whether to add all messages, even if duplicate. */
const bool m_addAll;
@@ -1405,7 +1375,6 @@ private:
/** the list of @a Instruction instances by filename. */
map<string, vector<Instruction*> > m_instructions;
};
#endif // LIB_EBUS_MESSAGE_H_
+2 -4
View File
@@ -28,8 +28,7 @@ using namespace std;
/**
* CRC8 lookup table for the polynom 0x9b = x^8 + x^7 + x^4 + x^3 + x^1 + 1.
*/
static const unsigned char CRC_LOOKUP_TABLE[] =
{
static const unsigned char CRC_LOOKUP_TABLE[] = {
0x00, 0x9b, 0xad, 0x36, 0xc1, 0x5a, 0x6c, 0xf7, 0x19, 0x82, 0xb4, 0x2f, 0xd8, 0x43, 0x75, 0xee,
0x32, 0xa9, 0x9f, 0x04, 0xf3, 0x68, 0x5e, 0xc5, 0x2b, 0xb0, 0x86, 0x1d, 0xea, 0x71, 0x47, 0xdc,
0x64, 0xff, 0xc9, 0x52, 0xa5, 0x3e, 0x08, 0x93, 0x7d, 0xe6, 0xd0, 0x4b, 0xbc, 0x27, 0x11, 0x8a,
@@ -194,8 +193,7 @@ void SymbolString::addCRC(const unsigned char value) {
* @return the 1-based index of the upper or lower 4 bits of a master address (1 to 5), or 0.
*/
unsigned char getMasterPartIndex(unsigned char bits) {
switch (bits)
{
switch (bits) {
case 0x0:
return 1;
case 0x1:
+3 -5
View File
@@ -75,10 +75,8 @@ static const unsigned char BROADCAST = 0xFE; //!< the broadcast destination addr
/**
* A string of escaped or unescaped bus symbols.
*/
class SymbolString
{
public:
class SymbolString {
public:
/**
* Creates a new empty escaped or unescaped instance.
* @param escaped whether to create an escaped instance.
@@ -186,8 +184,8 @@ public:
*/
void clear(const bool escape) { m_data.clear(); m_unescapeState = escape ? 0 : 1; m_crc = 0; }
private:
private:
/**
* Hidden copy constructor.
* @param str the @a SymbolString to copy from.
+234 -234
View File
@@ -86,45 +86,45 @@ int main() {
{"x,,hex:5, == 48 61 6c 6c 6f", "", "10fe070005ababababab", "00", "rW"},
{"x,,hex:5,=48 61 6c 6c 6f", "", "10fe07000548616c6c6f", "00", ""},
{"x,,hex:5, == 48 61 6c 6c 6f", "", "10fe07000548616c6c6f", "00", ""},
{"x,,bda", "26.10.2014","10fe07000426100614", "00", ""}, // Sunday
{"x,,bda", "01.01.2000","10fe07000401010500", "00", ""}, // Saturday
{"x,,bda", "31.12.2099","10fe07000431120399", "00", ""}, // Thursday
{"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"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", "", "10fe070003321299", "00", "rw"},
{"x,,bda,2", "", "", "", "c"},
{"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", "", "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", "", "10fe070003200c63", "00", "rw"},
{"x,,hda,2", "", "", "", "c"},
{"x,,day", "26.10.2014","10fe070002d0a3", "00", ""},
{"x,,day", "01.01.2000","10fe070002ac8e", "00", ""},
{"x,,day", "31.12.2078","10fe07000262ff", "00", ""},
{"x,,day", "-.-.-", "10fe070002ffff", "00", ""},
{"x,,day", "", "10fe0700020000", "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", "-:-:-", "10fe070003ffffff", "00", ""},
{"x,,bti", "", "10fe070003605923", "00", "rw"},
{"x,,bti,2", "", "", "", "c"},
{"x,,hti", "21:04:58", "10fe07000315043a", "00", ""},
{"x,,hti", "-:-:-", "10fe070003ffffff", "00", ""},
{"x,,hti,2", "", "", "", "c"},
{"x,,vti", "21:04:58", "10fe0700033a0415", "00", ""},
{"x,,vti", "-:-:-", "10fe070003636363", "00", ""},
{"x,,vti,2", "", "", "", "c"},
{"x,,bda", "26.10.2014", "10fe07000426100614", "00", ""}, // Sunday
{"x,,bda", "01.01.2000", "10fe07000401010500", "00", ""}, // Saturday
{"x,,bda", "31.12.2099", "10fe07000431120399", "00", ""}, // Thursday
{"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"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", "", "10fe070003321299", "00", "rw"},
{"x,,bda,2", "", "", "", "c"},
{"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", "", "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", "", "10fe070003200c63", "00", "rw"},
{"x,,hda,2", "", "", "", "c"},
{"x,,day", "26.10.2014", "10fe070002d0a3", "00", ""},
{"x,,day", "01.01.2000", "10fe070002ac8e", "00", ""},
{"x,,day", "31.12.2078", "10fe07000262ff", "00", ""},
{"x,,day", "-.-.-", "10fe070002ffff", "00", ""},
{"x,,day", "", "10fe0700020000", "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", "-:-:-", "10fe070003ffffff", "00", ""},
{"x,,bti", "", "10fe070003605923", "00", "rw"},
{"x,,bti,2", "", "", "", "c"},
{"x,,hti", "21:04:58", "10fe07000315043a", "00", ""},
{"x,,hti", "-:-:-", "10fe070003ffffff", "00", ""},
{"x,,hti,2", "", "", "", "c"},
{"x,,vti", "21:04:58", "10fe0700033a0415", "00", ""},
{"x,,vti", "-:-:-", "10fe070003636363", "00", ""},
{"x,,vti,2", "", "", "", "c"},
{"x,,btm", "21:04", "10fe0700020421", "00", ""},
{"x,,btm", "00:00", "10fe0700020000", "00", ""},
{"x,,btm", "23:59", "10fe0700025923", "00", ""},
@@ -191,9 +191,9 @@ int main() {
{"x,,hdy", "Mon", "10fe07000101", "00", ""},
{"x,,hdy", "Sun", "10fe07000107", "00", ""},
{"x,,hdy", "8", "10fe07000108", "00", "w"},
{"x,,pin","1234", "10feffff021234", "00", ""},
{"x,,pin","0000", "10feffff020000", "00", ""},
{"x,,pin","9999", "10feffff029999", "00", ""},
{"x,,pin", "1234", "10feffff021234", "00", ""},
{"x,,pin", "0000", "10feffff020000", "00", ""},
{"x,,pin", "9999", "10feffff029999", "00", ""},
{"x,,pin", "", "10feffff020000", "00", "Rw"},
{"x,,pin", "100", "10feffff020100", "00", "R"},
{"x,,bcd", "26", "10feffff0126", "00", ""},
@@ -202,194 +202,194 @@ int main() {
{"x,,bcd", "100", "10feffff0199", "00", "Rw"},
{"x,,bcd", "-", "10feffff01ff", "00", ""},
{"x,,bcd", "", "10feffff019a", "00", "rw"},
{"x,,bcd:1","26", "10feffff0126", "00", ""},
{"x,,bcd:1","0", "10feffff0100", "00", ""},
{"x,,bcd:1","99", "10feffff0199", "00", ""},
{"x,,bcd:1","100", "10feffff0199", "00", "Rw"},
{"x,,bcd:1","-", "10feffff01ff", "00", ""},
{"x,,bcd:1","", "10feffff019a", "00", "rw"},
{"x,,bcd:2","126", "10feffff022601", "00", ""},
{"x,,bcd:2","0", "10feffff020000", "00", ""},
{"x,,bcd:2","9999", "10feffff029999", "00", ""},
{"x,,bcd:2","10000","10feffff029999", "00", "Rw"},
{"x,,bcd:2","-", "10feffff02ffff", "00", ""},
{"x,,bcd:2","", "10feffff029a00", "00", "rw"},
{"x,,bcd:3","12346", "10feffff03462301", "00", ""},
{"x,,bcd:3","0", "10feffff03000000", "00", ""},
{"x,,bcd:3","999999", "10feffff03999999", "00", ""},
{"x,,bcd:3","1000000","10feffff03999999", "00", "Rw"},
{"x,,bcd:3","-", "10feffff03ffffff", "00", ""},
{"x,,bcd:3","", "10feffff03009a00", "00", "rw"},
{"x,,bcd:4","1234567", "10feffff0467452301", "00", ""},
{"x,,bcd:4","0", "10feffff0400000000", "00", ""},
{"x,,bcd:4","99999999", "10feffff0499999999", "00", ""},
{"x,,bcd:4","100000000","10feffff0499999999", "00", "Rw"},
{"x,,bcd:4","-", "10feffff04ffffffff", "00", ""},
{"x,,bcd:4","", "10feffff0400009a00", "00", "rw"},
{"x,,hcd:1", "26", "10feffff011a", "00", ""},
{"x,,hcd:1", "0", "10feffff0100", "00", ""},
{"x,,hcd:1", "99", "10feffff0163", "00", ""},
{"x,,hcd:1", "100", "10feffff0163", "00", "Rw"},
{"x,,hcd:1", "", "10feffff019a", "00", "rw"},
{"x,,hcd:2", "126", "10feffff021a01", "00", ""},
{"x,,hcd:2", "0", "10feffff020000", "00", ""},
{"x,,hcd:2", "9999", "10feffff026363", "00", ""},
{"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"},
{"x,,hcd:2", "", "10feffff029a00", "00", "rw"},
{"x,,hcd:3","12346", "10feffff032e1701", "00", ""},
{"x,,hcd:3","0", "10feffff03000000", "00", ""},
{"x,,hcd:3","999999", "10feffff03636363", "00", ""},
{"x,,hcd:3","1000000", "10feffff03636363", "00", "Rw"},
{"x,,hcd:3","", "10feffff03009a00", "00", "rw"},
{"x,,hcd:4","1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd:4","0", "10feffff0400000000", "00", ""},
{"x,,hcd:4","99999999", "10feffff0463636363", "00", ""},
{"x,,hcd:4","100000000","10feffff0463636363", "00", "Rw"},
{"x,,hcd","", "10feffff0400006400", "00", "rw"},
{"x,,hcd","1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd","0", "10feffff0400000000", "00", ""},
{"x,,hcd","99999999", "10feffff0463636363", "00", ""},
{"x,,hcd","100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd","", "10feffff0400006400", "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", "38.5", "10feffff0126", "00", "R"},
{"x,,uch", "0", "10feffff0100", "00", ""},
{"x,,uch", "254", "10feffff01fe", "00", ""},
{"x,,uch", "-", "10feffff01ff", "00", ""},
{"x,,uch,10", "3.8", "10feffff0126", "00", ""},
{"x,,uch,-10", "380","10feffff0126", "00", ""},
{"x,,uch,=48", "", "10feffff01ab", "00", "W"},
{"x,,bcd:1", "26", "10feffff0126", "00", ""},
{"x,,bcd:1", "0", "10feffff0100", "00", ""},
{"x,,bcd:1", "99", "10feffff0199", "00", ""},
{"x,,bcd:1", "100", "10feffff0199", "00", "Rw"},
{"x,,bcd:1", "-", "10feffff01ff", "00", ""},
{"x,,bcd:1", "", "10feffff019a", "00", "rw"},
{"x,,bcd:2", "126", "10feffff022601", "00", ""},
{"x,,bcd:2", "0", "10feffff020000", "00", ""},
{"x,,bcd:2", "9999", "10feffff029999", "00", ""},
{"x,,bcd:2", "10000", "10feffff029999", "00", "Rw"},
{"x,,bcd:2", "-", "10feffff02ffff", "00", ""},
{"x,,bcd:2", "", "10feffff029a00", "00", "rw"},
{"x,,bcd:3", "12346", "10feffff03462301", "00", ""},
{"x,,bcd:3", "0", "10feffff03000000", "00", ""},
{"x,,bcd:3", "999999", "10feffff03999999", "00", ""},
{"x,,bcd:3", "1000000", "10feffff03999999", "00", "Rw"},
{"x,,bcd:3", "-", "10feffff03ffffff", "00", ""},
{"x,,bcd:3", "", "10feffff03009a00", "00", "rw"},
{"x,,bcd:4", "1234567", "10feffff0467452301", "00", ""},
{"x,,bcd:4", "0", "10feffff0400000000", "00", ""},
{"x,,bcd:4", "99999999", "10feffff0499999999", "00", ""},
{"x,,bcd:4", "100000000", "10feffff0499999999", "00", "Rw"},
{"x,,bcd:4", "-", "10feffff04ffffffff", "00", ""},
{"x,,bcd:4", "", "10feffff0400009a00", "00", "rw"},
{"x,,hcd:1", "26", "10feffff011a", "00", ""},
{"x,,hcd:1", "0", "10feffff0100", "00", ""},
{"x,,hcd:1", "99", "10feffff0163", "00", ""},
{"x,,hcd:1", "100", "10feffff0163", "00", "Rw"},
{"x,,hcd:1", "", "10feffff019a", "00", "rw"},
{"x,,hcd:2", "126", "10feffff021a01", "00", ""},
{"x,,hcd:2", "0", "10feffff020000", "00", ""},
{"x,,hcd:2", "9999", "10feffff026363", "00", ""},
{"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"},
{"x,,hcd:2", "", "10feffff029a00", "00", "rw"},
{"x,,hcd:3", "12346", "10feffff032e1701", "00", ""},
{"x,,hcd:3", "0", "10feffff03000000", "00", ""},
{"x,,hcd:3", "999999", "10feffff03636363", "00", ""},
{"x,,hcd:3", "1000000", "10feffff03636363", "00", "Rw"},
{"x,,hcd:3", "", "10feffff03009a00", "00", "rw"},
{"x,,hcd:4", "1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd:4", "0", "10feffff0400000000", "00", ""},
{"x,,hcd:4", "99999999", "10feffff0463636363", "00", ""},
{"x,,hcd:4", "100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd", "", "10feffff0400006400", "00", "rw"},
{"x,,hcd", "1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd", "0", "10feffff0400000000", "00", ""},
{"x,,hcd", "99999999", "10feffff0463636363", "00", ""},
{"x,,hcd", "100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd", "", "10feffff0400006400", "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", "38.5", "10feffff0126", "00", "R"},
{"x,,uch", "0", "10feffff0100", "00", ""},
{"x,,uch", "254", "10feffff01fe", "00", ""},
{"x,,uch", "-", "10feffff01ff", "00", ""},
{"x,,uch,10", "3.8", "10feffff0126", "00", ""},
{"x,,uch,-10", "380", "10feffff0126", "00", ""},
{"x,,uch,=48", "", "10feffff01ab", "00", "W"},
{"x,,uch, == 48", "", "10feffff01ab", "00", "rW"},
{"x,,uch,=48", "", "10feffff0130", "00", ""},
{"x,,uch,=48", "", "10feffff0130", "00", ""},
{"x,,uch, == 48", "", "10feffff0130", "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,,sch,10", "-9.0","10feffff01a6", "00", ""},
{"x,,sch,-10","-900","10feffff01a6", "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,,d1b,-10","-900","10feffff01a6", "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,,sch,10", "-9.0", "10feffff01a6", "00", ""},
{"x,,sch,-10", "-900", "10feffff01a6", "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,,d1b,-10", "-900", "10feffff01a6", "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,,uin,10", "3.8", "10feffff022600", "00", ""},
{"x,,uin,-10","380", "10feffff022600", "00", ""},
{"x,,uir", "38", "10feffff020026", "00", ""},
{"x,,uir", "0", "10feffff020000", "00", ""},
{"x,,uir", "65534", "10feffff02fffe", "00", ""},
{"x,,uir", "-", "10feffff02ffff", "00", ""},
{"x,,uir,10", "3.8", "10feffff020026", "00", ""},
{"x,,uir,-10","380", "10feffff020026", "00", ""},
{"uin10,uin,-10","", "", "", "t"}, // template
{"x,,uin10","380", "10feffff022600", "00", ""}, // template reference
{"x,,uin10,-10","3800","10feffff022600", "00", ""}, // template reference, valid divider product
{"x,,uin10,10","","", "", "c"}, // template reference, invalid divider product
{"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,,sin,10","-9.0", "10feffff02a6ff", "00", ""},
{"x,,sin,-10","-900","10feffff02a6ff", "00", ""},
{"x,,sir", "-90", "10feffff02ffa6", "00", ""},
{"x,,sir", "0", "10feffff020000", "00", ""},
{"x,,sir", "-1", "10feffff02ffff", "00", ""},
{"x,,sir", "-", "10feffff028000", "00", ""},
{"x,,sir", "-32767", "10feffff028001", "00", ""},
{"x,,sir", "32767", "10feffff027fff", "00", ""},
{"x,,sir,10","-9.0", "10feffff02ffa6", "00", ""},
{"x,,sir,-10","-900","10feffff02ffa6", "00", ""},
{"x,,u3n", "38", "10feffff03260000", "00", ""},
{"x,,u3n", "0", "10feffff03000000", "00", ""},
{"x,,uin", "38", "10feffff022600", "00", ""},
{"x,,uin", "0", "10feffff020000", "00", ""},
{"x,,uin", "65534", "10feffff02feff", "00", ""},
{"x,,uin", "-", "10feffff02ffff", "00", ""},
{"x,,uin,10", "3.8", "10feffff022600", "00", ""},
{"x,,uin,-10", "380", "10feffff022600", "00", ""},
{"x,,uir", "38", "10feffff020026", "00", ""},
{"x,,uir", "0", "10feffff020000", "00", ""},
{"x,,uir", "65534", "10feffff02fffe", "00", ""},
{"x,,uir", "-", "10feffff02ffff", "00", ""},
{"x,,uir,10", "3.8", "10feffff020026", "00", ""},
{"x,,uir,-10", "380", "10feffff020026", "00", ""},
{"uin10,uin,-10", "", "", "", "t"}, // template
{"x,,uin10", "380", "10feffff022600", "00", ""}, // template reference
{"x,,uin10,-10", "3800", "10feffff022600", "00", ""}, // template reference, valid divider product
{"x,,uin10,10", "", "", "", "c"}, // template reference, invalid divider product
{"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,,sin,10", "-9.0", "10feffff02a6ff", "00", ""},
{"x,,sin,-10", "-900", "10feffff02a6ff", "00", ""},
{"x,,sir", "-90", "10feffff02ffa6", "00", ""},
{"x,,sir", "0", "10feffff020000", "00", ""},
{"x,,sir", "-1", "10feffff02ffff", "00", ""},
{"x,,sir", "-", "10feffff028000", "00", ""},
{"x,,sir", "-32767", "10feffff028001", "00", ""},
{"x,,sir", "32767", "10feffff027fff", "00", ""},
{"x,,sir,10", "-9.0", "10feffff02ffa6", "00", ""},
{"x,,sir,-10", "-900", "10feffff02ffa6", "00", ""},
{"x,,u3n", "38", "10feffff03260000", "00", ""},
{"x,,u3n", "0", "10feffff03000000", "00", ""},
{"x,,u3n", "16777214", "10feffff03feffff", "00", ""},
{"x,,u3n", "-", "10feffff03ffffff", "00", ""},
{"x,,u3n,10", "3.8", "10feffff03260000", "00", ""},
{"x,,u3n,-10","380", "10feffff03260000", "00", ""},
{"x,,u3r", "38", "10feffff03000026", "00", ""},
{"x,,u3r", "0", "10feffff03000000", "00", ""},
{"x,,u3n", "-", "10feffff03ffffff", "00", ""},
{"x,,u3n,10", "3.8", "10feffff03260000", "00", ""},
{"x,,u3n,-10", "380", "10feffff03260000", "00", ""},
{"x,,u3r", "38", "10feffff03000026", "00", ""},
{"x,,u3r", "0", "10feffff03000000", "00", ""},
{"x,,u3r", "16777214", "10feffff03fffffe", "00", ""},
{"x,,u3r", "-", "10feffff03ffffff", "00", ""},
{"x,,u3r,10", "3.8", "10feffff03000026", "00", ""},
{"x,,u3r,-10","380", "10feffff03000026", "00", ""},
{"x,,s3n", "-90", "10feffff03a6ffff", "00", ""},
{"x,,s3n", "0", "10feffff03000000", "00", ""},
{"x,,s3n", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3n", "-", "10feffff03000080", "00", ""},
{"x,,u3r", "-", "10feffff03ffffff", "00", ""},
{"x,,u3r,10", "3.8", "10feffff03000026", "00", ""},
{"x,,u3r,-10", "380", "10feffff03000026", "00", ""},
{"x,,s3n", "-90", "10feffff03a6ffff", "00", ""},
{"x,,s3n", "0", "10feffff03000000", "00", ""},
{"x,,s3n", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3n", "-", "10feffff03000080", "00", ""},
{"x,,s3n", "-8388607", "10feffff03010080", "00", ""},
{"x,,s3n", "8388607", "10feffff03ffff7f", "00", ""},
{"x,,s3n,10","-9.0", "10feffff03a6ffff", "00", ""},
{"x,,s3n,-10","-900","10feffff03a6ffff", "00", ""},
{"x,,s3r", "-90", "10feffff03ffffa6", "00", ""},
{"x,,s3r", "0", "10feffff03000000", "00", ""},
{"x,,s3r", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3r", "-", "10feffff03800000", "00", ""},
{"x,,s3n,10", "-9.0", "10feffff03a6ffff", "00", ""},
{"x,,s3n,-10", "-900", "10feffff03a6ffff", "00", ""},
{"x,,s3r", "-90", "10feffff03ffffa6", "00", ""},
{"x,,s3r", "0", "10feffff03000000", "00", ""},
{"x,,s3r", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3r", "-", "10feffff03800000", "00", ""},
{"x,,s3r", "-8388607", "10feffff03800001", "00", ""},
{"x,,s3r", "8388607", "10feffff037fffff", "00", ""},
{"x,,s3r,10","-9.0", "10feffff03ffffa6", "00", ""},
{"x,,s3r,-10","-900","10feffff03ffffa6", "00", ""},
{"x,,s3r,10", "-9.0", "10feffff03ffffa6", "00", ""},
{"x,,s3r,-10", "-900", "10feffff03ffffa6", "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", "10feffff020180", "00", ""},
{"x,,flt", "32.767", "10feffff02ff7f", "00", ""},
{"x,,flr", "-0.090", "10feffff02ffa6", "00", ""},
{"x,,flr", "0.000", "10feffff020000", "00", ""},
{"x,,flr", "-0.001", "10feffff02ffff", "00", ""},
{"x,,flr", "-", "10feffff028000", "00", ""},
{"x,,flr","-32.767", "10feffff028001", "00", ""},
{"x,,flr", "-32.767", "10feffff028001", "00", ""},
{"x,,flr", "32.767", "10feffff027fff", "00", ""},
{"x,,exp", "-0.09", "10feffff04ec51b8bd", "00", ""},
{"x,,exp", "0.0", "10feffff0400000000", "00", ""},
{"x,,exp", "-0.001", "10feffff046f1283ba", "00", ""},
{"x,,exp", "-", "10feffff040000807f", "00", ""},
{"x,,exp","-32.767", "10feffff04681103c2", "00", ""},
{"x,,exp", "-32.767", "10feffff04681103c2", "00", ""},
{"x,,exp,1000", "-0.000090000", "10feffff04ec51b8bd", "00", ""},
{"x,,exp,-100", "-9", "10feffff04ec51b8bd", "00", ""},
{"x,,exr", "-0.09", "10feffff04bdb851ec", "00", ""},
{"x,,exr", "0.0", "10feffff0400000000", "00", ""},
{"x,,exr", "-0.001", "10feffff04ba83126f", "00", ""},
{"x,,exr", "-", "10feffff047f800000", "00", ""},
{"x,,exr","-32.767", "10feffff04c2031168", "00", ""},
{"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""},
{"x,,exr", "-32.767", "10feffff04c2031168", "00", ""},
{"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""},
{"x,,exr,-100", "-9", "10feffff04bdb851ec", "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,,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,,ulg,10","3.8", "10feffff0426000000", "00", ""},
{"x,,ulg,-10","380", "10feffff0426000000", "00", ""},
{"x,,ulg,10", "3.8", "10feffff0426000000", "00", ""},
{"x,,ulg,-10", "380", "10feffff0426000000", "00", ""},
{"x,,ulg,0x0FF0F00F = VRT 350 ;0x33CCCC33=VRT 360;0x3CC3C33C=SD 17;0x66999966=SD 37;0x69969669=VRT 360+",
"VRT 350", "10feffff040FF0F00F", "00", ""},
{"x,,ulg,0x=test", "", "10feffff040FF0F00F", "00", "c"},
@@ -397,8 +397,8 @@ int main() {
{"x,,ulr", "0", "10feffff0400000000", "00", ""},
{"x,,ulr", "4294967294", "10feffff04fffffffe", "00", ""},
{"x,,ulr", "-", "10feffff04ffffffff", "00", ""},
{"x,,ulr,10","3.8", "10feffff0400000026", "00", ""},
{"x,,ulr,-10","380", "10feffff0400000026", "00", ""},
{"x,,ulr,10", "3.8", "10feffff0400000026", "00", ""},
{"x,,ulr,-10", "380", "10feffff0400000026", "00", ""},
{"x,,slg", "-90", "10feffff04a6ffffff", "00", ""},
{"x,,slg", "0", "10feffff0400000000", "00", ""},
{"x,,slg", "-1", "10feffff04ffffffff", "00", ""},
@@ -409,53 +409,53 @@ int main() {
{"x,,slr", "-1", "10feffff04ffffffff", "00", ""},
{"x,,slr,10", "-9.0", "10feffff04ffffffa6", "00", ""},
{"x,,slr,-10", "-900", "10feffff04ffffffa6", "00", ""},
{"x,,bi3", "1", "10feffff0108", "00", ""},
{"x,,bi3", "0", "10feffff0100", "00", ""},
{"x,,bi3,0=off;1=on","on", "10feffff0108", "00", ""},
{"x,,bi3,0=off;1=on","off","10feffff0100", "00", ""},
{"x,,bi3", "1", "10feffff0108", "00", ""},
{"x,,bi3", "0", "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", "0", "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;2=auto;3=eco","2.5", "10feffff0110", "00", "R"},
{"x,,bi3:2,0=off;1=on","on", "10feffff0108", "00", ""},
{"x,,bi3:2,0=off;1=on","off","10feffff0100", "00", ""},
{"x,,bi3:2,0=off;1=on","1", "10feffff0108", "00", "n"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","x=on ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvv"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","x=1 ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvvn"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": \"on\"}", "10feffff0108", "00", "vj"},
{",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "vj"},
{",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "j"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": \"on\", \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": 1}", "10feffff0108", "00", "vnj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": 1, \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvnj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"0\": {\"name\": \"x\", \"value\": 1}", "10feffff0108", "00", "nj"},
{"x,,uch,1=test;2=high;3=off;0x10=on","on","10feffff0110", "00", ""},
{"x,s,uch","3","1050ffff00", "0103", ""},
{"x,,d2b,,°C,Aussentemperatur","x=18.004 °C [Aussentemperatur]","10fe0700090112", "00", "vvv"},
{"x,,bti,,,,y,,bda,,,,z,,bdy", "21:04:58;26.10.2014;Sun","10fe0700085804212610061406", "00", ""}, // combination
{"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;2=auto;3=eco", "2.5", "10feffff0110", "00", "R"},
{"x,,bi3:2,0=off;1=on", "on", "10feffff0108", "00", ""},
{"x,,bi3:2,0=off;1=on", "off", "10feffff0100", "00", ""},
{"x,,bi3:2,0=off;1=on", "1", "10feffff0108", "00", "n"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "x=on ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvv"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "x=1 ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvvn"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": \"on\"}", "10feffff0108", "00", "vj"},
{",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "vj"},
{",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "j"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": \"on\", \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": 1}", "10feffff0108", "00", "vnj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": 1, \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvnj"},
{"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"x\", \"value\": 1}", "10feffff0108", "00", "nj"},
{"x,,uch,1=test;2=high;3=off;0x10=on", "on", "10feffff0110", "00", ""},
{"x,s,uch", "3", "1050ffff00", "0103", ""},
{"x,,d2b,,°C,Aussentemperatur", "x=18.004 °C [Aussentemperatur]", "10fe0700090112", "00", "vvv"},
{"x,,bti,,,,y,,bda,,,,z,,bdy", "21:04:58;26.10.2014;Sun", "10fe0700085804212610061406", "00", ""}, // combination
{"x,,bi3,,,,y,,bi5", "1;0", "10feffff0108", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi5", "1;1", "10feffff0128", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi5", "0;1", "10feffff0120", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi5", "0;0", "10feffff0100", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi7,,,,t,,uch", "0;0;9","10feffff020009", "00", ""}, // bit combination
{"x,,bi6:2,,,,y,,bi0:2,,,,t,,uch", "2;1;9","10feffff03800109", "00", ""}, // bit combination
{"x,,BI0;BI1;BI2;BI3;BI4;BI5;BI6;BI7", "0;0;1;0;0;0;0;0","ff75b50900", "0104", ""}, // bits
{"temp,d2b,,°C,Aussentemperatur","","", "", "t"}, // template with relative pos
{"x,,temp","18.004","10fe0700020112", "00", ""}, // reference to template
{"x,,temp,10","1.8004","10fe0700020112", "00", ""}, // reference to template, valid divider product
{"x,,temp,-10","","", "", "c"}, // reference to template, invalid divider product
{"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,,temp;HEX:2","18.004;13 14","10fe07000401121314", "00", ""}, // reference to template and base type
{"x,,temp;HEX:2","temp=18.004;=13 14","10fe07000401121314", "00", "v"}, // reference to template and base type
{"x,,temp:degrees;HEX:2","degrees=18.004;=13 14","10fe07000401121314", "00", "v"}, // reference to template and base type
{"x,,bi3,,,,y,,bi7,,,,t,,uch", "0;0;9", "10feffff020009", "00", ""}, // bit combination
{"x,,bi6:2,,,,y,,bi0:2,,,,t,,uch", "2;1;9", "10feffff03800109", "00", ""}, // bit combination
{"x,,BI0;BI1;BI2;BI3;BI4;BI5;BI6;BI7", "0;0;1;0;0;0;0;0", "ff75b50900", "0104", ""}, // bits
{"temp,d2b,,°C,Aussentemperatur", "", "", "", "t"}, // template with relative pos
{"x,,temp", "18.004", "10fe0700020112", "00", ""}, // reference to template
{"x,,temp,10", "1.8004", "10fe0700020112", "00", ""}, // reference to template, valid divider product
{"x,,temp,-10", "", "", "", "c"}, // reference to template, invalid divider product
{"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,,temp;HEX:2", "18.004;13 14", "10fe07000401121314", "00", ""}, // reference to template and base type
{"x,,temp;HEX:2", "temp=18.004;=13 14", "10fe07000401121314", "00", "v"}, // reference to template and base type
{"x,,temp:degrees;HEX:2", "degrees=18.004;=13 14", "10fe07000401121314", "00", "v"}, // reference to template and base type
};
DataFieldTemplates* templates = new DataFieldTemplates();
DataField* fields = NULL;
+1 -1
View File
@@ -22,7 +22,7 @@
using namespace std;
int main () {
int main() {
Device* device = Device::create("/dev/ttyUSB20", true, false, false);
if (device == NULL) {
cout << "unable to create device" << endl;
+3 -4
View File
@@ -71,7 +71,7 @@ int main() {
{"pumpstate,UCH,0=off;1=on;2=overrun,,Pumpenstatus", "", "", "", "template"},
{"tempsensor,temp;sensor,,Temperatursensor", "", "", "", "template"},
{"tempsensorc,temp;sensorc,,Temperatursensor", "", "", "", "template"},
{"r,,Status01,VL/RL/AussenTemp/VLWW/SpeicherTemp/Status,,08,B511,01,,,temp1;temp1;temp2;temp1;temp1;pumpstate","28.0;24.0;4.938;35.0;41.0;4","ff08b5110101","093830f00446520400ff","d"},
{"r,,Status01,VL/RL/AussenTemp/VLWW/SpeicherTemp/Status,,08,B511,01,,,temp1;temp1;temp2;temp1;temp1;pumpstate", "28.0;24.0;4.938;35.0;41.0;4", "ff08b5110101", "093830f00446520400ff", "d"},
{"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor", "temp=-14.00 Temperatursensor [Temperatur];sensor=ok [Fühlerstatus]", "ff25b509030d2800", "0320ff00", "mD"},
{"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor,,field unit,field comment", "temp=-14.00 field unit [field comment];sensor=ok [Fühlerstatus]", "ff25b509030d2800", "0320ff00", "mD"},
{"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor,,field unit,field comment", "\n \"temp\": {\"value\": -14.00},\n \"sensor\": {\"value\": \"ok\"}", "ff25b509030d2800", "0320ff00", "mj"},
@@ -99,8 +99,8 @@ int main() {
{"r,ehp,error,,,08,b509,0d2800,index,m,UCH,,,,,,time", "index=3;time=15:00:17", "ff08b509040d280003", "0311000f", "mD"},
{"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,ehp,hwTankTemp,Speichertemperatur IST,,25,B509,290000,,,IGN:2,,,,,,tempsensor", "","","","M"},
{"", "55.50;ok","1025b50903290000","050000780300","d"},
{"u,ehp,hwTankTemp,Speichertemperatur IST,,25,B509,290000,,,IGN:2,,,,,,tempsensor", "", "", "", "M"},
{"", "55.50;ok", "1025b50903290000", "050000780300", "d"},
{"r,ehp,datetime,Datum Uhrzeit,,50,B504,00,,,dcfstate,,,,time,,BTI,,,,date,,BDA,,,,temp,,temp2", "valid;08:24:51;31.12.2014;-0.875", "1050b5040100", "0a035124083112031420ff", "md" },
{"r,ehp,bad,invalid pos,,50,B5ff,000102,,m,HEX:8;tempsensor;tempsensor;tempsensor;tempsensor;power;power,,,", "", "", "", "c" },
{"r,ehp,bad,invalid pos,,50,B5ff,,,s,HEX:8;tempsensor;tempsensor;tempsensor;tempsensor;tempsensor;power;power,,,", "", "", "", "c" },
@@ -418,5 +418,4 @@ int main() {
delete *it;
}
return 0;
}
+5 -9
View File
@@ -27,15 +27,12 @@
/**
* class to notify other thread per pipe.
*/
class Notify
{
public:
class Notify {
public:
/**
* constructs a new instance and do notifying.
*/
Notify()
{
Notify() {
int pipefd[2];
int ret = pipe(pipefd);
@@ -62,15 +59,14 @@ public:
* write notify event to file descriptor.
* @return result of writing notification.
*/
int notify() const { return write(m_sendfd,"1",1); }
int notify() const { return write(m_sendfd, "1", 1); }
private:
private:
/** file descriptor to watch */
int m_recvfd;
/** file descriptor to notify */
int m_sendfd;
};
#endif // LIB_UTILS_NOTIFY_H_
+12 -20
View File
@@ -33,15 +33,12 @@ using namespace std;
* @param T the item type.
*/
template <typename T>
class Queue
{
public:
class Queue {
public:
/**
* Constructor.
*/
Queue()
{
Queue() {
pthread_mutex_init(&m_mutex, NULL);
pthread_cond_init(&m_cond, NULL);
}
@@ -49,28 +46,26 @@ public:
/**
* Destructor.
*/
~Queue()
{
~Queue() {
pthread_mutex_destroy(&m_mutex);
pthread_cond_destroy(&m_cond);
}
private:
private:
/**
* Hidden copy constructor.
* @param src the object to copy from.
*/
Queue(const Queue& src);
public:
public:
/**
* Add an item to the end of queue.
* @param item the item to add.
*/
void push(T item)
{
void push(T item) {
pthread_mutex_lock(&m_mutex);
m_queue.push_back(item);
pthread_cond_broadcast(&m_cond);
@@ -82,8 +77,7 @@ public:
* @param timeout the maximum time in seconds to wait for the queue being filled, or 0 for no wait.
* @return the item, or NULL if no item is available within the specified time.
*/
T pop(int timeout = 0)
{
T pop(int timeout = 0) {
T item;
pthread_mutex_lock(&m_mutex);
if (timeout > 0) {
@@ -112,8 +106,7 @@ public:
* @param wait true to wait for the item to appear in the queue.
* @return whether the item was removed.
*/
bool remove(T item, bool wait = false)
{
bool remove(T item, bool wait = false) {
bool ret = false;
pthread_mutex_lock(&m_mutex);
do {
@@ -135,8 +128,7 @@ public:
* Return the first item in the queue without removing it.
* @return the item, or NULL if no item is available.
*/
T peek()
{
T peek() {
T item;
pthread_mutex_lock(&m_mutex);
if (m_queue.empty()) {
@@ -148,7 +140,8 @@ public:
return item;
}
private:
private:
/** the queue itself */
list<T> m_queue;
@@ -157,7 +150,6 @@ private:
/** condition variable for exclusive lock */
pthread_cond_t m_cond;
};
#endif // LIB_UTILS_QUEUE_H_
+1 -2
View File
@@ -64,8 +64,7 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) {
fprintf(m_stream, "%04d-%02d-%02d %02d:%02d:%02d.%03ld %c",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000,
received ? '<' : '>'
);
received ? '<' : '>');
for (unsigned int pos = 0; pos < size; pos++) {
fprintf(m_stream, "%2.2x ", value[pos]);
}
+4 -5
View File
@@ -33,9 +33,8 @@ using namespace std;
/**
* Helper class for writing to a rotating file with maximum size.
*/
class RotateFile
{
public:
class RotateFile {
public:
/**
* Construct a new instance.
* @param fileName the name of the file write to.
@@ -71,7 +70,8 @@ public:
*/
void write(unsigned char* value, unsigned int size, bool received = true);
private:
private:
/** whether writing to the file is enabled. */
bool m_enabled;
@@ -89,7 +89,6 @@ private:
/** the number of bytes already written to the @a m_file. */
unsigned long m_fileSize;
};
#endif // LIB_UTILS_ROTATEFILE_H_
+10 -17
View File
@@ -37,10 +37,8 @@ using namespace std;
/**
* class for low level tcp socket operations. (open, close, send, receive).
*/
class TCPSocket
{
public:
class TCPSocket {
public:
/** grant access for friend class TCPClient */
friend class TCPClient;
@@ -92,7 +90,8 @@ public:
*/
bool isValid();
private:
private:
/** file descriptor from tcp socket */
int m_sfd;
@@ -108,16 +107,13 @@ private:
* @param address struct which holds the ip address.
*/
TCPSocket(int sfd, struct sockaddr_in* address);
};
/**
* class to initiate a tcp socket connection to a listening server.
*/
class TCPClient
{
public:
class TCPClient {
public:
/**
* initiate a tcp socket connection to a listening server.
* @param server the server name or ip address to connect.
@@ -125,16 +121,13 @@ public:
* @return pointer to an opened tcp socket.
*/
TCPSocket* connect(const string& server, const uint16_t& port);
};
/**
* class for a tcp based network server.
*/
class TCPServer
{
public:
class TCPServer {
public:
/**
* creates a new instance of a listening tcp server.
* @param port the tcp port.
@@ -166,7 +159,8 @@ public:
*/
int getFD() const { return m_lfd; }
private:
private:
/** file descriptor from listening tcp socket */
int m_lfd;
@@ -178,7 +172,6 @@ private:
/** true if object is already listening */
bool m_listening;
};
#endif // LIB_UTILS_TCPSOCKET_H_
-9
View File
@@ -36,37 +36,28 @@ Thread::~Thread() {
}
bool Thread::start(const char* name) {
int result = pthread_create(&m_threadid, NULL, runThread, this);
if (result == 0) {
#ifdef HAVE_PTHREAD_SETNAME_NP
#ifndef __MACH__
pthread_setname_np(m_threadid, name);
#endif
#endif
m_started = true;
return true;
}
return false;
}
bool Thread::join() {
int result = -1;
if (m_started) {
m_stopped = true;
result = pthread_join(m_threadid, NULL);
if (result == 0) {
m_started = false;
}
}
return result == 0;
}
+8 -13
View File
@@ -26,10 +26,8 @@
/**
* wrapper class for pthread.
*/
class Thread
{
public:
class Thread {
public:
/**
* constructor.
*/
@@ -77,15 +75,15 @@ public:
*/
pthread_t self() { return m_threadid; }
protected:
protected:
/**
* Thread entry method to be overridden by derived class.
*/
virtual void run() = 0;
private:
private:
/**
* Enter the Thread loop by calling run().
*/
@@ -102,17 +100,14 @@ private:
/** Whether the thread was stopped by @a stop() or @a join(). */
bool m_stopped;
};
/**
* A @a Thread that can be waited on.
*/
class WaitThread : public Thread
{
public:
class WaitThread : public Thread {
public:
/**
* Constructor.
*/
@@ -136,13 +131,13 @@ public:
*/
bool Wait(int seconds);
private:
private:
/** the mutex for waiting. */
pthread_mutex_t m_mutex;
/** the condition for waiting. */
pthread_cond_t m_cond;
};
#endif // LIB_UTILS_THREAD_H_