com.dalsemi.onewire.container
Class OneWireContainer2C

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer2C
All Implemented Interfaces:
OneWireSensor, PotentiometerContainer

public class OneWireContainer2C
extends OneWireContainer
implements PotentiometerContainer

iButton container for iButton family type 2C (hex). This family type is a 'digital potentiometer' (DS2890).

Version:
0.00, 28 Aug 2000

Field Summary
static byte DECREMENT
          Useful constant for one wire communications.
static byte INCREMENT
          Useful constant for one wire communications.
static byte READ_CONTROL
          Useful constant for one wire communications.
static byte READ_POSITION
          Useful constant for one wire communications.
static byte WRITE_CONTROL
          Useful constant for one wire communications.
static byte WRITE_POSITION
          Useful constant for one wire communications.
 
Constructor Summary
OneWireContainer2C()
          Default constructor
OneWireContainer2C(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer2C(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer2C(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
 int decrement()
          Decrements the wiper position after selecting the part.
 int decrement(boolean reselect)
          Decrements the wiper position.
 java.lang.String getAlternateNames()
          Retrieve the alternate Dallas Semiconductor part numbers or names.
 int getCurrentWiperNumber(byte[] state)
          Gets the currently selected wiper number.
 java.lang.String getDescription()
          Retrieve a short description of the function of the iButton type.
 int getMaxSpeed()
          Returns the maximum speed this iButton or 1-Wire device can communicate at.
 java.lang.String getName()
          Retrieve the Dallas Semiconductor part number of the iButton as a string.
 int getWiperPosition()
          Get the current wiper position of the 2890.
 int increment()
          Increments the wiper position after selecting the part.
 int increment(boolean reselect)
          Increments the wiper position.
 boolean isChargePumpOn(byte[] state)
          Determines if the 2890's charge pump is enabled.
 boolean isLinear(byte[] state)
          Query to see if this Potentiometer One Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).
 int numberOfPotentiometers(byte[] state)
          Query to see how many potentiometers this Potentiometer One Wire Device has.
 int numberOfWiperSettings(byte[] state)
          Query to find the number of wiper settings that any wiper on this Potentiometer One Wire Device can have.
 int potentiometerResistance(byte[] state)
          Query to find the resistance value of the potentiometer.
 byte[] readDevice()
          This method retrieves the 1-Wire device sensor state.
 void setChargePump(boolean charge_pump_on, byte[] state)
          Set the 2890's charge pump.
 void setCurrentWiperNumber(int wiper_number, byte[] state)
          Sets the currently selected wiper number.
 boolean setWiperPosition(int position)
          Set the wiper position for the potentiometer.
 boolean wiperSettingsAreVolatile(byte[] state)
          Query to see if this Potentiometer One Wire Device's wiper settings are volatile or non-volatile.
 void writeDevice(byte[] state)
          This method write the 1-Wire device sensor state that have been changed by the 'set' methods.
 
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRITE_CONTROL

public static final byte WRITE_CONTROL
Useful constant for one wire communications.

READ_CONTROL

public static final byte READ_CONTROL
Useful constant for one wire communications.

WRITE_POSITION

public static final byte WRITE_POSITION
Useful constant for one wire communications.

READ_POSITION

public static final byte READ_POSITION
Useful constant for one wire communications.

INCREMENT

public static final byte INCREMENT
Useful constant for one wire communications.

DECREMENT

public static final byte DECREMENT
Useful constant for one wire communications.
Constructor Detail

OneWireContainer2C

public OneWireContainer2C()
Default constructor

OneWireContainer2C

public OneWireContainer2C(DSPortAdapter sourceAdapter,
                          byte[] newAddress)
Create a container with a provided adapter object 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

OneWireContainer2C

public OneWireContainer2C(DSPortAdapter sourceAdapter,
                          long newAddress)
Create a container with a provided adapter object 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

OneWireContainer2C

public OneWireContainer2C(DSPortAdapter sourceAdapter,
                          java.lang.String newAddress)
Create a container with a provided adapter object 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
Method Detail

getName

public java.lang.String getName()
Retrieve the Dallas Semiconductor part number of the iButton as a string. For example 'DS1992'.
Overrides:
getName in class OneWireContainer
Returns:
String representation of the iButton name.

getAlternateNames

public java.lang.String getAlternateNames()
Retrieve the alternate Dallas Semiconductor part numbers or names. A 'family' of MicroLan devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.
Overrides:
getAlternateNames in class OneWireContainer
Returns:
String representation of the alternate names.

getDescription

public java.lang.String getDescription()
Retrieve a short description of the function of the iButton type.
Overrides:
getDescription in class OneWireContainer
Returns:
String representation of the function description.

getMaxSpeed

public int getMaxSpeed()
Returns the maximum speed this iButton or 1-Wire device can communicate at.
Overrides:
getMaxSpeed in class OneWireContainer

isLinear

public boolean isLinear(byte[] state)
Query to see if this Potentiometer One Wire Device has linear potentiometer element(s) or logarithmic potentiometer element(s).
Specified by:
isLinear in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
True if this device has linear potentiometer element(s). False if this device has logarithmic potentiometer element(s).

wiperSettingsAreVolatile

public boolean wiperSettingsAreVolatile(byte[] state)
Query to see if this Potentiometer One Wire Device's wiper settings are volatile or non-volatile.
Specified by:
wiperSettingsAreVolatile in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
True if the wiper settings are volatile. False if the wiper settings are non-volatile.

numberOfPotentiometers

public int numberOfPotentiometers(byte[] state)
Query to see how many potentiometers this Potentiometer One Wire Device has.
Specified by:
numberOfPotentiometers in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
The number of potentiometers on this device.

numberOfWiperSettings

public int numberOfWiperSettings(byte[] state)
Query to find the number of wiper settings that any wiper on this Potentiometer One Wire Device can have.
Specified by:
numberOfWiperSettings in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
Number of wiper positions available.

potentiometerResistance

public int potentiometerResistance(byte[] state)
Query to find the resistance value of the potentiometer.
Specified by:
potentiometerResistance in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
The resistance value in k-Ohms.

getCurrentWiperNumber

public int getCurrentWiperNumber(byte[] state)
Gets the currently selected wiper number. All wiper actions affect this wiper. The number of wipers is the same as numberOfPotentiometers().
Specified by:
getCurrentWiperNumber in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
The current wiper number.

setCurrentWiperNumber

public void setCurrentWiperNumber(int wiper_number,
                                  byte[] state)
Sets the currently selected wiper number. All wiper actions affect this wiper. The number of wipers is the same as numberOfPotentiometers().
Specified by:
setCurrentWiperNumber in interface PotentiometerContainer
Parameters:
wiper_number - Wiper number to select for communication. Valid choices are 0 to 3.
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).

isChargePumpOn

public boolean isChargePumpOn(byte[] state)
Determines if the 2890's charge pump is enabled.
Specified by:
isChargePumpOn in interface PotentiometerContainer
Parameters:
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
True if it is enabled, false if not.

setChargePump

public void setChargePump(boolean charge_pump_on,
                          byte[] state)
Set the 2890's charge pump. This decreases the wiper's resistance, but increases the power consumption by the part. Vdd must be connected to use the charge pump (see the DS2890 datasheet for more information at www.dalsemi.com)
Specified by:
setChargePump in interface PotentiometerContainer
Parameters:
charge_pump_on - True if you want to enable the charge pump.
state - State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
Returns:
True if the operation was successful, false if there was an error.

getWiperPosition

public int getWiperPosition()
                     throws OneWireIOException,
                            OneWireException
Get the current wiper position of the 2890. The wiper position is between 0 and 255, and describes the voltage output. The output lies between RH and RL.
Specified by:
getWiperPosition in interface PotentiometerContainer
Returns:
The wiper position between 0 and 255.
Throws:
OneWireIOException -  
OneWireException -  

setWiperPosition

public boolean setWiperPosition(int position)
                         throws OneWireIOException,
                                OneWireException
Set the wiper position for the potentiometer.
Specified by:
setWiperPosition in interface PotentiometerContainer
Parameters:
position - The position to set the wiper. This value will be cast to a byte, only the 8 least significant bits matter.
Returns:
True if the operation was successful, false otherwise.
Throws:
OneWireIOException -  
OneWireException -  

increment

public int increment(boolean reselect)
              throws OneWireIOException,
                     OneWireException
Increments the wiper position.
Specified by:
increment in interface PotentiometerContainer
Parameters:
reselect - Increment/Decrement can be called without resetting the part if the last call was an Increment/Decrement. True if you want to select the part (you must call with true after any other one-wire method)
Returns:
The new position of the wiper (0-255).
Throws:
OneWireIOException -  
OneWireException -  

decrement

public int decrement(boolean reselect)
              throws OneWireIOException,
                     OneWireException
Decrements the wiper position.
Specified by:
decrement in interface PotentiometerContainer
Parameters:
reselect - Increment/Decrement can be called without resetting the part if the last call was an Increment/Decrement. True if you want to select the part (you must call with true after any other one-wire method)
Returns:
The new position of the wiper (0-255).
Throws:
OneWireIOException -  
OneWireException -  

increment

public int increment()
              throws OneWireIOException,
                     OneWireException
Increments the wiper position after selecting the part.
Specified by:
increment in interface PotentiometerContainer
Returns:
The new position of the wiper (0-255).
Throws:
OneWireIOException -  
OneWireException -  

decrement

public int decrement()
              throws OneWireIOException,
                     OneWireException
Decrements the wiper position after selecting the part.
Specified by:
decrement in interface PotentiometerContainer
Returns:
The new position of the wiper (0-255).
Throws:
OneWireIOException -  
OneWireException -  

readDevice

public byte[] readDevice()
                  throws OneWireIOException,
                         OneWireException
This method retrieves the 1-Wire device sensor state. This state is returned as a byte array. Pass this byte array to the static query and set methods. If the device state needs to be changed then call the 'writeDevice' to finalize the one or more change.
Specified by:
readDevice in interface OneWireSensor
Returns:
byte[]<\code> 1-Wire device sensor state *
Throws:
OneWireIOException -  
OneWireException -  

writeDevice

public void writeDevice(byte[] state)
                 throws OneWireIOException,
                        OneWireException
This method write the 1-Wire device sensor state that have been changed by the 'set' methods. It knows which registers have changed by looking at the bitmap fields appended to the state data.
Specified by:
writeDevice in interface OneWireSensor
Parameters:
state - - byte array of clock register page contents
Throws:
OneWireIOException -  
OneWireException -