
/*---------------------------------------------------------------------------
 * 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.utils;

import com.dalsemi.onewire.container.OneWireContainer;
import com.dalsemi.onewire.utils.OWPath;
import com.dalsemi.onewire.adapter.DSPortAdapter;


/**
 * 1-Wire Network Device State.  Used for keeping the state of devices
 * on the network in the NetworkMonitor.
 *
 * @version    0.00, 12 September 2000
 * @author     DS
 */
class NetworkDeviceState
{

   //--------
   //-------- Static Final Variables
   //--------

   /** Number of times device not seen before removed */
   public static final int MAX_COUNT = 3;

   //--------
   //-------- Variables
   //--------

   /** Current path of device */
   private OWPath path;

   /** Current debound cound of device */
   private int count;

   //--------
   //-------- Constructor
   //--------

   /**
    * Creates a device state with the adapter and path
    *
    * @param adapter the DSPortAdapter that the device is on
    * @param startOWPath OWPath that the device is on
    */
   public NetworkDeviceState (DSPortAdapter adapter, OWPath startOWPath)
   {
      path  = new OWPath(adapter, startOWPath);
      count = MAX_COUNT;
   }

   /**
    * Retrieve the path
    *
    * @return the OWPath that the device is on
    */
   public OWPath getOWPath ()
   {
      return path;
   }

   /**
    * Retrieve the current count
    *
    * @return the current debounce count
    */
   public int getCount ()
   {
      return count;
   }

   /**
    * Set the current debounce count
    *
    * @param newCount set the debounce count to this value
    */
   public void setCount (int newCount)
   {
      count = newCount;
   }
}
