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
+5 -11
View File
@@ -45,8 +45,7 @@ using namespace std;
* @return the string corresponding to the @a BusState. * @return the string corresponding to the @a BusState.
*/ */
const char* getStateCode(BusState state) { const char* getStateCode(BusState state) {
switch (state) switch (state) {
{
case bs_noSignal: return "no signal"; case bs_noSignal: return "no signal";
case bs_skip: return "skip"; case bs_skip: return "skip";
case bs_ready: return "ready"; case bs_ready: return "ready";
@@ -322,8 +321,7 @@ result_t BusHandler::handleSymbol() {
BusRequest* startRequest = NULL; BusRequest* startRequest = NULL;
// check if another symbol has to be sent and determine timeout for receive // check if another symbol has to be sent and determine timeout for receive
switch (m_state) switch (m_state) {
{
case bs_noSignal: case bs_noSignal:
timeout = m_generateSynInterval > 0 ? m_generateSynInterval : SIGNAL_TIMEOUT; timeout = m_generateSynInterval > 0 ? m_generateSynInterval : SIGNAL_TIMEOUT;
break; break;
@@ -489,8 +487,7 @@ result_t BusHandler::handleSymbol() {
unsigned int headerLen, crcPos; unsigned int headerLen, crcPos;
switch (m_state) switch (m_state) {
{
case bs_noSignal: case bs_noSignal:
return setState(bs_skip, RESULT_OK); return setState(bs_skip, RESULT_OK);
@@ -728,7 +725,6 @@ result_t BusHandler::handleSymbol() {
return setState(bs_skip, RESULT_OK); return setState(bs_skip, RESULT_OK);
} }
return setState(bs_skip, RESULT_ERR_INVALID_ARG); return setState(bs_skip, RESULT_ERR_INVALID_ARG);
} }
return RESULT_OK; return RESULT_OK;
} }
@@ -740,16 +736,14 @@ result_t BusHandler::setState(BusState state, result_t result, bool firstRepetit
m_currentRequest->m_busLostRetries++; m_currentRequest->m_busLostRetries++;
m_nextRequests.push(m_currentRequest); // repeat m_nextRequests.push(m_currentRequest); // repeat
m_currentRequest = NULL; m_currentRequest = NULL;
} } else if (state == bs_sendSyn || (result != RESULT_OK && !firstRepetition)) {
else if (state == bs_sendSyn || (result != RESULT_OK && !firstRepetition)) {
logDebug(lf_bus, "notify request: %s", getResultCode(result)); logDebug(lf_bus, "notify request: %s", getResultCode(result));
unsigned char dstAddress = m_currentRequest->m_master[1]; unsigned char dstAddress = m_currentRequest->m_master[1];
if (result == RESULT_OK) { if (result == RESULT_OK) {
addSeenAddress(dstAddress); addSeenAddress(dstAddress);
} }
bool restart = m_currentRequest->notify( bool restart = m_currentRequest->notify(
result == RESULT_ERR_SYN && (m_state == bs_recvCmdAck || m_state == bs_recvRes) ? RESULT_ERR_TIMEOUT : result, m_response result == RESULT_ERR_SYN && (m_state == bs_recvCmdAck || m_state == bs_recvRes) ? RESULT_ERR_TIMEOUT : result, m_response);
);
if (restart) { if (restart) {
m_currentRequest->m_busLostRetries = 0; m_currentRequest->m_busLostRetries = 0;
m_nextRequests.push(m_currentRequest); m_nextRequests.push(m_currentRequest);
+20 -37
View File
@@ -93,11 +93,10 @@ class BusHandler;
/** /**
* Generic request for sending to and receiving from the bus. * Generic request for sending to and receiving from the bus.
*/ */
class BusRequest class BusRequest {
{
friend class BusHandler; friend class BusHandler;
public:
public:
/** /**
* Constructor. * Constructor.
* @param master the escaped master data @a SymbolString to send. * @param master the escaped master data @a SymbolString to send.
@@ -120,8 +119,8 @@ public:
*/ */
virtual bool notify(result_t result, SymbolString& slave) = 0; virtual bool notify(result_t result, SymbolString& slave) = 0;
protected:
protected:
/** the escaped master data @a SymbolString to send. */ /** the escaped master data @a SymbolString to send. */
SymbolString& m_master; SymbolString& m_master;
@@ -130,18 +129,16 @@ protected:
/** whether to automatically delete this @a BusRequest when finished. */ /** whether to automatically delete this @a BusRequest when finished. */
const bool m_deleteOnFinish; const bool m_deleteOnFinish;
}; };
/** /**
* A poll @a BusRequest handled by @a BusHandler itself. * A poll @a BusRequest handled by @a BusHandler itself.
*/ */
class PollRequest : public BusRequest class PollRequest : public BusRequest {
{
friend class BusHandler; friend class BusHandler;
public:
public:
/** /**
* Constructor. * Constructor.
* @param message the associated @a Message. * @param message the associated @a Message.
@@ -164,8 +161,8 @@ public:
// @copydoc // @copydoc
virtual bool notify(result_t result, SymbolString& slave); virtual bool notify(result_t result, SymbolString& slave);
private:
private:
/** the escaped master data @a SymbolString. */ /** the escaped master data @a SymbolString. */
SymbolString m_master; SymbolString m_master;
@@ -174,18 +171,16 @@ private:
/** the current part index in @a m_message. */ /** the current part index in @a m_message. */
unsigned char m_index; unsigned char m_index;
}; };
/** /**
* A scan @a BusRequest handled by @a BusHandler itself. * A scan @a BusRequest handled by @a BusHandler itself.
*/ */
class ScanRequest : public BusRequest class ScanRequest : public BusRequest {
{
friend class BusHandler; friend class BusHandler;
public:
public:
/** /**
* Constructor. * Constructor.
* @param messageMap the @a MessageMap instance. * @param messageMap the @a MessageMap instance.
@@ -194,8 +189,7 @@ public:
* @param busHandler the @a BusHandler instance to notify of final scan result. * @param busHandler the @a BusHandler instance to notify of final scan result.
*/ */
ScanRequest(MessageMap* messageMap, deque<Message*> messages, deque<unsigned char> slaves, BusHandler* busHandler) ScanRequest(MessageMap* messageMap, deque<Message*> messages, deque<unsigned char> slaves, BusHandler* busHandler)
: BusRequest(m_master, true), m_messageMap(messageMap), m_index(0), m_allMessages(messages), m_messages(messages), m_slaves(slaves), m_busHandler(busHandler) : BusRequest(m_master, true), m_messageMap(messageMap), m_index(0), m_allMessages(messages), m_messages(messages), m_slaves(slaves), m_busHandler(busHandler) {
{
m_message = m_messages.front(); m_message = m_messages.front();
m_messages.pop_front(); m_messages.pop_front();
} }
@@ -215,8 +209,8 @@ public:
// @copydoc // @copydoc
virtual bool notify(result_t result, SymbolString& slave); virtual bool notify(result_t result, SymbolString& slave);
private:
private:
/** the @a MessageMap instance. */ /** the @a MessageMap instance. */
MessageMap* m_messageMap; MessageMap* m_messageMap;
@@ -243,18 +237,16 @@ private:
/** the @a BusHandler instance to notify of final scan result. */ /** the @a BusHandler instance to notify of final scan result. */
BusHandler* m_busHandler; BusHandler* m_busHandler;
}; };
/** /**
* An active @a BusRequest that can be waited for. * An active @a BusRequest that can be waited for.
*/ */
class ActiveBusRequest : public BusRequest class ActiveBusRequest : public BusRequest {
{
friend class BusHandler; friend class BusHandler;
public:
public:
/** /**
* Constructor. * Constructor.
* @param master the escaped master data @a SymbolString to send. * @param master the escaped master data @a SymbolString to send.
@@ -271,25 +263,21 @@ public:
// @copydoc // @copydoc
virtual bool notify(result_t result, SymbolString& slave); virtual bool notify(result_t result, SymbolString& slave);
private:
private:
/** the result of handling the request. */ /** the result of handling the request. */
result_t m_result; result_t m_result;
/** reference to @a SymbolString for filling in the received slave data. */ /** reference to @a SymbolString for filling in the received slave data. */
SymbolString& m_slave; SymbolString& m_slave;
}; };
/** /**
* Helper class for keeping track of grabbed messages. * Helper class for keeping track of grabbed messages.
*/ */
class GrabbedMessage class GrabbedMessage {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
*/ */
@@ -321,8 +309,8 @@ public:
*/ */
bool dump(const bool unknown, MessageMap* messages, bool first, ostringstream& output); bool dump(const bool unknown, MessageMap* messages, bool first, ostringstream& output);
private:
private:
/** the last master @a SymbolString. */ /** the last master @a SymbolString. */
SymbolString m_lastMaster; SymbolString m_lastMaster;
@@ -331,17 +319,14 @@ private:
/** the number of times this message was seen. */ /** the number of times this message was seen. */
unsigned int m_count; unsigned int m_count;
}; };
/** /**
* Handles input from and output to the bus with respect to the eBUS protocol. * Handles input from and output to the bus with respect to the eBUS protocol.
*/ */
class BusHandler : public WaitThread class BusHandler : public WaitThread {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param device the @a Device instance for accessing the bus. * @param device the @a Device instance for accessing the bus.
@@ -375,8 +360,7 @@ public:
m_symPerSec(0), m_maxSymPerSec(0), m_symPerSec(0), m_maxSymPerSec(0),
m_state(bs_noSignal), m_repeat(false), m_state(bs_noSignal), m_repeat(false),
m_command(false), m_commandCrcValid(false), m_response(false), m_responseCrcValid(false), m_command(false), m_commandCrcValid(false), m_response(false), m_responseCrcValid(false),
m_grabMessages(true) m_grabMessages(true) {
{
memset(m_seenAddresses, 0, sizeof(m_seenAddresses)); memset(m_seenAddresses, 0, sizeof(m_seenAddresses));
} }
@@ -525,8 +509,8 @@ public:
*/ */
void setScanConfigLoaded(unsigned char address, string file); void setScanConfigLoaded(unsigned char address, string file);
private:
private:
/** /**
* Handle the next symbol on the bus. * Handle the next symbol on the bus.
* @return RESULT_OK on success, or an error code. * @return RESULT_OK on success, or an error code.
@@ -664,7 +648,6 @@ private:
/** the grabbed messages by key.*/ /** the grabbed messages by key.*/
map<unsigned long long, GrabbedMessage> m_grabbedMessages; map<unsigned long long, GrabbedMessage> m_grabbedMessages;
}; };
#endif // EBUSD_BUSHANDLER_H_ #endif // EBUSD_BUSHANDLER_H_
+8 -16
View File
@@ -54,9 +54,8 @@ bool datahandler_register(BusHandler* busHandler, MessageMap* messages, list<Dat
/** /**
* Base class for all kinds of data handlers. * Base class for all kinds of data handlers.
*/ */
class DataHandler class DataHandler {
{ public:
public:
/** /**
* Constructor. * Constructor.
*/ */
@@ -83,17 +82,14 @@ public:
* @return whether this is a @a DataSource instance. * @return whether this is a @a DataSource instance.
*/ */
virtual bool isDataSource() { return false; } virtual bool isDataSource() { return false; }
}; };
/** /**
* Base class for listening to data updates. * Base class for listening to data updates.
*/ */
class DataSink : virtual public DataHandler class DataSink : virtual public DataHandler {
{ public:
public:
/** /**
* Constructor. * Constructor.
*/ */
@@ -113,21 +109,18 @@ public:
// @copydoc // @copydoc
virtual bool isDataSink() { return true; } virtual bool isDataSink() { return true; }
protected:
protected:
/** a map of updated @p Message instances. */ /** a map of updated @p Message instances. */
map<Message*, int> m_updatedMessages; map<Message*, int> m_updatedMessages;
}; };
/** /**
* Base class providing data to be sent on the bus. * Base class providing data to be sent on the bus.
*/ */
class DataSource : virtual public DataHandler class DataSource : virtual public DataHandler {
{ public:
public:
/** /**
* Constructor. * Constructor.
* @param busHandler the @a BusHandler instance. * @param busHandler the @a BusHandler instance.
@@ -143,11 +136,10 @@ public:
// @copydoc // @copydoc
virtual bool isDataSource() { return true; } virtual bool isDataSource() { return true; }
protected:
protected:
/** the @a BusHandler instance. */ /** the @a BusHandler instance. */
BusHandler* m_busHandler; BusHandler* m_busHandler;
}; };
#endif // EBUSD_DATAHANDLER_H_ #endif // EBUSD_DATAHANDLER_H_
+1 -1
View File
@@ -397,7 +397,7 @@ void MqttHandler::handleTraffic() {
if (m_mosquitto) { if (m_mosquitto) {
mosquitto_loop(m_mosquitto, -1 mosquitto_loop(m_mosquitto, -1
#if (LIBMOSQUITTO_MAJOR >= 1) #if (LIBMOSQUITTO_MAJOR >= 1)
,1 , 1
#endif #endif
); );
} }
+5 -8
View File
@@ -50,10 +50,8 @@ DataHandler* mqtthandler_register(BusHandler* busHandler, MessageMap* messages);
/** /**
* The main class supporting MQTT data handling. * The main class supporting MQTT data handling.
*/ */
class MqttHandler : public DataSink, public DataSource, public Thread class MqttHandler : public DataSink, public DataSource, public Thread {
{ public:
public:
/** /**
* Constructor. * Constructor.
* @param busHandler the @a BusHandler instance. * @param busHandler the @a BusHandler instance.
@@ -76,13 +74,13 @@ public:
*/ */
void notifyTopic(string topic, string data); void notifyTopic(string topic, string data);
protected:
protected:
// @copydoc // @copydoc
virtual void run(); virtual void run();
private:
private:
/** /**
* Called regularly to handle MQTT traffic. * Called regularly to handle MQTT traffic.
*/ */
@@ -128,7 +126,6 @@ private:
/** the mosquitto structure if initialized, or NULL. */ /** the mosquitto structure if initialized, or NULL. */
struct mosquitto* m_mosquitto; struct mosquitto* m_mosquitto;
}; };
#endif // EBUSD_DATAHANDLER_H_ #endif // EBUSD_MQTTHANDLER_H_
-2
View File
@@ -141,7 +141,6 @@ void Connection::run() {
break; break;
} }
} }
} }
delete m_socket; delete m_socket;
@@ -230,7 +229,6 @@ void Network::run() {
} }
#endif #endif
#endif #endif
while (true) { while (true) {
#ifdef HAVE_PPOLL #ifdef HAVE_PPOLL
// wait for new fd event // wait for new fd event
+23 -32
View File
@@ -38,17 +38,14 @@ class Connection;
/** /**
* Class for data/message transfer between @a Connection and @a MainLoop. * Class for data/message transfer between @a Connection and @a MainLoop.
*/ */
class NetMessage class NetMessage {
{ public:
public:
/** /**
* Constructor. * Constructor.
* @param isHttp whether this is a HTTP message. * @param isHttp whether this is a HTTP message.
*/ */
NetMessage(const bool isHttp) NetMessage(const bool isHttp)
: m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) : m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) {
{
pthread_mutex_init(&m_mutex, NULL); pthread_mutex_init(&m_mutex, NULL);
pthread_cond_init(&m_cond, NULL); pthread_cond_init(&m_cond, NULL);
} }
@@ -56,28 +53,27 @@ public:
/** /**
* Destructor. * Destructor.
*/ */
~NetMessage() ~NetMessage() {
{
pthread_mutex_destroy(&m_mutex); pthread_mutex_destroy(&m_mutex);
pthread_cond_destroy(&m_cond); pthread_cond_destroy(&m_cond);
} }
private:
private:
/** /**
* Hidden copy constructor. * Hidden copy constructor.
* @param src the object to copy from. * @param src the object to copy from.
*/ */
NetMessage(const NetMessage& src); NetMessage(const NetMessage& src);
public:
public:
/** /**
* Add request data received from the client. * Add request data received from the client.
* @param request the request data from the client. * @param request the request data from the client.
* @return true when the request is complete and the response shall be prepared. * @return true when the request is complete and the response shall be prepared.
*/ */
bool add(string request) bool add(string request) {
{
if (request.length() > 0) { if (request.length() > 0) {
request.erase(remove(request.begin(), request.end(), '\r'), request.end()); request.erase(remove(request.begin(), request.end(), '\r'), request.end());
m_request.append(request); m_request.append(request);
@@ -125,8 +121,7 @@ public:
* Wait for the result being set and return the result string. * Wait for the result being set and return the result string.
* @return the result string. * @return the result string.
*/ */
string getResult() string getResult() {
{
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
while (!m_resultSet) while (!m_resultSet)
@@ -148,8 +143,7 @@ public:
* @param listenUntil the end time to which to updates were added (exclusive). * @param listenUntil the end time to which to updates were added (exclusive).
* @param disconnect true when the client shall be disconnected. * @param disconnect true when the client shall be disconnected.
*/ */
void setResult(const string result, const bool listening, const time_t listenUntil, const bool disconnect) void setResult(const string result, const bool listening, const time_t listenUntil, const bool disconnect) {
{
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
m_result = result; m_result = result;
m_disconnect = disconnect; m_disconnect = disconnect;
@@ -173,7 +167,8 @@ public:
*/ */
bool isDisconnect() { return m_disconnect; } bool isDisconnect() { return m_disconnect; }
private:
private:
/** whether this is a HTTP message. */ /** whether this is a HTTP message. */
const bool m_isHttp; const bool m_isHttp;
@@ -200,16 +195,13 @@ private:
/** start timestamp of listening update. */ /** start timestamp of listening update. */
time_t m_listenSince; time_t m_listenSince;
}; };
/** /**
* class connection which handle client and baseloop communication. * class connection which handle client and baseloop communication.
*/ */
class Connection : public Thread class Connection : public Thread {
{ public:
public:
/** /**
* Constructor. * Constructor.
* @param socket the @a TCPSocket for communication. * @param socket the @a TCPSocket for communication.
@@ -217,8 +209,9 @@ public:
* @param netQueue the reference to the @a NetMessage @a Queue. * @param netQueue the reference to the @a NetMessage @a Queue.
*/ */
Connection(TCPSocket* socket, const bool isHttp, Queue<NetMessage*>* netQueue) Connection(TCPSocket* socket, const bool isHttp, Queue<NetMessage*>* netQueue)
: Thread(), m_isHttp(isHttp), m_socket(socket), m_netQueue(netQueue) : Thread(), m_isHttp(isHttp), m_socket(socket), m_netQueue(netQueue) {
{ m_id = ++m_ids; } m_id = ++m_ids;
}
virtual ~Connection() { if (m_socket) delete m_socket; } virtual ~Connection() { if (m_socket) delete m_socket; }
/** /**
@@ -237,7 +230,8 @@ public:
*/ */
int getID() { return m_id; } int getID() { return m_id; }
private:
private:
/** whether this is a HTTP connection. */ /** whether this is a HTTP connection. */
const bool m_isHttp; const bool m_isHttp;
@@ -255,16 +249,13 @@ private:
/** the IF of the last opened connection. */ /** the IF of the last opened connection. */
static int m_ids; static int m_ids;
}; };
/** /**
* class network which listening on tcp socket for incoming connections. * class network which listening on tcp socket for incoming connections.
*/ */
class Network : public Thread class Network : public Thread {
{ public:
public:
/** /**
* create a network instance and listening for incoming connections. * create a network instance and listening for incoming connections.
* @param local true to accept connections only for local host. * @param local true to accept connections only for local host.
@@ -289,7 +280,8 @@ public:
*/ */
void stop() const { m_notify.notify(); usleep(100000); } void stop() const { m_notify.notify(); usleep(100000); }
private:
private:
/** the list of active @a Connection instances. */ /** the list of active @a Connection instances. */
list<Connection*> m_connections; list<Connection*> m_connections;
@@ -312,7 +304,6 @@ private:
* clean inactive connections from container. * clean inactive connections from container.
*/ */
void cleanConnections(); void cleanConnections();
}; };
#endif // EBUSD_NETWORK_H_ #endif // EBUSD_NETWORK_H_
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIB_EBUS_CONTRIB_H_ #ifndef LIB_EBUS_CONTRIB_CONTRIB_H_
#define LIB_EBUS_CONTRIB_H_ #define LIB_EBUS_CONTRIB_CONTRIB_H_
/** @file contrib.h /** @file contrib.h
* Contributed sources that may be excluded from regular builds. * Contributed sources that may be excluded from regular builds.
@@ -32,4 +32,4 @@ using namespace std;
*/ */
bool libebus_contrib_register(); 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 * A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave
* data. * data.
*/ */
class TemParamDataType : public NumberDataType class TemParamDataType : public NumberDataType {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param id the type identifier. * @param id the type identifier.
@@ -63,7 +61,6 @@ public:
virtual result_t writeSymbols(istringstream& input, virtual result_t writeSymbols(istringstream& input,
const unsigned char offset, const unsigned char length, const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength); 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) { if (partType != m_partType) {
return RESULT_EMPTY; return RESULT_EMPTY;
} }
switch (m_partType) switch (m_partType) {
{
case pt_masterData: case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break; break;
@@ -368,8 +367,7 @@ result_t SingleDataField::read(const PartType partType,
if (partType != m_partType) { if (partType != m_partType) {
return RESULT_OK; return RESULT_OK;
} }
switch (m_partType) switch (m_partType) {
{
case pt_masterData: case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break; break;
@@ -435,8 +433,7 @@ result_t SingleDataField::write(istringstream& input,
if (partType != m_partType) { if (partType != m_partType) {
return RESULT_OK; return RESULT_OK;
} }
switch (m_partType) switch (m_partType) {
{
case pt_masterData: case pt_masterData:
offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
break; break;
+21 -42
View File
@@ -53,10 +53,8 @@ class SingleDataField;
/** /**
* Base class for all kinds of data fields. * Base class for all kinds of data fields.
*/ */
class DataField class DataField {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param name the field name. * @param name the field name.
@@ -205,24 +203,21 @@ public:
const PartType partType, SymbolString& data, const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL) = 0; unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL) = 0;
protected:
protected:
/** the field name. */ /** the field name. */
const string m_name; const string m_name;
/** the field comment. */ /** the field comment. */
const string m_comment; const string m_comment;
}; };
/** /**
* A single @a DataField holding a value. * A single @a DataField holding a value.
*/ */
class SingleDataField : public DataField class SingleDataField : public DataField {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param name the field name. * @param name the field name.
@@ -325,8 +320,8 @@ public:
const PartType partType, SymbolString& data, const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL); unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL);
protected:
protected:
/** /**
* Internal method for reading the field from a @a SymbolString. * Internal method for reading the field from a @a SymbolString.
* @param input the unescaped @a SymbolString to read the binary value from. * @param input the unescaped @a SymbolString to read the binary value from.
@@ -353,8 +348,6 @@ protected:
const unsigned char offset, const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
protected:
/** the value unit. */ /** the value unit. */
const string m_unit; const string m_unit;
@@ -366,17 +359,14 @@ protected:
/** the number of symbols in the message part in which the field is stored. */ /** the number of symbols in the message part in which the field is stored. */
const unsigned char m_length; const unsigned char m_length;
}; };
/** /**
* A numeric data field with a list of value=text assignments and a string representation. * A numeric data field with a list of value=text assignments and a string representation.
*/ */
class ValueListDataField : public SingleDataField class ValueListDataField : public SingleDataField {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param name the field name. * @param name the field name.
@@ -410,8 +400,8 @@ public:
// @copydoc // @copydoc
virtual void dump(ostream& output); virtual void dump(ostream& output);
protected:
protected:
// @copydoc // @copydoc
virtual result_t readSymbols(SymbolString& input, const bool isMaster, virtual result_t readSymbols(SymbolString& input, const bool isMaster,
const unsigned char offset, const unsigned char offset,
@@ -422,21 +412,18 @@ protected:
const unsigned char offset, const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the value=text assignments. */ /** the value=text assignments. */
map<unsigned int, string> m_values; map<unsigned int, string> m_values;
}; };
/** /**
* A data field with a constant value. * A data field with a constant value.
*/ */
class ConstantDataField : public SingleDataField class ConstantDataField : public SingleDataField {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param name the field name. * @param name the field name.
@@ -471,8 +458,8 @@ public:
// @copydoc // @copydoc
virtual void dump(ostream& output); virtual void dump(ostream& output);
protected:
protected:
// @copydoc // @copydoc
virtual result_t readSymbols(SymbolString& input, const bool isMaster, virtual result_t readSymbols(SymbolString& input, const bool isMaster,
const unsigned char offset, const unsigned char offset,
@@ -483,24 +470,21 @@ protected:
const unsigned char offset, const unsigned char offset,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the constant value. */ /** the constant value. */
const string m_value; const string m_value;
/** whether to verify the read value against the constant value. */ /** whether to verify the read value against the constant value. */
const bool m_verify; const bool m_verify;
}; };
/** /**
* A set of @a DataField instances. * A set of @a DataField instances.
*/ */
class DataFieldSet : public DataField class DataFieldSet : public DataField {
{ public:
public:
/** /**
* Get the @a DataFieldSet for parsing the identification message (service 0x07 0x04). * Get the @a DataFieldSet for parsing the identification message (service 0x07 0x04).
* @return the @a DataFieldSet for parsing the identification message. This is:<ul> * @return the @a DataFieldSet for parsing the identification message. This is:<ul>
@@ -522,8 +506,7 @@ public:
DataFieldSet(const string name, const string comment, DataFieldSet(const string name, const string comment,
const vector<SingleDataField*> fields) const vector<SingleDataField*> fields)
: DataField(name, comment), : DataField(name, comment),
m_fields(fields) m_fields(fields) {
{
bool uniqueNames = true; bool uniqueNames = true;
map<string, string> names; map<string, string> names;
for (vector<SingleDataField*>::const_iterator it = fields.begin(); it != fields.end(); it++) { for (vector<SingleDataField*>::const_iterator it = fields.begin(); it != fields.end(); it++) {
@@ -603,8 +586,8 @@ public:
const PartType partType, SymbolString& data, const PartType partType, SymbolString& data,
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL); 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. */ /** the @a DataFieldSet containing the ident message @a SingleDataField instances, or NULL. */
static DataFieldSet* s_identFields; static DataFieldSet* s_identFields;
@@ -613,17 +596,14 @@ private:
/** whether all fields have a unique name. */ /** whether all fields have a unique name. */
bool m_uniqueNames; bool m_uniqueNames;
}; };
/** /**
* A map of template @a DataField instances. * A map of template @a DataField instances.
*/ */
class DataFieldTemplates : public FileReader class DataFieldTemplates : public FileReader {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
*/ */
@@ -670,11 +650,10 @@ public:
*/ */
DataField* get(string name); DataField* get(string name);
private:
private:
/** the known template @a DataField instances by name. */ /** the known template @a DataField instances by name. */
map<string, DataField*> m_fieldsByName; map<string, DataField*> m_fieldsByName;
}; };
#endif // LIB_EBUS_DATA_H_ #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; output << m_id;
if (isAdjustableLength()) { if (isAdjustableLength()) {
if (length == REMAIN_LEN) { 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)); ch = (unsigned char)((ch >> 4) * 10 + (ch & 0x0f));
} }
switch (type) switch (type) {
{
case 2: // date only case 2: // date only
if (!hasFlag(REQ) && ch == m_replacement) { if (!hasFlag(REQ) && ch == m_replacement) {
if (i + 1 != length) { if (i + 1 != length) {
@@ -440,10 +438,9 @@ result_t DateTimeDataType::writeSymbols(istringstream& input,
size_t i = 0, offset; size_t i = 0, offset;
int type = (m_hasDate?2:0) | (m_hasTime?1:0); int type = (m_hasDate?2:0) | (m_hasTime?1:0);
bool skip = false; 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; skip = false;
switch (type) switch (type) {
{
case 2: // date only case 2: // date only
if (length == 4 && i == 2) { if (length == 4 && i == 2) {
continue; // skip weekday in between continue; // skip weekday in between
@@ -584,8 +581,7 @@ unsigned char NumberDataType::calcPrecision(const int divisor) {
return precision; return precision;
} }
bool NumberDataType::dump(ostream& output, unsigned char length) const bool NumberDataType::dump(ostream& output, unsigned char length) const {
{
if (m_bitCount < 8) { if (m_bitCount < 8) {
DataType::dump(output, m_bitCount); DataType::dump(output, m_bitCount);
} else { } 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. * Base class for all kinds of data types.
*/ */
class DataType class DataType {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param id the type identifier. * @param id the type identifier.
@@ -251,8 +249,8 @@ public:
const unsigned char offset, const unsigned char length, const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength) = 0; SymbolString& output, const bool isMaster, unsigned char* usedLength) = 0;
protected:
protected:
/** the type identifier. */ /** the type identifier. */
const string m_id; 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). */ /** the replacement value (fill-up value for @a StringDataType, no replacement if equal to @a NumberDataType#minValue). */
const unsigned int m_replacement; const unsigned int m_replacement;
}; };
/** /**
* A string based @a DataType. * A string based @a DataType.
*/ */
class StringDataType : public DataType class StringDataType : public DataType {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param id the type identifier. * @param id the type identifier.
@@ -307,21 +302,18 @@ public:
const unsigned char offset, const unsigned char length, const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** true for hex digits instead of characters. */ /** true for hex digits instead of characters. */
const bool m_isHex; const bool m_isHex;
}; };
/** /**
* A date/time based @a DataType. * A date/time based @a DataType.
*/ */
class DateTimeDataType : public DataType class DateTimeDataType : public DataType {
{ public:
public:
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param id the type identifier. * @param id the type identifier.
@@ -371,8 +363,8 @@ public:
const unsigned char offset, const unsigned char length, const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** true if date part is present. */ /** true if date part is present. */
const bool m_hasDate; const bool m_hasDate;
@@ -381,17 +373,14 @@ private:
/** the resolution in minutes for time types, or 1. */ /** the resolution in minutes for time types, or 1. */
const short m_resolution; const short m_resolution;
}; };
/** /**
* A number based @a DataType. * A number based @a DataType.
*/ */
class NumberDataType : public DataType class NumberDataType : public DataType {
{ public:
public:
/** /**
* Constructs a new instance for multiple of 8 bits. * Constructs a new instance for multiple of 8 bits.
* @param id the type identifier. * @param id the type identifier.
@@ -501,8 +490,8 @@ public:
const unsigned char offset, const unsigned char length, const unsigned char offset, const unsigned char length,
SymbolString& output, const bool isMaster, unsigned char* usedLength); SymbolString& output, const bool isMaster, unsigned char* usedLength);
private:
private:
/** the minimum raw value. */ /** the minimum raw value. */
const unsigned int m_minValue; const unsigned int m_minValue;
@@ -520,17 +509,14 @@ private:
/** the base @a NumberDataType for derived instances. */ /** the base @a NumberDataType for derived instances. */
NumberDataType* m_baseType; NumberDataType* m_baseType;
}; };
/** /**
* A map of base @a DataType instances. * A map of base @a DataType instances.
*/ */
class DataTypeList class DataTypeList {
{ public:
public:
/** /**
* Constructs a new instance and registers the known base data types. * 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); DataType* get(const string id, const unsigned char length = 0);
private:
private:
/** the known @a DataType instances by ID only. */ /** the known @a DataType instances by ID only. */
map<string, DataType*> m_typesById; map<string, DataType*> m_typesById;
@@ -596,7 +582,6 @@ private:
/** true when contributed datatypes were successfully initialized. */ /** true when contributed datatypes were successfully initialized. */
static bool s_contrib_initialized; static bool s_contrib_initialized;
#endif #endif
}; };
#endif // LIB_EBUS_DATATYPE_H_ #endif // LIB_EBUS_DATATYPE_H_
+2 -1
View File
@@ -269,7 +269,8 @@ result_t NetworkDevice::open() {
if (ioctl(m_fd, FIONREAD, &cnt) >= 0 && cnt > 1) { if (ioctl(m_fd, FIONREAD, &cnt) >= 0 && cnt > 1) {
// skip buffered input // skip buffered input
unsigned char buf[256]; unsigned char buf[256];
while (::read(m_fd, &buf, 256) > 0); while (::read(m_fd, &buf, 256) > 0) {
}
} }
if (m_bufSize == 0) { if (m_bufSize == 0) {
m_bufSize = MAX_LEN+1; 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. * Interface for listening to data received on/sent to a device.
*/ */
class DeviceListener class DeviceListener {
{ public:
public:
/** /**
* Destructor. * Destructor.
*/ */
@@ -56,17 +54,14 @@ public:
* @param received @a true on reception, @a false on sending. * @param received @a true on reception, @a false on sending.
*/ */
virtual void notifyDeviceData(const unsigned char byte, bool received) = 0; // abstract virtual void notifyDeviceData(const unsigned char byte, bool received) = 0; // abstract
}; };
/** /**
* The base class for accessing an eBUS. * The base class for accessing an eBUS.
*/ */
class Device class Device {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). * @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; } void setListener(DeviceListener* listener) { m_listener = listener; }
protected:
protected:
/** /**
* Check if the device is still available and close it if not. * 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); } 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). */ /** the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). */
const char* m_name; const char* m_name;
@@ -192,19 +187,17 @@ protected:
/** the opened file descriptor, or -1. */ /** the opened file descriptor, or -1. */
int m_fd; int m_fd;
private:
private:
/** the @a DeviceListener, or NULL. */ /** the @a DeviceListener, or NULL. */
DeviceListener* m_listener; DeviceListener* m_listener;
}; };
/** /**
* The @a Device for directly connected serial interfaces (tty). * The @a Device for directly connected serial interfaces (tty).
*/ */
class SerialDevice : public Device class SerialDevice : public Device {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). * @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network).
@@ -221,22 +214,22 @@ public:
// @copydoc // @copydoc
virtual void close(); virtual void close();
protected:
protected:
// @copydoc // @copydoc
virtual void checkDevice(); virtual void checkDevice();
private:
private:
/** the previous settings of the device for restoring. */ /** the previous settings of the device for restoring. */
termios m_oldSettings; termios m_oldSettings;
}; };
/** /**
* The @a Device for remote network interfaces. * The @a Device for remote network interfaces.
*/ */
class NetworkDevice : public Device class NetworkDevice : public Device {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). * @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network).
@@ -256,7 +249,8 @@ public:
// @copydoc // @copydoc
virtual result_t open(); virtual result_t open();
protected:
protected:
// @copydoc // @copydoc
virtual void checkDevice(); virtual void checkDevice();
@@ -269,7 +263,8 @@ protected:
// @copydoc // @copydoc
virtual ssize_t read(unsigned char& value); virtual ssize_t read(unsigned char& value);
private:
private:
/** the socket address of the device. */ /** the socket address of the device. */
const struct sockaddr_in m_address; const struct sockaddr_in m_address;
@@ -287,7 +282,6 @@ private:
/** the buffer read position. */ /** the buffer read position. */
unsigned char m_bufPos; unsigned char m_bufPos;
}; };
#endif // LIB_EBUS_DEVICE_H_ #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. * An abstract class that support reading definitions from a file.
*/ */
class FileReader class FileReader {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
*/ */
@@ -85,8 +83,7 @@ public:
* @return @a RESULT_OK on success, or an error code. * @return @a RESULT_OK on success, or an error code.
*/ */
virtual result_t readFromFile(const string filename, bool verbose = false, virtual result_t readFromFile(const string filename, bool verbose = false,
string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "") string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "") {
{
ifstream ifs; ifstream ifs;
ifs.open(filename.c_str(), ifstream::in); ifs.open(filename.c_str(), ifstream::in);
if (!ifs.is_open()) { if (!ifs.is_open()) {
@@ -177,8 +174,7 @@ public:
*/ */
virtual result_t addDefaultFromFile(vector< vector<string> >& defaults, vector<string>& row, virtual result_t addDefaultFromFile(vector< vector<string> >& defaults, vector<string>& row,
vector<string>::iterator& begin, string defaultDest, string defaultCircuit, string defaultSuffix, 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); defaults.push_back(row);
begin = row.end(); begin = row.end();
return RESULT_OK; return RESULT_OK;
@@ -204,8 +200,7 @@ public:
* Left and right trim the string. * Left and right trim the string.
* @param str the @a string to trim. * @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"); size_t pos = str.find_first_not_of(" \t");
if (pos != string::npos) { if (pos != string::npos) {
str.erase(0, pos); str.erase(0, pos);
@@ -220,8 +215,7 @@ public:
* Convert all upper case characters in the string to lower case. * Convert all upper case characters in the string to lower case.
* @param str the @a string to convert. * @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); transform(str.begin(), str.end(), str.begin(), ::tolower);
} }
@@ -232,8 +226,7 @@ public:
* @param lineNo the current line number (incremented with each line read). * @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. * @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(); row.clear();
string line; string line;
bool quotedText = false, wasQuoted = false; bool quotedText = false, wasQuoted = false;
@@ -251,8 +244,7 @@ public:
} }
for (size_t pos = 0; pos < length; pos++) { for (size_t pos = 0; pos < length; pos++) {
char ch = line[pos]; char ch = line[pos];
switch (ch) switch (ch) {
{
case FIELD_SEPARATOR: case FIELD_SEPARATOR:
if (quotedText) { if (quotedText) {
field << ch; field << ch;
@@ -317,8 +309,7 @@ public:
* @return true if at least the address and the identification part were extracted, false otherwise. * @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, 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 = ""; ident = circuit = suffix = "";
software = hardware = UINT_MAX; software = hardware = UINT_MAX;
if (name.length() > 4 && name.substr(name.length()-4) == ".csv") { if (name.length() > 4 && name.substr(name.length()-4) == ".csv") {
@@ -374,16 +365,15 @@ public:
return true; return true;
} }
private:
private:
/** whether this instance supports rows with defaults (starting with a star). */ /** whether this instance supports rows with defaults (starting with a star). */
bool m_supportsDefaults; bool m_supportsDefaults;
protected:
protected:
/** a @a string describing the last error position. */ /** a @a string describing the last error position. */
string m_lastError; string m_lastError;
}; };
#endif // LIB_EBUS_FILEREADER_H_ #endif // LIB_EBUS_FILEREADER_H_
+2 -3
View File
@@ -834,8 +834,7 @@ ChainedMessage::ChainedMessage(const string circuit, const string name,
srcAddress, dstAddress, id, srcAddress, dstAddress, id,
data, deleteData, pollPriority, condition), data, deleteData, pollPriority, condition),
m_ids(ids), m_lengths(lengths), 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(); size_t cnt = ids.size();
m_lastMasterDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*)); m_lastMasterDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*));
m_lastSlaveDatas = (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 { } else {
Message* first = getFirstAvailable(*derived, message); Message* first = getFirstAvailable(*derived, message);
if (first == NULL) { 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; return RESULT_ERR_INVALID_ARG;
} }
message = first; message = first;
+50 -81
View File
@@ -93,11 +93,9 @@ class MessageMap;
/** /**
* Defines parameters of a message sent or received on the bus. * Defines parameters of a message sent or received on the bus.
*/ */
class Message class Message {
{
friend class MessageMap; friend class MessageMap;
public: public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param circuit the optional circuit name. * @param circuit the optional circuit name.
@@ -122,7 +120,8 @@ public:
const unsigned char pollPriority = 0, const unsigned char pollPriority = 0,
Condition* condition = NULL); Condition* condition = NULL);
private:
private:
/** /**
* Construct a new scan @a Message instance. * Construct a new scan @a Message instance.
* @param circuit the circuit name, or empty for not storing by name. * @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, const unsigned char pb, const unsigned char sb,
DataField* data, const bool deleteData); DataField* data, const bool deleteData);
public:
public:
/** /**
* Destructor. * Destructor.
*/ */
@@ -394,8 +394,8 @@ public:
istringstream& input, char separator = UI_FIELD_SEPARATOR, istringstream& input, char separator = UI_FIELD_SEPARATOR,
const unsigned char dstAddress = SYN, unsigned char index = 0); 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). * 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. * @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); 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. * Prepare the slave @a SymbolString for sending an answer to the bus.
* @param input the @a istringstream to parse the formatted value(s) from. * @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); virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false);
protected:
protected:
/** the optional circuit name. */ /** the optional circuit name. */
const string m_circuit; const string m_circuit;
@@ -606,17 +606,14 @@ protected:
/** the system time when this message was last polled for, 0 for never. */ /** the system time when this message was last polled for, 0 for never. */
time_t m_lastPollTime; time_t m_lastPollTime;
}; };
/** /**
* A chained @a Message that needs more than one read/write on the bus to collect/send the data. * A chained @a Message that needs more than one read/write on the bus to collect/send the data.
*/ */
class ChainedMessage : public Message class ChainedMessage : public Message {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param circuit the optional circuit name. * @param circuit the optional circuit name.
@@ -659,26 +656,26 @@ public:
// @copydoc // @copydoc
virtual unsigned char getCount() { return (unsigned char)m_ids.size(); } virtual unsigned char getCount() { return (unsigned char)m_ids.size(); }
protected:
protected:
// @copydoc // @copydoc
virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index); virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index);
public:
public:
// @copydoc // @copydoc
virtual result_t storeLastData(SymbolString& master, SymbolString& slave); virtual result_t storeLastData(SymbolString& master, SymbolString& slave);
// @copydoc // @copydoc
virtual result_t storeLastData(const PartType partType, SymbolString& data, unsigned char index); virtual result_t storeLastData(const PartType partType, SymbolString& data, unsigned char index);
protected:
protected:
// @copydoc // @copydoc
virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false); 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. */ /** the primary, secondary, and optional further ID bytes for each part of the chain. */
const vector< vector<unsigned char> > m_ids; 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. */ /** array of the system times when the corresponding slave data was last updated, 0 for never. */
time_t* m_lastSlaveUpdateTimes; time_t* m_lastSlaveUpdateTimes;
}; };
/** /**
* A function that compares the weighted poll priority of two @a Message instances. * 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. * Compare the weighted poll priority of the two @a Message instances.
* @param x the first @a Message. * @param x the first @a Message.
* @param y the second @a Message. * @param y the second @a Message.
* @return whether @a x is smaller than @a y with regard to their weighted poll priority. * @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. * Helper class extending @a priority_queue to hold distinct values only.
*/ */
class MessagePriorityQueue class MessagePriorityQueue
: public priority_queue<Message*, vector<Message*>, compareMessagePriority> : public priority_queue<Message*, vector<Message*>, compareMessagePriority> {
{ public:
public:
/** /**
* Add data to the queue and ensure it is contained only once. * Add data to the queue and ensure it is contained only once.
* @param __x the element to add. * @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++) { for (vector<Message*>::iterator it = c.begin(); it != c.end(); it++) {
if (*it == __x) { if (*it == __x) {
c.erase(it); c.erase(it);
@@ -744,10 +738,8 @@ public:
/** /**
* An abstract condition based on the value of one or more @a Message instances. * An abstract condition based on the value of one or more @a Message instances.
*/ */
class Condition class Condition {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
*/ */
@@ -776,7 +768,7 @@ public:
* @param valueList the @a string with the new list of values. * @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. * @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. * Write the condition definition or resolved expression to the @a ostream.
@@ -807,24 +799,21 @@ public:
*/ */
virtual bool isTrue() = 0; virtual bool isTrue() = 0;
protected:
protected:
/** the system time when the condition was last checked, 0 for never. */ /** the system time when the condition was last checked, 0 for never. */
time_t m_lastCheckTime; time_t m_lastCheckTime;
/** whether the condition was @a true during the last check. */ /** whether the condition was @a true during the last check. */
bool m_isTrue; bool m_isTrue;
}; };
/** /**
* A simple @a Condition based on the value of one @a Message. * A simple @a Condition based on the value of one @a Message.
*/ */
class SimpleCondition : public Condition class SimpleCondition : public Condition {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param condName the name of the condition. * @param condName the name of the condition.
@@ -865,8 +854,8 @@ public:
*/ */
virtual bool isNumeric() { return true; } virtual bool isNumeric() { return true; }
protected:
protected:
/** /**
* Check the values against the field in the @a Message. * Check the values against the field in the @a Message.
* @param message the @a Message to check against. * @param message the @a Message to check against.
@@ -878,8 +867,8 @@ protected:
/** the value that matched in @a checkValue. */ /** the value that matched in @a checkValue. */
string m_matchedValue; string m_matchedValue;
private:
private:
/** the condition name. */ /** the condition name. */
const string m_condName; const string m_condName;
@@ -903,17 +892,14 @@ private:
/** the resolved @a Message instance, or NULL. */ /** the resolved @a Message instance, or NULL. */
Message* m_message; Message* m_message;
}; };
/** /**
* A simple @a Condition based on the numeric value of one @a Message. * A simple @a Condition based on the numeric value of one @a Message.
*/ */
class SimpleNumericCondition : public SimpleCondition class SimpleNumericCondition : public SimpleCondition {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param condName the name of the condition. * @param condName the name of the condition.
@@ -933,26 +919,23 @@ public:
*/ */
virtual ~SimpleNumericCondition() {} virtual ~SimpleNumericCondition() {}
protected:
protected:
// @copydoc // @copydoc
virtual bool checkValue(Message* message, const string field); 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. */ /** the valid value ranges (pairs of from/to inclusive), empty for @a m_message seen check. */
const vector<unsigned int> m_valueRanges; const vector<unsigned int> m_valueRanges;
}; };
/** /**
* A simple @a Condition based on the string value of one @a Message. * A simple @a Condition based on the string value of one @a Message.
*/ */
class SimpleStringCondition : public SimpleCondition class SimpleStringCondition : public SimpleCondition {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param condName the name of the condition. * @param condName the name of the condition.
@@ -975,26 +958,23 @@ public:
// @copydoc // @copydoc
virtual bool isNumeric() { return false; } virtual bool isNumeric() { return false; }
protected:
protected:
// @copydoc // @copydoc
virtual bool checkValue(Message* message, const string field); virtual bool checkValue(Message* message, const string field);
private:
private:
/** the valid values. */ /** the valid values. */
const vector<string> m_values; const vector<string> m_values;
}; };
/** /**
* A @a Condition combining two or more @a SimpleCondition instances with a logical and. * A @a Condition combining two or more @a SimpleCondition instances with a logical and.
*/ */
class CombinedCondition : public Condition class CombinedCondition : public Condition {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
*/ */
@@ -1018,21 +998,18 @@ public:
// @copydoc // @copydoc
virtual bool isTrue(); virtual bool isTrue();
private:
private:
/** the @a Condition instances used. */ /** the @a Condition instances used. */
vector<Condition*> m_conditions; vector<Condition*> m_conditions;
}; };
/** /**
* An abstract instruction based on the value of one or more @a Message instances. * An abstract instruction based on the value of one or more @a Message instances.
*/ */
class Instruction class Instruction {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param condition the @a Condition this instruction requires, or null. * @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; virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition) = 0;
private:
private:
/** the @a Condition this instruction requires, or null. */ /** the @a Condition this instruction requires, or null. */
Condition* m_condition; 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. */ /** 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; bool m_singleton;
protected:
protected:
/** the default destination address, or empty. */ /** the default destination address, or empty. */
const string m_defaultDest; const string m_defaultDest;
@@ -1110,17 +1087,14 @@ protected:
/** the default circuit name suffix (starting with a "."), or empty. */ /** the default circuit name suffix (starting with a "."), or empty. */
const string m_defaultSuffix; const string m_defaultSuffix;
}; };
/** /**
* An @a Instruction allowing to load another file. * An @a Instruction allowing to load another file.
*/ */
class LoadInstruction : public Instruction class LoadInstruction : public Instruction {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param condition the @a Condition this instruction requires, or null. * @param condition the @a Condition this instruction requires, or null.
@@ -1141,28 +1115,24 @@ public:
// @copydoc // @copydoc
virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition); virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition);
private:
private:
/** the name of the file to load. */ /** the name of the file to load. */
const string m_filename; const string m_filename;
}; };
/** /**
* Holds a map of all known @a Message instances. * Holds a map of all known @a Message instances.
*/ */
class MessageMap : public FileReader class MessageMap : public FileReader {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param addAll whether to add all messages, even if duplicate. * @param addAll whether to add all messages, even if duplicate.
*/ */
MessageMap(const bool addAll = false) : FileReader::FileReader(true), 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(); m_scanMessage = Message::createScanMessage();
} }
@@ -1368,8 +1338,8 @@ public:
*/ */
void dump(ostream& output, bool withConditions = false); void dump(ostream& output, bool withConditions = false);
private:
private:
/** whether to add all messages, even if duplicate. */ /** whether to add all messages, even if duplicate. */
const bool m_addAll; const bool m_addAll;
@@ -1405,7 +1375,6 @@ private:
/** the list of @a Instruction instances by filename. */ /** the list of @a Instruction instances by filename. */
map<string, vector<Instruction*> > m_instructions; map<string, vector<Instruction*> > m_instructions;
}; };
#endif // LIB_EBUS_MESSAGE_H_ #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. * 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, 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, 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, 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. * @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) { unsigned char getMasterPartIndex(unsigned char bits) {
switch (bits) switch (bits) {
{
case 0x0: case 0x0:
return 1; return 1;
case 0x1: 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. * A string of escaped or unescaped bus symbols.
*/ */
class SymbolString class SymbolString {
{ public:
public:
/** /**
* Creates a new empty escaped or unescaped instance. * Creates a new empty escaped or unescaped instance.
* @param escaped whether to create an escaped 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; } void clear(const bool escape) { m_data.clear(); m_unescapeState = escape ? 0 : 1; m_crc = 0; }
private:
private:
/** /**
* Hidden copy constructor. * Hidden copy constructor.
* @param str the @a SymbolString to copy from. * @param str the @a SymbolString to copy from.
+125 -125
View File
@@ -86,31 +86,31 @@ int main() {
{"x,,hex:5, == 48 61 6c 6c 6f", "", "10fe070005ababababab", "00", "rW"}, {"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,,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", "26.10.2014", "10fe07000426100614", "00", ""}, // Sunday
{"x,,bda", "01.01.2000","10fe07000401010500", "00", ""}, // Saturday {"x,,bda", "01.01.2000", "10fe07000401010500", "00", ""}, // Saturday
{"x,,bda", "31.12.2099","10fe07000431120399", "00", ""}, // Thursday {"x,,bda", "31.12.2099", "10fe07000431120399", "00", ""}, // Thursday
{"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""}, {"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"x,,bda", "", "10fe07000432100014", "00", "rw"}, {"x,,bda", "", "10fe07000432100014", "00", "rw"},
{"x,,bda:3", "26.10.2014","10fe070003261014", "00", ""}, {"x,,bda:3", "26.10.2014", "10fe070003261014", "00", ""},
{"x,,bda:3", "01.01.2000","10fe070003010100", "00", ""}, {"x,,bda:3", "01.01.2000", "10fe070003010100", "00", ""},
{"x,,bda:3", "31.12.2099","10fe070003311299", "00", ""}, {"x,,bda:3", "31.12.2099", "10fe070003311299", "00", ""},
{"x,,bda:3", "-.-.-", "10fe070003ffffff", "00", ""}, {"x,,bda:3", "-.-.-", "10fe070003ffffff", "00", ""},
{"x,,bda:3", "", "10fe070003321299", "00", "rw"}, {"x,,bda:3", "", "10fe070003321299", "00", "rw"},
{"x,,bda,2", "", "", "", "c"}, {"x,,bda,2", "", "", "", "c"},
{"x,,hda", "26.10.2014","10fe0700041a0a070e", "00", ""}, // Sunday {"x,,hda", "26.10.2014", "10fe0700041a0a070e", "00", ""}, // Sunday
{"x,,hda", "01.01.2000","10fe07000401010600", "00", ""}, // Saturday {"x,,hda", "01.01.2000", "10fe07000401010600", "00", ""}, // Saturday
{"x,,hda", "31.12.2099","10fe0700041f0c0463", "00", ""}, // Thursday {"x,,hda", "31.12.2099", "10fe0700041f0c0463", "00", ""}, // Thursday
{"x,,hda", "-.-.-", "10fe070004ffff00ff", "00", ""}, {"x,,hda", "-.-.-", "10fe070004ffff00ff", "00", ""},
{"x,,hda", "", "10fe070004200c0463", "00", "rw"}, {"x,,hda", "", "10fe070004200c0463", "00", "rw"},
{"x,,hda:3", "26.10.2014","10fe0700031a0a0e", "00", ""}, {"x,,hda:3", "26.10.2014", "10fe0700031a0a0e", "00", ""},
{"x,,hda:3", "01.01.2000","10fe070003010100", "00", ""}, {"x,,hda:3", "01.01.2000", "10fe070003010100", "00", ""},
{"x,,hda:3", "31.12.2099","10fe0700031f0c63", "00", ""}, {"x,,hda:3", "31.12.2099", "10fe0700031f0c63", "00", ""},
{"x,,hda:3", "-.-.-", "10fe070003ffffff", "00", ""}, {"x,,hda:3", "-.-.-", "10fe070003ffffff", "00", ""},
{"x,,hda:3", "", "10fe070003200c63", "00", "rw"}, {"x,,hda:3", "", "10fe070003200c63", "00", "rw"},
{"x,,hda,2", "", "", "", "c"}, {"x,,hda,2", "", "", "", "c"},
{"x,,day", "26.10.2014","10fe070002d0a3", "00", ""}, {"x,,day", "26.10.2014", "10fe070002d0a3", "00", ""},
{"x,,day", "01.01.2000","10fe070002ac8e", "00", ""}, {"x,,day", "01.01.2000", "10fe070002ac8e", "00", ""},
{"x,,day", "31.12.2078","10fe07000262ff", "00", ""}, {"x,,day", "31.12.2078", "10fe07000262ff", "00", ""},
{"x,,day", "-.-.-", "10fe070002ffff", "00", ""}, {"x,,day", "-.-.-", "10fe070002ffff", "00", ""},
{"x,,day", "", "10fe0700020000", "00", "Rw"}, {"x,,day", "", "10fe0700020000", "00", "Rw"},
{"x,,bti", "21:04:58", "10fe070003580421", "00", ""}, {"x,,bti", "21:04:58", "10fe070003580421", "00", ""},
@@ -191,9 +191,9 @@ int main() {
{"x,,hdy", "Mon", "10fe07000101", "00", ""}, {"x,,hdy", "Mon", "10fe07000101", "00", ""},
{"x,,hdy", "Sun", "10fe07000107", "00", ""}, {"x,,hdy", "Sun", "10fe07000107", "00", ""},
{"x,,hdy", "8", "10fe07000108", "00", "w"}, {"x,,hdy", "8", "10fe07000108", "00", "w"},
{"x,,pin","1234", "10feffff021234", "00", ""}, {"x,,pin", "1234", "10feffff021234", "00", ""},
{"x,,pin","0000", "10feffff020000", "00", ""}, {"x,,pin", "0000", "10feffff020000", "00", ""},
{"x,,pin","9999", "10feffff029999", "00", ""}, {"x,,pin", "9999", "10feffff029999", "00", ""},
{"x,,pin", "", "10feffff020000", "00", "Rw"}, {"x,,pin", "", "10feffff020000", "00", "Rw"},
{"x,,pin", "100", "10feffff020100", "00", "R"}, {"x,,pin", "100", "10feffff020100", "00", "R"},
{"x,,bcd", "26", "10feffff0126", "00", ""}, {"x,,bcd", "26", "10feffff0126", "00", ""},
@@ -202,30 +202,30 @@ int main() {
{"x,,bcd", "100", "10feffff0199", "00", "Rw"}, {"x,,bcd", "100", "10feffff0199", "00", "Rw"},
{"x,,bcd", "-", "10feffff01ff", "00", ""}, {"x,,bcd", "-", "10feffff01ff", "00", ""},
{"x,,bcd", "", "10feffff019a", "00", "rw"}, {"x,,bcd", "", "10feffff019a", "00", "rw"},
{"x,,bcd:1","26", "10feffff0126", "00", ""}, {"x,,bcd:1", "26", "10feffff0126", "00", ""},
{"x,,bcd:1","0", "10feffff0100", "00", ""}, {"x,,bcd:1", "0", "10feffff0100", "00", ""},
{"x,,bcd:1","99", "10feffff0199", "00", ""}, {"x,,bcd:1", "99", "10feffff0199", "00", ""},
{"x,,bcd:1","100", "10feffff0199", "00", "Rw"}, {"x,,bcd:1", "100", "10feffff0199", "00", "Rw"},
{"x,,bcd:1","-", "10feffff01ff", "00", ""}, {"x,,bcd:1", "-", "10feffff01ff", "00", ""},
{"x,,bcd:1","", "10feffff019a", "00", "rw"}, {"x,,bcd:1", "", "10feffff019a", "00", "rw"},
{"x,,bcd:2","126", "10feffff022601", "00", ""}, {"x,,bcd:2", "126", "10feffff022601", "00", ""},
{"x,,bcd:2","0", "10feffff020000", "00", ""}, {"x,,bcd:2", "0", "10feffff020000", "00", ""},
{"x,,bcd:2","9999", "10feffff029999", "00", ""}, {"x,,bcd:2", "9999", "10feffff029999", "00", ""},
{"x,,bcd:2","10000","10feffff029999", "00", "Rw"}, {"x,,bcd:2", "10000", "10feffff029999", "00", "Rw"},
{"x,,bcd:2","-", "10feffff02ffff", "00", ""}, {"x,,bcd:2", "-", "10feffff02ffff", "00", ""},
{"x,,bcd:2","", "10feffff029a00", "00", "rw"}, {"x,,bcd:2", "", "10feffff029a00", "00", "rw"},
{"x,,bcd:3","12346", "10feffff03462301", "00", ""}, {"x,,bcd:3", "12346", "10feffff03462301", "00", ""},
{"x,,bcd:3","0", "10feffff03000000", "00", ""}, {"x,,bcd:3", "0", "10feffff03000000", "00", ""},
{"x,,bcd:3","999999", "10feffff03999999", "00", ""}, {"x,,bcd:3", "999999", "10feffff03999999", "00", ""},
{"x,,bcd:3","1000000","10feffff03999999", "00", "Rw"}, {"x,,bcd:3", "1000000", "10feffff03999999", "00", "Rw"},
{"x,,bcd:3","-", "10feffff03ffffff", "00", ""}, {"x,,bcd:3", "-", "10feffff03ffffff", "00", ""},
{"x,,bcd:3","", "10feffff03009a00", "00", "rw"}, {"x,,bcd:3", "", "10feffff03009a00", "00", "rw"},
{"x,,bcd:4","1234567", "10feffff0467452301", "00", ""}, {"x,,bcd:4", "1234567", "10feffff0467452301", "00", ""},
{"x,,bcd:4","0", "10feffff0400000000", "00", ""}, {"x,,bcd:4", "0", "10feffff0400000000", "00", ""},
{"x,,bcd:4","99999999", "10feffff0499999999", "00", ""}, {"x,,bcd:4", "99999999", "10feffff0499999999", "00", ""},
{"x,,bcd:4","100000000","10feffff0499999999", "00", "Rw"}, {"x,,bcd:4", "100000000", "10feffff0499999999", "00", "Rw"},
{"x,,bcd:4","-", "10feffff04ffffffff", "00", ""}, {"x,,bcd:4", "-", "10feffff04ffffffff", "00", ""},
{"x,,bcd:4","", "10feffff0400009a00", "00", "rw"}, {"x,,bcd:4", "", "10feffff0400009a00", "00", "rw"},
{"x,,hcd:1", "26", "10feffff011a", "00", ""}, {"x,,hcd:1", "26", "10feffff011a", "00", ""},
{"x,,hcd:1", "0", "10feffff0100", "00", ""}, {"x,,hcd:1", "0", "10feffff0100", "00", ""},
{"x,,hcd:1", "99", "10feffff0163", "00", ""}, {"x,,hcd:1", "99", "10feffff0163", "00", ""},
@@ -236,33 +236,33 @@ int main() {
{"x,,hcd:2", "9999", "10feffff026363", "00", ""}, {"x,,hcd:2", "9999", "10feffff026363", "00", ""},
{"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"}, {"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"},
{"x,,hcd:2", "", "10feffff029a00", "00", "rw"}, {"x,,hcd:2", "", "10feffff029a00", "00", "rw"},
{"x,,hcd:3","12346", "10feffff032e1701", "00", ""}, {"x,,hcd:3", "12346", "10feffff032e1701", "00", ""},
{"x,,hcd:3","0", "10feffff03000000", "00", ""}, {"x,,hcd:3", "0", "10feffff03000000", "00", ""},
{"x,,hcd:3","999999", "10feffff03636363", "00", ""}, {"x,,hcd:3", "999999", "10feffff03636363", "00", ""},
{"x,,hcd:3","1000000", "10feffff03636363", "00", "Rw"}, {"x,,hcd:3", "1000000", "10feffff03636363", "00", "Rw"},
{"x,,hcd:3","", "10feffff03009a00", "00", "rw"}, {"x,,hcd:3", "", "10feffff03009a00", "00", "rw"},
{"x,,hcd:4","1234567", "10feffff04432d1701", "00", ""}, {"x,,hcd:4", "1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd:4","0", "10feffff0400000000", "00", ""}, {"x,,hcd:4", "0", "10feffff0400000000", "00", ""},
{"x,,hcd:4","99999999", "10feffff0463636363", "00", ""}, {"x,,hcd:4", "99999999", "10feffff0463636363", "00", ""},
{"x,,hcd:4","100000000","10feffff0463636363", "00", "Rw"}, {"x,,hcd:4", "100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd","", "10feffff0400006400", "00", "rw"}, {"x,,hcd", "", "10feffff0400006400", "00", "rw"},
{"x,,hcd","1234567", "10feffff04432d1701", "00", ""}, {"x,,hcd", "1234567", "10feffff04432d1701", "00", ""},
{"x,,hcd","0", "10feffff0400000000", "00", ""}, {"x,,hcd", "0", "10feffff0400000000", "00", ""},
{"x,,hcd","99999999", "10feffff0463636363", "00", ""}, {"x,,hcd", "99999999", "10feffff0463636363", "00", ""},
{"x,,hcd","100000000", "10feffff0463636363", "00", "Rw"}, {"x,,hcd", "100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd","", "10feffff0400006400", "00", "rw"}, {"x,,hcd", "", "10feffff0400006400", "00", "rw"},
{"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""}, {"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""},
{"x,,uch:17", "", "10feffff00", "00", "c"}, {"x,,uch:17", "", "10feffff00", "00", "c"},
{"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"}, {"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"},
{"x,s,uch", "0", "1025ffff00", "0100", ""}, {"x,s,uch", "0", "1025ffff00", "0100", ""},
{"x,s,uch,,,,y,m,uch", "3;2","1025ffff0103", "0102", ""}, {"x,s,uch,,,,y,m,uch", "3;2", "1025ffff0103", "0102", ""},
{"x,,uch", "38", "10feffff0126", "00", ""}, {"x,,uch", "38", "10feffff0126", "00", ""},
{"x,,uch", "38.5", "10feffff0126", "00", "R"}, {"x,,uch", "38.5", "10feffff0126", "00", "R"},
{"x,,uch", "0", "10feffff0100", "00", ""}, {"x,,uch", "0", "10feffff0100", "00", ""},
{"x,,uch", "254", "10feffff01fe", "00", ""}, {"x,,uch", "254", "10feffff01fe", "00", ""},
{"x,,uch", "-", "10feffff01ff", "00", ""}, {"x,,uch", "-", "10feffff01ff", "00", ""},
{"x,,uch,10", "3.8", "10feffff0126", "00", ""}, {"x,,uch,10", "3.8", "10feffff0126", "00", ""},
{"x,,uch,-10", "380","10feffff0126", "00", ""}, {"x,,uch,-10", "380", "10feffff0126", "00", ""},
{"x,,uch,=48", "", "10feffff01ab", "00", "W"}, {"x,,uch,=48", "", "10feffff01ab", "00", "W"},
{"x,,uch, == 48", "", "10feffff01ab", "00", "rW"}, {"x,,uch, == 48", "", "10feffff01ab", "00", "rW"},
{"x,,uch,=48", "", "10feffff0130", "00", ""}, {"x,,uch,=48", "", "10feffff0130", "00", ""},
@@ -273,15 +273,15 @@ int main() {
{"x,,sch", "-", "10feffff0180", "00", ""}, {"x,,sch", "-", "10feffff0180", "00", ""},
{"x,,sch", "-127", "10feffff0181", "00", ""}, {"x,,sch", "-127", "10feffff0181", "00", ""},
{"x,,sch", "127", "10feffff017f", "00", ""}, {"x,,sch", "127", "10feffff017f", "00", ""},
{"x,,sch,10", "-9.0","10feffff01a6", "00", ""}, {"x,,sch,10", "-9.0", "10feffff01a6", "00", ""},
{"x,,sch,-10","-900","10feffff01a6", "00", ""}, {"x,,sch,-10", "-900", "10feffff01a6", "00", ""},
{"x,,d1b", "-90", "10feffff01a6", "00", ""}, {"x,,d1b", "-90", "10feffff01a6", "00", ""},
{"x,,d1b", "0", "10feffff0100", "00", ""}, {"x,,d1b", "0", "10feffff0100", "00", ""},
{"x,,d1b", "-1", "10feffff01ff", "00", ""}, {"x,,d1b", "-1", "10feffff01ff", "00", ""},
{"x,,d1b", "-", "10feffff0180", "00", ""}, {"x,,d1b", "-", "10feffff0180", "00", ""},
{"x,,d1b", "-127", "10feffff0181", "00", ""}, {"x,,d1b", "-127", "10feffff0181", "00", ""},
{"x,,d1b", "127", "10feffff017f", "00", ""}, {"x,,d1b", "127", "10feffff017f", "00", ""},
{"x,,d1b,-10","-900","10feffff01a6", "00", ""}, {"x,,d1b,-10", "-900", "10feffff01a6", "00", ""},
{"x,,d1c", "19.5", "10feffff0127", "00", ""}, {"x,,d1c", "19.5", "10feffff0127", "00", ""},
{"x,,d1c", "0.0", "10feffff0100", "00", ""}, {"x,,d1c", "0.0", "10feffff0100", "00", ""},
{"x,,d1c", "100.0", "10feffff01c8", "00", ""}, {"x,,d1c", "100.0", "10feffff01c8", "00", ""},
@@ -291,105 +291,105 @@ int main() {
{"x,,uin", "65534", "10feffff02feff", "00", ""}, {"x,,uin", "65534", "10feffff02feff", "00", ""},
{"x,,uin", "-", "10feffff02ffff", "00", ""}, {"x,,uin", "-", "10feffff02ffff", "00", ""},
{"x,,uin,10", "3.8", "10feffff022600", "00", ""}, {"x,,uin,10", "3.8", "10feffff022600", "00", ""},
{"x,,uin,-10","380", "10feffff022600", "00", ""}, {"x,,uin,-10", "380", "10feffff022600", "00", ""},
{"x,,uir", "38", "10feffff020026", "00", ""}, {"x,,uir", "38", "10feffff020026", "00", ""},
{"x,,uir", "0", "10feffff020000", "00", ""}, {"x,,uir", "0", "10feffff020000", "00", ""},
{"x,,uir", "65534", "10feffff02fffe", "00", ""}, {"x,,uir", "65534", "10feffff02fffe", "00", ""},
{"x,,uir", "-", "10feffff02ffff", "00", ""}, {"x,,uir", "-", "10feffff02ffff", "00", ""},
{"x,,uir,10", "3.8", "10feffff020026", "00", ""}, {"x,,uir,10", "3.8", "10feffff020026", "00", ""},
{"x,,uir,-10","380", "10feffff020026", "00", ""}, {"x,,uir,-10", "380", "10feffff020026", "00", ""},
{"uin10,uin,-10","", "", "", "t"}, // template {"uin10,uin,-10", "", "", "", "t"}, // template
{"x,,uin10","380", "10feffff022600", "00", ""}, // template reference {"x,,uin10", "380", "10feffff022600", "00", ""}, // template reference
{"x,,uin10,-10","3800","10feffff022600", "00", ""}, // template reference, valid divider product {"x,,uin10,-10", "3800", "10feffff022600", "00", ""}, // template reference, valid divider product
{"x,,uin10,10","","", "", "c"}, // template reference, invalid divider product {"x,,uin10,10", "", "", "", "c"}, // template reference, invalid divider product
{"x,,sin", "-90", "10feffff02a6ff", "00", ""}, {"x,,sin", "-90", "10feffff02a6ff", "00", ""},
{"x,,sin", "0", "10feffff020000", "00", ""}, {"x,,sin", "0", "10feffff020000", "00", ""},
{"x,,sin", "-1", "10feffff02ffff", "00", ""}, {"x,,sin", "-1", "10feffff02ffff", "00", ""},
{"x,,sin", "-", "10feffff020080", "00", ""}, {"x,,sin", "-", "10feffff020080", "00", ""},
{"x,,sin", "-32767", "10feffff020180", "00", ""}, {"x,,sin", "-32767", "10feffff020180", "00", ""},
{"x,,sin", "32767", "10feffff02ff7f", "00", ""}, {"x,,sin", "32767", "10feffff02ff7f", "00", ""},
{"x,,sin,10","-9.0", "10feffff02a6ff", "00", ""}, {"x,,sin,10", "-9.0", "10feffff02a6ff", "00", ""},
{"x,,sin,-10","-900","10feffff02a6ff", "00", ""}, {"x,,sin,-10", "-900", "10feffff02a6ff", "00", ""},
{"x,,sir", "-90", "10feffff02ffa6", "00", ""}, {"x,,sir", "-90", "10feffff02ffa6", "00", ""},
{"x,,sir", "0", "10feffff020000", "00", ""}, {"x,,sir", "0", "10feffff020000", "00", ""},
{"x,,sir", "-1", "10feffff02ffff", "00", ""}, {"x,,sir", "-1", "10feffff02ffff", "00", ""},
{"x,,sir", "-", "10feffff028000", "00", ""}, {"x,,sir", "-", "10feffff028000", "00", ""},
{"x,,sir", "-32767", "10feffff028001", "00", ""}, {"x,,sir", "-32767", "10feffff028001", "00", ""},
{"x,,sir", "32767", "10feffff027fff", "00", ""}, {"x,,sir", "32767", "10feffff027fff", "00", ""},
{"x,,sir,10","-9.0", "10feffff02ffa6", "00", ""}, {"x,,sir,10", "-9.0", "10feffff02ffa6", "00", ""},
{"x,,sir,-10","-900","10feffff02ffa6", "00", ""}, {"x,,sir,-10", "-900", "10feffff02ffa6", "00", ""},
{"x,,u3n", "38", "10feffff03260000", "00", ""}, {"x,,u3n", "38", "10feffff03260000", "00", ""},
{"x,,u3n", "0", "10feffff03000000", "00", ""}, {"x,,u3n", "0", "10feffff03000000", "00", ""},
{"x,,u3n", "16777214", "10feffff03feffff", "00", ""}, {"x,,u3n", "16777214", "10feffff03feffff", "00", ""},
{"x,,u3n", "-", "10feffff03ffffff", "00", ""}, {"x,,u3n", "-", "10feffff03ffffff", "00", ""},
{"x,,u3n,10", "3.8", "10feffff03260000", "00", ""}, {"x,,u3n,10", "3.8", "10feffff03260000", "00", ""},
{"x,,u3n,-10","380", "10feffff03260000", "00", ""}, {"x,,u3n,-10", "380", "10feffff03260000", "00", ""},
{"x,,u3r", "38", "10feffff03000026", "00", ""}, {"x,,u3r", "38", "10feffff03000026", "00", ""},
{"x,,u3r", "0", "10feffff03000000", "00", ""}, {"x,,u3r", "0", "10feffff03000000", "00", ""},
{"x,,u3r", "16777214", "10feffff03fffffe", "00", ""}, {"x,,u3r", "16777214", "10feffff03fffffe", "00", ""},
{"x,,u3r", "-", "10feffff03ffffff", "00", ""}, {"x,,u3r", "-", "10feffff03ffffff", "00", ""},
{"x,,u3r,10", "3.8", "10feffff03000026", "00", ""}, {"x,,u3r,10", "3.8", "10feffff03000026", "00", ""},
{"x,,u3r,-10","380", "10feffff03000026", "00", ""}, {"x,,u3r,-10", "380", "10feffff03000026", "00", ""},
{"x,,s3n", "-90", "10feffff03a6ffff", "00", ""}, {"x,,s3n", "-90", "10feffff03a6ffff", "00", ""},
{"x,,s3n", "0", "10feffff03000000", "00", ""}, {"x,,s3n", "0", "10feffff03000000", "00", ""},
{"x,,s3n", "-1", "10feffff03ffffff", "00", ""}, {"x,,s3n", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3n", "-", "10feffff03000080", "00", ""}, {"x,,s3n", "-", "10feffff03000080", "00", ""},
{"x,,s3n", "-8388607", "10feffff03010080", "00", ""}, {"x,,s3n", "-8388607", "10feffff03010080", "00", ""},
{"x,,s3n", "8388607", "10feffff03ffff7f", "00", ""}, {"x,,s3n", "8388607", "10feffff03ffff7f", "00", ""},
{"x,,s3n,10","-9.0", "10feffff03a6ffff", "00", ""}, {"x,,s3n,10", "-9.0", "10feffff03a6ffff", "00", ""},
{"x,,s3n,-10","-900","10feffff03a6ffff", "00", ""}, {"x,,s3n,-10", "-900", "10feffff03a6ffff", "00", ""},
{"x,,s3r", "-90", "10feffff03ffffa6", "00", ""}, {"x,,s3r", "-90", "10feffff03ffffa6", "00", ""},
{"x,,s3r", "0", "10feffff03000000", "00", ""}, {"x,,s3r", "0", "10feffff03000000", "00", ""},
{"x,,s3r", "-1", "10feffff03ffffff", "00", ""}, {"x,,s3r", "-1", "10feffff03ffffff", "00", ""},
{"x,,s3r", "-", "10feffff03800000", "00", ""}, {"x,,s3r", "-", "10feffff03800000", "00", ""},
{"x,,s3r", "-8388607", "10feffff03800001", "00", ""}, {"x,,s3r", "-8388607", "10feffff03800001", "00", ""},
{"x,,s3r", "8388607", "10feffff037fffff", "00", ""}, {"x,,s3r", "8388607", "10feffff037fffff", "00", ""},
{"x,,s3r,10","-9.0", "10feffff03ffffa6", "00", ""}, {"x,,s3r,10", "-9.0", "10feffff03ffffa6", "00", ""},
{"x,,s3r,-10","-900","10feffff03ffffa6", "00", ""}, {"x,,s3r,-10", "-900", "10feffff03ffffa6", "00", ""},
{"x,,flt", "-0.090", "10feffff02a6ff", "00", ""}, {"x,,flt", "-0.090", "10feffff02a6ff", "00", ""},
{"x,,flt", "0.000", "10feffff020000", "00", ""}, {"x,,flt", "0.000", "10feffff020000", "00", ""},
{"x,,flt", "-0.001", "10feffff02ffff", "00", ""}, {"x,,flt", "-0.001", "10feffff02ffff", "00", ""},
{"x,,flt", "-", "10feffff020080", "00", ""}, {"x,,flt", "-", "10feffff020080", "00", ""},
{"x,,flt","-32.767", "10feffff020180", "00", ""}, {"x,,flt", "-32.767", "10feffff020180", "00", ""},
{"x,,flt", "32.767", "10feffff02ff7f", "00", ""}, {"x,,flt", "32.767", "10feffff02ff7f", "00", ""},
{"x,,flr", "-0.090", "10feffff02ffa6", "00", ""}, {"x,,flr", "-0.090", "10feffff02ffa6", "00", ""},
{"x,,flr", "0.000", "10feffff020000", "00", ""}, {"x,,flr", "0.000", "10feffff020000", "00", ""},
{"x,,flr", "-0.001", "10feffff02ffff", "00", ""}, {"x,,flr", "-0.001", "10feffff02ffff", "00", ""},
{"x,,flr", "-", "10feffff028000", "00", ""}, {"x,,flr", "-", "10feffff028000", "00", ""},
{"x,,flr","-32.767", "10feffff028001", "00", ""}, {"x,,flr", "-32.767", "10feffff028001", "00", ""},
{"x,,flr", "32.767", "10feffff027fff", "00", ""}, {"x,,flr", "32.767", "10feffff027fff", "00", ""},
{"x,,exp", "-0.09", "10feffff04ec51b8bd", "00", ""}, {"x,,exp", "-0.09", "10feffff04ec51b8bd", "00", ""},
{"x,,exp", "0.0", "10feffff0400000000", "00", ""}, {"x,,exp", "0.0", "10feffff0400000000", "00", ""},
{"x,,exp", "-0.001", "10feffff046f1283ba", "00", ""}, {"x,,exp", "-0.001", "10feffff046f1283ba", "00", ""},
{"x,,exp", "-", "10feffff040000807f", "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,1000", "-0.000090000", "10feffff04ec51b8bd", "00", ""},
{"x,,exp,-100", "-9", "10feffff04ec51b8bd", "00", ""}, {"x,,exp,-100", "-9", "10feffff04ec51b8bd", "00", ""},
{"x,,exr", "-0.09", "10feffff04bdb851ec", "00", ""}, {"x,,exr", "-0.09", "10feffff04bdb851ec", "00", ""},
{"x,,exr", "0.0", "10feffff0400000000", "00", ""}, {"x,,exr", "0.0", "10feffff0400000000", "00", ""},
{"x,,exr", "-0.001", "10feffff04ba83126f", "00", ""}, {"x,,exr", "-0.001", "10feffff04ba83126f", "00", ""},
{"x,,exr", "-", "10feffff047f800000", "00", ""}, {"x,,exr", "-", "10feffff047f800000", "00", ""},
{"x,,exr","-32.767", "10feffff04c2031168", "00", ""}, {"x,,exr", "-32.767", "10feffff04c2031168", "00", ""},
{"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""}, {"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""},
{"x,,exr,-100", "-9", "10feffff04bdb851ec", "00", ""}, {"x,,exr,-100", "-9", "10feffff04bdb851ec", "00", ""},
{"x,,d2b", "18.004", "10fe0700090112", "00", ""}, {"x,,d2b", "18.004", "10fe0700090112", "00", ""},
{"x,,d2b", "0.000", "10feffff020000", "00", ""}, {"x,,d2b", "0.000", "10feffff020000", "00", ""},
{"x,,d2b", "-0.004", "10feffff02ffff", "00", ""}, {"x,,d2b", "-0.004", "10feffff02ffff", "00", ""},
{"x,,d2b", "-", "10feffff020080", "00", ""}, {"x,,d2b", "-", "10feffff020080", "00", ""},
{"x,,d2b","-127.996","10feffff020180", "00", ""}, {"x,,d2b", "-127.996", "10feffff020180", "00", ""},
{"x,,d2b", "127.996","10feffff02ff7f", "00", ""}, {"x,,d2b", "127.996", "10feffff02ff7f", "00", ""},
{"x,,d2c", "288.06", "10fe0700090112", "00", ""}, {"x,,d2c", "288.06", "10fe0700090112", "00", ""},
{"x,,d2c", "0.00", "10feffff020000", "00", ""}, {"x,,d2c", "0.00", "10feffff020000", "00", ""},
{"x,,d2c", "-0.06", "10feffff02ffff", "00", ""}, {"x,,d2c", "-0.06", "10feffff02ffff", "00", ""},
{"x,,d2c", "-", "10feffff020080", "00", ""}, {"x,,d2c", "-", "10feffff020080", "00", ""},
{"x,,d2c","-2047.94","10feffff020180", "00", ""}, {"x,,d2c", "-2047.94", "10feffff020180", "00", ""},
{"x,,d2c", "2047.94","10feffff02ff7f", "00", ""}, {"x,,d2c", "2047.94", "10feffff02ff7f", "00", ""},
{"x,,ulg", "38", "10feffff0426000000", "00", ""}, {"x,,ulg", "38", "10feffff0426000000", "00", ""},
{"x,,ulg", "0", "10feffff0400000000", "00", ""}, {"x,,ulg", "0", "10feffff0400000000", "00", ""},
{"x,,ulg", "4294967294", "10feffff04feffffff", "00", ""}, {"x,,ulg", "4294967294", "10feffff04feffffff", "00", ""},
{"x,,ulg", "-", "10feffff04ffffffff", "00", ""}, {"x,,ulg", "-", "10feffff04ffffffff", "00", ""},
{"x,,ulg,10","3.8", "10feffff0426000000", "00", ""}, {"x,,ulg,10", "3.8", "10feffff0426000000", "00", ""},
{"x,,ulg,-10","380", "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+", {"x,,ulg,0x0FF0F00F = VRT 350 ;0x33CCCC33=VRT 360;0x3CC3C33C=SD 17;0x66999966=SD 37;0x69969669=VRT 360+",
"VRT 350", "10feffff040FF0F00F", "00", ""}, "VRT 350", "10feffff040FF0F00F", "00", ""},
{"x,,ulg,0x=test", "", "10feffff040FF0F00F", "00", "c"}, {"x,,ulg,0x=test", "", "10feffff040FF0F00F", "00", "c"},
@@ -397,8 +397,8 @@ int main() {
{"x,,ulr", "0", "10feffff0400000000", "00", ""}, {"x,,ulr", "0", "10feffff0400000000", "00", ""},
{"x,,ulr", "4294967294", "10feffff04fffffffe", "00", ""}, {"x,,ulr", "4294967294", "10feffff04fffffffe", "00", ""},
{"x,,ulr", "-", "10feffff04ffffffff", "00", ""}, {"x,,ulr", "-", "10feffff04ffffffff", "00", ""},
{"x,,ulr,10","3.8", "10feffff0400000026", "00", ""}, {"x,,ulr,10", "3.8", "10feffff0400000026", "00", ""},
{"x,,ulr,-10","380", "10feffff0400000026", "00", ""}, {"x,,ulr,-10", "380", "10feffff0400000026", "00", ""},
{"x,,slg", "-90", "10feffff04a6ffffff", "00", ""}, {"x,,slg", "-90", "10feffff04a6ffffff", "00", ""},
{"x,,slg", "0", "10feffff0400000000", "00", ""}, {"x,,slg", "0", "10feffff0400000000", "00", ""},
{"x,,slg", "-1", "10feffff04ffffffff", "00", ""}, {"x,,slg", "-1", "10feffff04ffffffff", "00", ""},
@@ -411,51 +411,51 @@ int main() {
{"x,,slr,-10", "-900", "10feffff04ffffffa6", "00", ""}, {"x,,slr,-10", "-900", "10feffff04ffffffa6", "00", ""},
{"x,,bi3", "1", "10feffff0108", "00", ""}, {"x,,bi3", "1", "10feffff0108", "00", ""},
{"x,,bi3", "0", "10feffff0100", "00", ""}, {"x,,bi3", "0", "10feffff0100", "00", ""},
{"x,,bi3,0=off;1=on","on", "10feffff0108", "00", ""}, {"x,,bi3,0=off;1=on", "on", "10feffff0108", "00", ""},
{"x,,bi3,0=off;1=on","off","10feffff0100", "00", ""}, {"x,,bi3,0=off;1=on", "off", "10feffff0100", "00", ""},
{"x,,bi3:2", "1", "10feffff0108", "00", ""}, {"x,,bi3:2", "1", "10feffff0108", "00", ""},
{"x,,bi3:2", "1", "10feffff01ef", "00", "W"}, {"x,,bi3:2", "1", "10feffff01ef", "00", "W"},
{"x,,bi3:2", "0", "10feffff0100", "00", ""}, {"x,,bi3:2", "0", "10feffff0100", "00", ""},
{"x,,bi3:2", "3", "10feffff0118", "00", ""}, {"x,,bi3:2", "3", "10feffff0118", "00", ""},
{"x,,bi3:2,1=on","on", "10feffff0108", "00", ""}, {"x,,bi3:2,1=on", "on", "10feffff0108", "00", ""},
{"x,,bi3:2,1=on","-", "10feffff0100", "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", "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;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", "on", "10feffff0108", "00", ""},
{"x,,bi3:2,0=off;1=on","off","10feffff0100", "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", "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=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", "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"}, {"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", "vj"},
{",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "j"}, {",,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\": \"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}", "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 \"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,,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,,uch,1=test;2=high;3=off;0x10=on", "on", "10feffff0110", "00", ""},
{"x,s,uch","3","1050ffff00", "0103", ""}, {"x,s,uch", "3", "1050ffff00", "0103", ""},
{"x,,d2b,,°C,Aussentemperatur","x=18.004 °C [Aussentemperatur]","10fe0700090112", "00", "vvv"}, {"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,,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;0", "10feffff0108", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi5", "1;1", "10feffff0128", "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;1", "10feffff0120", "00", ""}, // bit combination
{"x,,bi3,,,,y,,bi5", "0;0", "10feffff0100", "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,,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,,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 {"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 {"temp,d2b,,°C,Aussentemperatur", "", "", "", "t"}, // template with relative pos
{"x,,temp","18.004","10fe0700020112", "00", ""}, // reference to template {"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", "1.8004", "10fe0700020112", "00", ""}, // reference to template, valid divider product
{"x,,temp,-10","","", "", "c"}, // reference to template, invalid divider product {"x,,temp,-10", "", "", "", "c"}, // reference to template, invalid divider product
{"relrel,d2b,,,,y,d1c","","", "", "t"}, // template struct with relative pos {"relrel,d2b,,,,y,d1c", "", "", "", "t"}, // template struct with relative pos
{"x,,relrel","18.004;9.5","10fe070003011213", "00", ""}, // reference to template struct {"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 {"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,,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,,,,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", "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;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,,temp:degrees;HEX:2", "degrees=18.004;=13 14", "10fe07000401121314", "00", "v"}, // reference to template and base type
}; };
DataFieldTemplates* templates = new DataFieldTemplates(); DataFieldTemplates* templates = new DataFieldTemplates();
DataField* fields = NULL; DataField* fields = NULL;
+1 -1
View File
@@ -22,7 +22,7 @@
using namespace std; using namespace std;
int main () { int main() {
Device* device = Device::create("/dev/ttyUSB20", true, false, false); Device* device = Device::create("/dev/ttyUSB20", true, false, false);
if (device == NULL) { if (device == NULL) {
cout << "unable to create device" << endl; 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"}, {"pumpstate,UCH,0=off;1=on;2=overrun,,Pumpenstatus", "", "", "", "template"},
{"tempsensor,temp;sensor,,Temperatursensor", "", "", "", "template"}, {"tempsensor,temp;sensor,,Temperatursensor", "", "", "", "template"},
{"tempsensorc,temp;sensorc,,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", "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", "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"}, {"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"}, {"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"}, {"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"}, {"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"}, {"u,ehp,hwTankTemp,Speichertemperatur IST,,25,B509,290000,,,IGN:2,,,,,,tempsensor", "", "", "", "M"},
{"", "55.50;ok","1025b50903290000","050000780300","d"}, {"", "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,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,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" }, {"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; delete *it;
} }
return 0; return 0;
} }
+5 -9
View File
@@ -27,15 +27,12 @@
/** /**
* class to notify other thread per pipe. * class to notify other thread per pipe.
*/ */
class Notify class Notify {
{ public:
public:
/** /**
* constructs a new instance and do notifying. * constructs a new instance and do notifying.
*/ */
Notify() Notify() {
{
int pipefd[2]; int pipefd[2];
int ret = pipe(pipefd); int ret = pipe(pipefd);
@@ -62,15 +59,14 @@ public:
* write notify event to file descriptor. * write notify event to file descriptor.
* @return result of writing notification. * @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 */ /** file descriptor to watch */
int m_recvfd; int m_recvfd;
/** file descriptor to notify */ /** file descriptor to notify */
int m_sendfd; int m_sendfd;
}; };
#endif // LIB_UTILS_NOTIFY_H_ #endif // LIB_UTILS_NOTIFY_H_
+12 -20
View File
@@ -33,15 +33,12 @@ using namespace std;
* @param T the item type. * @param T the item type.
*/ */
template <typename T> template <typename T>
class Queue class Queue {
{ public:
public:
/** /**
* Constructor. * Constructor.
*/ */
Queue() Queue() {
{
pthread_mutex_init(&m_mutex, NULL); pthread_mutex_init(&m_mutex, NULL);
pthread_cond_init(&m_cond, NULL); pthread_cond_init(&m_cond, NULL);
} }
@@ -49,28 +46,26 @@ public:
/** /**
* Destructor. * Destructor.
*/ */
~Queue() ~Queue() {
{
pthread_mutex_destroy(&m_mutex); pthread_mutex_destroy(&m_mutex);
pthread_cond_destroy(&m_cond); pthread_cond_destroy(&m_cond);
} }
private:
private:
/** /**
* Hidden copy constructor. * Hidden copy constructor.
* @param src the object to copy from. * @param src the object to copy from.
*/ */
Queue(const Queue& src); Queue(const Queue& src);
public:
public:
/** /**
* Add an item to the end of queue. * Add an item to the end of queue.
* @param item the item to add. * @param item the item to add.
*/ */
void push(T item) void push(T item) {
{
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
m_queue.push_back(item); m_queue.push_back(item);
pthread_cond_broadcast(&m_cond); 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. * @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. * @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; T item;
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
if (timeout > 0) { if (timeout > 0) {
@@ -112,8 +106,7 @@ public:
* @param wait true to wait for the item to appear in the queue. * @param wait true to wait for the item to appear in the queue.
* @return whether the item was removed. * @return whether the item was removed.
*/ */
bool remove(T item, bool wait = false) bool remove(T item, bool wait = false) {
{
bool ret = false; bool ret = false;
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
do { do {
@@ -135,8 +128,7 @@ public:
* Return the first item in the queue without removing it. * Return the first item in the queue without removing it.
* @return the item, or NULL if no item is available. * @return the item, or NULL if no item is available.
*/ */
T peek() T peek() {
{
T item; T item;
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
if (m_queue.empty()) { if (m_queue.empty()) {
@@ -148,7 +140,8 @@ public:
return item; return item;
} }
private:
private:
/** the queue itself */ /** the queue itself */
list<T> m_queue; list<T> m_queue;
@@ -157,7 +150,6 @@ private:
/** condition variable for exclusive lock */ /** condition variable for exclusive lock */
pthread_cond_t m_cond; pthread_cond_t m_cond;
}; };
#endif // LIB_UTILS_QUEUE_H_ #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", fprintf(m_stream, "%04d-%02d-%02d %02d:%02d:%02d.%03ld %c",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000, tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000,
received ? '<' : '>' received ? '<' : '>');
);
for (unsigned int pos = 0; pos < size; pos++) { for (unsigned int pos = 0; pos < size; pos++) {
fprintf(m_stream, "%2.2x ", value[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. * Helper class for writing to a rotating file with maximum size.
*/ */
class RotateFile class RotateFile {
{ public:
public:
/** /**
* Construct a new instance. * Construct a new instance.
* @param fileName the name of the file write to. * @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); void write(unsigned char* value, unsigned int size, bool received = true);
private:
private:
/** whether writing to the file is enabled. */ /** whether writing to the file is enabled. */
bool m_enabled; bool m_enabled;
@@ -89,7 +89,6 @@ private:
/** the number of bytes already written to the @a m_file. */ /** the number of bytes already written to the @a m_file. */
unsigned long m_fileSize; unsigned long m_fileSize;
}; };
#endif // LIB_UTILS_ROTATEFILE_H_ #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 for low level tcp socket operations. (open, close, send, receive).
*/ */
class TCPSocket class TCPSocket {
{ public:
public:
/** grant access for friend class TCPClient */ /** grant access for friend class TCPClient */
friend class TCPClient; friend class TCPClient;
@@ -92,7 +90,8 @@ public:
*/ */
bool isValid(); bool isValid();
private:
private:
/** file descriptor from tcp socket */ /** file descriptor from tcp socket */
int m_sfd; int m_sfd;
@@ -108,16 +107,13 @@ private:
* @param address struct which holds the ip address. * @param address struct which holds the ip address.
*/ */
TCPSocket(int sfd, struct sockaddr_in* address); TCPSocket(int sfd, struct sockaddr_in* address);
}; };
/** /**
* class to initiate a tcp socket connection to a listening server. * class to initiate a tcp socket connection to a listening server.
*/ */
class TCPClient class TCPClient {
{ public:
public:
/** /**
* initiate a tcp socket connection to a listening server. * initiate a tcp socket connection to a listening server.
* @param server the server name or ip address to connect. * @param server the server name or ip address to connect.
@@ -125,16 +121,13 @@ public:
* @return pointer to an opened tcp socket. * @return pointer to an opened tcp socket.
*/ */
TCPSocket* connect(const string& server, const uint16_t& port); TCPSocket* connect(const string& server, const uint16_t& port);
}; };
/** /**
* class for a tcp based network server. * class for a tcp based network server.
*/ */
class TCPServer class TCPServer {
{ public:
public:
/** /**
* creates a new instance of a listening tcp server. * creates a new instance of a listening tcp server.
* @param port the tcp port. * @param port the tcp port.
@@ -166,7 +159,8 @@ public:
*/ */
int getFD() const { return m_lfd; } int getFD() const { return m_lfd; }
private:
private:
/** file descriptor from listening tcp socket */ /** file descriptor from listening tcp socket */
int m_lfd; int m_lfd;
@@ -178,7 +172,6 @@ private:
/** true if object is already listening */ /** true if object is already listening */
bool m_listening; bool m_listening;
}; };
#endif // LIB_UTILS_TCPSOCKET_H_ #endif // LIB_UTILS_TCPSOCKET_H_
-9
View File
@@ -36,37 +36,28 @@ Thread::~Thread() {
} }
bool Thread::start(const char* name) { bool Thread::start(const char* name) {
int result = pthread_create(&m_threadid, NULL, runThread, this); int result = pthread_create(&m_threadid, NULL, runThread, this);
if (result == 0) { if (result == 0) {
#ifdef HAVE_PTHREAD_SETNAME_NP #ifdef HAVE_PTHREAD_SETNAME_NP
#ifndef __MACH__ #ifndef __MACH__
pthread_setname_np(m_threadid, name); pthread_setname_np(m_threadid, name);
#endif #endif
#endif #endif
m_started = true; m_started = true;
return true; return true;
} }
return false; return false;
} }
bool Thread::join() { bool Thread::join() {
int result = -1; int result = -1;
if (m_started) { if (m_started) {
m_stopped = true; m_stopped = true;
result = pthread_join(m_threadid, NULL); result = pthread_join(m_threadid, NULL);
if (result == 0) { if (result == 0) {
m_started = false; m_started = false;
} }
} }
return result == 0; return result == 0;
} }
+8 -13
View File
@@ -26,10 +26,8 @@
/** /**
* wrapper class for pthread. * wrapper class for pthread.
*/ */
class Thread class Thread {
{ public:
public:
/** /**
* constructor. * constructor.
*/ */
@@ -77,15 +75,15 @@ public:
*/ */
pthread_t self() { return m_threadid; } pthread_t self() { return m_threadid; }
protected:
protected:
/** /**
* Thread entry method to be overridden by derived class. * Thread entry method to be overridden by derived class.
*/ */
virtual void run() = 0; virtual void run() = 0;
private:
private:
/** /**
* Enter the Thread loop by calling run(). * Enter the Thread loop by calling run().
*/ */
@@ -102,17 +100,14 @@ private:
/** Whether the thread was stopped by @a stop() or @a join(). */ /** Whether the thread was stopped by @a stop() or @a join(). */
bool m_stopped; bool m_stopped;
}; };
/** /**
* A @a Thread that can be waited on. * A @a Thread that can be waited on.
*/ */
class WaitThread : public Thread class WaitThread : public Thread {
{ public:
public:
/** /**
* Constructor. * Constructor.
*/ */
@@ -136,13 +131,13 @@ public:
*/ */
bool Wait(int seconds); bool Wait(int seconds);
private:
private:
/** the mutex for waiting. */ /** the mutex for waiting. */
pthread_mutex_t m_mutex; pthread_mutex_t m_mutex;
/** the condition for waiting. */ /** the condition for waiting. */
pthread_cond_t m_cond; pthread_cond_t m_cond;
}; };
#endif // LIB_UTILS_THREAD_H_ #endif // LIB_UTILS_THREAD_H_
+2 -5
View File
@@ -36,8 +36,7 @@
using namespace std; using namespace std;
/** A structure holding all program options. */ /** A structure holding all program options. */
struct options struct options {
{
const char* server; //!< ebusd server host (name or ip) [localhost] const char* server; //!< ebusd server host (name or ip) [localhost]
uint16_t port; //!< ebusd server port [8888] uint16_t port; //!< ebusd server port [8888]
@@ -229,7 +228,6 @@ string fetchData(TCPSocket* socket, bool& listening) {
} }
void connect(const char* host, uint16_t port, char* const *args, int argCount) { void connect(const char* host, uint16_t port, char* const *args, int argCount) {
TCPClient* client = new TCPClient(); TCPClient* client = new TCPClient();
TCPSocket* socket = client->connect(host, port); TCPSocket* socket = client->connect(host, port);
@@ -242,8 +240,7 @@ void connect(const char* host, uint16_t port, char* const *args, int argCount) {
if (!once) { if (!once) {
cout << host << ": "; cout << host << ": ";
getline(cin, message); getline(cin, message);
} } else {
else {
for (int i = 0; i < argCount; i++) { for (int i = 0; i < argCount; i++) {
if (i > 0) { if (i > 0) {
message += " "; message += " ";
+3 -3
View File
@@ -32,8 +32,7 @@
using namespace std; using namespace std;
/** A structure holding all program options. */ /** A structure holding all program options. */
struct options struct options {
{
const char* device; //!< device to write to [/dev/ttyUSB60] const char* device; //!< device to write to [/dev/ttyUSB60]
unsigned int time; //!< delay between bytes in us [10000] unsigned int time; //!< delay between bytes in us [10000]
@@ -111,8 +110,9 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
return EINVAL; return EINVAL;
} }
opt->dumpFile = arg; opt->dumpFile = arg;
} else } else {
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
}
break; break;
default: default:
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;