|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.citar.diablu.nxt.protocol.NXTCommand
public abstract class NXTCommand
Represents a Command that can be sent to the NXTBrick. This class cannot be instantiated.
Only subclasses which represent concrete Commands should be used.
Commands can generate Responses if so required. Responses are encapsulated by NXTResponse
subclasses.
Subclasses should implement the sendCommand()
method and any specific parameter setting methods.
NXTResponse
Constructor Summary | |
---|---|
NXTCommand()
Constructs a new command object with no response requirement. |
|
NXTCommand(boolean responseRequired)
Constructs a new command object with a response requirement. |
Method Summary | |
---|---|
int |
getPacketLength()
|
boolean |
isResponseRequired()
Returns the response requirements for the command. |
NXTResponse |
sendCommand(NXTCommChannel channel)
Sends the command to the brick and returns the response (if required). |
void |
setResponseRequired(boolean responseRequired)
Sets the requirement for a response to the command. |
String |
toString()
Formats the command packet in hex form. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NXTCommand()
public NXTCommand(boolean responseRequired)
responseRequired
- The response requirement. false
, no response required. true
, response
required.Method Detail |
---|
public NXTResponse sendCommand(NXTCommChannel channel) throws IOException
is
- The InputStream
from which the response can be read.os
- The OutputStream
to send the command.
NXTResponse
response. This should be cast to the apropriate subclass.
IOException
public int getPacketLength()
public boolean isResponseRequired()
public void setResponseRequired(boolean responseRequired)
responseRequired
- true
if a response is required, false
if a response is not required.public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |