Changes between Version 4 and Version 5 of Java Client Tutorial


Ignore:
Timestamp:
Oct 23, 2011 1:41:01 PM (13 years ago)
Author:
jherwitz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Java Client Tutorial

    v4 v5  
    155155This section describes back-end Quagents development
    156156
    157 ==== Modifying internal structures =====
     157==== Modifying internal structures ====
     158
     159Much of the client-server interaction and multithreading control is handled internally by the Java client. Any modification to these controllers (mostly located in Command, ProtocolZero, and ReaderThread) must ensure that the server will accept/recognize the changes will equivalent functionality.
     160
     161'''Commands'''
     162
     163The developer may desire to create a new Command. There are two types of commands, ProtocolZero commands, which carry a one-to-one correspondence with the preexisting [[ProtocolZero]] commands within the server. Any modification to these must, in most cases, also include server modification, as all currently recognized server actions are spanned by the current set of client P0 commands. Most uses will be for ProtocolOne commands, which abstract away from the server and can provide arbitrary complexity.
     164To implement a new Command, the developer must extend either ProtocolZero or ProtocolOne.
     165
     166For P0 commands, the user must define four things:
     167 * A set of constructors which will be used to instantiate the command, specifically the parameters sent to the server.
     168 * A ''setOP'' function which will create the protocol message to send to the server. NOTE: This '''must''' be consistent with server protocol exceptions, defined in [[ProtocolZero]].
     169 * A set of functions used by external sources to access data or exit codes returned by the server.
     170 * A ''setData'' function, used by the socket reader to send server return data. This is only valid for functions which have an associated data response. For example, for the Facing command we have:
     171
     172{{{
     173public void setData(String params) {
     174                datastring = params;
     175                paramscan = new Scanner(params);
     176                viewangle[YAW] = paramscan.nextDouble();
     177                viewangle[PITCH] = paramscan.nextDouble();
     178                viewangle[ROLL] = paramscan.nextDouble();
     179        }
     180}}}
     181
     182ProtocolOne comamnds are slightly different in their implementation. By design, these commands have no direct server interaction, handling all interaction through nested ProtocolZero commands. Only three components need to be implemented for this class of command:
     183 * A set of constructors which initialize the command and any subcommands.
     184 * An ''addChildren'' function, which adds all nested P0 commands to the children list. This is necessary for internal client verification and execution. An example function looks like:
     185
     186{{{
     187protected void addChildren(){
     188                children.add(lookforward);  //rangefinder
     189                children.add(lookbackward); //rangefinder
     190                children.add(turnright);    //rotate
     191                children.add(turnleft);     //rotate
     192        }
     193}}}
     194
     195
     196
     197For more information, see the CartesianSensor2D source, as well as its implementation in the CaveExplorer class.
    158198
    159199==== Implementing a new Entity ====