|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.application.monitor.AbstractDeviceMonitor
Abstract super-class for 1-Wire Monitors, a optionally-threadable object for searching 1-Wire networks. If this object is not run in it's own thread, it is possible to perform single-step searches by calling the search method directly {@see #search(Vector, Vector)}. The monitor will generate events for device arrivals, device departures, and exceptions from the DSPortAdapter.
In a touch-contact environment, it is not suitable to say that a device has "departed" because it was missing for one cycle of searching. In the time it takes to get an iButton into a blue-dot receptor, the monitor could have generated a handful of arrival and departure events. To circumvent this problem, the device monitor keeps a "missing state count" for each device on the network. Each search cycle that passes where the device is missing causes it's "missing state count" to be incremented. Once the device's "missing state count" is equal to the "max state count" {@see #getMaxStateCount()}, a departure event is generated for the device. If the 1-Wire Network is not in a touch environment, it may be unnecessary to use this "missing state count". In those instances, setting the state count to 1 will disable the feature {@see #setMaxStateCount(int)}.
Similarly, the reporting of exceptions could be spurious in a touch-contact environment. Instead of reporting the exception on each failed search attempt, the monitor will default to retrying the search a handful of times {@see #getMaxErrorCount()} before finally reporting the exception. To disable this feature, set the max error count to 1 {@see #setMaxErrorCount(int)}.
To receive events, an object must implement the
DeviceMonitorEventListener
interface
{@see DeviceMonitorEventListener} and must be added to
the list of listeners {@see #addDeviceMonitorEventListener}.
Constructor Summary | |
AbstractDeviceMonitor()
|
Method Summary | |
void |
addDeviceMonitorEventListener(DeviceMonitorEventListener dmel)
Add a listener, to be notified of arrivals, departures, and exceptions. |
void |
cleanUpStaleContainerReferences()
The device monitor will internally cache OneWireContainer objects for each 1-Wire device. |
void |
cleanUpStalePathReferences()
The device monitor will internally cache OWPath objects for each 1-Wire device. |
DSPortAdapter |
getAdapter()
Returns the DSPortAdapter this device is searching |
Enumeration |
getAllAddresses()
Returns all addresses known by this monitor as an Enumeration of Long objects. |
static OneWireContainer |
getDeviceContainer(DSPortAdapter adapter,
byte[] address)
Returns the OneWireContainer object of the device with the given address. |
static OneWireContainer |
getDeviceContainer(DSPortAdapter adapter,
long address)
Returns the OneWireContainer object of the device with the given address. |
static OneWireContainer |
getDeviceContainer(DSPortAdapter adapter,
Long longAddress)
Returns the OneWireContainer object of the device with the given address. |
static OneWireContainer |
getDeviceContainer(DSPortAdapter adapter,
String address)
Returns the OneWireContainer object of the device with the given address. |
OWPath |
getDevicePath(byte[] address)
Returns the OWPath of the device with the given address. |
OWPath |
getDevicePath(long address)
Returns the OWPath of the device with the given address. |
abstract OWPath |
getDevicePath(Long address)
Returns the OWPath of the device with the given address. |
OWPath |
getDevicePath(String address)
Returns the OWPath of the device with the given address. |
int |
getMaxErrorCount()
Number of searches that an error occurs before listener's are notified |
int |
getMaxStateCount()
The number of searches that a button should be "missing" before it is removed. |
boolean |
isMonitorRunning()
Check if this monitor is running. |
void |
killMonitor()
Kill this monitor. |
boolean |
pauseMonitor(boolean blocking)
Pause this monitor |
static void |
putDeviceContainer(byte[] address,
OneWireContainer owc)
Sets the OneWireContainer object of the device with the given address. |
static void |
putDeviceContainer(long address,
OneWireContainer owc)
Sets the OneWireContainer object of the device with the given address. |
static void |
putDeviceContainer(Long longAddress,
OneWireContainer owc)
Sets the OneWireContainer object of the device with the given address. |
static void |
putDeviceContainer(String address,
OneWireContainer owc)
Sets the OneWireContainer object of the device with the given address. |
void |
resetSearch()
Resets this device monitor. |
boolean |
resumeMonitor(boolean blocking)
Resume this monitor |
void |
run()
Monitor run method that performs a periodic search of the entire 1-Wire network. |
abstract void |
search(Vector arrivals,
Vector departures)
Performs a search of the 1-Wire network |
abstract void |
setAdapter(DSPortAdapter adapter)
Sets this monitor to search a new DSPortAdapter |
void |
setMaxErrorCount(int errorCnt)
Number of searches that an error occurs before listener's are notified |
void |
setMaxStateCount(int stateCnt)
The number of searches that a button should be "missing" before it is removed |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractDeviceMonitor()
Method Detail |
public void cleanUpStaleContainerReferences()
public void cleanUpStalePathReferences()
public void resetSearch()
public int getMaxStateCount()
public void setMaxStateCount(int stateCnt)
stateCnt
- The number of searches that a button should be "missing"
before it is removed.public int getMaxErrorCount()
public void setMaxErrorCount(int errorCnt)
errorCnt
- Number of searches that an error occurs before listener's
are notifiedpublic DSPortAdapter getAdapter()
the
- DSPortAdapter this monitor is searchingpublic abstract void setAdapter(DSPortAdapter adapter)
the
- DSPortAdapter this monitor should searchpublic abstract void search(Vector arrivals, Vector departures) throws OneWireException, OneWireIOException
arrivals
- A vector of Long objects, represent new arrival addresses.departures
- A vector of Long objects, represent departed addresses.public boolean pauseMonitor(boolean blocking)
blocking
- if true, this method will block until the monitor is paused.public boolean resumeMonitor(boolean blocking)
blocking
- if true, this method will block until the monitor is resumed.public boolean isMonitorRunning()
true
if monitor is runningpublic void killMonitor()
public void run()
run
in interface Runnable
public void addDeviceMonitorEventListener(DeviceMonitorEventListener dmel)
dmel
- Listener of monitor events.public OWPath getDevicePath(byte[] address)
address
- a byte array representing the address of the devicepublic OWPath getDevicePath(String address)
address
- a string representing the address of the devicepublic OWPath getDevicePath(long address)
address
- a long representing the address of the devicepublic abstract OWPath getDevicePath(Long address)
address
- a Long object representing the address of the devicepublic Enumeration getAllAddresses()
public static OneWireContainer getDeviceContainer(DSPortAdapter adapter, byte[] address)
adapter
- The DSPortAdapter that the device is connected to.address
- a byte array representing the address of the devicepublic static OneWireContainer getDeviceContainer(DSPortAdapter adapter, String address)
adapter
- The DSPortAdapter that the device is connected to.address
- a String representing the address of the devicepublic static OneWireContainer getDeviceContainer(DSPortAdapter adapter, long address)
adapter
- The DSPortAdapter that the device is connected to.address
- a long representing the address of the devicepublic static OneWireContainer getDeviceContainer(DSPortAdapter adapter, Long longAddress)
adapter
- The DSPortAdapter that the device is connected to.address
- a Long object representing the address of the devicepublic static void putDeviceContainer(byte[] address, OneWireContainer owc)
address
- a byte array object representing the address of the deviceowc
- The specific OneWireContainer object of the devicepublic static void putDeviceContainer(String address, OneWireContainer owc)
address
- a String object representing the address of the deviceowc
- The specific OneWireContainer object of the devicepublic static void putDeviceContainer(long address, OneWireContainer owc)
address
- a long object representing the address of the deviceowc
- The specific OneWireContainer object of the devicepublic static void putDeviceContainer(Long longAddress, OneWireContainer owc)
address
- a Long object representing the address of the deviceowc
- The specific OneWireContainer object of the device
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |