Receive Message Block Icon of block

接收訊息指令
Receive Message Block

接收無線訊息須先跟發送的NXT設定好相對應的訊息型態,信箱號碼.本指令的輸出可以為收到的訊息本身,或是"真/偽"邏輯訊號(如果設定為比較收到的訊息).
To receive a wireless message, set the message type and mailbox number to match those of the sending NXT. This block’s output can be the incoming message itself or a “true/false” logic value (if you are comparing the incoming message to a test message).

設定NXT的無線連結
Configuring the NXT for Wireless Communication

在發送或接收無線訊息前,所有的NXT都需設定為無線傳輸模式.
Before wireless messages can be sent or received, the participating NXTs must be set up for wireless communication.

(主)NXT會是用來發送訊息裝置.先瀏覽藍芽目錄並啟動搜索來尋找其他裝置.當搜尋完畢後,選擇通訊號碼(1, 2, 或3)來設定(從)NXT.在首次通訊建立時,NXT之間會出現輸入密碼的協定程序.雙方皆必須同意才行.接著在主NXT的連接目錄上可以看見已經標好通訊號碼的從NXT.而在從NXT上會看到主NXT的通訊號碼為0.此時,就表示主NXT準備好溝通程序.
On the (master) NXT that will communicate with other NXTs, navigate to the Bluetooth category and choose Search that will start a search for other devices. When the search is complete, choose which connection number (1, 2, or 3) you want the second (slave) NXT to be known as. The first time a connection is established between two NXTs, a prompt to enter the Passkey will appear on both NXTs; this needs to be accepted by both. Now when you navigate to the Connection category on the master NXT, the slave NXT should be shown by its name occupying the selected connection number. On the slave NXT, the master NXT should be shown occupying connection number 0. At this point, the master NXT is ready to initiate communication with the slave NXT.

如果主NXT想對多個NXT(至多3個)建立通訊時,必須要重複上述動作.
If the master NXT needs to communicate with multiple NXTs (up to a maximum of three), you should repeat the above process again.

只需要在一台NXT做這步驟,接收的NXT會自動地依主NXT設定的通訊號碼而更新.
It’s only necessary to go through this process on one NXT. The receiving NXT will automatically update its connection when the master NXT is setting up its connection number.

連結號碼
Connection Number

連結號碼可視為無線傳輸時的NXT位址.透過這個號碼可以傳訊到指定的NXT.
The connection number for each NXT might be considered its address in the wireless world. You send a message to a specific NXT by indicating its connection number.

信箱號碼
Mailbox Number

無線傳輸時,每個NXT有十個信箱號碼可以儲存資料.而每個信箱號碼最多可以保留五筆訊息.如果超過五筆訊息則最舊的訊息會被NXT刪除.
Each NXT has ten mailbox numbers where wireless messages can be deposited. Each mailbox number can hold up to five messages. If the mailbox number fills up with five messages, adding one more message will cause the NXT to erase the oldest message.

接收訊息
Receiving a Message

在所有NXT都設定好通訊號碼後,需設定訊息型態(文字,號碼,或邏輯).
To receive a wireless message (after all NXTs have been configured with connection numbers), first indicate the format of the incoming message (Text, Number, or Logic).

如果要測試訊息接收是否正確並讓接收訊息指令傳送"真"值,可以在輸入區測試文字, 數字或是勾選 真或偽值.如果接收的訊息符合測試的訊息,則會經由“√/x” 連接埠送出"真"值.
If you want to test that a certain message has been received (and have the Receive Message block send out a “true” signal), type the test text or number in the input box, or check either true or false. If the incoming message, matches the test message, a “true” signal will be sent from the block through the “√/x” plug.

最後選擇用來儲存訊息的信箱號碼.
To finish configuring the block, choose the mailbox number where the incoming message will be stored.

注意: 參閱"傳送訊息指令"中傳送無線訊息的內容.
Note: See the Send Message block for information on sending a wireless message.

