|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ukcrobots.simplecore.Motor
Model a motor. Only one instance may be created for each output port. This class is based on josx.platform.rcx.Motor
Field Summary | |
static int |
DEVICE_MODE_BACKWARD
|
static int |
DEVICE_MODE_FLOATING
|
static int |
DEVICE_MODE_FORWARD
|
static int |
DEVICE_MODE_STOPPED
|
Constructor Summary | |
Motor(char port)
Create a motor. |
Method Summary | |
void |
backward()
Causes the device to rotate backwards. |
void |
flt()
Causes the motor to float. |
void |
forward()
Causes the device to rotate forward. |
int |
getMode()
Return one of the following values: DEVICE_MODE_STOPPED - the device is stopped DEVICE_MODE_FORWARD - the device is running forward DEVICE_MODE_BACKWARD - the device is running backward DEVICE_MODE_FLOATING - the device is floating |
int |
getPower()
Returns the motor's current power level. |
boolean |
isBackward()
|
boolean |
isFloating()
|
boolean |
isForward()
|
boolean |
isMoving()
|
boolean |
isStopped()
|
void |
reverse()
Reverses direction of the device. |
void |
setPower(int power)
Sets power to a value between 0 and 7. |
void |
stop()
Causes the motor to stop, pretty much instantaneously. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Field Detail |
public static final int DEVICE_MODE_FORWARD
public static final int DEVICE_MODE_BACKWARD
public static final int DEVICE_MODE_STOPPED
public static final int DEVICE_MODE_FLOATING
Constructor Detail |
public Motor(char port) throws NoSuchDeviceException, AlreadyCreatedException
port
- Which output port the motor is attached to.
This should have a value of 'A', 'B', or 'C'.
NoSuchDeviceException
- If the value of id is incorrect.
AlreadyCreatedException
- If a Motor has already been created
for this output port.Method Detail |
public void setPower(int power)
public void forward()
public void backward()
public void reverse()
public int getPower()
public int getMode()
public void stop()
public void flt()
public boolean isMoving()
public boolean isForward()
public boolean isBackward()
public boolean isFloating()
public boolean isStopped()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |