Changes between Version 31 and Version 32 of ProtocolOne
- Timestamp:
- Jun 29, 2011 12:16:09 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ProtocolOne
v31 v32 15 15 * [[Compound Functions]] 16 16 17 '''Flow of Execution''' 18 To create a Quagent, simply create a new client using the Client constructor. The constructor takes one argument, which must specify the IP address of the Quagents server.17 = Flow of Execution = 18 To create a Quagent, simply instantiate a new client using the Client constructor. The constructor takes one argument, which must specify the IP address of the Quagents server. 19 19 20 20 ''Example:'' … … 42 42 43 43 == Command Structure == 44 [[ProtocolOne]] provides the user two ways of executing Quagent commands. Both of these adhere to a uniqueprogramming paradigm - one method is [http://en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented] while the other is [http://en.wikipedia.org/wiki/Functional_programming Functional]. These methods are (approximately) equivalent in usability and accessibility, so the user may choose to use whichever paradigm is preferred.44 [[ProtocolOne]] provides the user two ways of executing Quagent commands. Both of these adhere to a distinct programming paradigm - one method is [http://en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented] while the other is [http://en.wikipedia.org/wiki/Functional_programming Functional]. These methods are (approximately) equivalent in usability and accessibility, so the user may choose to use whichever paradigm is preferred. 45 45 The user may choose to execute commands by either explicitly instantiating the command objects or calling a relevant function. Internally, all commands are represented as command-specific objects. These objects handle writing the specified command to the server, automatically update data fields with any relevant server data response, and maintain auxiliary data related to the command, such as command [[exitcode]] and runtime. To execute a command explicitly using the object, simply call the member function {{{run()}}}. Function calls automatically instantiate, run, and return the relevant object. 46 46 It is important to note that all Commands are implemented as [http://download.oracle.com/javase/1.4.2/docs/api/java/util/TimerTask.html TimerTasks], so a user may easily implement an application involving high-level scheduling or planning using [http://download.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html Timers] (this is actually how the periodic execution is implemented). … … 49 49 ''Example'' 50 50 The following two code blocks are identical. 51 ''Functional'' 51 52 {{{ 52 53 client.fireWeapon(); 53 54 }}} 55 ''Object-Oriented'' 54 56 {{{ 55 57 FireWeapon fw = new FireWeapon(); … … 59 61 60 62 = Retrieving Data = 63 Client/Server data response in Quagents 3 is asynchronous. Thus, the object-oriented and functional methods of execution do not directly return related data. Instead, the user gets a reference to the related command object. This object automatically updates data specific to itself as it is read from the socket. The user must poll this object using object query functions to gain access to data. The following example illustrates this interaction. 61 64 62 65 The following is an example of a complete Quagents session: