Commit ultra solide !

This commit is contained in:
Quentin Rouland 2017-01-26 22:29:32 +01:00
parent 1b624c0bae
commit 30b7b81041
9 changed files with 66 additions and 38 deletions

View File

@ -1,4 +0,0 @@
[Dolphin]
PreviewsShown=true
Timestamp=2017,1,18,16,56,50
Version=3

5
.gitignore vendored
View File

@ -46,4 +46,7 @@ __pycache__/
pyvenv.cfg
.venv
*.egg
pip-selfcheck.json
pip-selfcheck.json
# dolphin de merde
.directory

View File

@ -1,6 +0,0 @@
[Dolphin]
Timestamp=2017,1,18,15,21,34
Version=3
[Settings]
HiddenFilesShown=true

View File

@ -27,11 +27,11 @@ class automate:
self.form = larg[0]
self.state = 1
elif larg[0] == "Z":
elif larg[0] == "TRAIT":
self.__reinit_timer()
self.state = 4
elif larg[0] == "TRAIT":
elif larg[0] == "Z":
self.__reinit_timer()
self.state = 7
@ -108,7 +108,7 @@ class automate:
self.__maybe_send_create()
self.state = 1
elif self.state == 4 and larg[0].split(" ")[0] == "la" and int(larg[0].split(",")[1][0:2]) > 85:
elif self.state == 4 and larg[0].split(" ")[0] == "là" and int(larg[0].split(",")[1][0:2]) > 85:
self.__reinit_timer()
self.la_xy = self.xy
self.state = 6
@ -118,12 +118,18 @@ class automate:
self.ca_xy = self.xy
self.state = 5
elif self.state == 5 and larg[0].split(" ")[0] == "la" and int(larg[0].split(",")[1][0:2]) > 85:
elif self.state == 5 and larg[0].split(" ")[0] == "là" and int(larg[0].split(",")[1][0:2]) > 85:
self.__reinit_timer()
self.la_xy = self.xy
self.__maybe_send_deplacer()
self.state = 4
elif self.state == 6 and larg[0].split(" ")[0] == "ça" and int(larg[0].split(",")[1][0:2]) > 85:
self.__reinit_timer()
self.ca_xy = self.xy
self.__maybe_send_deplacer()
self.state = 4
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()
if "ce rectangle" in larg[0]:
@ -139,7 +145,9 @@ class automate:
print("all " + str(larg))
def __timeout(self):
if self.state in [1, 4]:
print("timeout")
print("state = " + str(self.state))
if self.state in [1, 4, 7]:
self.form = None
self.state = 0
@ -155,8 +163,14 @@ class automate:
self.color = None
self.state = 4
elif self.state == 8:
self.form = None
self.state = 4
print("endstate = " + str(self.state))
def __reinit_timer(self):
pass
if self.timer:
self.timer.cancel()
self.timer = Timer(5, self.__timeout)
@ -174,7 +188,7 @@ class automate:
print("Send Deplacer")
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],
self.color if not None else ""))
self.color))
self.ca_xy = None
self.la_xy = None
self.xy = None
@ -186,7 +200,7 @@ class automate:
print("Send Delete")
IvySendMsg("MULTIMODAL:supprimer forme={} x={} y={} couleur={}"
.format(self.form, self.xy[0], self.xy[1],
self.color if not None else ""))
self.color))
self.xy = None
self.color = None

View File

@ -1,6 +0,0 @@
[Dolphin]
Timestamp=2017,1,18,15,21,46
Version=3
[Settings]
HiddenFilesShown=true

View File

@ -43,7 +43,7 @@ class Form:
def aim_delete(l_form, type_form, x, y, color=""):
for form in l_form:
if form.__class__.__name__.upper() == type_form.upper() and form.is_in(x, y) \
and color in ("", form.color):
and color in ("None", form.color):
form.delete()
l_form.remove(form)
break
@ -57,7 +57,7 @@ class Form:
def aim_move(l_form, x, y, tx, ty, color=""):
for form in l_form:
if form.is_in(x, y)\
and color in ("", form.color):
and color in ("None", form.color):
form.delete()
form.x = tx
form.y = ty
@ -72,7 +72,7 @@ class Rond(Form):
self.radius = radius
def is_in(self, x, y):
return (x - self.x) ** 2 + (y - self.y) ** 2 < self.radius ** 2
return (x - self.x) ** 2 + (y - self.y - self.radius) ** 2 < self.radius ** 2
def draw(self):
self._setup_draw(self.x, self.y, self.color)
@ -123,6 +123,7 @@ class MyTurtle(turtle.Turtle):
IvySendMsg("PALETTE x={} y={}".format(x, y))
class MyIvyPalette(myIvy.MyIvy):
LIST_FORM = []
def _createbind(self):
@ -131,6 +132,7 @@ class MyIvyPalette(myIvy.MyIvy):
IvyBindMsg(self.delete, '^MULTIMODAL:supprimer forme=(.*) x=(.*) y=(.*) couleur=(.*)')
def create(self, agent, *larg):
print("create " + str(larg))
if larg[0] == "RECTANGLE":
r = Rectangle(myturtle, self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])
r.draw()
@ -141,11 +143,13 @@ class MyIvyPalette(myIvy.MyIvy):
self.LIST_FORM.append(c)
def move(self, agent, *larg):
self.LIST_FORM = Form.aim_move(self.LIST_FORM, larg[0],
print("move " + str(larg))
self.LIST_FORM = Form.aim_move(self.LIST_FORM, self.__my_int(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):
print("delete " + str(larg))
self.LIST_FORM = Form.aim_delete(self.LIST_FORM, larg[0],
self.__my_int(larg[1]), self.__my_int(larg[2]), color=larg[3])

View File

@ -8,39 +8,65 @@ ivy = myIvy.MyIvy("Simu", "127.255.255.255:2010")
list_cmds = [
(
# Test création RECTANGLE xy en premier -> REC1
# 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
# 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
# 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
# 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"),
# Test supression RECTANGLE, sans couleur annonce REC2
"Geste forme={}".format("Z"),
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("jaune"),
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ce rectangle"),
"PALETTE x={} y={}".format(15, 435),
),
(
# Test supression ROND, avec couleur annonce RON2
"Geste forme={}".format("Z"),
"sra5 Parsed=VOCAL couleur={} confiance=0,99".format("vert"),
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ce rond"),
"PALETTE x={} y={}".format(300, 450),
),
########################################################################################################################
(
# Test deplacement RECTANGLE, ça d'abord -> REC1
"Geste forme={}".format("TRAIT"),
"PALETTE x={} y={}".format(30, 80),
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ça"),
"PALETTE x={} y={}".format(600, 450),
"sra5 Parsed=VOCAL action={} confiance=0,99".format(""),
),
(
# Test deplacement RECTANGLE, la d'abord -> REC1
"Geste forme={}".format("TRAIT"),
"PALETTE x={} y={}".format(610, 460),
"sra5 Parsed=VOCAL action={} confiance=0,99".format("ça"),
"PALETTE x={} y={}".format(600, 100),
"sra5 Parsed=VOCAL action={} confiance=0,99".format(""),
),
]
for cmds in list_cmds:

View File

View File

@ -1,3 +0,0 @@
[Dolphin]
Timestamp=2017,1,18,15,39,7
Version=3