# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2014-07-02 12:51+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #. type: One-char language identifier #: train702.languagecode:1 #, no-wrap msgid "E" msgstr "" #. type: Title-text #: train702/scene.txt:1 #, no-wrap msgid "train702:Remote control #4" msgstr "" #. type: Resume-text #: train702/scene.txt:2 #, no-wrap msgid "" "train702:Remote control a bot without using an information exchange post by " "defining a class for the orders." msgstr "" #. type: ScriptName-text #: train702/scene.txt:3 #, no-wrap msgid "train702:Remote4" msgstr "" #. type: \b; header #: train702-help/tremote4.txt:1 #, no-wrap msgid "Exercise" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:3 #, no-wrap msgid "" "Remote control a slave robot without using an <a object|exchange>information " "exchange post</a>. The robot should pass over the 6 blue crosses. You must " "use a <code><a cbot|static>static</a></code> variable to pass the orders to " "the slave bot." msgstr "" #. type: Plain text #: train702-help/tremote4.txt:5 #, no-wrap msgid "The two main actors of this exercise are:\n" msgstr "" #. type: Bullet: '1)' #: train702-help/tremote4.txt:5 #, no-wrap msgid "" "The <a object|botgr>wheeled grabber</a> without an energy pack and therefore " "immobile. This is the master you should program so it will transmit orders " "to the slave." msgstr "" #. type: Bullet: '2)' #: train702-help/tremote4.txt:6 #, no-wrap msgid "" "The slave <a object|bottr>practice bot</a> which is already programmed and " "just waits for orders from the master." msgstr "" #. type: \b; header #: train702-help/tremote4.txt:8 #, no-wrap msgid "The slave" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:10 #, no-wrap msgid "" "First of all we must understand how the program of the slave works. The <a " "cbot|class>class</a> <code>order</code> contains two members: " "<code>m_type</code> is the order to execute (move or turn) and " "<code>m_param</code> is the distance to move or the rotation angle¦:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:12 #, no-wrap msgid "<c/><s/><a cbot|public>public</a> <a cbot|class>class</a> order" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:16 #, no-wrap msgid "" "{\n" "\t<a cbot|int>int</a> m_type = <a cbot|nan>nan</a>;\n" "\t<a cbot|float>float</a> m_param;\n" "}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:18 #, no-wrap msgid "" "A second <a cbot|class>class</a> <code>exchange</code> contains the " "mechanism for exchanging the orders. We declare a <code><a " "cbot|static>static</a></code> class member <code>m_order</code> which will " "contain the order to be executed. The word <code>static</code> insures that " "the member <code>m_order</code> is shared between all instances of the <a " "cbot|class>class</a> exchange." msgstr "" #. type: Plain text #: train702-help/tremote4.txt:20 #, no-wrap msgid "<c/><s/><a cbot|public>public</a> <a cbot|class>class</a> exchange" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:22 #, no-wrap msgid "" "{\n" "\t<a cbot|static>static</a> <a cbot|private>private</a> order m_order = new " "order;" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:24 #, no-wrap msgid "" "<n/>The <code>put</code> method will be used by the master robot for " "transmitting an order. As long as <code>m_order</code> is different from " "<code><a cbot|nan>nan</a></code>, the slave has not finished the order and " "the <code>put</code> method will return <code>false</code> and will do " "nothing¦:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:26 #, no-wrap msgid "" "<c/><s/>\t<a cbot|synchro>synchronized</a> <a cbot|bool>bool</a> put(order " "a)" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:37 #, no-wrap msgid "" "\t{\n" "\t\tif ( m_order.m_type == nan )\n" "\t\t{\n" "\t\t\tm_order = a;\n" "\t\t\treturn true;\n" "\t\t}\n" "\t\telse\n" "\t\t{\n" "\t\t\treturn false;\n" "\t\t}\n" "\t}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:39 #, no-wrap msgid "" "Another method <code>get</code> will be used by the slave to retrieve the " "orders. This method returns the order to be executed:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:41 #, no-wrap msgid "<c/><s/>\t<a cbot|synchro>synchronized</a> order get()" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:44 #, no-wrap msgid "" "\t{\n" "\t\treturn m_order;\n" "\t}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:46 #, no-wrap msgid "" "A third method <code>delete</code> will be used by the slave to indicate " "that the order has been executed:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:48 #, no-wrap msgid "<c/><s/>\t<a cbot|synchro>synchronized</a> void delete()" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:52 #, no-wrap msgid "" "\t{\n" "\t\tm_order.m_type = nan;\n" "\t}\n" "}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:54 #, no-wrap msgid "" "The main program of the slave contains an instance of the class " "<code>exchange</code> called <code>list</code>. We put () after the word " "<code>list</code> in order to create an instance of the class " "<code>exchange</code>." msgstr "" #. type: Plain text #: train702-help/tremote4.txt:56 #, no-wrap msgid "<c/><s/><a cbot|extern>extern</a> void object::Slave3( )" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:59 #, no-wrap msgid "" "{\n" "\texchange list();\n" "\torder todo;" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:61 #, no-wrap msgid "" "The outer <code>while</code> loop lasts for ever. The inner " "<code>while</code> loop waits for an order by using the <code>get</code> " "method of the <code>exchange</code> class. As soon as <code>get</code> " "returns a value different from <code>nan</code>, the while loop stops." msgstr "" #. type: Plain text #: train702-help/tremote4.txt:63 #, no-wrap msgid "<c/><s/>\t<a cbot|while>while</a> ( true )" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:70 #, no-wrap msgid "" "\t{\n" "\t\t<a cbot|while>while</a> ( true )\n" "\t\t{\n" "\t\t\ttodo = list.get();\n" "\t\t\tif ( todo.m_type != nan ) break;\n" "\t\t\twait(1);\n" "\t\t}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:72 #, no-wrap msgid "" "Now we have received the order in the <code>todo</code> variable. All we " "have to do is execute it:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:74 #, no-wrap msgid "<c/><s/>\t\tif ( todo.m_type == 1 )" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:85 #, no-wrap msgid "" "\t\t{\n" "\t\t\tmove(todo.m_param);\n" "\t\t}\n" "\t\telse if ( todo.m_type == 2 )\n" "\t\t{\n" "\t\t\tturn(todo.m_param);\n" "\t\t}\n" "\t\telse\n" "\t\t{\n" "\t\t\tmessage(\"Unknown order\");\n" "\t\t}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:87 #, no-wrap msgid "" "As soon as the execution of the order is finished, we must call the " "<code>delete</code> method so the master knows that another order can be " "sent¦:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:89 #, no-wrap msgid "<c/><s/>\t\tlist.delete();" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:91 #, no-wrap msgid "" "\t}\n" "}" msgstr "" #. type: \b; header #: train702-help/tremote4.txt:92 #, no-wrap msgid "The master" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:94 #, no-wrap msgid "" "In the master we write an function called <code>SendOrder</code> which will " "send an order to the slave:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:96 #, no-wrap msgid "<c/><s/>void object::SendOrder(float order, float param)" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:108 #, no-wrap msgid "" "{\n" "\texchange list();\n" "\torder todo();\n" "\t\n" "\ttodo.m_type = order;\n" "\ttodo.m_param = param;\n" "\t\n" "\twhile ( list.put(todo) == false )\n" "\t{\n" "\t\twait(1);\n" "\t}\n" "}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:111 #, no-wrap msgid "" "The <code>while</code> loop waits until a pending order has been terminated, " "that is the slaved has exited from the <code>get</code> method and the " "<code>delete</code> method has been called.\n" "Now the main program of the master is very simple:" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:113 #, no-wrap msgid "<c/><s/>extern void object::Remote4( )" msgstr "" #. type: \s; block (usually verbatim code) #: train702-help/tremote4.txt:124 #, no-wrap msgid "" "{\n" "\tSendOrder(1, 20); // move(20);\n" "\tSendOrder(2, 90); // turn(90);\n" "\tSendOrder(1, 20); // move(20);\n" "\tSendOrder(2, 90); // turn(90);\n" "\tSendOrder(1, 10); // move(10);\n" "\tSendOrder(2, 90); // turn(90);\n" "\tSendOrder(1, 10); // move(10);\n" "\tSendOrder(2,-90); // turn(-90);\n" "\tSendOrder(1, 10); // move(10);\n" "}" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:126 #, no-wrap msgid "<format key><key help/></format> show these instruction at any time." msgstr "" #. type: \t; header #: train702-help/tremote4.txt:128 #, no-wrap msgid "See also" msgstr "" #. type: Plain text #: train702-help/tremote4.txt:129 #, no-wrap msgid "<a command>Controls</a> and <a cbot>programming</a>." msgstr ""