public class LegoRobot
extends java.lang.Object
Constructor and Description |
---|
LegoRobot()
Same as LegoRobot(connectionListener) with connectionListener = null.
|
LegoRobot(ConnectionListener connectionListener)
Creates a EV3Robot and engages a connection trial.
|
LegoRobot(ConnectionListener connectionListener,
java.lang.String ipAddress)
Creates a EV3Robot instance with given IP address.
|
LegoRobot(ConnectionListener connectionListener,
java.lang.String ipAddress,
boolean immediateConnect)
Creates a EV3Robot instance with given IP address.
|
LegoRobot(ConnectionListener connectionListener,
java.lang.String ipAddress,
int port,
boolean immediateConnect)
Creates a EV3Robot instance with given IP address.
|
LegoRobot(java.lang.String ipAddress)
Same as LegoRobot(connectionListener, ipAddress) with connectionListener = null.
|
LegoRobot(java.lang.String ipAddress,
boolean immediateConnect)
Same as LegoRobot(connectionListener, ipAddress, immediateConnect) with
connectionsListener = null.
|
LegoRobot(java.lang.String ipAddress,
int port,
boolean immediateConnect)
Same as LegoRobot(connectionlistener, ipAddress, port, immediateConnect) with
connectionListener = null.
|
Modifier and Type | Method and Description |
---|---|
void |
addPart(Part part)
Assembles the given part into the robot.
|
boolean |
connect()
Connects the host to the robot via an IP socket.
|
boolean |
connect(boolean isAnnounce)
Connects the host to the robot via an IP socket.
|
void |
exit()
Disconnects the communication link and terminates the program.
|
static java.lang.String |
getAbout()
Returns copywrite information.
|
int |
getBatteryLevel()
Returns the battery level.
|
java.io.InputStream |
getInputStream()
Returns the InputStream reference of the connection link.
|
java.lang.String |
getIPAddress()
Returns the IP address (in dotted format).
|
java.io.OutputStream |
getOutputStream()
Returns the OutputStream reference of the connection link.
|
static java.lang.String |
getVersion()
Returns library version information.
|
boolean |
isConnected()
Returns the connection state.
|
void |
playTone(int frequency,
int duration)
Plays a tone with given frequency (in Hertz) and duration (in seconds).
|
void |
reset()
Resets EV3 to start location/direction.
|
public LegoRobot(ConnectionListener connectionListener, java.lang.String ipAddress, int port, boolean immediateConnect)
connectionListener
- a ConnectionListener to get connection notifications
If null, no ConnectionListener is registered.ipAddress
- the IP address of the brick, e.g. "10.0.1.1"port
- the IP port where the EV3DirectServer is listeningimmediateConnect
- if true, a connection trial is engagedpublic LegoRobot(java.lang.String ipAddress, int port, boolean immediateConnect)
ipAddress
- the IP address of the brick, e.g. "10.0.1.1"port
- the IP port where the EV3DirectServer is listeningimmediateConnect
- if true, a connection trial is engagedpublic LegoRobot(ConnectionListener connectionListener, java.lang.String ipAddress, boolean immediateConnect)
connectionListener
- a ConnectionListener to get connection notifications
If null, no ConnectionListener is registered.ipAddress
- the IP address of the brick, e.g. "10.0.1.1"immediateConnect
- if true, a connection trial is engagedpublic LegoRobot(java.lang.String ipAddress, boolean immediateConnect)
ipAddress
- the IP address of the brick, e.g. "10.0.1.1"immediateConnect
- if true, a connection trial is engagedpublic LegoRobot(ConnectionListener connectionListener, java.lang.String ipAddress)
connectionListener
- a ConnectionListener to get connection notifications
If null, no ConnectionListener is registered.ipAddress
- the IP address of the brick, e.g. "10.0.1.1"public LegoRobot(java.lang.String ipAddress)
ipAddress
- the IP address of the brick, e.g. "10.0.1.1"public LegoRobot(ConnectionListener connectionListener)
connectionListener
- a ConnectionListener to get connection notifications.
If null, no ConnectionListener is registered.
The default IP address "10.0.1.1" and port 1299 is used.public LegoRobot()
public void addPart(Part part)
part
- the part to assemblepublic boolean connect()
public boolean connect(boolean isAnnounce)
isAnnounce
- if true, a connect/disconnect melody is playedpublic void exit()
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public boolean isConnected()
public void playTone(int frequency, int duration)
public int getBatteryLevel()
public java.lang.String getIPAddress()
public static java.lang.String getVersion()
public static java.lang.String getAbout()
public void reset()