Skip to content
Snippets Groups Projects
Commit 93d06b60 authored by phil's avatar phil Committed by Guillaume Valadon
Browse files

Added new pipe: TriggeredSwitch

parent f1288d41
No related branches found
No related tags found
No related merge requests found
...@@ -294,3 +294,24 @@ class TriggeredQueueingValve(Drain): ...@@ -294,3 +294,24 @@ class TriggeredQueueingValve(Drain):
self._send(msg) self._send(msg)
else: else:
self._high_send(msg) self._high_send(msg)
class TriggeredSwitch(Drain):
"""Let messages alternatively high or low, changing on trigger
+------^------+
>>-|-\ | /-|->>
| [up/down] |
>-|-/ | \-|->
+------^------+
"""
def __init__(self, start_state=True, name=None):
Drain.__init__(self, name=name)
self.low = start_state
def push(self, msg):
if self.low:
self._send(msg)
else:
self._high_send(msg)
high_push = push
def on_trigger(self, msg):
self.low ^= True
self._trigger(msg)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment