Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Vicente Castellano Gómez
/
robotAmbientales
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8cacd52c
authored
May 07, 2024
by
Samuel Valverde Garcia
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
envia pedido
parent
cb2b5935
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
interfaz.py
main_map.py
interfaz.py
View file @
8cacd52c
...
...
@@ -91,6 +91,7 @@ class MainApp:
#Inicializa la posicion del robot
self
.
robot_position
=
None
self
.
borrar
=
False
self
.
master
=
master
...
...
@@ -178,13 +179,40 @@ class MainApp:
self
.
highlight_path
()
def
schedule_robot_updates
(
self
):
""" Programa la actualización de la posición del robot cada 1
0 segundos
. """
""" Programa la actualización de la posición del robot cada 1
segundo
. """
self
.
update_robot_position
(
self
.
mensaje
.
getPosicion
())
self
.
master
.
after
(
1000
,
self
.
schedule_robot_updates
)
# Revisa si hay pedidos pendientes y si se ha solicitado un pedido
if
self
.
mensaje
.
pedidoSolicitado
and
self
.
queue_listbox
.
size
()
>
0
:
# Si self.borrar es True, borra el pedido anterior y prepara para enviar el siguiente
if
self
.
borrar
:
self
.
queue_listbox
.
delete
(
0
)
self
.
borrar
=
False
# Resetear self.borrar después de borrar el pedido
# Si aún hay pedidos después de borrar, enviar el siguiente pedido
if
self
.
queue_listbox
.
size
()
>
0
:
print
(
"Breakpoint Enviar Pedido: "
,
self
.
queue_listbox
.
get
(
0
))
self
.
mensaje
.
sendPedido
(
self
.
queue_listbox
.
get
(
0
))
self
.
borrar
=
True
# Aquí asumimos que self.borrar debe ser seteado a True por alguna función que
# detecte que el robot ha completado el pedido, por ejemplo en un callback de MQTT
"""
#Eviar pedido al robot cuando lo solicita y hay pedidos
if self.mensaje.pedidoSolicitado:
if self.queue_listbox.size() >0:
if(self.borrar is True):
self.queue_listbox.delete(0)
if self.queue_listbox.size() > 0:
print("Breakpint Enviar Pedido: ",self.queue_listbox.get(0))
self.mensaje.sendPedido(self.queue_listbox.get(0))
self.borrar = True
"""
#Actualiza la posición del robot y actualiza el resaltado correspondiente.
def
update_robot_position
(
self
,
new_position
):
self
.
robot_position
=
mi
.
MensajeInterfaz
()
.
getPosicion
()
self
.
robot_position
=
self
.
mensaje
.
getPosicion
()
self
.
highlight_path
()
# Resalta los botones correspondientes al primer elemento de la Listbox
...
...
main_map.py
View file @
8cacd52c
...
...
@@ -5,12 +5,12 @@ mapa = "0202000105030705000200041109060110031000000200080101100110000106010701"
while
(
True
):
"""
cn
.
send_mqtt_message
(
"map"
,
mapa
)
print
(
"Enviado"
)
time
.
sleep
(
10
)
"""
topic = "A3-467/GrupoL/Interfaz"
msg = "pos:(6,1)"
cn.send_mqtt_message(topic, msg)
...
...
@@ -24,3 +24,4 @@ while(True):
msg = "pos:(3,1)"
cn.send_mqtt_message(topic, msg)
time.sleep(10)
"""
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment