Class NetworkDeviceMonitor
java.lang.Object
com.dalsemi.onewire.application.monitor.AbstractDeviceMonitor
com.dalsemi.onewire.application.monitor.NetworkDeviceMonitor
- All Implemented Interfaces:
Runnable
Class NetworkDeviceMonitor represents the monitor that searches the 1-Wire
net, including the traversal of branches, looing for new arrivals and
departures.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
indicates whether or not branches are automatically traversedhashtable for holding the OWPath objects for each device container.A vector of paths, or branches, to searchFields inherited from class com.dalsemi.onewire.application.monitor.AbstractDeviceMonitor
adapter, deviceAddressHash, deviceContainerHash, hasCompletelyStopped, isRunning, keepRunning, listeners, max_error_count, max_state_count, startRunning, sync_flag
-
Constructor Summary
ConstructorDescriptionNetworkDeviceMonitor
(DSPortAdapter adapter) Create a complex monitor that does search branches -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a branch for searching.void
The device monitor will internally cache OWPath objects for each 1-Wire device.boolean
Indicates whether or not branches are automatically traversed.getDevicePath
(Long address) Returns the OWPath of the device with the given address.void
Performs a search of the 1-Wire network, with branch searchingvoid
setAdapter
(DSPortAdapter adapter) Sets this monitor to search a new DSPortAdaptervoid
setBranchAutoSearching
(boolean enabled) Indicates whether or not branches are automatically traversed.Methods inherited from class com.dalsemi.onewire.application.monitor.AbstractDeviceMonitor
addDeviceMonitorEventListener, cleanUpStaleContainerReferences, fireArrivalEvent, fireDepartureEvent, getAdapter, getAllAddresses, getDeviceContainer, getDeviceContainer, getDeviceContainer, getDeviceContainer, getDevicePath, getDevicePath, getDevicePath, getMaxErrorCount, getMaxStateCount, isMonitorRunning, killMonitor, msSleep, pauseMonitor, putDeviceContainer, putDeviceContainer, putDeviceContainer, putDeviceContainer, resetSearch, resumeMonitor, run, setMaxErrorCount, setMaxStateCount
-
Field Details
-
devicePathHash
hashtable for holding the OWPath objects for each device container. -
paths
A vector of paths, or branches, to search -
branchAutoSearching
protected boolean branchAutoSearchingindicates whether or not branches are automatically traversed
-
-
Constructor Details
-
NetworkDeviceMonitor
Create a complex monitor that does search branches- Parameters:
adapter
- the DSPortAdapter this monitor should search
-
-
Method Details
-
setAdapter
Sets this monitor to search a new DSPortAdapter- Specified by:
setAdapter
in classAbstractDeviceMonitor
- Parameters:
adapter
- the DSPortAdapter this monitor should search
-
setBranchAutoSearching
public void setBranchAutoSearching(boolean enabled) Indicates whether or not branches are automatically traversed. If false, new branches must be indicated using the "addBranch" method.- Parameters:
enabled
- if true, all branches are automatically traversed during a search operation.
-
getBranchAutoSearching
public boolean getBranchAutoSearching()Indicates whether or not branches are automatically traversed. If false, new branches must be indicated using the "addBranch" method.- Returns:
- true if all branches are automatically traversed during a search operation.
-
addBranch
Adds a branch for searching. Must be used to traverse branches if auto-searching is disabled.- Parameters:
path
- A branch to be searched during the next search routine
-
getDevicePath
Returns the OWPath of the device with the given address.- Specified by:
getDevicePath
in classAbstractDeviceMonitor
- Parameters:
address
- a Long object representing the address of the device- Returns:
- The OWPath representing the network path to the device.
-
cleanUpStalePathReferences
public void cleanUpStalePathReferences()The device monitor will internally cache OWPath objects for each 1-Wire device. Use this method to clean up all stale OWPath objects. A stale path object is a OWPath which references a branching path to a 1-Wire device address which has not been seen by a recent search. This will be essential in a touch-contact environment which could run for some time and needs to conserve memory.- Overrides:
cleanUpStalePathReferences
in classAbstractDeviceMonitor
-
search
public void search(Vector<Long> arrivals, Vector<Long> departures) throws OneWireException, OneWireIOException Performs a search of the 1-Wire network, with branch searching- Specified by:
search
in classAbstractDeviceMonitor
- Parameters:
arrivals
- A vector of Long objects, represent new arrival addresses.departures
- A vector of Long objects, represent departed addresses.- Throws:
OneWireException
OneWireIOException
-