顯示設定Display Settings

Image of Send Message block, data hub open

  1. 當指令連結到序列軸時,資料集線器會自動打開.接收的訊息會依照型態從輸出連接埠送出.如果是文字型態,會從"T"連接埠送出;如果是數字,會從"#"連接埠送出;如果是邏輯訊號,會從"√x"連接埠送出.
    The data hub will open automatically when the block is attached to a sequence beam. The incoming message will be sent as output from one of three data hub plugs depending on the message format: if the incoming message is in text format, it will be sent through the “T” plug; if the message is a number, it will be sent through the “#” plug; and if the message is a logic value, it will be sent through the “√x” plug.

    藉由"√x"連接埠可以傳送邏輯訊號(真/偽)來比較接收的訊息跟測試訊息.(參考下列資料集線器章節).
    You can also send out a logic (true/false) signal through the “√/x” plug if you want to compare the incoming message to a test message you provide. (See the Data Hub section below for more information.)

設定接收訊息指令
Configuring the Receive Message Block

Image of configuration panel, default conditions

  1. 下拉式選單可以設定訊息型態(文字,數字,邏輯).
    The pull-down menu will let you select the message type (Text, Number, or Logic) of the message being received.
  2. 如果要比較接收到的訊息,可以輸入測試文字或數字(如果型態是相對的文字或數字).或是單選按鍵還選擇邏輯訊號(真或偽).
    If you want to compare the incoming message to a test message, either type in the test text or number (if you chosen Text or Number respectively as the format), or use the radio buttons to choose the test logic value (true or false).
  3. 選擇信箱號碼來儲存訊息.
    Choose the mailbox number where the incoming message will be stored.

設定接收訊息指令的資料集線器
configuring the Receive Message block’s Data Hub

用資料線可以任意地用來控制接收訊息指令.(從其他指令的資料集線器到接收訊息指令的資料集線器).
You can control the Receive Message block dynamically by connecting data wires (from other blocks’ data hubs) to the Receive Message block’s data hub.

把指令放在工作區上後,可以按圖示的左下角來打開資料集線器.
Open a block’s data hub by clicking the tab at the lower left edge of the block after it has been placed on the work area.

Image showing unopened tab on a generic block

連接到集線器左邊連接埠的資料線是屬於負責傳遞資料進入指令中,而要從指令送出資料時,則須從集線器的右邊連接埠連接資料線.
Data wires carrying input information to a block are connected to the plugs on the left side of its data hub. Data wires carrying output information are connected to the plugs on the right side.

Image of data wires

[A]輸入連接埠 [A] Input plug
[B]輸出連結部 [B] Output plug
[C]數字資料線(黃) [C] Number data wire (yellow)
[D]邏輯資料線(綠) [D]Logic data wire (green)
[E]文字資料線(橘) [E]Text data wire (orange)
[F]無效資料線(灰) [F]Broken data wire (gray)

資料由輸入端傳至傳出端
Passing from the input plug to the output plug

如果輸入連接埠有對應的輸出連接埠(請參閱 A 以上)時,那麼輸入的資料就會原封不動地傳遞到輸出連接埠.在這樣的情況下, 如果輸入連接埠連著資料線,那麼就只能使用輸出連結埠來做連結. 也就是說,當連結輸出連接線到這樣的輸出連接埠,而不透過相對應的輸入資料線時,就會讓該輸出連接線呈現無效的狀態.
If an input plug has a corresponding output plug (see A above), the input data will pass through from the input plug to the output plug without being changed. In this case, you can only use the output plug if the input plug is connected to an input data wire; connecting an output data wire to such an output plug without a connected input data wire will cause the output data wire to be “broken” (and colored gray).

特定的資料型態
Data wires carry specific types of data

