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

📄 tmexadapter.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    *         adapter    */   public native boolean canHyperdrive ()      throws OneWireIOException, OneWireException;   /**    * Returns whether the adapter can physically support flex speed mode.    *    * @return  <code>true</code> if this port adapter can do flex speed,    * <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error with the adapter    * @throws OneWireException on a setup error with the 1-Wire     *         adapter    */   public native boolean canFlex ()      throws OneWireIOException, OneWireException;   /**    * Returns whether adapter can physically support 12 volt power mode.    *    * @return  <code>true</code> if this port adapter can do Program voltage,    * <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error with the adapter    * @throws OneWireException on a setup error with the 1-Wire     *         adapter    */   public native boolean canProgram ()      throws OneWireIOException, OneWireException;   /**    * Returns whether the adapter can physically support strong 5 volt power    * mode.    *    * @return  <code>true</code> if this port adapter can do strong 5 volt    * mode, <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error with the adapter    * @throws OneWireException on a setup error with the 1-Wire     *         adapter    */   public native boolean canDeliverPower ()      throws OneWireIOException, OneWireException;   /**    * Returns whether the adapter can physically support "smart" strong 5    * volt power mode.  "smart" power delivery is the ability to deliver    * power until it is no longer needed.  The current drop it detected    * and power delivery is stopped.    *    * @return  <code>true</code> if this port adapter can do "smart" strong    * 5 volt mode, <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error with the adapter    * @throws OneWireException on a setup error with the 1-Wire     *         adapter    */   public native boolean canDeliverSmartPower ()      throws OneWireIOException, OneWireException;   /**    * Returns whether adapter can physically support 0 volt 'break' mode.    *    * @return  <code>true</code> if this port adapter can do break,    * <code>false</code> otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error with the adapter    * @throws OneWireException on a setup error with the 1-Wire     *         adapter    */   public native boolean canBreak ()      throws OneWireIOException, OneWireException;   //--------   //-------- Finding iButtons and 1-Wire devices   //--------   /**    * Returns <code>true</code> if the first iButton or 1-Wire device    * is found on the 1-Wire Network.    * If no devices are found, then <code>false</code> will be returned.    *    * @return  <code>true</code> if an iButton or 1-Wire device is found.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public boolean findFirstDevice ()      throws OneWireIOException, OneWireException   {      // reset the internal rom buffer      resetSearch = true;      return findNextDevice();   }   /**    * Returns <code>true</code> if the next iButton or 1-Wire device    * is found. The previous 1-Wire device found is used    * as a starting point in the search.  If no more devices are found    * then <code>false</code> will be returned.    *    * @return  <code>true</code> if an iButton or 1-Wire device is found.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public boolean findNextDevice ()      throws OneWireIOException, OneWireException   {      boolean retval;      while (true)      {         retval = romSearch_Native(skipResetOnSearch, resetSearch,                                   doAlarmSearch, RomDta);         if (retval)         {            resetSearch = false;            // check if this is an OK family type            if (isValidFamily(RomDta))               return true;            // Else, loop to the top and do another search.         }         else         {            resetSearch = true;            return false;         }      }   }   /**    * Copies the 'current' iButton address being used by the adapter into    * the array.  This address is the last iButton or 1-Wire device found    * in a search (findNextDevice()...).    * This method copies into a user generated array to allow the    * reuse of the buffer.  When searching many iButtons on the one    * wire network, this will reduce the memory burn rate.    *    * @param  address An array to be filled with the current iButton address.    * @see    Address    */   public void getAddress (byte[] address)   {      System.arraycopy(RomDta, 0, address, 0, 8);   }   /**    * Verifies that the iButton or 1-Wire device specified is present on    * the 1-Wire Network. This does not affect the 'current' device    * state information used in searches (findNextDevice...).    *    * @param  address  device address to verify is present    *    * @return  <code>true</code> if device is present else    *         <code>false</code>.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    *    * @see    Address    */   public native boolean isPresent (byte[] address)      throws OneWireIOException, OneWireException;   /**    * Verifies that the iButton or 1-Wire device specified is present    * on the 1-Wire Network and in an alarm state. This does not    * affect the 'current' device state information used in searches    * (findNextDevice...).    *    * @param  address  device address to verify is present and alarming    *    * @return  <code>true</code> if device is present and alarming else    * <code>false</code>.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    *    * @see    Address    */   public native boolean isAlarming (byte[] address)      throws OneWireIOException, OneWireException;   /**    * Selects the specified iButton or 1-Wire device by broadcasting its    * address.  This operation is refered to a 'MATCH ROM' operation    * in the iButton and 1-Wire device data sheets.  This does not    * affect the 'current' device state information used in searches    * (findNextDevice...).    *    * Warning, this does not verify that the device is currently present    * on the 1-Wire Network (See isPresent).    *    * @param  address     iButton to select    *    * @return  <code>true</code> if device address was sent,<code>false</code>    * otherwise.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    *    * @see com.dalsemi.onewire.adapter.DSPortAdapter#isPresent(byte[] address)    * @see  Address    */   public native boolean select (byte[] address)      throws OneWireIOException, OneWireException;   //--------   //-------- Finding iButton/1-Wire device options    //--------   /**    * Set the 1-Wire Network search to find only iButtons and 1-Wire    * devices that are in an 'Alarm' state that signals a need for    * attention.  Not all iButton types    * have this feature.  Some that do: DS1994, DS1920, DS2407.    * This selective searching can be canceled with the    * 'setSearchAllDevices()' method.    *    * @see #setNoResetSearch    */   public void setSearchOnlyAlarmingDevices ()   {      doAlarmSearch = true;   }   /**    * Set the 1-Wire Network search to not perform a 1-Wire    * reset before a search.  This feature is chiefly used with    * the DS2409 1-Wire coupler.    * The normal reset before each search can be restored with the    * 'setSearchAllDevices()' method.    */   public void setNoResetSearch ()   {      skipResetOnSearch = true;   }   /**    * Set the 1-Wire Network search to find all iButtons and 1-Wire    * devices whether they are in an 'Alarm' state or not and    * restores the default setting of providing a 1-Wire reset    * command before each search. (see setNoResetSearch() method).    *    * @see #setNoResetSearch    */   public void setSearchAllDevices ()   {      doAlarmSearch     = false;      skipResetOnSearch = false;   }   //--------   //-------- 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 native 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 native 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 void putBit (boolean bitValue)      throws OneWireIOException, OneWireException   {      if (dataBit_Native(bitValue) != bitValue)         throw new OneWireIOException("Error during putBit()");   }   /**    * 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 boolean getBit ()      throws OneWireIOException, OneWireException   {      return dataBit_Native(true);   }   /**    * 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 void putByte (int byteValue)      throws OneWireIOException, OneWireException   {      if (dataByte_Native(byteValue & 0x00FF) != ((0x00FF) & byteValue))         throw new OneWireIOException(            "Error during putByte(), echo was incorrect ");   }   /**    * 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 int getByte ()      throws OneWireIOException, OneWireException   {      return dataByte_Native(0x00FF);   }   /**    * Get 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 byte[] getBlock (int len)      throws OneWireIOException, OneWireException   {      byte[] barr = new byte [len];      getBlock(barr, 0, len);      return barr;   }   /**    * Get 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 void getBlock (byte[] arr, int len)      throws OneWireIOException, OneWireException   {      getBlock(arr, 0, len);   }   /**    * Get 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 native 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 native 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:

⌨️ 快捷键说明

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