ResponseCollector
ResponseCollector

Stores all the expected command responses

Variables
m_expectedResponses
std::vector<ResponseInfo> m_expectedResponses

Holds the response patterns that, if matched, belong to this collector

m_responseMutex
std::mutex m_responseMutex

A mutex used for thread safety when accessing/modifying the m_expectedResponses vector

m_connection
Connection* m_connection

The Connection pointer to use for retrieving byte information.

Functions
setConnection
void setConnection(
Connection *connection
)

Sets the connection points to use for retrieving byte information.

Parameters
connection

The Connection pointer to use for retrieving byte info.

registerResponse
void registerResponse(
ResponsePattern *response
)

Registers a ResponsePattern with this collector

Parameters
response

The ResponsePattern to register

unregisterResponse
void unregisterResponse(
ResponsePattern *response
)

Unregisters a ResponsePattern that is within this collector

Parameters
response

A pointer to the ResponsePattern to unregister

waitingForResponse
bool waitingForResponse()

Gets whether or not this response collector currently has any response patterns to match

Returns

true if the response collector has any response patterns to match, false otherwise

matchExpected
bool matchExpected(
DataBuffer &data
)

Checks to see if the byte(s) passed in match any of the expected responses

Parameters
data

The DataBuffer containing the bytes to be read and compared against the expected responses, starting at the current read position.

Returns

true if the byte(s) matched an expected response, false otherwise

matchExpected
bool matchExpected(
const WirelessPacket &packet,
std::size_t lastReadPos
)

Checks to see if the wireless packet passed in matches any of the expected responses

Parameters
packet

The WirelessPacket to be compared against the expected responses

lastReadPos
std::size_t

The last read position where the packet was parsed from.

Returns

true if the packet matched an expected response, false otherwise

matchExpected
bool matchExpected(
InertialDataField &field
)

Checks to see if the InertialDataField passed in matches any of the expected responses

Parameters
field

The InertialDataField to be compared against the expected responses

Returns

true if the packet matched an expected response, false otherwise