mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
add an easy way for a state to ignore packets by creating a ReceiveTransition back to itself
This commit is contained in:
parent
9db07dc8d5
commit
e9c511c2c2
|
@ -346,6 +346,24 @@ class State(object):
|
|||
"""Called with PDU received after match."""
|
||||
self.state_machine.after_receive(pdu)
|
||||
|
||||
def ignore(self, pdu_type, **pdu_attrs):
|
||||
"""Create a ReceiveTransition from this state to itself, if match
|
||||
is successful the effect is to ignore the PDU.
|
||||
|
||||
:param criteria: PDU to match
|
||||
"""
|
||||
if _debug: State._debug("ignore(%s) %r %r", self.doc_string, pdu_type, pdu_attrs)
|
||||
|
||||
# create a bundle of the match criteria
|
||||
criteria = (pdu_type, pdu_attrs)
|
||||
if _debug: State._debug(" - criteria: %r", criteria)
|
||||
|
||||
# add this to the list of transitions
|
||||
self.receive_transitions.append(ReceiveTransition(criteria, self))
|
||||
|
||||
# return this state, no new state is created
|
||||
return self
|
||||
|
||||
def unexpected_receive(self, pdu):
|
||||
"""Called with PDU that did not match. Unless this is trapped by the
|
||||
state, the default behaviour is to fail."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user