Class OneWireContainer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected DSPortAdapter adapter
      Reference to the adapter that is needed to communicate with this iButton or 1-Wire device.
      protected byte[] address
      1-Wire Network Address of this iButton or 1-Wire device.
      protected int speed
      Communication speed requested.
      protected boolean speedFallBackOK
      Flag to indicate that falling back to a slower speed then requested is OK.
    • Constructor Summary

      Constructors 
      Constructor Description
      OneWireContainer()
      Create an empty container.
      OneWireContainer​(DSPortAdapter sourceAdapter, byte[] newAddress)
      Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
      OneWireContainer​(DSPortAdapter sourceAdapter, long newAddress)
      Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
      OneWireContainer​(DSPortAdapter sourceAdapter, java.lang.String newAddress)
      Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doSpeed()
      Go to the specified speed for this container.
      boolean equals​(java.lang.Object obj)
      Indicates whether some other object is "equal to" this one.
      DSPortAdapter getAdapter()
      Retrieves the port adapter object used to create this container.
      byte[] getAddress()
      Gets the 1-Wire Network address of this device as an array of bytes.
      long getAddressAsLong()
      Gets this device's 1-Wire Network address as a long.
      java.lang.String getAddressAsString()
      Gets this device's 1-Wire Network address as a String.
      java.lang.String getAlternateNames()
      Retrieves the alternate Maxim Integrated Products part numbers or names.
      java.lang.String getDescription()
      Retrieves a short description of the function of the 1-Wire device type.
      int getMaxSpeed()
      Returns the maximum speed this iButton or 1-Wire device can communicate at.
      java.util.Enumeration<MemoryBank> getMemoryBanks()
      Returns an Enumeration of MemoryBank.
      java.lang.String getName()
      Retrieves the Maxim Integrated Products part number of the 1-Wire device as a String.
      int hashCode()
      Returns a hash code value for the object.
      boolean isAlarming()
      Verifies that the iButton or 1-Wire device is present on the 1-Wire Network and in an alarm state.
      boolean isPresent()
      Verifies that the iButton or 1-Wire device is present on the 1-Wire Network.
      void setSpeed​(int newSpeed, boolean fallBack)
      Sets the maximum speed for this container.
      void setupContainer​(DSPortAdapter sourceAdapter, byte[] newAddress)
      Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
      void setupContainer​(DSPortAdapter sourceAdapter, long newAddress)
      Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
      void setupContainer​(DSPortAdapter sourceAdapter, java.lang.String newAddress)
      Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
      java.lang.String toString()
      Returns a string representation of the object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • adapter

        protected DSPortAdapter adapter
        Reference to the adapter that is needed to communicate with this iButton or 1-Wire device.
      • address

        protected byte[] address
        1-Wire Network Address of this iButton or 1-Wire device. Family code is byte at offset 0.
        See Also:
        Address
      • speed

        protected int speed
        Communication speed requested.
        • 0 (SPEED_REGULAR)
        • 1 (SPEED_FLEX)
        • 2 (SPEED_OVERDRIVE)
        • 3 (SPEED_HYPERDRIVE)
        • >3 future speeds
        See Also:
        DSPortAdapter.setSpeed(int)
      • speedFallBackOK

        protected boolean speedFallBackOK
        Flag to indicate that falling back to a slower speed then requested is OK.
    • Constructor Detail

      • OneWireContainer

        public OneWireContainer​(DSPortAdapter sourceAdapter,
                                byte[] newAddress)
        Create a container with a provided adapter object and the address of the iButton or 1-Wire device.

        This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.

        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton.
        newAddress - address of this 1-Wire device
        See Also:
        OneWireContainer(), Address
      • OneWireContainer

        public OneWireContainer​(DSPortAdapter sourceAdapter,
                                long newAddress)
        Create a container with a provided adapter object and the address of the iButton or 1-Wire device.

        This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.

        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton.
        newAddress - address of this 1-Wire device
        See Also:
        OneWireContainer(), Address
      • OneWireContainer

        public OneWireContainer​(DSPortAdapter sourceAdapter,
                                java.lang.String newAddress)
        Create a container with a provided adapter object and the address of the iButton or 1-Wire device.

        This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.

        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton.
        newAddress - address of this 1-Wire device
        See Also:
        OneWireContainer(), Address
    • Method Detail

      • setupContainer

        public void setupContainer​(DSPortAdapter sourceAdapter,
                                   byte[] newAddress)
        Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton
        newAddress - address of this 1-Wire device
        See Also:
        Address
      • setupContainer

        public void setupContainer​(DSPortAdapter sourceAdapter,
                                   long newAddress)
        Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton
        newAddress - address of this 1-Wire device
        See Also:
        Address
      • setupContainer

        public void setupContainer​(DSPortAdapter sourceAdapter,
                                   java.lang.String newAddress)
        Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
        Parameters:
        sourceAdapter - adapter object required to communicate with this iButton
        newAddress - address of this 1-Wire device
        See Also:
        Address
      • getAdapter

        public DSPortAdapter getAdapter()
        Retrieves the port adapter object used to create this container.
        Returns:
        port adapter instance
      • getName

        public java.lang.String getName()
        Retrieves the Maxim Integrated Products part number of the 1-Wire device as a String. For example 'Crypto iButton' or 'DS1992'.
        Returns:
        1-Wire device name
      • getAlternateNames

        public java.lang.String getAlternateNames()
        Retrieves the alternate Maxim Integrated Products part numbers or names. A 'family' of 1-Wire Network devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.
        Returns:
        1-Wire device alternate names
      • getDescription

        public java.lang.String getDescription()
        Retrieves a short description of the function of the 1-Wire device type.
        Returns:
        device functional description
      • setSpeed

        public void setSpeed​(int newSpeed,
                             boolean fallBack)
        Sets the maximum speed for this container. Note this may be slower then the devices maximum speed. This method can be used by an application to restrict the communication rate due 1-Wire line conditions.

        Parameters:
        newSpeed -
        • 0 (SPEED_REGULAR) set to normal communication speed
        • 1 (SPEED_FLEX) set to flexible communication speed used for long lines
        • 2 (SPEED_OVERDRIVE) set to normal communication speed to overdrive
        • 3 (SPEED_HYPERDRIVE) set to normal communication speed to hyperdrive
        • >3 future speeds
        fallBack - boolean indicating it is OK to fall back to a slower speed if true
      • getMaxSpeed

        public int getMaxSpeed()
        Returns the maximum speed this iButton or 1-Wire device can communicate at. Override this method if derived iButton type can go faster then SPEED_REGULAR(0).
        Returns:
        maximum speed
        See Also:
        DSPortAdapter.setSpeed(int)
      • getAddress

        public byte[] getAddress()
        Gets the 1-Wire Network address of this device as an array of bytes.
        Returns:
        1-Wire address
        See Also:
        Address
      • getAddressAsString

        public java.lang.String getAddressAsString()
        Gets this device's 1-Wire Network address as a String.
        Returns:
        1-Wire address
        See Also:
        Address
      • getAddressAsLong

        public long getAddressAsLong()
        Gets this device's 1-Wire Network address as a long.
        Returns:
        1-Wire address
        See Also:
        Address
      • getMemoryBanks

        public java.util.Enumeration<MemoryBank> getMemoryBanks()
        Returns an Enumeration of MemoryBank. Default is no memory banks.
        Returns:
        enumeration of memory banks to read and write memory on this iButton or 1-Wire device
        See Also:
        MemoryBank
      • isPresent

        public boolean isPresent()
                          throws OneWireIOException,
                                 OneWireException
        Verifies that the iButton or 1-Wire device is present on the 1-Wire Network.
        Returns:
        true if device present on the 1-Wire Network
        Throws:
        OneWireIOException - on a 1-Wire communication error such as a read back verification fails.
        OneWireException - if adapter is not open
      • isAlarming

        public boolean isAlarming()
                           throws OneWireIOException,
                                  OneWireException
        Verifies that the iButton or 1-Wire device is present on the 1-Wire Network and in an alarm state. This does not apply to all device types.
        Returns:
        true if device present and in alarm condition
        Throws:
        OneWireIOException - on a 1-Wire communication error such as a read back verification fails.
        OneWireException - if adapter is not open
      • doSpeed

        public void doSpeed()
                     throws OneWireIOException,
                            OneWireException
        Go to the specified speed for this container. This method uses the containers selected speed (method setSpeed(speed, fallback)) and will optionally fall back to a slower speed if communication failed. Only call this method once to get the device into the desired speed as long as the device is still responding.
        Throws:
        OneWireIOException - WHEN selected speed fails and fallback is false
        OneWireException - WHEN hypterdrive is selected speed
        See Also:
        setSpeed(int,boolean)
      • hashCode

        public int hashCode()
        Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object.
        See Also:
        Hashtable
      • equals

        public boolean equals​(java.lang.Object obj)
        Indicates whether some other object is "equal to" this one.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • toString

        public java.lang.String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the object.