⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onewirecontainer28.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*--------------------------------------------------------------------------- * 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;// importsimport com.dalsemi.onewire.*;import com.dalsemi.onewire.utils.*;import com.dalsemi.onewire.adapter.*;//----------------------------------------------------------------------------/** * <P> 1-Wire container for temperature iButton which measures temperatures * from -55&#176C to +125&#176C, DS18B20.  This container encapsulates the * functionality of the iButton family type <B>28</B> (hex)</P> * * <H3> Features </H3> * <UL> *   <LI> Measures temperatures from -55&#176C to +125&#176C. Fahrenheit *        equivalent is -67&#176F to +257&#176F *   <LI> Power supply range is 3.0V to 5.5V *   <LI> Zero standby power *   <LI> +/- 0.5&#176C accuracy from -10&#176C to +85&#176C *   <LI> Thermometer resolution programmable from 9 to 12 bits *   <LI> Converts 12-bit temperature to digital word in 750 ms (max.) *   <LI> User-definable, nonvolatile temperature alarm settings *   <LI> Alarm search command identifies and addresses devices whose temperature is *        outside of programmed limits (temperature alarm condition) * </UL> * * <H3> Usage </H3> * * <DL> * <DD> See the usage example in * {@link com.dalsemi.onewire.container.TemperatureContainer TemperatureContainer} * for temperature specific operations. * </DL> * * <H3> DataSheet </H3> * <DL> * <DD><A HREF="http://pdfserv.maxim-ic.com/arpdf/DS18B20.pdf"> http://pdfserv.maxim-ic.com/arpdf/DS18B20.pdf</A> * </DL> * * @see com.dalsemi.onewire.container.TemperatureContainer * * @version    1.00, 15 September 2000 * @author     BH */public class OneWireContainer28   extends OneWireContainer   implements TemperatureContainer{   //-------------------------------------------------------------------------   //-------- Static Final Variables   //-------------------------------------------------------------------------   /** DS18B20 writes data to scratchpad command */   public static final byte WRITE_SCRATCHPAD_COMMAND = ( byte ) 0x4E;   /** DS18B20 reads data from scratchpad command */   public static final byte READ_SCRATCHPAD_COMMAND = ( byte ) 0xBE;   /** DS18B20 copys data from scratchpad to E-squared memory command */   public static final byte COPY_SCRATCHPAD_COMMAND = ( byte ) 0x48;   /** DS18B20 converts temperature command */   public static final byte CONVERT_TEMPERATURE_COMMAND = ( byte ) 0x44;   /** DS18B20 recalls E-squared memory command */   public static final byte RECALL_E2MEMORY_COMMAND = ( byte ) 0xB8;   /**    * DS18B20 reads power supply command.  This command is used to determine    * if external power is supplied.    */   public static final byte READ_POWER_SUPPLY_COMMAND = ( byte ) 0xB4;   /** DS18B20 12-bit resolution constant for CONFIG byte  */   public static final byte RESOLUTION_12_BIT = ( byte ) 0x7F;   /** DS18B20 11-bit resolution constant for CONFIG byte  */   public static final byte RESOLUTION_11_BIT = ( byte ) 0x5F;   /** DS18B20 10-bit resolution constant for CONFIG byte  */   public static final byte RESOLUTION_10_BIT = ( byte ) 0x3F;   /** DS18B20 9-bit resolution constant for CONFIG byte   */   public static final byte RESOLUTION_9_BIT = ( byte ) 0x1F;   /**    * Creates an empty <code>OneWireContainer28</code>.  Must call    * <code>setupContainer()</code> before using this new container.<p>    *    * This is one of the methods to construct a <code>OneWireContainer28</code>.    * The others are through creating a <code>OneWireContainer28</code> with    * parameters.    *    * @see #OneWireContainer28(DSPortAdapter,byte[])    * @see #OneWireContainer28(DSPortAdapter,long)    * @see #OneWireContainer28(DSPortAdapter,String)    */   public OneWireContainer28 ()   {      super();   }   /**    * Creates a <code>OneWireContainer28</code> with the provided adapter    * object and the address of this One-Wire device.    *    * This is one of the methods to construct a <code>OneWireContainer28</code>.    * The others are through creating a <code>OneWireContainer28</code> with    * different parameters types.    *    * @param  sourceAdapter     adapter object required to communicate with    *                           this One-Wire device    * @param  newAddress        address of this One-Wire device    *    * @see com.dalsemi.onewire.utils.Address    * @see #OneWireContainer28()    * @see #OneWireContainer28(DSPortAdapter,long)    * @see #OneWireContainer28(DSPortAdapter,String)    */   public OneWireContainer28 (DSPortAdapter sourceAdapter, byte[] newAddress)   {      super(sourceAdapter, newAddress);   }   /**    * Creates a <code>OneWireContainer28</code> with the provided adapter    * object and the address of this One-Wire device.    *    * This is one of the methods to construct a <code>OneWireContainer28</code>.    * The others are through creating a <code>OneWireContainer28</code> with    * different parameters types.    *    * @param  sourceAdapter     adapter object required to communicate with    *                           this One-Wire device    * @param  newAddress        address of this One-Wire device    *    * @see com.dalsemi.onewire.utils.Address    * @see #OneWireContainer28()    * @see #OneWireContainer28(DSPortAdapter,byte[])    * @see #OneWireContainer28(DSPortAdapter,String)    */   public OneWireContainer28 (DSPortAdapter sourceAdapter, long newAddress)   {      super(sourceAdapter, newAddress);   }   /**    * Creates a <code>OneWireContainer28</code> with the provided adapter    * object and the address of this One-Wire device.    *    * This is one of the methods to construct a <code>OneWireContainer28</code>.    * The others are through creating a <code>OneWireContainer28</code> with    * different parameters types.    *    * @param  sourceAdapter     adapter object required to communicate with    *                           this One-Wire device    * @param  newAddress        address of this One-Wire device    *    * @see com.dalsemi.onewire.utils.Address    * @see #OneWireContainer28()    * @see #OneWireContainer28(DSPortAdapter,byte[])    * @see #OneWireContainer28(DSPortAdapter,long)    */   public OneWireContainer28 (DSPortAdapter sourceAdapter, String newAddress)   {      super(sourceAdapter, newAddress);   }   //--------   //-------- Information methods   //--------   /**    * Retrieves the Dallas Semiconductor part number of this    * <code>OneWireContainer28</code> as a <code>String</code>.    * For example 'DS18B20'.    *    * @return this <code>OneWireContainer28</code> name    */   public String getName ()   {      return "DS18B20";   }   /**    * Retrieves the alternate Dallas Semiconductor 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'.    *    * @return this <code>OneWireContainer28</code> alternate names    */   public String getAlternateNames ()   {      return "DS1820B, DS18B20X";   }   /**    * Retrieves a short description of the function of this    * <code>OneWireContainer28</code> type.    *    * @return <code>OneWireContainer28</code> functional description    */   public String getDescription ()   {      return "Digital thermometer measures temperatures from "             + "-55C to 125C in 0.75 seconds (max).  +/- 0.5C "             + "accuracy between -10C and 85C. Thermometer "             + "resolution is programmable at 9, 10, 11, and 12 bits. ";   }   //--------   //-------- Temperature Feature methods   //--------   /**    * Checks to see if this temperature measuring device has high/low    * trip alarms.    *    * @return <code>true</code> if this <code>OneWireContainer28</code>    *         has high/low trip alarms    *    * @see    #getTemperatureAlarm    * @see    #setTemperatureAlarm    */   public boolean hasTemperatureAlarms ()   {      return true;   }   /**    * Checks to see if this device has selectable temperature resolution.    *    * @return <code>true</code> if this <code>OneWireContainer28</code>    *         has selectable temperature resolution    *    * @see    #getTemperatureResolution    * @see    #getTemperatureResolutions    * @see    #setTemperatureResolution    */   public boolean hasSelectableTemperatureResolution ()   {      return true;   }   /**    * Gets an array of available temperature resolutions in Celsius.    *    * @return byte array of available temperature resolutions in Celsius for    *         this <code>OneWireContainer28</code>. The minimum resolution is    *         returned as the first element and maximum resolution as the last    *         element.    *    * @see    #hasSelectableTemperatureResolution    * @see    #getTemperatureResolution    * @see    #setTemperatureResolution    */   public double[] getTemperatureResolutions ()   {      double[] resolutions = new double [4];      resolutions [0] = ( double ) 0.5;      // 9-bit      resolutions [1] = ( double ) 0.25;     // 10-bit      resolutions [2] = ( double ) 0.125;    // 11-bit      resolutions [3] = ( double ) 0.0625;   // 12-bit      return resolutions;   }   /**    * Gets the temperature alarm resolution in Celsius.    *    * @return temperature alarm resolution in Celsius for this    *         <code>OneWireContainer28</code>    *    * @see    #hasTemperatureAlarms    * @see    #getTemperatureAlarm    * @see    #setTemperatureAlarm    *    */   public double getTemperatureAlarmResolution ()   {      return 1.0;   }   /**    * Gets the maximum temperature in Celsius.    *    * @return maximum temperature in Celsius for this    *         <code>OneWireContainer28</code>    *    * @see    #getMinTemperature    */   public double getMaxTemperature ()   {      return 125.0;   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -