Class NetworkDeviceMonitor

  • All Implemented Interfaces:
    java.lang.Runnable

    public class NetworkDeviceMonitor
    extends AbstractDeviceMonitor
    Class NetworkDeviceMonitor represents the monitor that searches the 1-Wire net, including the traversal of branches, looing for new arrivals and departures.
    • Field Detail

      • devicePathHash

        protected final java.util.Hashtable<java.lang.Long,​OWPath> devicePathHash
        hashtable for holding the OWPath objects for each device container.
      • paths

        protected java.util.Vector<OWPath> paths
        A vector of paths, or branches, to search
      • branchAutoSearching

        protected boolean branchAutoSearching
        indicates whether or not branches are automatically traversed
    • Constructor Detail

      • NetworkDeviceMonitor

        public NetworkDeviceMonitor​(DSPortAdapter adapter)
        Create a complex monitor that does search branches
        Parameters:
        adapter - the DSPortAdapter this monitor should search
    • Method Detail

      • setAdapter

        public void setAdapter​(DSPortAdapter adapter)
        Sets this monitor to search a new DSPortAdapter
        Specified by:
        setAdapter in class AbstractDeviceMonitor
        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

        public void addBranch​(OWPath path)
        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

        public OWPath getDevicePath​(java.lang.Long address)
        Returns the OWPath of the device with the given address.
        Specified by:
        getDevicePath in class AbstractDeviceMonitor
        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 class AbstractDeviceMonitor
      • search

        public void search​(java.util.Vector<java.lang.Long> arrivals,
                           java.util.Vector<java.lang.Long> departures)
                    throws OneWireException,
                           OneWireIOException
        Performs a search of the 1-Wire network, with branch searching
        Specified by:
        search in class AbstractDeviceMonitor
        Parameters:
        arrivals - A vector of Long objects, represent new arrival addresses.
        departures - A vector of Long objects, represent departed addresses.
        Throws:
        OneWireException
        OneWireIOException