summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorNicolas Schodet2011-06-13 00:40:31 +0200
committerNicolas Schodet2011-06-13 00:40:31 +0200
commit1ba50389bff517512e417500f4c52ceeafdb06a5 (patch)
tree59418d78032e48dc1a10ecba8ef1ec71971d36e2 /host
parent90a89850cbc3e4540543784813a71a7b2ac97dfc (diff)
host/simu: randomize team color
Diffstat (limited to 'host')
-rw-r--r--host/simu/robots/robospierre/model/bag.py3
-rw-r--r--host/simu/view/switch.py2
2 files changed, 5 insertions, 0 deletions
diff --git a/host/simu/robots/robospierre/model/bag.py b/host/simu/robots/robospierre/model/bag.py
index b9d3bc3f..cedb3805 100644
--- a/host/simu/robots/robospierre/model/bag.py
+++ b/host/simu/robots/robospierre/model/bag.py
@@ -28,11 +28,14 @@ from simu.model.motor_basic import MotorBasic
from simu.model.distance_sensor_sensopart import DistanceSensorSensopart
from simu.robots.robospierre.model.clamp import Clamp
from math import pi
+import random
class Bag:
def __init__ (self, scheduler, table, link_bag):
self.color_switch = Switch (link_bag.io_hub.contact[0], invert = True)
+ self.color_switch.state = random.choice ((False, True))
+ self.color_switch.notify ()
self.jack = Switch (link_bag.io_hub.contact[1], invert = True)
self.strat_switch = Switch (link_bag.io_hub.contact[9], invert = True)
self.contact = [ Switch (contact)
diff --git a/host/simu/view/switch.py b/host/simu/view/switch.py
index c0ec2d58..445cbd02 100644
--- a/host/simu/view/switch.py
+++ b/host/simu/view/switch.py
@@ -28,6 +28,8 @@ class Switch:
def __init__ (self, frame, model, text):
self.var = IntVar ()
+ if model.state is not None:
+ self.var.set ((0, 1)[model.state])
self.button = Checkbutton (frame, variable = self.var,
command = self.__update, text = text, indicatoron = False)
self.button.pack ()