fix for storing own prepared master data, set m_lastUpdateTime only if reasonable data was seen
This commit is contained in:
@@ -497,12 +497,9 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
|
|||||||
result = prepareMasterPart(master, input, separator, index);
|
result = prepareMasterPart(master, input, separator, index);
|
||||||
if (result != RESULT_OK)
|
if (result != RESULT_OK)
|
||||||
return result;
|
return result;
|
||||||
result = storeLastData(pt_masterData, master, index);
|
|
||||||
if (result < RESULT_OK)
|
|
||||||
return result;
|
|
||||||
masterData.clear();
|
masterData.clear();
|
||||||
masterData.addAll(master);
|
masterData.addAll(master);
|
||||||
return RESULT_OK;
|
return storeLastData(pt_masterData, masterData, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
result_t Message::prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index)
|
result_t Message::prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index)
|
||||||
@@ -558,7 +555,9 @@ result_t Message::storeLastData(SymbolString& master, SymbolString& slave)
|
|||||||
|
|
||||||
result_t Message::storeLastData(const PartType partType, SymbolString& data, unsigned char index)
|
result_t Message::storeLastData(const PartType partType, SymbolString& data, unsigned char index)
|
||||||
{
|
{
|
||||||
time(&m_lastUpdateTime);
|
if (data.size() > 0 && (this->m_dstAddress == BROADCAST || partType == pt_slaveData)) {
|
||||||
|
time(&m_lastUpdateTime);
|
||||||
|
}
|
||||||
if (partType == pt_masterData) {
|
if (partType == pt_masterData) {
|
||||||
switch (data.compareMaster(m_lastMasterData)) {
|
switch (data.compareMaster(m_lastMasterData)) {
|
||||||
case 1: // completely different
|
case 1: // completely different
|
||||||
|
|||||||
@@ -396,14 +396,14 @@ public:
|
|||||||
SymbolString& getLastSlaveData() { return m_lastSlaveData; }
|
SymbolString& getLastSlaveData() { return m_lastSlaveData; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time when @a m_lastValue was last stored.
|
* Get the time when this message was last seen with reasonable data.
|
||||||
* @return the time when @a m_lastValue was last stored, or 0 if this message was not decoded yet.
|
* @return the time when this message was last seen, or 0.
|
||||||
*/
|
*/
|
||||||
time_t getLastUpdateTime() { return m_lastUpdateTime; }
|
time_t getLastUpdateTime() { return m_lastUpdateTime; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time when @a m_lastValue was last changed.
|
* Get the time when the message data was last changed.
|
||||||
* @return the time when @a m_lastValue was last changed, or 0 if this message was not decoded yet.
|
* @return the time when the message data was last changed, or 0 if this message was not decoded yet.
|
||||||
*/
|
*/
|
||||||
time_t getLastChangeTime() { return m_lastChangeTime; }
|
time_t getLastChangeTime() { return m_lastChangeTime; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user