public class UltrasonicSensor extends Service implements RangeListener, RangePublisher, UltrasonicSensorControl
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
log |
java.util.Set<java.lang.String> |
types |
cfgDir, dnaPool, MESSAGE_RECORDING_FORMAT_BINARY, MESSAGE_RECORDING_FORMAT_XML
Constructor and Description |
---|
UltrasonicSensor(java.lang.String n) |
Modifier and Type | Method and Description |
---|---|
void |
addRangeListener(Service service) |
void |
attach(java.lang.String port,
int trigPin,
int echoPin) |
void |
attach(UltrasonicSensorController controller,
java.lang.Integer trigPin,
java.lang.Integer echoPin) |
static int |
byteArrayToInt(int[] b) |
void |
detach(java.lang.String controllerName)
Attachable.detach(serviceName) - routes to reference parameter
Attachable.detach(Attachable)
|
java.util.Set<java.lang.String> |
getAttached()
returns all currently attached services
|
UltrasonicSensorController |
getController() |
int |
getEchoPin() |
static ServiceType |
getMetaData()
This static method returns all the details of the class without it having
to be constructed.
|
int |
getPings() |
int |
getTriggerPin() |
java.lang.String |
getType() |
boolean |
isAttached(java.lang.String name)
returns if the Attachable has been set or not - name interface
|
static void |
main(java.lang.String[] args) |
void |
onRange(java.lang.Double range) |
java.lang.Double |
onUltrasonicSensorData(java.lang.Double rawMs) |
java.lang.Double |
ping() |
java.lang.Double |
publishRange(java.lang.Double range) |
java.lang.Double |
range() |
boolean |
setType(java.lang.String type) |
void |
setUnitCm() |
void |
setUnitInches() |
void |
startRanging() |
void |
stopRanging() |
addListener, addListener, addTask, addTask, addTask, addTaskOneShot, allowDisplay, allowDisplay, attach, 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, 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, attach, detach, detach, isAttached, isLocal
getName
public static final org.slf4j.Logger log
public final java.util.Set<java.lang.String> types
public void addRangeListener(Service service)
public void attach(java.lang.String port, int trigPin, int echoPin) throws java.lang.Exception
java.lang.Exception
public void attach(UltrasonicSensorController controller, java.lang.Integer trigPin, java.lang.Integer echoPin) throws java.lang.Exception
attach
in interface UltrasonicSensorControl
java.lang.Exception
public UltrasonicSensorController getController()
public int getEchoPin()
public int getTriggerPin()
public void onRange(java.lang.Double range)
onRange
in interface RangeListener
public java.lang.Double publishRange(java.lang.Double range)
publishRange
in interface RangePublisher
public boolean setType(java.lang.String type)
public void startRanging()
startRanging
in interface RangingControl
public void stopRanging()
stopRanging
in interface RangingControl
public java.lang.Double range()
public java.lang.Double ping()
public static int byteArrayToInt(int[] b)
public static ServiceType getMetaData()
public int getPings()
public java.lang.String getType()
getType
in interface ServiceInterface
getType
in class Service
public void detach(java.lang.String controllerName)
Service
detach
in interface Attachable
detach
in class Service
controllerName
- - name of servicepublic java.lang.Double onUltrasonicSensorData(java.lang.Double rawMs)
onUltrasonicSensorData
in interface UltrasonicSensorControl
public void setUnitCm()
setUnitCm
in interface RangingControl
public void setUnitInches()
setUnitInches
in interface RangingControl
public boolean isAttached(java.lang.String name)
Attachable
isAttached
in interface Attachable
isAttached
in class Service
name
- - name of servicepublic java.util.Set<java.lang.String> getAttached()
Service
getAttached
in interface Attachable
getAttached
in class Service
public static void main(java.lang.String[] args)