added Message::setPollPriority and MessageMap::addPollMessage
This commit is contained in:
@@ -282,6 +282,15 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Message::setPollPriority(unsigned char priority)
|
||||||
|
{
|
||||||
|
if (priority == m_pollPriority || m_isPassive)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_pollPriority = priority;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& masterData, istringstream& input, char separator, const unsigned char dstAddress)
|
result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& masterData, istringstream& input, char separator, const unsigned char dstAddress)
|
||||||
{
|
{
|
||||||
if (m_isPassive)
|
if (m_isPassive)
|
||||||
@@ -538,10 +547,7 @@ result_t MessageMap::add(Message* message)
|
|||||||
m_maxIdLength = idLength;
|
m_maxIdLength = idLength;
|
||||||
m_messagesByKey[key] = message;
|
m_messagesByKey[key] = message;
|
||||||
|
|
||||||
if (message->getPollPriority() > 0) {
|
addPollMessage(message);
|
||||||
message->m_lastPollTime = m_pollMessages.size();
|
|
||||||
m_pollMessages.push(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
@@ -680,6 +686,14 @@ Message* MessageMap::find(SymbolString& master)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageMap::addPollMessage(Message* message)
|
||||||
|
{
|
||||||
|
if (message != NULL && message->getPollPriority() > 0) {
|
||||||
|
message->m_lastPollTime = m_pollMessages.size();
|
||||||
|
m_pollMessages.push(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessageMap::clear()
|
void MessageMap::clear()
|
||||||
{
|
{
|
||||||
// clear poll messages
|
// clear poll messages
|
||||||
|
|||||||
+14
-1
@@ -156,6 +156,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
unsigned char getPollPriority() const { return m_pollPriority; }
|
unsigned char getPollPriority() const { return m_pollPriority; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the polling priority.
|
||||||
|
* @param priority the polling priority, or 0 for no polling at all.
|
||||||
|
* @return true when the priority was changed, false otherwise.
|
||||||
|
*/
|
||||||
|
bool setPollPriority(unsigned char priority);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the master @a SymbolString for sending a query or command to the bus.
|
* Prepare the master @a SymbolString for sending a query or command to the bus.
|
||||||
* @param srcAddress the source address to set.
|
* @param srcAddress the source address to set.
|
||||||
@@ -290,7 +297,7 @@ private:
|
|||||||
const bool m_deleteData;
|
const bool m_deleteData;
|
||||||
|
|
||||||
/** the priority for polling, or 0 for no polling at all. */
|
/** the priority for polling, or 0 for no polling at all. */
|
||||||
const unsigned char m_pollPriority;
|
unsigned char m_pollPriority;
|
||||||
|
|
||||||
/** the last seen master data. */
|
/** the last seen master data. */
|
||||||
SymbolString m_lastMasterData;
|
SymbolString m_lastMasterData;
|
||||||
@@ -390,6 +397,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
Message* find(SymbolString& master);
|
Message* find(SymbolString& master);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a @a Message to the list of instances to poll.
|
||||||
|
* @param message the @a Message to poll.
|
||||||
|
*/
|
||||||
|
void addPollMessage(Message* message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all @a Message instances.
|
* Removes all @a Message instances.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user