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

📄 onewirecontainer26.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      return 1000;   }   //--------   //-------- Clock 'get' Methods   //--------   /**    * This method extracts the Clock Value in milliseconds from the    * state data retrieved from the <CODE>readDevice()</CODE> method.    *    * @param state  device state    *    * @return time in milliseconds that have    * occured since 1970    */   public long getClock (byte[] state)   {      return getTime(state, 8) * 1000;   }   /**    * This method extracts the Clock Alarm Value from the provided    * state data retrieved from the <CODE>readDevice()</CODE>    * method.    *    * @param state device state    *    * @return time in milliseconds that have    * the clock alarm is set to    *    * @throws OneWireException Device does not have clock alarm    */   public long getClockAlarm (byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have a clock alarm!");   }   /**    * This method checks if the Clock Alarm flag has been set    * from the state data retrieved from the    * <CODE>readDevice()</CODE> method.    *    * @param state device state    *    * @return true if clock is alarming    */   public boolean isClockAlarming (byte[] state)   {      return false;   }   /**    * This method checks if the Clock Alarm is enabled    * from the provided state data retrieved from the    * <CODE>readDevice()</CODE> method.    *    * @param state device state    *    * @return true if clock alarm is enabled    */   public boolean isClockAlarmEnabled (byte[] state)   {      return false;   }   /**    * This method checks if the device's oscilator is enabled.  The clock    * will not increment if the clock is not enabled.    * This value is read from the provided state data retrieved from the    * <CODE>readDevice()</CODE> method.    *    * @param state device state    *    * @return true if clock is running    */   public boolean isClockRunning (byte[] state)   {      return true;   }   //--------   //-------- Clock 'set' Methods   //--------   /**    * This method sets the Clock time in the provided state data    * Use the method <CODE>writeDevice()</CODE> with    * this data to finalize the change to the device.    *    * @param time new clock setting in milliseconds    * @param state device state    */   public void setClock (long time, byte[] state)   {      time       = time / 1000;   //convert to seconds      state [8]  = ( byte ) time;      state [9]  = ( byte ) (time >> 8);      state [10] = ( byte ) (time >> 16);      state [11] = ( byte ) (time >> 24);   }   /**    * This method sets the Clock Alarm in the provided state    * data.  Use the method <CODE>writeDevice()</CODE> with    * this data to finalize the change to the device.    *    * @param time new clock setting in mlliseconds    * @param state device state    *    * @throws OneWireException Device does not support clock alarm    */   public void setClockAlarm (long time, byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have a clock alarm!");   }   /**    * This method sets the oscillator enable to the specified    * value. Use the method <CODE>writeDevice()</CODE> with this    * data to finalize the change to the device.    *    * @param runEnable true to enable clock oscillator    * @param state device state    *    * @throws OneWireException Device does not support disabled clock    */   public void setClockRunEnable (boolean runEnable, byte[] state)      throws OneWireException   {      if (!runEnable)         throw new OneWireException(            "This device's clock cannot be disabled!");   }   /**    * This method sets the Clock Alarm enable. Use the method    * <CODE>writeDevice()</CODE> with this data to finalize the    * change to the device.    *    * @param  alarmEnable - true to enable clock alarm    * @param state device state    *    * @throws OneWireException Device does not support clock alarm    */   public void setClockAlarmEnable (boolean alarmEnable, byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have a clock alarm!");   }   //--------   //-------- Humidity Feature methods   //--------   /**    * Checks to see if humidity value given is a 'relative' humidity value.    *    * @return <code>true</code> if this <code>HumidityContainer</code>    *         provides a relative humidity reading    *    * @see    #getHumidityResolution    * @see    #getHumidityResolutions    * @see    #setHumidityResolution    */   public boolean isRelative()   {      return true;   }   /**    * Checks to see if this Humidity measuring device has high/low    * trip alarms.    *    * @return <code>true</code> if this <code>HumidityContainer</code>    *         has high/low trip alarms    *    * @see    #getHumidityAlarm    * @see    #setHumidityAlarm    */   public boolean hasHumidityAlarms()   {      return false;   }   /**    * Checks to see if this device has selectable Humidity resolution.    *    * @return <code>true</code> if this <code>HumidityContainer</code>    *         has selectable Humidity resolution    *    * @see    #getHumidityResolution    * @see    #getHumidityResolutions    * @see    #setHumidityResolution    */   public boolean hasSelectableHumidityResolution ()   {      return false;   }   /**    * Get an array of available Humidity resolutions in percent humidity (0 to 100).    *    * @return byte array of available Humidity resolutions in percent with    *         minimum resolution as the first element and maximum resolution    *         as the last element.    *    * @see    #hasSelectableHumidityResolution    * @see    #getHumidityResolution    * @see    #setHumidityResolution    */   public double[] getHumidityResolutions ()   {      double[] result = new double [1];      result [0] = 0.1;      return result;   }   /**    * Gets the Humidity alarm resolution in percent.    *    * @return Humidity alarm resolution in percent for this 1-wire device    *    * @throws OneWireException         Device does not support Humidity    *                                  alarms    *    * @see    #hasHumidityAlarms    * @see    #getHumidityAlarm    * @see    #setHumidityAlarm    *    */   public double getHumidityAlarmResolution ()      throws OneWireException   {      throw new OneWireException("This device does not have a humidity alarm!");   }   //--------   //-------- Humidity I/O Methods   //--------   /**    * Performs a Humidity conversion.    *    * @param  state byte array with device state information    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    */   public void doHumidityConvert (byte[] state)      throws OneWireIOException, OneWireException   {      // do temp convert      doTemperatureConvert(state);      // do VDD for supply voltage      doADConvert(CHANNEL_VDD,state);      // do VAD for sensor voltage      doADConvert(CHANNEL_VAD,state);   }   //--------   //-------- Humidity 'get' Methods   //--------   /**    * Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.    *    * @param  state byte array with device state information    * @return humidity expressed as a percent    *    * @see    #hasSelectableHumidityResolution    * @see    #getHumidityResolution    * @see    #setHumidityResolution    */   public double getHumidity (byte[] state)   {      double temp=0,vdd=0,vad=0,rh=0;      try      {         // read the temperature         temp = getTemperature(state);         // read the supply voltage         vdd = getADVoltage(CHANNEL_VDD,state);         // read the sample voltage         vad = getADVoltage(CHANNEL_VAD,state);      }      catch (OneWireException e)      {         // know from this implementatin that this will never happen         return 0.0;      }      // do calculation and check for out of range values      if (vdd != 0)         rh = (((vad/vdd) - 0.16)/0.0062)/(1.0546 - 0.00216 * temp);      if (rh < 0.0)         rh = 0.0;      else if (rh > 100.0)         rh = 100.0;      return rh;   }   /**    * Gets the current Humidity resolution in percent from the    * <code>state</code> data retrieved from the <code>readDevice()</code>    * method.    *    * @param  state byte array with device state information    *    * @return Humidity resolution in percent for this 1-wire device    *    * @see    #hasSelectableHumidityResolution    * @see    #getHumidityResolutions    * @see    #setHumidityResolution    */   public double getHumidityResolution (byte[] state)   {      return 0.1;   }   /**    * Gets the specified Humidity alarm value in percent from the    * <code>state</code> data retrieved from the    * <code>readDevice()</code> method.    *    * @param  alarmType valid value: <code>ALARM_HIGH</code> or    *                   <code>ALARM_LOW</code>    * @param  state     byte array with device state information    *    * @return Humidity alarm trip values in percent for this 1-wire device    *    * @throws OneWireException         Device does not support Humidity    *                                  alarms    *    * @see    #hasHumidityAlarms    * @see    #setHumidityAlarm    */   public double getHumidityAlarm (int alarmType, byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have a humidity alarm!");   }   //--------   //-------- Humidity 'set' Methods   //--------   /**    * Sets the Humidity alarm value in percent in the provided    * <code>state</code> data.    * Use the method <code>writeDevice()</code> with    * this data to finalize the change to the device.    *    * @param  alarmType  valid value: <code>ALARM_HIGH</code> or    *                    <code>ALARM_LOW</code>    * @param  alarmValue alarm trip value in percent    * @param  state      byte array with device state information    *    * @throws OneWireException         Device does not support Humidity    *                                  alarms    *    * @see    #hasHumidityAlarms    * @see    #getHumidityAlarm    */   public void setHumidityAlarm (int alarmType, double alarmValue,                                    byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have a humidity alarm!");   }   /**    * Sets the current Humidity resolution in percent in the provided    * <code>state</code> data.   Use the method <code>writeDevice()</code>    * with this data to finalize the change to the device.    *    * @param  resolution Humidity resolution in percent    * @param  state      byte array with device state information    *    * @throws OneWireException         Device does not support selectable    *                                  Humidity resolution    *    * @see    #hasSelectableHumidityResolution    * @see    #getHumidityResolution    * @see    #getHumidityResolutions    */   public void setHumidityResolution (double resolution, byte[] state)      throws OneWireException   {      throw new OneWireException("This device does not have selectable humidity resolution!");   }}

⌨️ 快捷键说明

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