added since and until params to MessageMap::findAll(), added column constants

This commit is contained in:
john30
2017-01-07 16:04:33 +01:00
parent 63e5cb3105
commit 2c0216a73b
2 changed files with 54 additions and 13 deletions
+21 -10
View File
@@ -745,7 +745,7 @@ void Message::dump(ostream& output, vector<size_t>* columns, bool withConditions
void Message::dumpColumn(ostream& output, size_t column, bool withConditions) void Message::dumpColumn(ostream& output, size_t column, bool withConditions)
{ {
switch (column) { switch (column) {
case 0: // type case COLUMN_TYPE: // type
if (withConditions && m_condition!=NULL) { if (withConditions && m_condition!=NULL) {
m_condition->dump(output); m_condition->dump(output);
} }
@@ -761,34 +761,34 @@ void Message::dumpColumn(ostream& output, size_t column, bool withConditions)
output << static_cast<unsigned>(m_pollPriority); output << static_cast<unsigned>(m_pollPriority);
} }
break; break;
case 1: // circuit case COLUMN_CIRCUIT: // circuit
DataField::dumpString(output, m_circuit, false); DataField::dumpString(output, m_circuit, false);
break; break;
case 2: // name case COLUMN_NAME: // name
DataField::dumpString(output, m_name, false); DataField::dumpString(output, m_name, false);
break; break;
case 3: // comment case COLUMN_COMMENT: // comment
DataField::dumpString(output, m_comment, false); DataField::dumpString(output, m_comment, false);
break; break;
case 4: // QQ case COLUMN_QQ: // QQ
if (m_srcAddress != SYN) if (m_srcAddress != SYN)
output << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_srcAddress); output << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_srcAddress);
break; break;
case 5: // ZZ case COLUMN_ZZ: // ZZ
if (m_dstAddress != SYN) if (m_dstAddress != SYN)
output << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_dstAddress); output << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_dstAddress);
break; break;
case 6: // PBSB case COLUMN_PBSB: // PBSB
for (vector<unsigned char>::const_iterator it = m_id.begin(); it < m_id.begin()+2 && it < m_id.end(); it++) { for (vector<unsigned char>::const_iterator it = m_id.begin(); it < m_id.begin()+2 && it < m_id.end(); it++) {
output << hex << setw(2) << setfill('0') << static_cast<unsigned>(*it); output << hex << setw(2) << setfill('0') << static_cast<unsigned>(*it);
} }
break; break;
case 7: // ID case COLUMN_ID: // ID
for (vector<unsigned char>::const_iterator it = m_id.begin()+2; it < m_id.end(); it++) { for (vector<unsigned char>::const_iterator it = m_id.begin()+2; it < m_id.end(); it++) {
output << hex << setw(2) << setfill('0') << static_cast<unsigned>(*it); output << hex << setw(2) << setfill('0') << static_cast<unsigned>(*it);
} }
break; break;
case 8: // fields case COLUMN_FIELDS: // fields
m_data->dump(output); m_data->dump(output);
break; break;
} }
@@ -1898,7 +1898,8 @@ Message* MessageMap::find(const string& circuit, const string& name, const bool
deque<Message*> MessageMap::findAll(const string& circuit, const string& name, const bool completeMatch, deque<Message*> MessageMap::findAll(const string& circuit, const string& name, const bool completeMatch,
const bool withRead, const bool withWrite, const bool withPassive, const bool withRead, const bool withWrite, const bool withPassive,
const bool completeMatchIgnoreCircuitSuffix, const bool onlyAvailable) const bool completeMatchIgnoreCircuitSuffix, const bool onlyAvailable,
const time_t since, const time_t until)
{ {
bool checkCircuitIgnoreSuffix = completeMatch && completeMatchIgnoreCircuitSuffix; bool checkCircuitIgnoreSuffix = completeMatch && completeMatchIgnoreCircuitSuffix;
deque<Message*> ret; deque<Message*> ret;
@@ -1950,6 +1951,16 @@ deque<Message*> MessageMap::findAll(const string& circuit, const string& name, c
continue; continue;
} }
} }
if (since!=0 || until!=0) {
if (message->getDstAddress() == SYN) {
continue;
}
time_t lastchg = message->getLastChangeTime();
if ((since!=0 && lastchg < since)
|| (until!=0 && lastchg >= until)) {
continue;
}
}
if (!onlyAvailable || message->isAvailable()) { if (!onlyAvailable || message->isAvailable()) {
ret.push_back(*msgIt); ret.push_back(*msgIt);
} }
+33 -3
View File
@@ -61,6 +61,33 @@ class SimpleCondition;
class CombinedCondition; class CombinedCondition;
class MessageMap; class MessageMap;
/** the column index in @a Message::dump() for the message type. */
#define COLUMN_TYPE 0
/** the column index in @a Message::dump() for the circuit name. */
#define COLUMN_CIRCUIT 1
/** the column index in @a Message::dump() for the message name. */
#define COLUMN_NAME 2
/** the column index in @a Message::dump() for the message comment. */
#define COLUMN_COMMENT 3
/** the column index in @a Message::dump() for the source address QQ. */
#define COLUMN_QQ 4
/** the column index in @a Message::dump() for the destination address QQ. */
#define COLUMN_ZZ 5
/** the column index in @a Message::dump() for the PBSB bytes. */
#define COLUMN_PBSB 6
/** the column index in @a Message::dump() for the ID columns (after the PBSB bytes). */
#define COLUMN_ID 7
/** the column index in @a Message::dump() for the field(s). */
#define COLUMN_FIELDS 8
/** /**
* Defines parameters of a message sent or received on the bus. * Defines parameters of a message sent or received on the bus.
*/ */
@@ -472,7 +499,7 @@ public:
/** /**
* Write the message definition or parts of it to the @a ostream. * Write the message definition or parts of it to the @a ostream.
* @param output the @a ostream to append the formatted value to. * @param output the @a ostream to append the formatted value to.
* @param columns the list of column indexes to write, or NULL for all. * @param columns the list of column indexes to write, or NULL for all (see @p COLUMN_TYPE index constants).
* @param withConditions whether to include the optional conditions prefix. * @param withConditions whether to include the optional conditions prefix.
*/ */
void dump(ostream& output, vector<size_t>* columns=NULL, bool withConditions=false); void dump(ostream& output, vector<size_t>* columns=NULL, bool withConditions=false);
@@ -480,7 +507,7 @@ public:
/** /**
* Write the specified column to the @a ostream. * Write the specified column to the @a ostream.
* @param output the @a ostream to append the formatted value to. * @param output the @a ostream to append the formatted value to.
* @param column the column indexes to write. * @param column the column index to write (see @p COLUMN_TYPE index constants).
* @param withConditions whether to include the optional conditions prefix. * @param withConditions whether to include the optional conditions prefix.
*/ */
virtual void dumpColumn(ostream& output, size_t column, bool withConditions); virtual void dumpColumn(ostream& output, size_t column, bool withConditions);
@@ -1242,11 +1269,14 @@ public:
* @return the found @a Message instances. * @return the found @a Message instances.
* @param completeMatchIgnoreCircuitSuffix ignore different circuit suffixes (after "#") for completeMatch. * @param completeMatchIgnoreCircuitSuffix ignore different circuit suffixes (after "#") for completeMatch.
* @param onlyAvailable true to include only available messages (default true), false to also include messages that are currently not available (e.g. due to unresolved or false conditions). * @param onlyAvailable true to include only available messages (default true), false to also include messages that are currently not available (e.g. due to unresolved or false conditions).
* @param since the start time from which to add updates (inclusive, also removes messages with unset destination address), or 0 to ignore.
* @param until the end time to which to add updates (exclusive, also removes messages with unset destination address), or 0 to ignore.
* Note: the caller may not free the returned instances. * Note: the caller may not free the returned instances.
*/ */
deque<Message*> findAll(const string& circuit, const string& name, const bool completeMatch=true, deque<Message*> findAll(const string& circuit, const string& name, const bool completeMatch=true,
const bool withRead=true, const bool withWrite=false, const bool withPassive=false, const bool withRead=true, const bool withWrite=false, const bool withPassive=false,
const bool completeMatchIgnoreCircuitSuffix=false, const bool onlyAvailable=true); const bool completeMatchIgnoreCircuitSuffix=false, const bool onlyAvailable=true,
const time_t since=0, const time_t until=0);
/** /**
* Find the @a Message instance for the specified master data. * Find the @a Message instance for the specified master data.