Package SmootLight :: Package inputs :: Module RandomLocs
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.inputs.RandomLocs

 1  import util.TimeOps as clock 
 2  import random 
 3  import util.Geo as Geo 
 4  import util.Strings as Strings 
 5  from operationscore.Input import * 
6 -class RandomLocs(Input):
7 """RandomLocs is an Input that generates RandomLocations at a preset but randomly changing time interval. Just a 8 prototype, some assembly required.""" 9
10 - def inputInit(self):
11 self['LastEvent'] = clock.time()
12 - def sensingLoop(self): #TODO: move to params
13 currentTime = clock.time() 14 if currentTime - self['LastEvent'] > 200+500*random.random(): 15 self.respond({Strings.LOCATION: Geo.randomLoc((200,200))}) 16 self['LastEvent'] = currentTime
17