diff options
author | dxiao <dxiao@mit.edu> | 2011-02-20 19:30:43 -0500 |
---|---|---|
committer | dxiao <dxiao@mit.edu> | 2011-02-20 19:30:43 -0500 |
commit | 42a3112b7cd7518ab69ba8d69c636a6278cfb288 (patch) | |
tree | e985992c23f1670f0e3ba17939bd68f1010af82d /behaviors/RunFinite.py | |
parent | 00576b225ad8b60ef1e0291e231aa499042436ba (diff) |
Added SplitBehavior and RunFinite behaviors
Diffstat (limited to 'behaviors/RunFinite.py')
-rw-r--r-- | behaviors/RunFinite.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/behaviors/RunFinite.py b/behaviors/RunFinite.py new file mode 100644 index 0000000..de2ce27 --- /dev/null +++ b/behaviors/RunFinite.py @@ -0,0 +1,25 @@ +from operationscore.Behavior import * +import util.ComponentRegistry as compReg + +class RunFinite(Behavior): + """RunFinite will just wire input to output, but only a finite number of + times as specified by the Iterations argument tag""" + + def behaviorInit(self): + pass + + def processResponse(self, inp, state): + + if state: + iterations = state + else: + iterations = self['Iterations'] + + if iterations > 0: + out = inp + else: + out = [] + + iterations -= 1 + + return (out, iterations) |