added last time to GrabbedMessage in preparation of direct mode
This commit is contained in:
Executable → Regular
+27
-13
@@ -190,6 +190,7 @@ bool ActiveBusRequest::notify(result_t result, const SlaveSymbolString& slave) {
|
|||||||
|
|
||||||
|
|
||||||
void GrabbedMessage::setLastData(const MasterSymbolString& master, const SlaveSymbolString& slave) {
|
void GrabbedMessage::setLastData(const MasterSymbolString& master, const SlaveSymbolString& slave) {
|
||||||
|
time(&m_lastTime);
|
||||||
m_lastMaster = master;
|
m_lastMaster = master;
|
||||||
m_lastSlave = slave;
|
m_lastSlave = slave;
|
||||||
m_count++;
|
m_count++;
|
||||||
@@ -249,7 +250,8 @@ bool decodeType(const DataType* type, const SymbolString& input, size_t length,
|
|||||||
return !first;
|
return !first;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrabbedMessage::dump(bool unknown, MessageMap* messages, bool first, bool decode, ostringstream* output) const {
|
bool GrabbedMessage::dump(bool unknown, MessageMap* messages, bool first, bool decode, ostringstream* output,
|
||||||
|
bool isDirectMode) const {
|
||||||
Message* message = messages->find(m_lastMaster);
|
Message* message = messages->find(m_lastMaster);
|
||||||
if (unknown && message) {
|
if (unknown && message) {
|
||||||
return false;
|
return false;
|
||||||
@@ -260,11 +262,13 @@ bool GrabbedMessage::dump(bool unknown, MessageMap* messages, bool first, bool d
|
|||||||
symbol_t dstAddress = m_lastMaster[1];
|
symbol_t dstAddress = m_lastMaster[1];
|
||||||
*output << m_lastMaster.getStr();
|
*output << m_lastMaster.getStr();
|
||||||
if (dstAddress != BROADCAST && !isMaster(dstAddress)) {
|
if (dstAddress != BROADCAST && !isMaster(dstAddress)) {
|
||||||
*output << " / " << m_lastSlave.getStr();
|
*output << (isDirectMode ? " " : " / ") << m_lastSlave.getStr();
|
||||||
}
|
}
|
||||||
*output << " = " << m_count;
|
if (!isDirectMode) {
|
||||||
if (message) {
|
*output << " = " << m_count;
|
||||||
*output << ": " << message->getCircuit() << " " << message->getName();
|
if (message) {
|
||||||
|
*output << ": " << message->getCircuit() << " " << message->getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (decode) {
|
if (decode) {
|
||||||
DataTypeList *types = DataTypeList::getInstance();
|
DataTypeList *types = DataTypeList::getInstance();
|
||||||
@@ -1544,16 +1548,26 @@ bool BusHandler::enableGrab(bool enable) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusHandler::formatGrabResult(bool unknown, bool decode, ostringstream* output) const {
|
void BusHandler::formatGrabResult(bool unknown, bool decode, ostringstream* output, bool isDirectMode,
|
||||||
|
time_t since, time_t until) const {
|
||||||
if (!m_grabMessages) {
|
if (!m_grabMessages) {
|
||||||
*output << "grab disabled";
|
if (!isDirectMode) {
|
||||||
} else {
|
*output << "grab disabled";
|
||||||
bool first = true;
|
|
||||||
for (const auto& it : m_grabbedMessages) {
|
|
||||||
if (it.second.dump(unknown, m_messages, first, decode, output)) {
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool first = true;
|
||||||
|
for (const auto& it : m_grabbedMessages) {
|
||||||
|
if (since > 0 && it.second.getLastTime() < since
|
||||||
|
|| until > 0 && it.second.getLastTime() >= until) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (it.second.dump(unknown, m_messages, first, decode, output, isDirectMode)) {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isDirectMode && !first) {
|
||||||
|
*output << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+24
-3
@@ -296,7 +296,7 @@ class GrabbedMessage {
|
|||||||
/**
|
/**
|
||||||
* Construct a new instance.
|
* Construct a new instance.
|
||||||
*/
|
*/
|
||||||
GrabbedMessage() : m_count(0) {}
|
GrabbedMessage() : m_lastTime(0), m_count(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
@@ -314,6 +314,12 @@ class GrabbedMessage {
|
|||||||
*/
|
*/
|
||||||
void setLastData(const MasterSymbolString& master, const SlaveSymbolString& slave);
|
void setLastData(const MasterSymbolString& master, const SlaveSymbolString& slave);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last received time.
|
||||||
|
* @return the last received time.
|
||||||
|
*/
|
||||||
|
time_t getLastTime() const { return m_lastTime; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last @a MasterSymbolString.
|
* Get the last @a MasterSymbolString.
|
||||||
* @return the last @a MasterSymbolString.
|
* @return the last @a MasterSymbolString.
|
||||||
@@ -327,12 +333,17 @@ class GrabbedMessage {
|
|||||||
* @param first whether this is the first message to be added to the output.
|
* @param first whether this is the first message to be added to the output.
|
||||||
* @param decode whether to add decoding hints.
|
* @param decode whether to add decoding hints.
|
||||||
* @param output the @a ostringstream to format the messages to.
|
* @param output the @a ostringstream to format the messages to.
|
||||||
|
* @param isDirectMode true for direct mode, false for grab command.
|
||||||
* @return whether the message was added to the output.
|
* @return whether the message was added to the output.
|
||||||
*/
|
*/
|
||||||
bool dump(bool unknown, MessageMap* messages, bool first, bool decode, ostringstream* output) const;
|
bool dump(bool unknown, MessageMap* messages, bool first, bool decode, ostringstream* output,
|
||||||
|
bool isDirectMode = false) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/** the last received time. */
|
||||||
|
time_t m_lastTime;
|
||||||
|
|
||||||
/** the last @a MasterSymbolString. */
|
/** the last @a MasterSymbolString. */
|
||||||
MasterSymbolString m_lastMaster;
|
MasterSymbolString m_lastMaster;
|
||||||
|
|
||||||
@@ -516,13 +527,23 @@ class BusHandler : public WaitThread {
|
|||||||
*/
|
*/
|
||||||
bool enableGrab(bool enable = true);
|
bool enableGrab(bool enable = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether grabbing unknown messages is enabled.
|
||||||
|
* @return whether grabbing unknown messages is enabled.
|
||||||
|
*/
|
||||||
|
bool isGrabEnabled() { return m_grabMessages; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the grabbed messages to the @a ostringstream.
|
* Format the grabbed messages to the @a ostringstream.
|
||||||
* @param unknown whether to dump only unknown messages.
|
* @param unknown whether to dump only unknown messages.
|
||||||
* @param decode whether to add decoding hints.
|
* @param decode whether to add decoding hints.
|
||||||
* @param output the @a ostringstream to format the messages to.
|
* @param output the @a ostringstream to format the messages to.
|
||||||
|
* @param isDirectMode true for direct mode, false for grab command.
|
||||||
|
* @param since the start time from which to add received messages (inclusive), or 0 for all.
|
||||||
|
* @param until the end time to which to add received messages (exclusive), or 0 for all.
|
||||||
*/
|
*/
|
||||||
void formatGrabResult(bool unknown, bool decode, ostringstream* output) const;
|
void formatGrabResult(bool unknown, bool decode, ostringstream* output, bool isDirectMode = false,
|
||||||
|
time_t since = 0, time_t until = 0) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when a signal on the bus is available.
|
* Return true when a signal on the bus is available.
|
||||||
|
|||||||
Reference in New Issue
Block a user