diff --git a/docs/allclasses-frame.html b/docs/allclasses-frame.html new file mode 100644 index 0000000..8d66533 --- /dev/null +++ b/docs/allclasses-frame.html @@ -0,0 +1,22 @@ + + + +
+ +Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+DecodedControlAction#STOP
as
+ the default action, DecodedControlAction#MOTOR_ABC
as motor flag, and
+ 0 as default speed.DecodedControlAction
into a two byte array.DecodedControlAction
, calling the user operation
+ listeners if needed.NxtARControlProtocol
instance.NxtARControlProtocol
instance.DecodedControlAction
is decoded with DecodedControlAction.Action.USER_1
.DecodedControlAction
is decoded with DecodedControlAction.Action.USER_2
.DecodedControlAction
is decoded with DecodedControlAction.Action.USER_3
.UserActionListener
to this object's listeners list calling it's
+ onListenerRegistered()
method.UserActionListener
from this object's listeners list calling it's
+ onListenerRemoved()
method.DataOutputStream
associated with this ARControl to the output stream passed as
+ parameter.DecodedControlAction
into the associated DataOutputStream
if any.DataOutputStream
if any.public static enum DecodedControlAction.Action +extends java.lang.Enum<DecodedControlAction.Action>+
All recognized actions.
Enum Constant and Description | +
---|
MOVE_BACKWARDS |
+
MOVE_FORWARD |
+
RECENTER |
+
STOP |
+
USER_1 |
+
USER_2 |
+
USER_3 |
+
Modifier and Type | +Method and Description | +
---|---|
static DecodedControlAction.Action |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static DecodedControlAction.Action[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final DecodedControlAction.Action MOVE_FORWARD+
public static final DecodedControlAction.Action MOVE_BACKWARDS+
public static final DecodedControlAction.Action STOP+
public static final DecodedControlAction.Action RECENTER+
public static final DecodedControlAction.Action USER_1+
public static final DecodedControlAction.Action USER_2+
public static final DecodedControlAction.Action USER_3+
public static DecodedControlAction.Action[] values()+
+for (DecodedControlAction.Action c : DecodedControlAction.Action.values()) + System.out.println(c); +
public static DecodedControlAction.Action valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static enum DecodedControlAction.Motor +extends java.lang.Enum<DecodedControlAction.Motor>+
All motor ports and possible combinations without repetitions.
Enum Constant and Description | +
---|
MOTOR_A |
+
MOTOR_AB |
+
MOTOR_ABC |
+
MOTOR_AC |
+
MOTOR_B |
+
MOTOR_BC |
+
MOTOR_C |
+
Modifier and Type | +Method and Description | +
---|---|
static DecodedControlAction.Motor |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static DecodedControlAction.Motor[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final DecodedControlAction.Motor MOTOR_A+
public static final DecodedControlAction.Motor MOTOR_B+
public static final DecodedControlAction.Motor MOTOR_C+
public static final DecodedControlAction.Motor MOTOR_AB+
public static final DecodedControlAction.Motor MOTOR_AC+
public static final DecodedControlAction.Motor MOTOR_BC+
public static final DecodedControlAction.Motor MOTOR_ABC+
public static DecodedControlAction.Motor[] values()+
+for (DecodedControlAction.Motor c : DecodedControlAction.Motor.values()) + System.out.println(c); +
public static DecodedControlAction.Motor valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic class DecodedControlAction
+extends java.lang.Object
+An immutable and pure data class that represents an action decoded from a protocol + data message.
Modifier and Type | +Class and Description | +
---|---|
static class |
+DecodedControlAction.Action
+All recognized actions.
+ |
+
static class |
+DecodedControlAction.Motor
+All motor ports and possible combinations without repetitions.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
DecodedControlAction.Action |
+action |
+
DecodedControlAction.Motor |
+motor |
+
int |
+speed |
+
Constructor and Description | +
---|
DecodedControlAction()
+Create a new ControlAction object using
+DecodedControlAction#STOP as
+ the default action, DecodedControlAction#MOTOR_ABC as motor flag, and
+ 0 as default speed. |
+
DecodedControlAction(DecodedControlAction.Action action)
+Create a new ControlAction object using the specified action.
+ |
+
DecodedControlAction(DecodedControlAction.Action action,
+ DecodedControlAction.Motor motor)
+Create a new ControlAction object using the specified action and motor flag.
+ |
+
DecodedControlAction(DecodedControlAction.Action action,
+ DecodedControlAction.Motor motor,
+ int speed)
+Create a new ControlAction object using the specified action, motor flag and speed.
+ |
+
public final DecodedControlAction.Action action+
public final DecodedControlAction.Motor motor+
public final int speed+
public DecodedControlAction()+
Create a new ControlAction object using DecodedControlAction#STOP
as
+ the default action, DecodedControlAction#MOTOR_ABC
as motor flag, and
+ 0 as default speed.
public DecodedControlAction(DecodedControlAction.Action action)+
Create a new ControlAction object using the specified action. The motor
+ flag is set to DecodedControlAction#MOTOR_ABC
and the speed is set to 100.
action
- The action flag to set.public DecodedControlAction(DecodedControlAction.Action action, + DecodedControlAction.Motor motor)+
Create a new ControlAction object using the specified action and motor flag. The + speed is set to 100.
action
- The action flag to set.motor
- The motor flag to set.public DecodedControlAction(DecodedControlAction.Action action, + DecodedControlAction.Motor motor, + int speed)+
Create a new ControlAction object using the specified action, motor flag and speed.
action
- The action flag to set.motor
- The motor flag to set.speed
- The speed to set. Will be clamped to the range [-100, 100].public class NxtARControlProtocol
+extends java.lang.Object
+A wrapper around the NxtAR robot control protocol for the LejOS operating system.
Constructor and Description | +
---|
NxtARControlProtocol(java.io.DataInputStream inputStream,
+ java.io.DataOutputStream outputStream)
+Create a new ARControl object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
DecodedControlAction |
+decodeMessage(byte[] message)
+Decodes a protocol message encoded as a byte array of two elements as specified
+ in the package definition.
+ |
+
byte[] |
+encodeControlAction(DecodedControlAction action)
+Encodes a given
+DecodedControlAction into a two byte array. |
+
boolean |
+executeControlAction(DecodedControlAction controlAction)
+Executes an already decoded
+DecodedControlAction , calling the user operation
+ listeners if needed. |
+
boolean |
+readAndExecuteMessage()
+Attempts to read, decode and execute a message, calling the user operation
+ listeners if needed.
+ |
+
byte[] |
+readRawControlMessage()
+Attempts to read a 2-byte message and returns it as is.
+ |
+
void |
+registerUserActionListener(UserActionListener listener)
+Adds an
+UserActionListener to this object's listeners list calling it's
+ UserActionListener.onListenerRegistered() method. |
+
void |
+removeUserActionListener(UserActionListener listener)
+Removes an
+UserActionListener from this object's listeners list calling it's
+ UserActionListener.onListenerRemoved() method. |
+
void |
+setInputStream(java.io.DataInputStream inputStream)
+Changes the input stream associated with this ARControl to the input stream passed as
+ parameter.
+ |
+
void |
+setOutputStream(java.io.DataOutputStream outputStream)
+Changes the
+DataOutputStream associated with this ARControl to the output stream passed as
+ parameter. |
+
boolean |
+writeMessage(DecodedControlAction action)
+Encodes and writes a
+DecodedControlAction into the associated DataOutputStream if any. |
+
void |
+writeRawControlMessage(byte[] message)
+Attempts to write a 2-byte message to the associated
+DataOutputStream if any. |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public NxtARControlProtocol(java.io.DataInputStream inputStream, + java.io.DataOutputStream outputStream)+
Create a new ARControl object.
inputStream
- A DataInputStream
used to read protocol messages from. Can be null.outputStream
- An DataOutputStream
used to write protocol messages to. Can be null.public void setOutputStream(java.io.DataOutputStream outputStream) + throws java.io.IOException+
Changes the DataOutputStream
associated with this ARControl to the output stream passed as
+ parameter. The currently set output stream is flushed and closed before replacing it.
outpuStream
- An opened output stream. Can be null.java.io.IOException
- If an error happened while closing the previous output stream.public void writeRawControlMessage(byte[] message) + throws java.io.IOException, + java.lang.IllegalArgumentException+
Attempts to write a 2-byte message to the associated DataOutputStream
if any.
Returns immediately if no DataOutputStream
has been set with
+ setOutputStream(DataOutputStream)
or if the message is null. If the
+ message is longer than two bytes only the first two bytes are written to the output stream.
java.io.IOException
- If writing the message fails. It is the same IOException
+ as thrown by DataOutput.write(byte[], int, int)
.java.lang.IllegalArgumentException
- If the message lenght is less than two.public byte[] encodeControlAction(DecodedControlAction action)+
Encodes a given DecodedControlAction
into a two byte array.
action
- the action to encode.public boolean writeMessage(DecodedControlAction action) + throws java.io.IOException+
Encodes and writes a DecodedControlAction
into the associated DataOutputStream
if any.
action
- The action to write.java.io.IOException
- If writing the message fails.public void setInputStream(java.io.DataInputStream inputStream) + throws java.io.IOException+
Changes the input stream associated with this ARControl to the input stream passed as + parameter. The currently set input stream is closed before replacing it.
inputStream
- An opened input stream. Can be null.java.io.IOException
- If an error happened while closing the previous input stream.public byte[] readRawControlMessage() + throws java.io.IOException+
Attempts to read a 2-byte message and returns it as is.
+ +Returns null if no DataInputStream
has been set with
+ setInputStream(DataInputStream)
.
java.io.IOException
- If reading the message fails. It is the same IOException
+ as thrown by DataInput.readByte()
.public boolean readAndExecuteMessage() + throws java.io.IOException+
Attempts to read, decode and execute a message, calling the user operation + listeners if needed.
java.io.IOException
- If reading the message fails. It is the same IOException
+ as thrown by DataInput.readByte()
if any.public DecodedControlAction decodeMessage(byte[] message) + throws java.lang.IllegalArgumentException+
Decodes a protocol message encoded as a byte array of two elements as specified + in the package definition.
+ +User actions have precedence over motor recentering and + this in turn has precedence over other movement actions. + User actions have precedence in decreasing order; that is, user action 1 has + precedence over user actions 2 and 3, etc.
+ +If the message indicates a movement (forward or backward) with all motors off, + then it is interpreted as a request to stop all motors. A recenter or user action + with all motors off will be decoded as is and must be interpreted by the user.
message
- A byte array of size two encoding a message recognized by the protocol. If the array
+ has 3 or more elements then only the first 2 are used during the decoding process.DecodedControlAction
instance containing the decoded message.java.lang.IllegalArgumentException
- If the array is null or has less than 2 elements.public boolean executeControlAction(DecodedControlAction controlAction) + throws java.lang.IllegalArgumentException+
Executes an already decoded DecodedControlAction
, calling the user operation
+ listeners if needed.
controlAction
- The action to execute.java.lang.IllegalArgumentException
- If controlAction is null.public void registerUserActionListener(UserActionListener listener) + throws java.lang.IllegalArgumentException+
Adds an UserActionListener
to this object's listeners list calling it's
+ UserActionListener.onListenerRegistered()
method. Adding a listener that
+ is already registered does nothing.
listener
- The listener to add.java.lang.IllegalArgumentException
- If listener is null.public void removeUserActionListener(UserActionListener listener) + throws java.lang.IllegalArgumentException+
Removes an UserActionListener
from this object's listeners list calling it's
+ UserActionListener.onListenerRemoved()
method. Removing a listener that
+ is NOT on the list does nothing.
listener
- The listener to remove.java.lang.IllegalArgumentException
- If listener is null.public interface UserActionListener
+An object to be notified when an user action has been received in a protocol message.
Modifier and Type | +Method and Description | +
---|---|
void |
+onListenerRegistered()
+Executes a set of instructions just after the listener has been registered with an
+NxtARControlProtocol instance. |
+
void |
+onListenerRemoved()
+Executes a set of instructions just after the listener has been removed from an
+NxtARControlProtocol instance. |
+
void |
+onUserAction1(DecodedControlAction.Motor motorFlag,
+ int speed)
+Executes a set of instructions when a
+DecodedControlAction is decoded with DecodedControlAction.Action.USER_1 . |
+
void |
+onUserAction2(DecodedControlAction.Motor motorFlag,
+ int speed)
+Executes a set of instructions when a
+DecodedControlAction is decoded with DecodedControlAction.Action.USER_2 . |
+
void |
+onUserAction3(DecodedControlAction.Motor motorFlag,
+ int speed)
+Executes a set of instructions when a
+DecodedControlAction is decoded with DecodedControlAction.Action.USER_3 . |
+
void onListenerRegistered()+
Executes a set of instructions just after the listener has been registered with an NxtARControlProtocol
instance.
void onUserAction1(DecodedControlAction.Motor motorFlag, + int speed)+
Executes a set of instructions when a DecodedControlAction
is decoded with DecodedControlAction.Action.USER_1
.
void onUserAction2(DecodedControlAction.Motor motorFlag, + int speed)+
Executes a set of instructions when a DecodedControlAction
is decoded with DecodedControlAction.Action.USER_2
.
void onUserAction3(DecodedControlAction.Motor motorFlag, + int speed)+
Executes a set of instructions when a DecodedControlAction
is decoded with DecodedControlAction.Action.USER_3
.
void onListenerRemoved()+
Executes a set of instructions just after the listener has been removed from an NxtARControlProtocol
instance.
See: Description
+Interface | +Description | +
---|---|
UserActionListener | +
+ An object to be notified when an user action has been received in a protocol message.
+ |
+
Class | +Description | +
---|---|
DecodedControlAction | +
+ An immutable and pure data class that represents an action decoded from a protocol
+ data message.
+ |
+
NxtARControlProtocol | +
+ A wrapper around the NxtAR robot control protocol for the LejOS operating system.
+ |
+
Enum | +Description | +
---|---|
DecodedControlAction.Action | +
+ All recognized actions.
+ |
+
DecodedControlAction.Motor | +
+ All motor ports and possible combinations without repetitions.
+ |
+
This package contains a wrapper library and reference implementation of the NxtAR + robot control protocol for the LejOS operating system.
+ +The protocol is based on 2 byte long data messages that encode a set of motor ports, actions + on those motors and the speed of the motors. The first byte encodes a set actions and motors, while the + second byte contains an integer number representing the speed to set to the enabled motors. The first + byte's bits encode the following data (from least significant to most significant bit):
+ +This bits are decoded using the binary masks defined in NxtARControlProtocol
.
+ This mechanism allows to set the state or execute an action on multiple motors simultaneously. The user actions are
+ executed using callback objects registered with the aforementioned class.
The NxtARControlProtocol
class includes methods to
+ read, decode and execute a protocol message, independently of how those messages are generated. An example
+ would be messages read from a Bluetooth or USB stream, as well as messages generated by the application
+ that is using the library.