
/*---------------------------------------------------------------------------
 * Copyright (C) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of Dallas Semiconductor
 * shall not be used except as stated in the Dallas Semiconductor
 * Branding Policy.
 *---------------------------------------------------------------------------
 */

package com.dalsemi.onewire.container;

// imports
import com.dalsemi.onewire.OneWireException;
import com.dalsemi.onewire.adapter.OneWireIOException;


/**
 * 1-Wire Switch interface class for basic potentiometer operations.
 * This class should be implemented for each potentiometer type
 * 1-Wire device.
 *
 * Currently there is only the DS2890, but it appears that plans have
 * been made for more complex parts with more wipers, different
 * possible number of wiper positions, etc.
 *
 * @version    0.00, 31 August 2000
 * @author     KLA
 */
public interface PotentiometerContainer
   extends OneWireSensor
{

   /**
    * Query to see if this Potentiometer One Wire Device
    * has linear potentiometer element(s) or logarithmic
    * potentiometer element(s).
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return True if this device has linear potentiometer element(s).
    * False if this device has logarithmic potentiometer element(s).
    */

   //--------
   //-------- Potentiometer Feature methods
   //--------
   public boolean isLinear (byte[] state);

   /**
    * Query to see if this Potentiometer One Wire Device's
    * wiper settings are volatile or non-volatile.
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return True if the wiper settings are volatile.
    * False if the wiper settings are non-volatile.
    */
   public boolean wiperSettingsAreVolatile (byte[] state);

   /**
    * Query to see how many potentiometers this
    * Potentiometer One Wire Device has.
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return The number of potentiometers on this device.
    */
   public int numberOfPotentiometers (byte[] state);

   /**
    * Query to find the number of wiper settings
    * that any wiper on this Potentiometer One Wire
    * Device can have.
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return Number of wiper positions available.
    */
   public int numberOfWiperSettings (byte[] state);

   /**
    * Query to find the resistance value of the potentiometer.
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return The resistance value in k-Ohms.
    */
   public int potentiometerResistance (byte[] state);

   /**
    * Gets the currently selected wiper number.  All wiper actions
    * affect this wiper.  The number of wipers is the same as
    * numberOfPotentiometers().
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return The current wiper number.
    */

   //--------
   //-------- Potentiometer State methods
   //--------
   public int getCurrentWiperNumber (byte[] state);

   /**
    * Sets the currently selected wiper number.  All wiper actions
    * affect this wiper.  The number of wipers is the same as
    * numberOfPotentiometers().
    *
    * @param wiper_number Wiper number to select for communication.
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    */
   public void setCurrentWiperNumber (int wiper_number, byte[] state);

   /**
    * Determines if the Potentiometer's charge pump is enabled.
    *
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return True if it is enabled, false if not.
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public boolean isChargePumpOn (byte[] state);

   /**
    * Set the Potentiometer'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.
    *
    * @param charge_pump_on True if you want to enable the charge pump.
    * @param state State buffer of the Potentiometer One Wire Device (reaturned by readDevice()).
    * @return True if the operation was successful, false if there was an error.
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public void setChargePump (boolean charge_pump_on, byte[] state);

   //--------
   //-------- Potentiometer Wiper access methods
   //--------

   /**
    * Get the current wiper position of the Potentiometer.  The wiper position
    * is between 0 and numberOfWiperPositions(), and describes the voltage output.
    *
    * @return The wiper position between 0 and numberOfWiperPositions().
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public int getWiperPosition ()
      throws OneWireIOException, OneWireException;

   /**
    * Set the wiper position for the potentiometer.
    *
    * @param position The position to set the wiper.
    * @return True if the operation was successful, false otherwise.
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public boolean setWiperPosition (int position)
      throws OneWireIOException, OneWireException;

   /**
    * Increments the wiper position.
    *
    * @param 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)
    * @return The new position of the wiper (0-numberOfWiperPositions()).
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public int increment (boolean reselect)
      throws OneWireIOException, OneWireException;

   /**
    * Decrements the wiper position.
    *
    * @param 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)
    * @return The new position of the wiper (0-numberOfWiperPositions()).
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public int decrement (boolean reselect)
      throws OneWireIOException, OneWireException;

   /**
    * Increments the wiper position after selecting the part.
    *
    * @return The new position of the wiper (0-numberOfWiperPositions()).
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public int increment ()
      throws OneWireIOException, OneWireException;

   /**
    * Decrements the wiper position after selecting the part.
    *
    * @return The new position of the wiper (0-numberOfWiperPositions()).
    * @exception com.dalsemi.onewire.adapter.OneWireIOException
    * @exception com.dalsemi.onewire.OneWireException
    */
   public int decrement ()
      throws OneWireIOException, OneWireException;
}
