-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ed0545
commit 98ccb45
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from goofi.data import Data, DataType | ||
from goofi.node import Node | ||
from goofi.params import BoolParam | ||
|
||
|
||
class StringAwait(Node): | ||
def config_input_slots(): | ||
return {"message": DataType.STRING, "trigger": DataType.ARRAY} | ||
|
||
def config_output_slots(): | ||
return {"out": DataType.STRING} | ||
|
||
def config_params(): | ||
return { | ||
"string_await": { | ||
"require_change": BoolParam(True, doc="Only output when the message changes, and we have an unconsumed trigger") | ||
} | ||
} | ||
|
||
def setup(self): | ||
self.last_message = None | ||
|
||
def process(self, message: Data, trigger: Data): | ||
if trigger is None or message is None: | ||
return | ||
|
||
if self.params.string_await.require_change.value and self.last_message == message.data: | ||
return | ||
|
||
self.input_slots["trigger"].clear() | ||
|
||
self.last_message = message.data | ||
return {"out": (message.data, message.meta)} |