public class Robot
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Robot.ClosingMode
Modes to determine what happens when the title bar close button is hit.
|
Constructor and Description |
---|
Robot()
Asks for the IP address and creates a RaspiRobot instance.
|
Robot(java.lang.String ipAddress)
Creates a RaspiRobot instance with given IP address.
|
Robot(java.lang.String ipAddress,
boolean immediateConnect)
Creates a RaspiRobot 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.
|
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.
|
void |
exit()
Closes the connection dialog and any open QuitPane, disconnects
the communication link and terminates the program.
|
java.io.OutputStream |
getDataOutputStream()
Returns the OutputStream reference of the connection link.
|
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 |
getIPAddresses()
Returns all IP addresses (in dotted format, comma separated).
|
static RaspiProperties |
getProperties()
Returns the properties from the RaspiJLib property file.
|
java.lang.String |
getVersion()
Returns library version information.
|
boolean |
isButtonHit()
Returns true, if any of the buttons was hit.
|
boolean |
isConnected()
Returns the connection state.
|
boolean |
isDownHit()
(Only in remote mode) Returns true, if the cursor down key was hit since the
last call of this method.
|
boolean |
isEnterHit()
(Only in remote mode) Returns true, if the ENTER key was hit since
the last call of this method.
|
boolean |
isEscapeHit()
Returns true, if the ESCAPE key (in remote mode) or the push button
(in autonomouse mode) was hit since
the last call of this method.
|
boolean |
isLeftHit()
(Only in remote mode) Returns true, if the cursor left key was hit since
the last call of this method.
|
boolean |
isRightHit()
(Only in remote mode) Returns true, if the cursor right key was 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()
(Only in remote mode) Returns true, if the cursor up key 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 Raspi to start location/direction.
|
void |
setSoundVolume(int volume)
Sets the sound volume.
|
public Robot(java.lang.String ipAddress, boolean immediateConnect)
ipAddress
- the IP address of the brick, e.g. "192.168.0.2"immediateConnect
- if true, a connection trial is engagedpublic Robot(java.lang.String ipAddress)
ipAddress
- the IP address of the brick, e.g. "192.168.0.2"public Robot()
public void addConnectionListener(ConnectionListener listener)
listener
- the ConnectionListener to registerpublic static RaspiProperties getProperties()
public boolean connect()
public boolean connect(boolean isConnectPane)
isConnectPane
- if true, an information pane is shownpublic void exit()
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 setSoundVolume(int volume)
volume
- the sound volume (0..100)public java.lang.String getIPAddresses()
public java.lang.String getVersion()
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()