also store derived scan messages with circuit name extended by address on success
This commit is contained in:
+21
-10
@@ -378,15 +378,25 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
Message* Message::derive(const unsigned char dstAddress, unsigned char srcAddress)
|
||||
Message* Message::derive(const unsigned char dstAddress, const unsigned char srcAddress, const string circuit)
|
||||
{
|
||||
return new Message(m_circuit, m_name, m_isWrite,
|
||||
m_isPassive, m_comment,
|
||||
return new Message(circuit.length()==0 ? m_circuit : circuit, m_name,
|
||||
m_isWrite, m_isPassive, m_comment,
|
||||
srcAddress==SYN ? m_srcAddress : srcAddress, dstAddress,
|
||||
m_id, m_data, false,
|
||||
m_pollPriority, m_condition);
|
||||
}
|
||||
|
||||
Message* Message::derive(const unsigned char dstAddress, const bool extendCircuit)
|
||||
{
|
||||
if (extendCircuit) {
|
||||
ostringstream out;
|
||||
out << m_circuit << '.' << hex << setw(2) << setfill('0') << static_cast<unsigned>(dstAddress);
|
||||
return derive(dstAddress, SYN, out.str());
|
||||
}
|
||||
return derive(dstAddress);
|
||||
}
|
||||
|
||||
bool Message::checkIdPrefix(vector<unsigned char>& id)
|
||||
{
|
||||
if (id.size() > m_id.size())
|
||||
@@ -746,11 +756,12 @@ ChainedMessage::~ChainedMessage()
|
||||
free(m_lastSlaveUpdateTimes);
|
||||
}
|
||||
|
||||
Message* ChainedMessage::derive(const unsigned char dstAddress, unsigned char srcAddress)
|
||||
Message* ChainedMessage::derive(const unsigned char dstAddress, const unsigned char srcAddress, const string circuit)
|
||||
{
|
||||
return new ChainedMessage(m_circuit, m_name, m_isWrite,
|
||||
m_comment, srcAddress==SYN ? m_srcAddress : srcAddress, dstAddress, m_id,
|
||||
m_ids, m_lengths, m_data, false,
|
||||
return new ChainedMessage(circuit.length()==0 ? m_circuit : circuit, m_name,
|
||||
m_isWrite, m_comment,
|
||||
srcAddress==SYN ? m_srcAddress : srcAddress, dstAddress,
|
||||
m_id, m_ids, m_lengths, m_data, false,
|
||||
m_pollPriority, m_condition);
|
||||
}
|
||||
|
||||
@@ -1075,7 +1086,7 @@ result_t SimpleCondition::resolve(MessageMap* messages, ostringstream& errorMess
|
||||
unsigned long long key = message->getDerivedKey(m_dstAddress);
|
||||
vector<Message*>* derived = messages->getByKey(key);
|
||||
if (derived==NULL) {
|
||||
message = message->derive(m_dstAddress);
|
||||
message = message->derive(m_dstAddress, true);
|
||||
messages->add(message);
|
||||
} else {
|
||||
message = getFirstAvailable(*derived, *message);
|
||||
@@ -1349,8 +1360,8 @@ Message* MessageMap::getScanMessage(const unsigned char dstAddress)
|
||||
vector<Message*>* msgs = getByKey(key);
|
||||
if (msgs!=NULL)
|
||||
return msgs->front();
|
||||
Message* message = m_scanMessage->derive(dstAddress);
|
||||
add(message, false);
|
||||
Message* message = m_scanMessage->derive(dstAddress, true);
|
||||
add(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -143,9 +143,18 @@ public:
|
||||
* Derive a new @a Message from this message.
|
||||
* @param dstAddress the new destination address.
|
||||
* @param srcAddress the new source address, or @a SYN to keep the current source address.
|
||||
* @param circuit the new circuit name, or empty to use the current circuit name.
|
||||
* @return the derived @a Message instance.
|
||||
*/
|
||||
virtual Message* derive(const unsigned char dstAddress, unsigned char srcAddress=SYN);
|
||||
virtual Message* derive(const unsigned char dstAddress, const unsigned char srcAddress=SYN, const string circuit="");
|
||||
|
||||
/**
|
||||
* Derive a new @a Message from this message.
|
||||
* @param dstAddress the new destination address.
|
||||
* @param extendCircuit whether to extend the current circuit name with a dot and the new destination address in hex.
|
||||
* @return the derived @a Message instance.
|
||||
*/
|
||||
Message* derive(const unsigned char dstAddress, const bool extendCircuit);
|
||||
|
||||
/**
|
||||
* Get the optional circuit name.
|
||||
@@ -548,7 +557,7 @@ public:
|
||||
virtual ~ChainedMessage();
|
||||
|
||||
// @copydoc
|
||||
virtual Message* derive(const unsigned char dstAddress, unsigned char srcAddress=SYN);
|
||||
virtual Message* derive(const unsigned char dstAddress, const unsigned char srcAddress=SYN, const string circuit="");
|
||||
|
||||
// @copydoc
|
||||
virtual unsigned char getIdLength() const { return (unsigned char)(m_ids[0].size() - 2); }
|
||||
|
||||
Reference in New Issue
Block a user