save
This commit is contained in:
parent
78ce3a0890
commit
1b624c0bae
@ -22,16 +22,16 @@ class automate:
|
|||||||
print("state = " + str(self.state))
|
print("state = " + str(self.state))
|
||||||
|
|
||||||
if self.state == 0:
|
if self.state == 0:
|
||||||
if larg[0] == "Rectangle" or larg[0] == "Cercle":
|
if larg[0] == "RECTANGLE" or larg[0] == "ROND":
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.form = larg[0]
|
self.form = larg[0]
|
||||||
self.state = 1
|
self.state = 1
|
||||||
|
|
||||||
elif larg[0] == "Deplacer":
|
elif larg[0] == "Z":
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.state = 4
|
self.state = 4
|
||||||
|
|
||||||
elif larg[0] == "Supprimer":
|
elif larg[0] == "TRAIT":
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.state = 7
|
self.state = 7
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class automate:
|
|||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.xy = (larg[0], larg[1])
|
self.xy = (larg[0], larg[1])
|
||||||
self.__maybe_send_delete()
|
self.__maybe_send_delete()
|
||||||
self.state = 1
|
self.state = 7
|
||||||
|
|
||||||
print("endstate = " + str(self.state))
|
print("endstate = " + str(self.state))
|
||||||
|
|
||||||
@ -103,34 +103,34 @@ class automate:
|
|||||||
def new_vocal_action(self, agent, *larg):
|
def new_vocal_action(self, agent, *larg):
|
||||||
print("new vocal action" + str(larg))
|
print("new vocal action" + str(larg))
|
||||||
print("state = " + str(self.state))
|
print("state = " + str(self.state))
|
||||||
if self.state == 1 and larg[0].split(" ")[0] == "ici":
|
if self.state == 1 and larg[0].split(" ")[0] == "ici" and int(larg[0].split(",")[1][0:2]) > 85:
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.__maybe_send_create()
|
self.__maybe_send_create()
|
||||||
self.state = 1
|
self.state = 1
|
||||||
|
|
||||||
if self.state == 4 and larg[0].split(" ")[0] == "la":
|
elif self.state == 4 and larg[0].split(" ")[0] == "la" and int(larg[0].split(",")[1][0:2]) > 85:
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.la_xy = self.xy
|
self.la_xy = self.xy
|
||||||
self.state = 6
|
self.state = 6
|
||||||
|
|
||||||
if self.state == 4 and larg[0].split(" ")[0] == "ça":
|
elif self.state == 4 and larg[0].split(" ")[0] == "ça" and int(larg[0].split(",")[1][0:2]) > 85:
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.ca_xy = self.xy
|
self.ca_xy = self.xy
|
||||||
self.state = 5
|
self.state = 5
|
||||||
|
|
||||||
if self.state == 5 and larg[0].split(" ")[0] == "la":
|
elif self.state == 5 and larg[0].split(" ")[0] == "la" and int(larg[0].split(",")[1][0:2]) > 85:
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
self.la_xy = self.xy
|
self.la_xy = self.xy
|
||||||
self.__maybe_send_deplacer()
|
self.__maybe_send_deplacer()
|
||||||
self.state = 4
|
self.state = 4
|
||||||
|
|
||||||
if self.state == 7 and larg[0].split(" ")[0] in ("Ce retangle", "Cette ellipse"):
|
elif self.state == 7 and ("ce rectangle" in larg[0] or "ce rond" in larg[0]) and int(larg[0].split(",")[1][0:2]) > 85:
|
||||||
self.__reinit_timer()
|
self.__reinit_timer()
|
||||||
if larg[0].split(" ")[0] == "Ce rectangle":
|
if "ce rectangle" in larg[0]:
|
||||||
self.form = "RECTANGLE"
|
self.form = "RECTANGLE"
|
||||||
elif larg[0].split(" ")[0] == "Cette ellipse":
|
if "ce rond" in larg[0]:
|
||||||
self.form = "ELLIPSE"
|
self.form = "ROND"
|
||||||
self.__maybe_send_deplacer()
|
print(self.form)
|
||||||
self.state = 8
|
self.state = 8
|
||||||
|
|
||||||
print("endstate = " + str(self.state))
|
print("endstate = " + str(self.state))
|
||||||
@ -142,6 +142,7 @@ class automate:
|
|||||||
if self.state in [1, 4]:
|
if self.state in [1, 4]:
|
||||||
self.form = None
|
self.form = None
|
||||||
self.state = 0
|
self.state = 0
|
||||||
|
|
||||||
elif self.state in [2, 3]:
|
elif self.state in [2, 3]:
|
||||||
self.xy = None
|
self.xy = None
|
||||||
self.color = None
|
self.color = None
|
||||||
@ -164,13 +165,13 @@ class automate:
|
|||||||
def __maybe_send_create(self):
|
def __maybe_send_create(self):
|
||||||
if None not in (self.form, self.xy, self.color):
|
if None not in (self.form, self.xy, self.color):
|
||||||
print("Send Forme")
|
print("Send Forme")
|
||||||
IvySendMsg("MULTIMODAL:creer forme={} x={} y={} couleur={}".format(self.form, self.xy[0], self.xy[1], self.color))
|
IvySendMsg("MULTIMODAL:creer forme={} x={} y={} couleur={}".format(self.form, self.xy[0], self.xy[1], self.color))
|
||||||
self.xy = None
|
self.xy = None
|
||||||
self.color = None
|
self.color = None
|
||||||
|
|
||||||
def __maybe_send_deplacer(self):
|
def __maybe_send_deplacer(self):
|
||||||
if None not in (self.la_xy, self.ca_xy):
|
if None not in (self.la_xy, self.ca_xy):
|
||||||
print("Send Forme")
|
print("Send Deplacer")
|
||||||
IvySendMsg("MULTIMODAL:deplacer ca_x={} ca_y={} la_x={} la_y={} couleur={}"
|
IvySendMsg("MULTIMODAL:deplacer ca_x={} ca_y={} la_x={} la_y={} couleur={}"
|
||||||
.format(self.ca_xy[0], self.ca_xy[1], self.la_xy[0], self.la_xy[1],
|
.format(self.ca_xy[0], self.ca_xy[1], self.la_xy[0], self.la_xy[1],
|
||||||
self.color if not None else ""))
|
self.color if not None else ""))
|
||||||
@ -180,8 +181,9 @@ class automate:
|
|||||||
self.color = None
|
self.color = None
|
||||||
|
|
||||||
def __maybe_send_delete(self):
|
def __maybe_send_delete(self):
|
||||||
|
print(self.form)
|
||||||
if None not in (self.form, self.xy):
|
if None not in (self.form, self.xy):
|
||||||
print("Send Forme")
|
print("Send Delete")
|
||||||
IvySendMsg("MULTIMODAL:supprimer forme={} x={} y={} couleur={}"
|
IvySendMsg("MULTIMODAL:supprimer forme={} x={} y={} couleur={}"
|
||||||
.format(self.form, self.xy[0], self.xy[1],
|
.format(self.form, self.xy[0], self.xy[1],
|
||||||
self.color if not None else ""))
|
self.color if not None else ""))
|
||||||
|
@ -42,7 +42,7 @@ class Form:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def aim_delete(l_form, type_form, x, y, color=""):
|
def aim_delete(l_form, type_form, x, y, color=""):
|
||||||
for form in l_form:
|
for form in l_form:
|
||||||
if form.__class__.__name__.upper() == type_form and form.is_in(x, y) \
|
if form.__class__.__name__.upper() == type_form.upper() and form.is_in(x, y) \
|
||||||
and color in ("", form.color):
|
and color in ("", form.color):
|
||||||
form.delete()
|
form.delete()
|
||||||
l_form.remove(form)
|
l_form.remove(form)
|
||||||
@ -66,7 +66,7 @@ class Form:
|
|||||||
return l_form
|
return l_form
|
||||||
|
|
||||||
|
|
||||||
class Ellipse(Form):
|
class Rond(Form):
|
||||||
def __init__(self, t, x, y, radius=50, color="red"):
|
def __init__(self, t, x, y, radius=50, color="red"):
|
||||||
super().__init__(t, x, y, color)
|
super().__init__(t, x, y, color)
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
@ -135,16 +135,19 @@ class MyIvyPalette(myIvy.MyIvy):
|
|||||||
r = Rectangle(myturtle, self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
|
r = Rectangle(myturtle, self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
|
||||||
r.draw()
|
r.draw()
|
||||||
self.LIST_FORM.append(r)
|
self.LIST_FORM.append(r)
|
||||||
elif larg[0] == "ELLIPSE":
|
elif larg[0] == "ROND":
|
||||||
c = Ellipse(myturtle, self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
|
c = Rond(myturtle, self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
|
||||||
c.draw()
|
c.draw()
|
||||||
self.LIST_FORM.append(c)
|
self.LIST_FORM.append(c)
|
||||||
|
|
||||||
def move(self, agent, *larg):
|
def move(self, agent, *larg):
|
||||||
self.LIST_FORM = Form.aim_move(self.LIST_FORM, larg[0], larg[1], larg[2], larg[3], larg[4])
|
self.LIST_FORM = Form.aim_move(self.LIST_FORM, larg[0],
|
||||||
|
self.__my_int(larg[1]), self.__my_int(larg[2]),
|
||||||
|
self.__my_int(larg[3]), color=larg[4])
|
||||||
|
|
||||||
def delete(self, agent, *larg):
|
def delete(self, agent, *larg):
|
||||||
self.LIST_FORM = Form.aim_delete(self.LIST_FORM, larg[0], larg[1], larg[2], larg[3])
|
self.LIST_FORM = Form.aim_delete(self.LIST_FORM, larg[0],
|
||||||
|
self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
|
||||||
|
|
||||||
def __my_int(self, str):
|
def __my_int(self, str):
|
||||||
return int(str.split(".")[0])
|
return int(str.split(".")[0])
|
||||||
@ -156,15 +159,5 @@ myturtle.color("green")
|
|||||||
|
|
||||||
my_ivy = MyIvyPalette("Palette", "127.255.255.255:2010")
|
my_ivy = MyIvyPalette("Palette", "127.255.255.255:2010")
|
||||||
|
|
||||||
|
|
||||||
r = Rectangle(myturtle, 500, 400, color="red")
|
|
||||||
r.draw()
|
|
||||||
|
|
||||||
e = Ellipse(myturtle, 100, 200, color="green")
|
|
||||||
e.draw()
|
|
||||||
|
|
||||||
|
|
||||||
Form.aim_delete(my_ivy.LIST_FORM, "RECTANGLE", 522, 403)
|
|
||||||
|
|
||||||
myturtle.screen._root.mainloop()
|
myturtle.screen._root.mainloop()
|
||||||
|
|
||||||
|
52
Simu/Simu.py
Normal file
52
Simu/Simu.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from ivy.std_api import IvySendMsg
|
||||||
|
|
||||||
|
from LibCommon import myIvy
|
||||||
|
|
||||||
|
ivy = myIvy.MyIvy("Simu", "127.255.255.255:2010")
|
||||||
|
|
||||||
|
list_cmds = [
|
||||||
|
(
|
||||||
|
# Test création RECTANGLE xy en premier -> REC1
|
||||||
|
"Geste forme={}".format("RECTANGLE"),
|
||||||
|
"PALETTE x={} y={}".format(25, 70),
|
||||||
|
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("rouge"),
|
||||||
|
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ici"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
# Test création ROND xy en premier -> RON1
|
||||||
|
"Geste forme={}".format("ROND"),
|
||||||
|
"PALETTE x={} y={}".format(250, 300),
|
||||||
|
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("bleu"),
|
||||||
|
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ici"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
# Test création RECTANGLE couleur en premier REC2
|
||||||
|
"Geste forme={}".format("RECTANGLE"),
|
||||||
|
"PALETTE x={} y={}".format(10, 425),
|
||||||
|
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("jaune"),
|
||||||
|
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ici"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
# Test création ROND couleur en premier RON2
|
||||||
|
"Geste forme={}".format("ROND"),
|
||||||
|
"PALETTE x={} y={}".format(300, 400),
|
||||||
|
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("vert"),
|
||||||
|
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ici"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
# Test supression Rond couleur en premier REC2
|
||||||
|
"Geste forme={}".format("TRAIT"),
|
||||||
|
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ce rectangle"),
|
||||||
|
"PALETTE x={} y={}".format(15, 435),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
for cmds in list_cmds:
|
||||||
|
sleep(5)
|
||||||
|
for cmd in cmds:
|
||||||
|
print(cmd)
|
||||||
|
IvySendMsg(cmd)
|
||||||
|
sleep(1)
|
||||||
|
exit(0)
|
0
Simu/__init__.py
Normal file
0
Simu/__init__.py
Normal file
@ -29,6 +29,8 @@
|
|||||||
<item>ici</item>
|
<item>ici</item>
|
||||||
<item>ça</item>
|
<item>ça</item>
|
||||||
<item>là</item>
|
<item>là</item>
|
||||||
|
<item>ce rond</item>
|
||||||
|
<item>ce rectangle</item>
|
||||||
</one-of>
|
</one-of>
|
||||||
<tag>out.text = "VOCAL action=" + meta.current().text;</tag>
|
<tag>out.text = "VOCAL action=" + meta.current().text;</tag>
|
||||||
</rule>
|
</rule>
|
||||||
|
Reference in New Issue
Block a user