每條資料線都負責傳送特定資料.例如,一條從邏輯連接埠拉出的資料線則只能連結到另一個同屬邏輯連接埠的集線器上.
Each data wire carries a specific type of data between blocks. For example, if a data wire is dragged from a logic plug on a block’s data hub, it can only be connected to a logic plug on another block’s data hub. The chart below shows what kind of data each plug can accept or send out.

資料線顏色
Data wire colors

資料線依照特定的顏色作識別:黃色資料線傳送數值資料、綠色資料線傳送邏輯資料(真/偽)及橘色資料線傳送文字資料
Data wires are identified with specific colors: wires carrying number data are colored yellow, wires carrying logic data are colored green, and wires carrying text data are colored orange.

無效的資料線
“Broken” data wires

如果資料線連結到錯誤資料型態的連接埠時,則該資料線會呈現斷線無效狀態並以灰色表示.而有無效的資料線存在就無法下載程式.
If you try to connect a data wire to a plug of the wrong data type, the data wire will be broken (and colored gray). You will not be able to download your program if a data wire is broken.

點選無效的資料線時,在工作區右下方的幫助視窗中會看到無效的原因.
IIf you click a broken wire you can read why it is broken in the small help window in the lower right corner of the work area.

資料必須在連接埠的限制範圍內
Data must bewithin the possible range of the plug

如果資料線傳輸該連接埠資料範圍之外的資料時,該指令不是忽略資料就是轉成合理範圍內的資料.對那些只能接收少量輸入值的連接埠來說(例如,0,1,或2),該連結埠就會忽略超出範圍的數值.
If an input data wire transmits a value outside the possible range of the plug it is connected to, the block will either ignore the value or change it to a value within its range. For plugs that allow just a few input values (example: just 0, 1, or 2), the plug will ignore the input if a value arrives outside its range.

而對那些可以接收大量範圍輸入值(例如: 0~100)的連接埠來說,該連接埠就會將數值轉成可接受的範圍. 例如, 移動指令的動力連接埠接收到150的輸入值時,那麼移動指令就會轉成100(也就是動力連接埠的範圍內).
For plugs that accept larger input ranges (example: 0 – 100), the plug will force any input outside its range to fit. For example, if a Move block’s Power plug receives an input value of 150, the block will change the input value to 100 (i.e., a number within the Power plug’s range).

下表列出本資料集線器中各連接埠的特性
This chart shows the different characteristics of the plugs on the Receive Message block’s data hub:

  連結埠
Plug
資料型態
Date Type
資料範圍
Possible Range
資料意義
What the Values Mean
連接埠例外說明
This Plug is Ignored When...
Port 信箱號碼
Mailbox
數字
Number
1 - 10 讀取的信箱號碼
Mailbox to read from
 
Port 輸入文字
Text in
文字
Text
最多58的字元
58 character maximum
比較的文字
Value to compare against
非文字訊息
Message Type not Text
Port 輸入數字
Number in
數字
Number
-2147483648 - 2147483647 比較的數字
Value to compare against
非數字訊息
Message Type not Number
Port 輸入邏輯
Logic in
邏輯
Logic
真/偽
True/False
比較的邏輯
Value to compare against
非邏輯訊息
Message Type not Logic
Port 訊息接收
Message Received
邏輯
Logic
真/偽
True/False
接收到訊息時為真(非空信箱)
True if a message is received (i.e., mailbox isn't empty)
 
Port 是 / 否
Yes / No
邏輯
Logic
真/偽
True/False
比較結果
Result of comparison
 
Port 輸出文字
Text out
文字
Text
最多58個字元
58 character maximum
訊息型態
Message data
非文字訊息
Message Type not Text
Port 輸出數字
Number out
數字
Number
-2147483648 - 2147483647 訊息型態
Message data
非數字訊息
Message Type not Number
Port 輸出邏輯
Logic out
邏輯
Logic
真/偽
True/False
訊息型態
Message data
非邏輯訊息
Message Type not Logic