Class OWPath


  • public class OWPath
    extends java.lang.Object
    1-Wire® Network path. Large 1-Wire networks can be sub-divided into branches for load, location, or organizational reasons. Once 1-Wire devices are placed on this branches there needs to be a mechanism to reach these devices. The OWPath class was designed to provide a convenient method to open and close 1-Wire paths to reach remote devices.

    Usage

    Example

    Open the path 'path' to the 1-Wire temperature device 'tc' and read the temperature:
      
      // open a path to the temp device
      path.open();
    
      // read the temp device
      byte[] state = tc.readDevice();
      tc.doTemperatureConvert(state);
      state = tc.readDevice();
      System.out.println("Temperature of " +
               address + " is " +
               tc.getTemperature(state) + " C");
    
      // close the path to the device
      path.close();
     
     
    See Also:
    OWPathElement, SwitchContainer, OneWireContainer05, OneWireContainer12, OneWireContainer1F
    • Constructor Summary

      Constructors 
      Constructor Description
      OWPath​(DSPortAdapter adapter)
      Create a new 1-Wire path with no elements.
      OWPath​(DSPortAdapter adapter, OWPath currentOWPath)
      Create a new path with a starting path.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(OneWireContainer owc, int channel)
      Add a 1-Wire path element to this 1-Wire path.
      void close()
      Close each element in this 1-Wire path in reverse order.
      void copy​(OWPath currentOWPath)
      Copy the elements from the provided 1-Wire path into this 1-Wire path.
      boolean equals​(OWPath compareOWPath)
      Compare this 1-Wire path with another.
      java.util.Enumeration<OWPathElement> getAllOWPathElements()
      Get an enumeration of all of the 1-Wire path elements in this 1-Wire path.
      void open()
      Open this 1-Wire path so that a remote device can be accessed.
      java.lang.String toString()
      Get a string representation of this 1-Wire path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • OWPath

        public OWPath​(DSPortAdapter adapter)
        Create a new 1-Wire path with no elements. Elements can be added by using copy and/or add .
        Parameters:
        adapter - where the path is based
        See Also:
        copy, add
      • OWPath

        public OWPath​(DSPortAdapter adapter,
                      OWPath currentOWPath)
        Create a new path with a starting path. New elements can be added with add.
        Parameters:
        adapter - where the 1-Wire path is based
        currentPath - starting value of this 1-Wire path
        See Also:
        add
    • Method Detail

      • copy

        public void copy​(OWPath currentOWPath)
        Copy the elements from the provided 1-Wire path into this 1-Wire path.
        Parameters:
        currentOWPath - path to copy from
      • add

        public void add​(OneWireContainer owc,
                        int channel)
        Add a 1-Wire path element to this 1-Wire path.
        Parameters:
        owc - 1-Wire device switch
        channel - of device that represents this 1-Wire path element
        See Also:
        copy
      • equals

        public boolean equals​(OWPath compareOWPath)
        Compare this 1-Wire path with another.
        Parameters:
        compareOWPath - 1-Wire path to compare to
        Returns:
        true if the 1-Wire paths are the same
      • getAllOWPathElements

        public java.util.Enumeration<OWPathElement> getAllOWPathElements()
        Get an enumeration of all of the 1-Wire path elements in this 1-Wire path.
        Returns:
        enumeration of all of the 1-Wire path elements
        See Also:
        OWPathElement
      • toString

        public java.lang.String toString()
        Get a string representation of this 1-Wire path.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string 1-Wire path as string
      • open

        public void open()
                  throws OneWireException,
                         OneWireIOException
        Open this 1-Wire path so that a remote device can be accessed.
        Throws:
        OneWireIOException - on a 1-Wire communication error such as no device present or a CRC read from the device is incorrect. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
        OneWireException - on a communication or setup error with the 1-Wire adapter.
      • close

        public void close()
                   throws OneWireException,
                          OneWireIOException
        Close each element in this 1-Wire path in reverse order.
        Throws:
        OneWireIOException - on a 1-Wire communication error such as no device present or a CRC read from the device is incorrect. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
        OneWireException - on a communication or setup error with the 1-Wire adapter.