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

📄 onewirecontainer41.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   // the average value for each reference point   private double Tread1 = 0, Tread2 = 0, Tread3 = 0;   // the average error for each reference point   private double Terror1 = 0, Terror2 = 0, Terror3 = 0;   // the coefficients for calibration of temperature   private double tempCoeffA, tempCoeffB, tempCoeffC;   // indicates whether or not to temperature compensate the humidity values   private boolean useTemperatureCompensation = false;   // indicates whether or not to use the temperature log for compensation   private boolean overrideTemperatureLog = false;   // default temperature in case of no log or override log   private double defaultTempCompensationValue = 25;   // indicates whether or not this is a DS1922H   private boolean hasHumiditySensor = false;   // temperature is 8-bit or 11-bit   private static final double temperatureResolutions[] = new double[] {.5d, .0625d};   // data is 10-bit or 16-bit   private static final double dataResolutions[] = new double[] {.5d, 0.001953125};   private static final double humidityResolutions[] = new double[] {.5d, .125d};   private String descriptionString =       "Rugged, self-sufficient 1-Wire device that, once setup for "       + "a mission, will measure temperature and A-to-D, with the "       + "result recorded in a protected memory section. It stores up "       + "to 8192 1-byte measurements, which can be filled with 1- or "       + "2-byte temperature readings and 1- or 2-byte A-to-D/Humidity readings "       + "taken at a user-specified rate.";   // first year that calendar starts counting years from   private static final int FIRST_YEAR_EVER = 2000;   // used to 'enable' passwords   private static final byte ENABLE_BYTE = (byte)0xAA;   // used to 'disable' passwords   private static final byte DISABLE_BYTE = 0x00;// *****************************************************************************//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// 1-Wire Commands//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// *****************************************************************************   /** Refers to the Temperature Channel for this device */   public static final int TEMPERATURE_CHANNEL = 0;   /** Refers to the Humidity/A-D Channel for this device */   public static final int DATA_CHANNEL = 1;   /** 1-Wire command for Write Scratchpad */   public static final byte WRITE_SCRATCHPAD_COMMAND   = (byte)0x0F;   /** 1-Wire command for Read Scratchpad */   public static final byte READ_SCRATCHPAD_COMMAND    = (byte)0xAA;   /** 1-Wire command for Copy Scratchpad With Password */   public static final byte COPY_SCRATCHPAD_PW_COMMAND = (byte)0x99;   /** 1-Wire command for Read Memory CRC With Password */   public static final byte READ_MEMORY_CRC_PW_COMMAND = (byte)0x69;   /** 1-Wire command for Clear Memory With Password */   public static final byte CLEAR_MEMORY_PW_COMMAND    = (byte)0x96;   /** 1-Wire command for Start Mission With Password */   public static final byte START_MISSION_PW_COMMAND   = (byte)0xCC;   /** 1-Wire command for Stop Mission With Password */   public static final byte STOP_MISSION_PW_COMMAND    = (byte)0x33;   /** 1-Wire command for Forced Conversion */   public static final byte FORCED_CONVERSION          = (byte)0x55;// *****************************************************************************//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Register addresses and control bits//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// *****************************************************************************   /** Address of the Real-time Clock Time value*/   public static final int RTC_TIME = 0x200;   /** Address of the Real-time Clock Date value*/   public static final int RTC_DATE = 0x203;   /** Address of the Sample Rate Register */   public static final int SAMPLE_RATE = 0x206;// 2 bytes, LSB first, MSB no greater than 0x3F   /** Address of the Temperature Low Alarm Register */   public static final int TEMPERATURE_LOW_ALARM_THRESHOLD = 0x208;   /** Address of the Temperature High Alarm Register */   public static final int TEMPERATURE_HIGH_ALARM_THRESHOLD = 0x209;   /** Address of the Data Low Alarm Register */   public static final int DATA_LOW_ALARM_THRESHOLD = 0x20A;   /** Address of the Data High Alarm Register */   public static final int DATA_HIGH_ALARM_THRESHOLD = 0x20B;   /** Address of the last temperature conversion's LSB */   public static final int LAST_TEMPERATURE_CONVERSION_LSB = 0x20C;   /** Address of the last temperature conversion's MSB */   public static final int LAST_TEMPERATURE_CONVERSION_MSB = 0x20D;   /** Address of the last data conversion's LSB */   public static final int LAST_DATA_CONVERSION_LSB = 0x20E;   /** Address of the last data conversion's MSB */   public static final int LAST_DATA_CONVERSION_MSB = 0x20F;   /** Address of Temperature Control Register */   public static final int TEMPERATURE_CONTROL_REGISTER = 0x210;   /** Temperature Control Register Bit: Enable Data Low Alarm */   public static final byte TCR_BIT_ENABLE_TEMPERATURE_LOW_ALARM = (byte)0x01;   /** Temperature Control Register Bit: Enable Data Low Alarm */   public static final byte TCR_BIT_ENABLE_TEMPERATURE_HIGH_ALARM = (byte)0x02;   /** Address of Data Control Register */   public static final int DATA_CONTROL_REGISTER = 0x211;   /** Data Control Register Bit: Enable Data Low Alarm */   public static final byte DCR_BIT_ENABLE_DATA_LOW_ALARM = (byte)0x01;   /** Data Control Register Bit: Enable Data High Alarm */   public static final byte DCR_BIT_ENABLE_DATA_HIGH_ALARM = (byte)0x02;   /** Address of Real-Time Clock Control Register */   public static final int RTC_CONTROL_REGISTER = 0x212;   /** Real-Time Clock Control Register Bit: Enable Oscillator */   public static final byte RCR_BIT_ENABLE_OSCILLATOR = (byte)0x01;   /** Real-Time Clock Control Register Bit: Enable High Speed Sample */   public static final byte RCR_BIT_ENABLE_HIGH_SPEED_SAMPLE = (byte)0x02;   /** Address of Mission Control Register */   public static final int MISSION_CONTROL_REGISTER = (byte)0x213;   /** Mission Control Register Bit: Enable Temperature Logging */   public static final byte MCR_BIT_ENABLE_TEMPERATURE_LOGGING = (byte)0x01;   /** Mission Control Register Bit: Enable Data Logging */   public static final byte MCR_BIT_ENABLE_DATA_LOGGING = (byte)0x02;   /** Mission Control Register Bit: Set Temperature Resolution */   public static final byte MCR_BIT_TEMPERATURE_RESOLUTION = (byte)0x04;   /** Mission Control Register Bit: Set Data Resolution */   public static final byte MCR_BIT_DATA_RESOLUTION = (byte)0x08;   /** Mission Control Register Bit: Enable Rollover */   public static final byte MCR_BIT_ENABLE_ROLLOVER = (byte)0x10;   /** Mission Control Register Bit: Start Mission on Temperature Alarm */   public static final byte MCR_BIT_START_MISSION_ON_TEMPERATURE_ALARM = (byte)0x20;   /** Address of Alarm Status Register */   public static final int ALARM_STATUS_REGISTER = 0x214;   /** Alarm Status Register Bit: Temperature Low Alarm */   public static final byte ASR_BIT_TEMPERATURE_LOW_ALARM = (byte)0x01;   /** Alarm Status Register Bit: Temperature High Alarm */   public static final byte ASR_BIT_TEMPERATURE_HIGH_ALARM = (byte)0x02;   /** Alarm Status Register Bit: Data Low Alarm */   public static final byte ASR_BIT_DATA_LOW_ALARM = (byte)0x04;   /** Alarm Status Register Bit: Data High Alarm */   public static final byte ASR_BIT_DATA_HIGH_ALARM = (byte)0x08;   /** Alarm Status Register Bit: Battery On Reset */   public static final byte ASR_BIT_BATTERY_ON_RESET = (byte)0x80;   /** Address of General Status Register */   public static final int GENERAL_STATUS_REGISTER = 0x215;   /** General Status Register Bit: Sample In Progress */   public static final byte GSR_BIT_SAMPLE_IN_PROGRESS = (byte)0x01;   /** General Status Register Bit: Mission In Progress */   public static final byte GSR_BIT_MISSION_IN_PROGRESS = (byte)0x02;   /** General Status Register Bit: Conversion In Progress */   public static final byte GSR_BIT_CONVERSION_IN_PROGRESS = (byte)0x04;   /** General Status Register Bit: Memory Cleared */   public static final byte GSR_BIT_MEMORY_CLEARED = (byte)0x08;   /** General Status Register Bit: Waiting for Temperature Alarm */   public static final byte GSR_BIT_WAITING_FOR_TEMPERATURE_ALARM = (byte)0x10;   /** General Status Register Bit: Forced Conversion In Progress */   public static final byte GSR_BIT_FORCED_CONVERSION_IN_PROGRESS = (byte)0x20;   /** Address of the Mission Start Delay */   public static final int MISSION_START_DELAY = 0x216; // 3 bytes, LSB first   /** Address of the Mission Timestamp Time value*/   public static final int MISSION_TIMESTAMP_TIME = 0x219;   /** Address of the Mission Timestamp Date value*/   public static final int MISSION_TIMESTAMP_DATE = 0x21C;   /** Address of Device Configuration Register */   public static final int DEVICE_CONFIGURATION_BYTE = 0x226;   /** Value of Device Configuration Register for DS1922S */   public static final byte DCB_DS2422S = 0x00;   /** Value of Device Configuration Register for DS1922H */   public static final byte DCB_DS1922H = 0x20;   /** Value of Device Configuration Register for DS1922L */   public static final byte DCB_DS1922L = 0x40;   /** Value of Device Configuration Register for DS1922T */   public static final byte DCB_DS1922T = 0x60;   // 1 byte, alternating ones and zeroes indicates passwords are enabled   /** Address of the Password Control Register. */   public static final int PASSWORD_CONTROL_REGISTER = 0x227;   // 8 bytes, write only, for setting the Read Access Password   /** Address of Read Access Password. */   public static final int READ_ACCESS_PASSWORD = 0x228;   // 8 bytes, write only, for setting the Read Access Password   /** Address of the Read Write Access Password. */   public static final int READ_WRITE_ACCESS_PASSWORD = 0x230;   // 3 bytes, LSB first   /** Address of the Mission Sample Count */   public static final int MISSION_SAMPLE_COUNT = 0x220;   // 3 bytes, LSB first   /** Address of the Device Sample Count */   public static final int DEVICE_SAMPLE_COUNT = 0x223;   /** maximum size of the mission log */   public static final int MISSION_LOG_SIZE = 8192;   /**    * mission log size for odd combination of resolutions (i.e. 8-bit temperature    * & 16-bit data or 16-bit temperature & 8-bit data    */   public static final int ODD_MISSION_LOG_SIZE = 7680;// *****************************************************************************//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Constructors and Initializers//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// *****************************************************************************   /**    * Creates a new <code>OneWireContainer</code> for communication with a    * DS1922.    * Note that the method <code>setupContainer(DSPortAdapter,byte[])</code>    * must be called to set the correct <code>DSPortAdapter</code> device address.    *    * @see com.dalsemi.onewire.container.OneWireContainer#setupContainer(com.dalsemi.onewire.adapter.DSPortAdapter,byte[]) setupContainer(DSPortAdapter,byte[])    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,byte[]) OneWireContainer41(DSPortAdapter,byte[])    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,long)   OneWireContainer41(DSPortAdapter,long)    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,java.lang.String) OneWireContainer41(DSPortAdapter,String)    */   public OneWireContainer41()   {      super();      // initialize the memory banks      initMem();      setContainerVariables(null);   }   /**    * Creates a new <code>OneWireContainer</code> for communication with a    * DS1922.    *    * @param  sourceAdapter     adapter object required to communicate with    * this iButton    * @param  newAddress        address of this DS1922    *    * @see #OneWireContainer41()    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,long)   OneWireContainer41(DSPortAdapter,long)    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,java.lang.String) OneWireContainer41(DSPortAdapter,String)    */   public OneWireContainer41(DSPortAdapter sourceAdapter, byte[] newAddress)   {      super(sourceAdapter, newAddress);      // initialize the memory banks      initMem();      setContainerVariables(null);   }   /**    * Creates a new <code>OneWireContainer</code> for communication with a    * DS1922.    *    * @param  sourceAdapter     adapter object required to communicate with    * this iButton    * @param  newAddress        address of this DS1922    *    * @see #OneWireContainer41()    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,byte[]) OneWireContainer41(DSPortAdapter,byte[])    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,java.lang.String) OneWireContainer41(DSPortAdapter,String)    */   public OneWireContainer41(DSPortAdapter sourceAdapter, long newAddress)   {      super(sourceAdapter, newAddress);      // initialize the memory banks      initMem();      setContainerVariables(null);   }   /**    * Creates a new <code>OneWireContainer</code> for communication with a    * DS1922.    *    * @param  sourceAdapter     adapter object required to communicate with    * this iButton    * @param  newAddress        address of this DS1922    *    * @see #OneWireContainer41()    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,long) OneWireContainer41(DSPortAdapter,long)    * @see #OneWireContainer41(com.dalsemi.onewire.adapter.DSPortAdapter,java.lang.String) OneWireContainer41(DSPortAdapter,String)    */   public OneWireContainer41(DSPortAdapter sourceAdapter, String newAddress)   {      super(sourceAdapter, newAddress);      // initialize the memory banks      initMem();      setContainerVariables(null);   }   /**    * Provides this container with the adapter object used to access this device and    * the address of the iButton or 1-Wire device.    *    * @param  sourceAdapter     adapter object required to communicate with    *                           this iButton    * @param  newAddress        address of this 1-Wire device    * @see com.dalsemi.onewire.utils.Address    */   public void setupContainer(DSPortAdapter sourceAdapter, byte[] newAddress)   {      super.setupContainer(sourceAdapter, newAddress);      // initialize the memory banks      initMem();      setContainerVariables(null);   }   /**    * Provides this container with the adapter object used to access this device and

⌨️ 快捷键说明

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