Mensaje#
Introducción#
Two VEX AIM Coding Robots can be linked so they communicate during a project. Using Message blocks, the robots can send and receive information to coordinate their actions.
Messages are stored in a first-in, first-out (FIFO) queue. The first message received is processed first, even if newer messages are available.
Nota: Para que se envíen y reciban mensajes, ambos robots deben estar ejecutando proyectos que manejen mensajes al mismo tiempo.
Below is a list of all blocks:
send message — Sends a string to the other linked robot.
send message with data — Sends a string and a number to the other linked robot.
get latest message — Stores the most recent string received.
get latest message with data — Stores the most recent string and number received.
latest message — Returns the most recent stored string.
latest data — Returns the most recent stored number.
is message available? — Returns a Boolean indicating whether the other linked robot has ever sent a message.
is connected? — Returns a Boolean indicating whether the robot is linked with another robot.
linked robot name — Returns a string with the name of the linked robot.
enviar mensaje#
El bloque enviar mensaje envía una cadena al otro robot vinculado.
enviar mensaje [message]
Parámetros |
Descripción |
|---|---|
mensaje |
La cadena que se enviará al otro robot vinculado. |
Ejemplo
Robot 1
cuando la pantalla [presionado v]
[Code for Robot 1.]
[Press the screen to send a message to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
[Change the string to display a different message.]
enviar mensaje [Hello, Robot 2!]
Robot 2
cuando empezó
[Code for Robot 2.]
[Display what message Robot 1 sends.]
imprimir [Robot 2] en la pantalla ▶
Colocar el cursor en la siguiente fila de la pantalla
esperar hasta <¿Está disponible el mensaje?>
recibir el último mensaje
imprimir (último mensaje) en la pantalla ▶
enviar mensaje con datos#
El bloque enviar mensaje con datos envía una cadena y un número al otro robot vinculado.
enviar mensaje [message] con datos [0]
Parámetros |
Descripción |
|---|---|
mensaje |
El valor que se enviará al otro robot vinculado. Debe ser una cadena. |
datos |
Un número para enviar al otro robot. |
Ejemplo
Robot 1
cuando la pantalla [presionado v]
[Code for Robot 1.]
[Continuously send the current heading to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
para siempre
enviar mensaje [message] con datos (rumbo en grados)
Robot 2
cuando empezó
[Code for Robot 2.]
[Turn to match Robot 1's heading.]
imprimir [Robot 2] en la pantalla ▶
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
recibir el último mensaje#
El bloque obtener último mensaje almacena la cadena más reciente recibida del otro robot vinculado.
recibir el último mensaje
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
Robot 1
cuando la pantalla [presionado v] :: hat events
[Code for Robot 1.]
[Press the screen to send a message to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
[Change the string to display a different message.]
enviar mensaje [Hello, Robot 2!]
Robot 2
cuando empezó
[Code for Robot 2.]
[Display what message Robot 1 sends.]
imprimir [Robot 2] en la pantalla ▶
Colocar el cursor en la siguiente fila de la pantalla
esperar hasta <¿Está disponible el mensaje?>
recibir el último mensaje
imprimir (último mensaje) en la pantalla ▶
Obtenga el último mensaje con datos#
El bloque obtener último mensaje con datos almacena la cadena y el número más recientes recibidos del otro robot vinculado.
Obtenga el último mensaje con datos
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
Robot 1
cuando la pantalla [presionado v] :: hat events
[Code for Robot 1.]
[Continuously send the current heading to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
para siempre
enviar mensaje [message] con datos (rumbo en grados)
Robot 2
cuando empezó
[Code for Robot 2.]
[Turn to match Robot 1's heading.]
imprimir [Robot 2] en la pantalla ▶
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
último mensaje#
El bloque último mensaje devuelve la cadena almacenada más reciente del último uso del bloque obtener último mensaje o obtener último mensaje con datos.
(último mensaje)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
Robot 1
cuando la pantalla [presionado v] :: hat events
[Code for Robot 1.]
[Press the screen to send a message to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
[Change the string to display a different message.]
enviar mensaje [Hello, Robot 2!]
Robot 2
cuando empezó
[Code for Robot 2.]
[Display what message Robot 1 sends.]
imprimir [Robot 2] en la pantalla ▶
Colocar el cursor en la siguiente fila de la pantalla
esperar hasta <¿Está disponible el mensaje?>
recibir el último mensaje
imprimir (último mensaje) en la pantalla ▶
últimos datos#
El bloque datos más recientes devuelve el número almacenado más reciente del último uso del bloque obtener el último mensaje con datos.
(últimos datos)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
Robot 1
cuando la pantalla [presionado v] :: hat events
[Code for Robot 1.]
[Continuously send the current heading to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
para siempre
enviar mensaje [message] con datos (rumbo en grados)
Robot 2
cuando empezó
[Code for Robot 2.]
[Turn to match Robot 1's heading.]
imprimir [Robot 2] en la pantalla ▶
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
¿Está disponible el mensaje?#
The is message available? block returns a Boolean indicating whether the other linked robot has ever used the send message or send message with data block.
True — The send message or send message with data block has been used by the other linked robot in the current project.
False — The send message or send message with data block has never been used by the other linked robot in the current project.
<¿Está disponible el mensaje?>
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
Robot 1
cuando la pantalla [presionado v] :: hat events
[Code for Robot 1.]
[Press the screen to send a message to Robot 2.]
imprimir [Robot 1] en la pantalla ▶
enviar mensaje [message]
Robot 2
cuando empezó
[Code for Robot 2.]
[Display a message when Robot 1 sends a message.]
imprimir [Robot 2] en la pantalla ▶
Colocar el cursor en la siguiente fila de la pantalla
esperar hasta <¿Está disponible el mensaje?>
imprimir [Received!] en la pantalla ▶
¿está conectado?#
El bloque ¿está conectado? devuelve un valor booleano que indica si el robot está actualmente vinculado con otro robot.
True — The robot is linked with another robot.
False — The robot is not linked with another robot.
<¿está conectado?>
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó
[Turn off one of the linked robots to see the message change.]
para siempre
pantalla clara
imprimir <¿está conectado?> en la pantalla ▶
nombre del robot vinculado#
El bloque nombre del robot vinculado devuelve una cadena con el nombre del robot vinculado. Si no hay ningún robot vinculado, se devolverá “Ninguno”.
(linked robot name)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó
[Display the name of the robot that's linked.]
imprimir (linked robot name) en la pantalla ▶