public class LegoRobot
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LegoRobot.ClosingMode
Modes to determine what happens when the title bar close button is hit.
|
Constructor and Description |
---|
LegoRobot()
Asks for the IP address and creates a EV3Robot instance.
|
LegoRobot(java.lang.String ipAddress)
Creates a EV3Robot instance with given IP address.
|
LegoRobot(java.lang.String ipAddress,
boolean immediateConnect)
Creates a EV3Robot instance with given IP address.
|
Modifier and Type | Method and Description |
---|---|
void |
addButtonListener(ButtonListener listener)
Registers a button listener that simulates the events
when one of the brick buttons is hit.
|
void |
addConnectionListener(ConnectionListener listener)
Registers a connection listener to get notifications when
the link is established or broken.
|
void |
addPart(Part part)
Assembles the given part into the robot.
|
void |
clearDisplay()
Clears the display.
|
boolean |
connect()
Connects the host to the robot via an IP socket.
|
boolean |
connect(boolean isConnectPane)
Connects the host to the robot via an IP socket.
|
boolean |
connect(boolean isConnectPane,
boolean isAnnounce)
Connects the host to the robot via an IP socket.
|
void |
disconnect()
Disconnects the TCP link.
|
void |
drawString(java.lang.String text,
int x,
int y)
Draws the given text line starting at given position.
|
void |
drawStringAt(java.lang.String text,
int count)
Draws the given text line starting at given screen cell count.
|
void |
exit()
Closes the connection dialog and any open QuitPane, disconnects
the communication link and terminates the program (depending on
setting in ev3jlib.properties).
|
static java.lang.String |
getAbout()
Returns copywrite information.
|
int |
getBatteryLevel()
Returns the battery level.
|
java.lang.String |
getBrickGateVersion()
Returns the version of the BrickGate server.
|
java.io.OutputStream |
getDataOutputStream()
Returns the OutputStream reference of the connection link.
|
static int |
getDebugLevel()
Returns the current debug level.
|
int |
getHitButtonID()
Returns the button ID of the button previously hit.
|
java.io.InputStream |
getInputStream()
Returns the InputStream reference of the connection link.
|
java.lang.String |
getIPAddress()
Returns the IP address (in dotted format).
|
java.lang.String[] |
getIPAddresses()
Returns a list with the current brick's IP addresses
|
static EV3Properties |
getProperties()
Returns the properties from the EV3JLib property file.
|
static java.lang.String |
getVersion()
Returns library version information.
|
boolean |
isAutonomous()
Returns true, if the client connects locally (with localhost connection).
|
boolean |
isButtonHit()
Returns true, if any of the buttons was hit.
|
boolean |
isConnected()
Returns the connection state.
|
boolean |
isDownHit()
Returns true, if the DOWN button was the last button hit since
the last call of this method.
|
boolean |
isEnterHit()
Returns true, if the ENTER button was the last button hit since
the last call of this method.
|
boolean |
isEscapeHit()
Returns true, if the ESCAPE button was the last button hit since
the last call of this method.
|
boolean |
isLeftHit()
Returns true, if the LEFT button was the last button hit since
the last call of this method.
|
boolean |
isRightHit()
Returns true, if the RIGHT button was the last button hit since
the last call of this method.
|
boolean |
isRunning()
Returns true as long as exit() is not called and the close
button of the Connection Pane is not hit.
|
boolean |
isUpHit()
Returns true, if the UP button was the last button hit since
the last call of this method.
|
void |
playTone(double frequency,
double duration)
Plays a tone with given frequency and duration.
|
void |
reset()
Resets EV3 to start location/direction.
|
void |
setLED(int pattern)
Turn on/off the brick's left/right LEDs (only affected in pair).
|
void |
setVolume(int volume)
Sets the sound volume.
|
public 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(java.lang.String ipAddress)
ipAddress
- the IP address of the brick, e.g. "10.0.1.1"public LegoRobot()
public void addConnectionListener(ConnectionListener listener)
listener
- the ConnectionListener to registerpublic static EV3Properties getProperties()
public static int getDebugLevel()
public void addPart(Part part)
part
- the part to assemblepublic boolean connect()
public boolean connect(boolean isConnectPane)
isConnectPane
- if true an information pane is shownpublic boolean connect(boolean isConnectPane, boolean isAnnounce)
isConnectPane
- if true, an information pane is shownisAnnounce
- if true, a connect/disconnect melody is playedpublic void exit()
public void disconnect()
public boolean isRunning()
public java.io.InputStream getInputStream()
public java.io.OutputStream getDataOutputStream()
public boolean isConnected()
public void playTone(double frequency, double duration)
frequency
- the frequency of the tone (in Hertz) (double rounded to int)duration
- the duration of the tone (in Millisec) (double rounded to int)public void setVolume(int volume)
volume
- the sound volume (0..100)public void setLED(int pattern)
pattern
- the pattern 0..9public int getBatteryLevel()
public java.lang.String getIPAddress()
public static java.lang.String getVersion()
public static java.lang.String getAbout()
public java.lang.String getBrickGateVersion()
public java.lang.String[] getIPAddresses()
public boolean isAutonomous()
public void reset()
public void addButtonListener(ButtonListener listener)
listener
- the ButtonListener to registerpublic boolean isButtonHit()
public int getHitButtonID()
public boolean isUpHit()
public boolean isDownHit()
public boolean isLeftHit()
public boolean isRightHit()
public boolean isEnterHit()
public boolean isEscapeHit()
public void drawString(java.lang.String text, int x, int y)
text
- the text to showx
- the column number (0..17)y
- the line number (0..7)public void drawStringAt(java.lang.String text, int count)
text
- the text to showcount
- the cell count (cells are counted from zero line-per-linepublic void clearDisplay()