changed from m_isActive to m_isPassive, made defaults more flexible (every char besides r/w/p/0-9 can be used for defining messages to listen to - aka cyc), fix for defaults field list and duplicate message definitions, multiple message types now need to be separated by comma, optimized finding messages
This commit is contained in:
+42
-34
@@ -37,22 +37,21 @@ class Message
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
* @brief Construct a new instance.
|
||||
* @param class the optional device class.
|
||||
* @param name the message name (unique within the same class and type).
|
||||
* @param isSet whether this is a set message.
|
||||
* @param isActive true if message can be initiated by the daemon
|
||||
* itself any any other participant, false if message can only be initiated
|
||||
* by a participant other than the daemon.
|
||||
* @param isPassive true if message can only be initiated by a participant other than us,
|
||||
* false if message can be initiated by any participant.
|
||||
* @param comment the comment.
|
||||
* @param srcAddress the source address (optional if passive), or @a SYN for any.
|
||||
* @param srcAddress the source address, or @a SYN for any (only relevant if passive).
|
||||
* @param dstAddress the destination address.
|
||||
* @param id the primary, secondary, and optional further ID bytes.
|
||||
* @param data the @a DataField for encoding/decoding the message.
|
||||
* @param pollPriority the priority for polling, or 0 for no polling at all.
|
||||
*/
|
||||
Message(const string clazz, const string name, const bool isSet,
|
||||
const bool isActive, const string comment,
|
||||
const bool isPassive, const string comment,
|
||||
const unsigned char srcAddress, const unsigned char dstAddress,
|
||||
const vector<unsigned char> id, DataField* data,
|
||||
const unsigned int pollPriority);
|
||||
@@ -64,15 +63,15 @@ public:
|
||||
* @brief Factory method for creating a new instance.
|
||||
* @param it the iterator to traverse for the definition parts.
|
||||
* @param end the iterator pointing to the end of the definition parts.
|
||||
* @param defaults a @a vector with known default values, or NULL.
|
||||
* @param defaultsRows a @a vector with rows containing defaults, or NULL.
|
||||
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
|
||||
* @param returnValue the variable in which to store the created instance.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
* Note: the caller needs to free the created instance.
|
||||
*/
|
||||
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
|
||||
vector<string>* defaults,
|
||||
DataFieldTemplates*, Message*& returnValue);
|
||||
vector< vector<string> >* defaultsRows,
|
||||
DataFieldTemplates* templates, Message*& returnValue);
|
||||
/**
|
||||
* @brief Get the optional device class.
|
||||
* @return the optional device class.
|
||||
@@ -89,13 +88,11 @@ public:
|
||||
*/
|
||||
bool isSet() const { return m_isSet; }
|
||||
/**
|
||||
* @brief Get whether message can be initiated by the daemon itself and any other
|
||||
* participant.
|
||||
* @return true if message can be initiated by the daemon itself and any other
|
||||
* participant, false if message can only be initiated by a participant
|
||||
* other than the daemon.
|
||||
* @brief Get whether message can be initiated only by a participant other than us.
|
||||
* @return true if message can only be initiated by a participant other than us,
|
||||
* false if message can be initiated by any participant.
|
||||
*/
|
||||
bool isActive() const { return m_isActive; }
|
||||
bool isPassive() const { return m_isPassive; }
|
||||
/**
|
||||
* @brief Get the comment.
|
||||
* @return the comment.
|
||||
@@ -117,7 +114,7 @@ public:
|
||||
*/
|
||||
vector<unsigned char> getId() const { return m_id; }
|
||||
/**
|
||||
* @brief Returns the key for storing in @a MessageSet.
|
||||
* @brief Return the key for storing in @a MessageSet.
|
||||
* @return the key for storing in @a MessageSet.
|
||||
*/
|
||||
unsigned long long getKey() { return m_key; }
|
||||
@@ -134,17 +131,24 @@ public:
|
||||
//result_t read(SymbolString& masterData, SymbolString& slaveData, ostringstream& output,
|
||||
// bool verbose=false, char separator=';') = 0;
|
||||
/**
|
||||
* @brief Writes the value to the master or slave @a SymbolString.
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
* @param masterData the unescaped master data @a SymbolString for writing binary data.
|
||||
* @param slaveData the unescaped slave data @a SymbolString for writing binary data.
|
||||
* @brief Prepare master @a SymbolString for sending to the bus.
|
||||
* @param masterData the master data @a SymbolString for writing symbols to.
|
||||
* @param input the @a istringstream to parse the formatted value(s) from.
|
||||
* @param separator the separator character between multiple fields.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t prepare(const unsigned char srcAddress, SymbolString& masterData,
|
||||
result_t prepareMaster(const unsigned char srcAddress, SymbolString& masterData,
|
||||
istringstream& input, char separator=';');
|
||||
/**
|
||||
* @brief Decode a received message.
|
||||
* @param masterData the unescaped received master @a SymbolString.
|
||||
* @param slaveData the unescaped received slave @a SymbolString.
|
||||
* @param output the @a ostringstream to append the formatted value to.
|
||||
* @param separator the separator character between multiple fields.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t decode(SymbolString& masterData, SymbolString& slaveData,
|
||||
ostringstream& output, char separator=';', bool answer=false);
|
||||
ostringstream& output, char separator=';');
|
||||
|
||||
private:
|
||||
|
||||
@@ -154,13 +158,12 @@ private:
|
||||
const string m_name;
|
||||
/** whether this is a set message. */
|
||||
const bool m_isSet;
|
||||
/** true if message can be initiated by the daemon itself and any other
|
||||
* participant, false if message can only be initiated by a participant
|
||||
* other than the daemon. */
|
||||
const bool m_isActive;
|
||||
/** true if message can only be initiated by a participant other than us,
|
||||
* false if message can be initiated by any participant. */
|
||||
const bool m_isPassive;
|
||||
/** the comment. */
|
||||
const string m_comment;
|
||||
/** the source address (optional if passive), or @a SYN for any. */
|
||||
/** the source address, or @a SYN for any (only relevant if passive). */
|
||||
const unsigned char m_srcAddress;
|
||||
/** the destination address. */
|
||||
const unsigned char m_dstAddress;
|
||||
@@ -183,15 +186,15 @@ class MessageMap : public FileReader<DataFieldTemplates*>
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
* @brief Construct a new instance.
|
||||
*/
|
||||
MessageMap() : FileReader(true), m_maxIdLength(0) {}
|
||||
MessageMap() : FileReader(true), m_minIdLength(4), m_maxIdLength(0) {}
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~MessageMap() { clear(); }
|
||||
/**
|
||||
* @brief Adds a @a Message instance to this set.
|
||||
* @brief Add a @a Message instance to this set.
|
||||
* @param message the @a Message instance to add.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
* Note: the caller may not free the added instance on success.
|
||||
@@ -200,14 +203,16 @@ public:
|
||||
// @copydoc
|
||||
virtual result_t addFromFile(vector<string>& row, DataFieldTemplates* arg, vector< vector<string> >* defaults);
|
||||
/**
|
||||
* @brief Finds the @a Message instance for the specified class and name.
|
||||
* @param master the master @a SymbolString for identifying the @a Message.
|
||||
* @brief Find the @a Message instance for the specified class and name.
|
||||
* @param class the optional device class.
|
||||
* @param name the message name.
|
||||
* @param isSet whether this is a set message.
|
||||
* @return the @a Message instance, or NULL.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(const string& clazz, const string& name, const bool isActive, const bool isSet);
|
||||
Message* find(const string& clazz, const string& name, const bool isSet);
|
||||
/**
|
||||
* @brief Finds the @a Message instance for the specified master data.
|
||||
* @brief Find the @a Message instance for the specified master data.
|
||||
* @param master the master @a SymbolString for identifying the @a Message.
|
||||
* @return the @a Message instance, or NULL.
|
||||
* Note: the caller may not free the returned instance.
|
||||
@@ -221,6 +226,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
/** the minimum ID length used by any of the known @a Message instances. */
|
||||
unsigned char m_minIdLength;
|
||||
|
||||
/** the maximum ID length used by any of the known @a Message instances. */
|
||||
unsigned char m_maxIdLength;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user