El bobino del diabolo
This commit is contained in:
parent
d618bc0431
commit
0ab5589a0b
@ -15,6 +15,8 @@ class MyIvy:
|
||||
self.oncxproc, # handler called on connection/disconnection
|
||||
self.ondieproc) # handler called when a <die> message is received
|
||||
|
||||
self._createbind()
|
||||
|
||||
IvyStart(self.bus)
|
||||
|
||||
def oncxproc(self, agent, connected):
|
||||
|
@ -10,18 +10,23 @@ class automate:
|
||||
timer = None
|
||||
|
||||
def __init__(self):
|
||||
self.timer = Timer(5, self.timeout)
|
||||
self.timer = None
|
||||
self.form = None
|
||||
self.xy = None
|
||||
self.color = None
|
||||
|
||||
def new_geste(self, agent, *larg):
|
||||
print("new_geste " + str(larg))
|
||||
print("state = " + str(self.state))
|
||||
if self.state == 0:
|
||||
self.__reinit_timer()
|
||||
self.form = larg[0]
|
||||
self.state = 1
|
||||
print("endstate = " + str(self.state))
|
||||
|
||||
def new_click(self, agent, *larg):
|
||||
print("new click " + str(larg))
|
||||
print("state = " + str(self.state))
|
||||
if self.state == 1:
|
||||
self.__reinit_timer()
|
||||
self.xy = (larg[0], larg[1])
|
||||
@ -30,22 +35,33 @@ class automate:
|
||||
self.__reinit_timer()
|
||||
self.xy = (larg[0], larg[1])
|
||||
self.state = 1
|
||||
print("endstate = " + str(self.state))
|
||||
|
||||
def new_vocal_couleur(self, agent, *larg):
|
||||
if self.state == 1 and larg[0] in self.list_color:
|
||||
print("new vocal couleur " + str(larg))
|
||||
print("state = " + str(self.state))
|
||||
if self.state == 1 and larg[0].split(" ")[0] in self.list_color and int(larg[0].split(",")[1][0:2]) > 85:
|
||||
print(larg[0].split(" ")[0])
|
||||
self.__reinit_timer()
|
||||
self.color = self.list_color[larg[0]]
|
||||
self.color = self.list_color[larg[0].split(" ")[0]]
|
||||
self.state = 3
|
||||
elif self.state == 2:
|
||||
self.__reinit_timer()
|
||||
self.color = larg[0]
|
||||
self.state = 1
|
||||
print("endstate = " + str(self.state))
|
||||
|
||||
def new_vocal_action(self, agent, *larg):
|
||||
if self.state == 1 and larg[0] == "ici":
|
||||
print("new vocal action" + str(larg))
|
||||
print("state = " + str(self.state))
|
||||
if self.state == 1 and larg[0].split(" ")[0] == "ici":
|
||||
self.__reinit_timer()
|
||||
self.__maybe_send_create()
|
||||
self.state = 1
|
||||
print("endstate = " + str(self.state))
|
||||
|
||||
def all(self, agent, *larg):
|
||||
print("all " + str(larg))
|
||||
|
||||
def timeout(self):
|
||||
if self.state == 1:
|
||||
@ -54,13 +70,16 @@ class automate:
|
||||
self.state = 1
|
||||
|
||||
def __reinit_timer(self):
|
||||
pass
|
||||
"""if self.timer:
|
||||
self.timer.cancel()
|
||||
self.timer.start()
|
||||
self.timer = Timer(5, self.timeout)
|
||||
self.timer.start()"""
|
||||
|
||||
def __maybe_send_create(self):
|
||||
if None not in [self.form, self.xy, self.color]:
|
||||
print("Send Forme")
|
||||
IvySendMsg("MULTIMODAL forme={} x={} y={} couleur={}".format(self.form, self.xy[0], self.xy[1], self.color))
|
||||
self.form = None
|
||||
self.xy = None
|
||||
self.color = None
|
||||
|
||||
@ -69,10 +88,11 @@ class MyIvyMultiModale(myIvy.MyIvy):
|
||||
a = automate()
|
||||
|
||||
def _createbind(self):
|
||||
IvyBindMsg(self.a.new_geste, '^GESTE forme=(.*)')
|
||||
IvyBindMsg(self.a.all, '(.*)')
|
||||
IvyBindMsg(self.a.new_geste, '^Geste forme=(.*)')
|
||||
IvyBindMsg(self.a.new_click, '^PALETTE x=(.*) y=(.*)')
|
||||
IvyBindMsg(self.a.new_vocal_couleur, '^VOCAL couleur=(.*)')
|
||||
IvyBindMsg(self.a.new_vocal_action, '^VOCAL action=(.*)')
|
||||
IvyBindMsg(self.a.new_vocal_couleur, '^sra5 Parsed=VOCAL couleur=(.*)')
|
||||
IvyBindMsg(self.a.new_vocal_action, '^sra5 Parsed=VOCAL action=(.*)')
|
||||
|
||||
|
||||
MyIvyMultiModale("MultiModal", "127.255.255.255:2010")
|
||||
|
@ -38,6 +38,7 @@ class Rectangle(Form):
|
||||
class MyTurtle(turtle.Turtle):
|
||||
def __init__(self, color="green", bgcolor="#FFFFFF"):
|
||||
turtle.Turtle.__init__(self, shape="turtle")
|
||||
|
||||
self.bgcolor = bgcolor
|
||||
|
||||
self.pensize(3)
|
||||
@ -83,10 +84,10 @@ class MyTurtle(turtle.Turtle):
|
||||
|
||||
def draw_rectangle(self, rectangle):
|
||||
self.__setup_draw(rectangle.x, rectangle.y, rectangle.color)
|
||||
self.setposition(rectangle.x + rectangle.vert, rectangle.x)
|
||||
self.setposition(rectangle.x + rectangle.vert, rectangle.x + rectangle.hor)
|
||||
self.setposition(rectangle.x, rectangle.x + rectangle.hor)
|
||||
self.setposition(rectangle.x, rectangle.x)
|
||||
self.setposition(rectangle.x + rectangle.hor, rectangle.y)
|
||||
self.setposition(rectangle.x + rectangle.hor, rectangle.y + rectangle.vert)
|
||||
self.setposition(rectangle.x, rectangle.y + rectangle.vert)
|
||||
self.setposition(rectangle.x, rectangle.y)
|
||||
self.__end_draw()
|
||||
|
||||
def delete_rectangle(self, rectangle):
|
||||
@ -104,16 +105,22 @@ class MyIvyPalette(myIvy.MyIvy):
|
||||
|
||||
def create(self, agent, *larg):
|
||||
if larg[0] == "RECTANGLE":
|
||||
r = Rectangle(larg[1], larg[2], 200, 100, larg[3])
|
||||
r = Rectangle(self.__my_int(larg[1]), self.__my_int(larg[2]), 200, 100, larg[3])
|
||||
myturtle.draw_rectangle(r)
|
||||
LIST_FORM.append(r)
|
||||
elif larg[0] == "ROND":
|
||||
c = Circle(larg[1], larg[2], 50, larg[3])
|
||||
c = Circle(self.__my_int(larg[1]), self.__my_int(larg[2]), 50, larg[3])
|
||||
myturtle.draw_circle(c)
|
||||
LIST_FORM.append(Circle(larg[1], larg[2], larg[3]))
|
||||
LIST_FORM.append(Circle(self.__my_int(larg[1]), self.__my_int(larg[2]), larg[3]))
|
||||
|
||||
def __my_int(self, str):
|
||||
print(int(str.split(".")[0]))
|
||||
return int(str.split(".")[0])
|
||||
|
||||
|
||||
myturtle = MyTurtle()
|
||||
myturtle.penup()
|
||||
myturtle.color("green")
|
||||
|
||||
my_ivy = MyIvyPalette("Palette", "127.255.255.255:2010")
|
||||
|
||||
|
@ -1 +1 @@
|
||||
sra5 -b 172.31.190.255:2010 -p on
|
||||
sra5 -b 127.255.255.255:2010 -p on
|
||||
|
Reference in New Issue
Block a user