public class Sabertooth extends AbstractMotorController implements PortConnector, MotorController
Modifier and Type | Field and Description |
---|---|
static int |
INPUT |
static org.slf4j.Logger |
log |
static int |
MOTOR1_BACKWARD |
static int |
MOTOR1_FORWARD |
static int |
MOTOR2_BACKWARD |
static int |
MOTOR2_FORWARD |
static int |
OUTPUT |
static int |
PACKETIZED_SERIAL_MODE |
static int |
PINMODE |
static int |
SET_MAX_VOLTAGE |
static int |
SET_MIN_VOLTAGE |
cfgDir, dnaPool, MESSAGE_RECORDING_FORMAT_BINARY, MESSAGE_RECORDING_FORMAT_XML
Constructor and Description |
---|
Sabertooth(java.lang.String n) |
Modifier and Type | Method and Description |
---|---|
void |
attach(Attachable service)
Routing Attach - routes ServiceInterface.attach(service) to appropriate
methods for this class
|
void |
connect(java.lang.String port) |
void |
connect(java.lang.String port,
int rate) |
void |
connect(java.lang.String port,
int rate,
int databits,
int stopbits,
int parity)
Sabertooth is a serial device, so it has a PortConnector interface.
|
void |
detach()
detaches ALL other services from this service
|
void |
detach(MotorControl device) |
void |
disconnect() |
void |
driveBackwardsMotor1(int speed) |
void |
driveBackwardsMotor2(int speed) |
void |
driveForwardMotor1(int speed) |
void |
driveForwardMotor2(int speed) |
java.util.Set<java.lang.String> |
getAttached()
returns all currently attached services
|
static ServiceType |
getMetaData()
This static method returns all the details of the class without it having
to be constructed.
|
java.util.List<java.lang.String> |
getPorts()
if the motor controller uses ports - this method will return a list of ports
|
SerialDevice |
getSerial() |
boolean |
isAttached(Attachable service)
the "routing" isAttached - when overridden by a service this
"routes" to the appropriate typed isAttached
|
boolean |
isConnected() |
static void |
main(java.lang.String[] args) |
boolean |
motorDetach(java.lang.String name) |
void |
motorMove(MotorControl mc)
request for motor to move the motor can be queried for the new powerlevel
and the controller shall appropriately change power level and direction
if necessary
|
void |
motorMove(java.lang.String name) |
void |
motorMoveTo(MotorControl motor)
moveTo - move the MotorControl a relative amount the amount can be
negative or positive an integer value is expected
param name
- name of the MotorControl
param position
- positive or negative absolute amount to move the
MotorControl
|
void |
motorMoveTo(java.lang.String name,
java.lang.Integer position) |
void |
motorReset(MotorControl motor)
method for resetting all the variables of a motor this will reset
counters if the motor is a stepper and / or other variables for other
sorts of motors
|
void |
motorStop(MotorControl motor)
stops the motor
|
void |
sendPacket(int command,
int data) |
void |
setAddress(java.lang.Integer address) |
void |
setMaxVoltage(int maxVolts) |
void |
setMinVoltage(int min) |
addListener, addListener, addTask, addTask, addTask, addTaskOneShot, allowDisplay, allowDisplay, attach, broadcastState, buildDna, buildDna, buildDnaKeys, buildDnaNames, clearLastError, close, containsTask, copyShallowFrom, createPeer, createPeer, createRootReserved, detach, detach, echoHeartbeat, error, error, error, getCfgDir, getComm, getDeclaredMethodNames, getDeclaredMethods, getDescription, getDna, getDnaString, getHostName, getInbox, getInstanceId, getIntanceName, getInterfaceSet, getLastError, getMessageSet, getMetaData, getMethodMap, getMethodNames, getMethods, getMethodToolTip, getMsg, getName, getNotifyList, getNotifyListKeySet, getOutbox, getPeerKey, getPeerName, getServiceResourceFile, getSimpleName, getTasks, getThisThread, getType, hasError, hasPeers, help, help, in, info, info, invoke, invoke, invoke, invokeOn, isAttached, isLocal, isReady, isRunning, isRuntime, isVirtual, load, load, logTimeEnable, mergeDna, mergeDna, mergePeerDna, movePeerDna, out, out, preProcessHook, preRoutingHook, publishError, publishQueueStats, publishState, publishStats, publishStatus, purgeTask, purgeTasks, releasePeers, releaseService, removeAllListeners, removeListener, requiresSecurity, reserve, reserve, reserveRoot, reserveRoot, reserveRootAs, run, save, save, save, send, send, send, send, sendBlocking, sendBlocking, sendBlocking, sendBlocking, sendPeer, setInstanceId, setName, setPeer, setSecurityProvider, setState, setThisThread, setVirtual, sleep, stackToString, startHeartbeat, startPeer, startPeer, startRecording, startService, stopHeartbeat, stopMsgRecording, stopService, subscribe, subscribe, subscribe, toString, unsubscribe, unsubscribe, unsubscribe, updateStats, warn, warn
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
attach, detach, detach, isAttached, isLocal
getName
public static final int PACKETIZED_SERIAL_MODE
public static final int PINMODE
public static final org.slf4j.Logger log
public static final int INPUT
public static final int OUTPUT
public static final int MOTOR1_FORWARD
public static final int MOTOR1_BACKWARD
public static final int SET_MIN_VOLTAGE
public static final int SET_MAX_VOLTAGE
public static final int MOTOR2_FORWARD
public static final int MOTOR2_BACKWARD
public void connect(java.lang.String port) throws java.lang.Exception
connect
in interface PortConnector
java.lang.Exception
public void disconnect() throws java.io.IOException
disconnect
in interface PortConnector
java.io.IOException
public void driveBackwardsMotor1(int speed)
public void driveBackwardsMotor2(int speed)
public void driveForwardMotor1(int speed)
public void driveForwardMotor2(int speed)
public boolean motorDetach(java.lang.String name)
public void motorMove(java.lang.String name)
public void motorMoveTo(java.lang.String name, java.lang.Integer position)
public void sendPacket(int command, int data)
public void setAddress(java.lang.Integer address)
public void setMaxVoltage(int maxVolts)
public void setMinVoltage(int min)
public SerialDevice getSerial()
public void motorMove(MotorControl mc)
MotorController
motorMove
in interface MotorController
mc
- the motor that will be movedpublic void motorMoveTo(MotorControl motor)
MotorController
motorMoveTo
in interface MotorController
motor
- the motor that will be movedpublic void motorStop(MotorControl motor)
MotorController
motorStop
in interface MotorController
motor
- the motor that will be stoppedpublic boolean isConnected()
isConnected
in interface PortConnector
public void motorReset(MotorControl motor)
MotorController
motorReset
in interface MotorController
motor
- the motor that will be resetpublic static ServiceType getMetaData()
public void connect(java.lang.String port, int rate, int databits, int stopbits, int parity) throws java.lang.Exception
connect
in interface PortConnector
java.lang.Exception
public void detach(MotorControl device)
public java.util.List<java.lang.String> getPorts()
MotorController
getPorts
in interface MotorController
public java.util.Set<java.lang.String> getAttached()
Service
getAttached
in interface Attachable
getAttached
in class Service
public void attach(Attachable service) throws java.lang.Exception
attach
in interface Attachable
attach
in class Service
service
- - the service to attach from this servicejava.lang.Exception
- - throws on error and cannot attachpublic boolean isAttached(Attachable service)
Service
isAttached
in interface Attachable
isAttached
in class Service
service
- - referenced service to testpublic void connect(java.lang.String port, int rate) throws java.lang.Exception
connect
in interface PortConnector
java.lang.Exception
public void detach()
Service
detach
in interface Attachable
detach
in class Service
public static void main(java.lang.String[] args)