<s> import sys <EOL> from calvin . actor . actor import Actor , ActionResult , manage , condition , guard <EOL> class CountTimerUnsigned ( Actor ) : <EOL> """<STR_LIT>""" <EOL> @ manage ( exclude = [ '<STR_LIT>' ] ) <EOL> def init ( self , sleep = <NUM_LIT:0.1> , steps = sys . maxint ) : <EOL> self . count = <NUM_LIT:0> <EOL> self . sleep = sleep <EOL> self . steps = steps <EOL> self . setup ( ) <EOL> def setup ( self ) : <EOL> self . use ( "<STR_LIT>" , shorthand = "<STR_LIT>" ) <EOL> if self . count < <NUM_LIT:3> : <EOL> self . timer = self [ '<STR_LIT>' ] . once ( self . sleep ) <EOL> else : <EOL> self . timer = self [ '<STR_LIT>' ] . repeat ( self . sleep ) <EOL> def will_migrate ( self ) : <EOL> self . timer . cancel ( ) <EOL> def did_migrate ( self ) : <EOL> self . setup ( ) <EOL> def will_end ( self ) : <EOL> self . timer . cancel ( ) <EOL> def timer_trigger_stepwise ( self ) : <EOL> return self . timer . triggered and self . count < self . steps and self . count < <NUM_LIT:3> <EOL> def timer_trigger_repeat ( self ) : <EOL> return self . timer . triggered and self . count < self . steps <EOL> def timer_trigger_stopped ( self ) : <EOL> return self . timer . triggered and self . count >= self . steps <EOL> @ condition ( action_output = ( '<STR_LIT>' , ) ) <EOL> @ guard ( timer_trigger_stepwise ) <EOL> def step_no_periodic ( self ) : <EOL> self . timer . ack ( ) <EOL> if self . count == <NUM_LIT:2> : <EOL> self . timer = self [ '<STR_LIT>' ] . repeat ( self . sleep ) <EOL> else : <EOL> self . timer = self [ '<STR_LIT>' ] . once ( self . sleep ) <EOL> self . count += <NUM_LIT:1> <EOL> return ActionResult ( production = ( self . count , ) ) <EOL> @ condition ( action_output = ( '<STR_LIT>' , ) ) <EOL> @ guard ( timer_trigger_repeat ) <EOL> def step_periodic ( self ) : <EOL> self . timer . ack ( ) <EOL> self . count += <NUM_LIT:1> <EOL> return ActionResult ( production = ( self . count , ) ) <EOL> @ condition ( ) <EOL> @ guard ( timer_trigger_stopped ) <EOL> def stop ( self ) : <EOL> self . timer . ack ( ) <EOL> self . timer . cancel ( ) <EOL> return ActionResult ( ) <EOL> def report ( self ) : <EOL> return self . count <EOL> action_priority = ( step_no_periodic , step_periodic , stop ) <EOL> requires = [ '<STR_LIT>' ] </s>
