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

📄 dsportadapter.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      include = null;      exclude = null;   }   /**    * Takes an integer to selectively search for this desired family type.    * If this method is used, then no devices of other families will be    * found by any of the search methods.    *    * @param  family   the code of the family type to target for searches    * @see    Address    * @see    #targetAllFamilies    */   public void targetFamily (int family)   {      if ((include == null) || (include.length != 1))         include = new byte [1];      include [0] = ( byte ) family;   }   /**    * Takes an array of bytes to use for selectively searching for acceptable    * family codes.  If used, only devices with family codes in this array    * will be found by any of the search methods.    *    * @param  family  array of the family types to target for searches    * @see    Address    * @see    #targetAllFamilies    */   public void targetFamily (byte family [])   {      if ((include == null) || (include.length != family.length))         include = new byte [family.length];      System.arraycopy(family, 0, include, 0, family.length);   }   /**    * Takes an integer family code to avoid when searching for iButtons.    * or 1-Wire devices.    * If this method is used, then no devices of this family will be    * found by any of the search methods.    *    * @param  family   the code of the family type NOT to target in searches    * @see    Address    * @see    #targetAllFamilies    */   public void excludeFamily (int family)   {      if ((exclude == null) || (exclude.length != 1))         exclude = new byte [1];      exclude [0] = ( byte ) family;   }   /**    * Takes an array of bytes containing family codes to avoid when finding    * iButtons or 1-Wire devices.  If used, then no devices with family    * codes in this array will be found by any of the search methods.    *    * @param  family  array of family cods NOT to target for searches    * @see    Address    * @see    #targetAllFamilies    */   public void excludeFamily (byte family [])   {      if ((exclude == null) || (exclude.length != family.length))         exclude = new byte [family.length];      System.arraycopy(family, 0, exclude, 0, family.length);   }   //--------   //-------- 1-Wire Network Semaphore methods   //--------   /**    * Gets exclusive use of the 1-Wire to communicate with an iButton or    * 1-Wire Device.    * This method should be used for critical sections of code where a    * sequence of commands must not be interrupted by communication of    * threads with other iButtons, and it is permissible to sustain    * a delay in the special case that another thread has already been    * granted exclusive access and this access has not yet been    * relinquished. <p>    *    * It can be called through the OneWireContainer    * class by the end application if they want to ensure exclusive    * use.  If it is not called around several methods then it    * will be called inside each method.    *    * @param blocking <code>true</code> if want to block waiting    *                 for an excluse access to the adapter    * @return <code>true</code> if blocking was false and a    *         exclusive session with the adapter was aquired    *    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract boolean beginExclusive (boolean blocking)      throws OneWireException;   /**    * Relinquishes exclusive control of the 1-Wire Network.    * This command dynamically marks the end of a critical section and    * should be used when exclusive control is no longer needed.    */   public abstract void endExclusive ();   //--------   //-------- Primitive 1-Wire Network data methods   //--------   /**    * Sends a bit to the 1-Wire Network.    *    * @param  bitValue  the bit value to send to the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract void putBit (boolean bitValue)      throws OneWireIOException, OneWireException;   /**    * Gets a bit from the 1-Wire Network.    *    * @return  the bit value recieved from the the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract boolean getBit ()      throws OneWireIOException, OneWireException;   /**    * Sends a byte to the 1-Wire Network.    *    * @param  byteValue  the byte value to send to the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract void putByte (int byteValue)      throws OneWireIOException, OneWireException;   /**    * Gets a byte from the 1-Wire Network.    *    * @return  the byte value received from the the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract int getByte ()      throws OneWireIOException, OneWireException;   /**    * Gets a block of data from the 1-Wire Network.    *    * @param  len  length of data bytes to receive    *    * @return  the data received from the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract byte[] getBlock (int len)      throws OneWireIOException, OneWireException;   /**    * Gets a block of data from the 1-Wire Network and write it into    * the provided array.    *    * @param  arr     array in which to write the received bytes    * @param  len     length of data bytes to receive    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract void getBlock (byte[] arr, int len)      throws OneWireIOException, OneWireException;   /**    * Gets a block of data from the 1-Wire Network and write it into    * the provided array.    *    * @param  arr     array in which to write the received bytes    * @param  off     offset into the array to start    * @param  len     length of data bytes to receive    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract void getBlock (byte[] arr, int off, int len)      throws OneWireIOException, OneWireException;   /**    * Sends a block of data and returns the data received in the same array.    * This method is used when sending a block that contains reads and writes.    * The 'read' portions of the data block need to be pre-loaded with 0xFF's.    * It starts sending data from the index at offset 'off' for length 'len'.    *    * @param  dataBlock  array of data to transfer to and from the 1-Wire Network.    * @param  off        offset into the array of data to start    * @param  len        length of data to send / receive starting at 'off'    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract void dataBlock (byte dataBlock [], int off, int len)      throws OneWireIOException, OneWireException;   /**    * Sends a Reset to the 1-Wire Network.    *    * @return  the result of the reset. Potential results are:    * <ul>    * <li> 0 (RESET_NOPRESENCE) no devices present on the 1-Wire Network.    * <li> 1 (RESET_PRESENCE) normal presence pulse detected on the 1-Wire    *        Network indicating there is a device present.    * <li> 2 (RESET_ALARM) alarming presence pulse detected on the 1-Wire    *        Network indicating there is a device present and it is in the    *        alarm condition.  This is only provided by the DS1994/DS2404    *        devices.    * <li> 3 (RESET_SHORT) inticates 1-Wire appears shorted.  This can be    *        transient conditions in a 1-Wire Network.  Not all adapter types    *        can detect this condition.    * </ul>    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public abstract int reset ()      throws OneWireIOException, OneWireException;   //--------   //-------- 1-Wire Network power methods   //--------   /**    * Sets the duration to supply power to the 1-Wire Network.    * This method takes a time parameter that indicates the program    * pulse length when the method startPowerDelivery().<p>    *    * Note: to avoid getting an exception,    * use the canDeliverPower() and canDeliverSmartPower()    * method to check it's availability. <p>    *    * @param timeFactor    * <ul>    * <li>   0 (DELIVERY_HALF_SECOND) provide power for 1/2 second.    * <li>   1 (DELIVERY_ONE_SECOND) provide power for 1 second.    * <li>   2 (DELIVERY_TWO_SECONDS) provide power for 2 seconds.    * <li>   3 (DELIVERY_FOUR_SECONDS) provide power for 4 seconds.    * <li>   4 (DELIVERY_SMART_DONE) provide power until the    *          the device is no longer drawing significant power.    * <li>   5 (DELIVERY_INFINITE) provide power until the    *          setPowerNormal() method is called.    * </ul>    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public void setPowerDuration (int timeFactor)      throws OneWireIOException, OneWireException   {      throw new OneWireException(         "Power delivery not supported by this adapter type");   }   /**    * Sets the 1-Wire Network voltage to supply power to a 1-Wire device.    * This method takes a time parameter that indicates whether the    * power delivery should be done immediately, or after certain    * conditions have been met. <p>    *    * Note: to avoid getting an exception,    * use the canDeliverPower() and canDeliverSmartPower()    * method to check it's availability. <p>    *    * @param changeCondition    * <ul>    * <li>   0 (CONDITION_NOW) operation should occur immediately.    * <li>   1 (CONDITION_AFTER_BIT) operation should be pending    *           execution immediately after the next bit is sent.    * <li>   2 (CONDITION_AFTER_BYTE) operation should be pending    *           execution immediately after next byte is sent.    * </ul>    *    * @return <code>true</code> if the voltage change was successful,    * <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public boolean startPowerDelivery (int changeCondition)      throws OneWireIOException, OneWireException   {      throw new OneWireException(         "Power delivery not supported by this adapter type");   }   /**    * Sets the duration for providing a program pulse on the    * 1-Wire Network.    * This method takes a time parameter that indicates the program    * pulse length when the method startProgramPulse().<p>    *    * Note: to avoid getting an exception,    * use the canDeliverPower() method to check it's    * availability. <p>    *    * @param timeFactor    * <ul>    * <li>   7 (DELIVERY_EPROM) provide program pulse for 480 microseconds    * <li>   5 (DELIVERY_INFINITE) provide power until the    *          setPowerNormal() method is called.    * </ul>    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public void setProgramPulseDuration (int timeFactor)      throws OneWireIOException, OneWireException   {      throw new OneWireException(         "Program pulse delivery not supported by this adapter type");   }   /**    * Sets the 1-Wire Network voltage to eprom programming level.    * This method takes a time parameter that indicates whether the    * power delivery should be done immediately, or after certain    * conditions have been met. <p>    *    * Note: to avoid getting an exception,    * use the canProgram() method to check it's    * availability. <p>    *    * @param changeCondition    * <ul>    * <li>   0 (CONDITION_NOW) operation should occur immediately.    * <li>   1 (CONDITION_AFTER_BIT) operation should be pending    *           execution immediately after the next bit is sent.    * <li>   2 (CONDITION_AFTER_BYTE) operation should be pending    *           execution immediately after next byte is sent.    * </ul>    *    * @return <code>true</code> if the voltage change was successful,    * <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    *         or the adapter does not support this operation    */   public boolean startProgramPulse (int changeCondition)      throws OneWireIOException, OneWireException   {      throw new OneWireException(         "Program pulse delivery not supported by this adapter type");   }   /**    * Sets the 1-Wire Network voltage to 0 volts.  This method is used    * rob all 1-Wire Network devices of parasite power delivery to force    * them into a hard reset.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    *         or the adapter does not support this operation    */   public void startBreak ()      throws OneWireIOException, OneWireException

⌨️ 快捷键说明

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