diff options
author | Daniel <dmt@daniel-desktop.(none)> | 2011-01-29 18:54:50 -0800 |
---|---|---|
committer | Daniel <dmt@daniel-desktop.(none)> | 2011-01-29 18:54:50 -0800 |
commit | ff07b18748c64243c1c6bc62f489bfd03205d13a (patch) | |
tree | db95373a3511be0dd1e700a78e9f1ea7320769a4 /inputs/RandomLocs.py | |
parent | 83931a3c8e65b4018e98b4986458d1df7172ab91 (diff) | |
parent | 277a5143165d2553ce5e97f151cc6b3cea426468 (diff) |
Merge branch 'master' of github.com:rcoh/SmootLight
Diffstat (limited to 'inputs/RandomLocs.py')
-rw-r--r-- | inputs/RandomLocs.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/inputs/RandomLocs.py b/inputs/RandomLocs.py index 2719981..f4182cf 100644 --- a/inputs/RandomLocs.py +++ b/inputs/RandomLocs.py @@ -1,16 +1,16 @@ -import util.TimeOps as clock -import random -import util.Geo as Geo -import util.Strings as Strings -from operationscore.Input import * -class RandomLocs(Input): - """RandomLocs is an Input that generates RandomLocations at a preset time interval. Just a - prototype, some assembly required.""" - - def inputInit(self): - self['LastEvent'] = clock.time() - def sensingLoop(self): #TODO: move to params - currentTime = clock.time() - if currentTime - self['LastEvent'] > 2000: - self.respond({Strings.LOCATION: Geo.randomLoc((50,50))}) - self['LastEvent'] = currentTime +import util.TimeOps as clock
+import random
+import util.Geo as Geo
+import util.Strings as Strings
+from operationscore.Input import *
+class RandomLocs(Input):
+ """RandomLocs is an Input that generates RandomLocations at a preset but randomly changing time interval. Just a
+ prototype, some assembly required."""
+
+ def inputInit(self):
+ self['LastEvent'] = clock.time()
+ def sensingLoop(self): #TODO: move to params
+ currentTime = clock.time()
+ if currentTime - self['LastEvent'] > 200+500*random.random():
+ self.respond({Strings.LOCATION: Geo.randomLoc((200,200))})
+ self['LastEvent'] = currentTime
|