added simple ctor, added override dstAddress to prepareMaster()
This commit is contained in:
@@ -28,10 +28,10 @@
|
||||
using namespace std;
|
||||
|
||||
Message::Message(const string clazz, const string name, const bool isSet,
|
||||
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)
|
||||
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)
|
||||
: m_class(clazz), m_name(name), m_isSet(isSet),
|
||||
m_isPassive(isPassive), m_comment(comment),
|
||||
m_srcAddress(srcAddress), m_dstAddress(dstAddress),
|
||||
@@ -50,6 +50,20 @@ Message::Message(const string clazz, const string name, const bool isSet,
|
||||
m_key = key;
|
||||
}
|
||||
|
||||
Message::Message(const bool isSet, const bool isPassive,
|
||||
const unsigned char pb, const unsigned char sb,
|
||||
DataField* data)
|
||||
: m_class(), m_name(), m_isSet(isSet),
|
||||
m_isPassive(isPassive), m_comment(),
|
||||
m_srcAddress(SYN), m_dstAddress(SYN),
|
||||
m_data(data), m_pollPriority(0),
|
||||
m_lastUpdateTime(0), m_pollCount(0), m_lastPollTime(0)
|
||||
{
|
||||
m_id.push_back(pb);
|
||||
m_id.push_back(sb);
|
||||
m_key = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper method for getting a default if the value is empty.
|
||||
* @param value the value to check.
|
||||
@@ -223,7 +237,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& masterData, istringstream& input, char separator)
|
||||
result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& masterData, istringstream& input, char separator, const unsigned char dstAddress)
|
||||
{
|
||||
if (m_isPassive == true)
|
||||
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||
@@ -232,7 +246,10 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
|
||||
result_t result = master.push_back(srcAddress, false, false);
|
||||
if (result != RESULT_OK)
|
||||
return result;
|
||||
result = master.push_back(m_dstAddress, false, false);
|
||||
if (dstAddress == SYN)
|
||||
result = master.push_back(m_dstAddress, false, false);
|
||||
else
|
||||
result = master.push_back(dstAddress, false, false);
|
||||
if (result != RESULT_OK)
|
||||
return result;
|
||||
result = master.push_back(m_id[0], false, false);
|
||||
|
||||
+17
-2
@@ -58,6 +58,18 @@ public:
|
||||
const unsigned char srcAddress, const unsigned char dstAddress,
|
||||
const vector<unsigned char> id, DataField* data,
|
||||
const unsigned int pollPriority);
|
||||
/**
|
||||
* @brief Construct a new temporary instance.
|
||||
* @param isSet whether this is a set message.
|
||||
* @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 pb the primary ID byte.
|
||||
* @param sb the secondary ID byte.
|
||||
* @param data the @a DataField for encoding/decoding the message.
|
||||
*/
|
||||
Message(const bool isSet, const bool isPassive,
|
||||
const unsigned char pb, const unsigned char sb,
|
||||
DataField* data);
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
@@ -129,13 +141,16 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Prepare the master @a SymbolString for sending a query or command to the bus.
|
||||
* @param srcAddress the source address to set.
|
||||
* @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.
|
||||
* @param dstAddress the destination address to set, or @a SYN to keep the address defined during construction.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t prepareMaster(const unsigned char srcAddress, SymbolString& masterData,
|
||||
istringstream& input, char separator=UI_FIELD_SEPARATOR);
|
||||
istringstream& input, char separator=UI_FIELD_SEPARATOR,
|
||||
const unsigned char dstAddress=SYN);
|
||||
|
||||
/**
|
||||
* @brief Prepare the slave @a SymbolString for sending an answer to the bus.
|
||||
@@ -199,7 +214,7 @@ private:
|
||||
/** the destination address. */
|
||||
const unsigned char m_dstAddress;
|
||||
/** the primary, secondary, and optionally further command ID bytes. */
|
||||
const vector<unsigned char> m_id;
|
||||
vector<unsigned char> m_id;
|
||||
/** the key for storing in @a MessageSet. */
|
||||
unsigned long long m_key;
|
||||
/** the @a DataField for encoding/decoding the message. */
|
||||
|
||||
Reference in New Issue
Block a user