<s> from calvin . actor . actor import Actor , ActionResult , manage , condition , guard <EOL> class RecTimer ( Actor ) : <EOL> """<STR_LIT>""" <EOL> @ manage ( [ '<STR_LIT>' ] ) <EOL> def init ( self , delay = <NUM_LIT:0.1> ) : <EOL> self . delay = delay <EOL> self . use ( '<STR_LIT>' , shorthand = '<STR_LIT>' ) <EOL> self . setup ( ) <EOL> def setup ( self ) : <EOL> self . timer = self [ '<STR_LIT>' ] . repeat ( self . delay ) <EOL> def will_migrate ( self ) : <EOL> self . timer . cancel ( ) <EOL> def did_migrate ( self ) : <EOL> self . setup ( ) <EOL> @ condition ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> @ guard ( lambda self , _ : self . timer and self . timer . triggered ) <EOL> def flush ( self , input ) : <EOL> return ActionResult ( production = ( input , ) ) <EOL> @ condition ( ) <EOL> @ guard ( lambda self : self . timer and self . timer . triggered ) <EOL> def clear ( self ) : <EOL> self . timer . ack ( ) <EOL> return ActionResult ( ) <EOL> action_priority = ( flush , clear ) <EOL> requires = [ '<STR_LIT>' ] <EOL> test_args = [ <NUM_LIT:1> ] <EOL> test_set = [ <EOL> { <EOL> '<STR_LIT>' : [ lambda self : self . timer . trigger ( ) ] , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : [ ] } <EOL> } <EOL> ] <EOL> test_set += [ <EOL> { '<STR_LIT>' : { '<STR_LIT>' : [ r ] } , '<STR_LIT>' : { '<STR_LIT>' : [ ] } } for r in range ( <NUM_LIT:3> ) <EOL> ] <EOL> test_set += [ <EOL> { <EOL> '<STR_LIT>' : [ lambda self : self . timer . trigger ( ) ] , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : [ <NUM_LIT:0> ] } <EOL> } , <EOL> { '<STR_LIT>' : { '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : [ <NUM_LIT:1> ] } } , <EOL> { '<STR_LIT>' : { '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : [ <NUM_LIT:2> ] } } <EOL> ] </s>
