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

📄 dsportadapter.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    * getPortNames()    *    * @return <code>true</code> if the port was aquired, <code>false</code>    * if the port is not available.    *    * @throws OneWireIOException If port does not exist, or unable to communicate with port.    * @throws OneWireException If port does not exist    */   public abstract boolean selectPort (String portName)      throws OneWireIOException, OneWireException;   /**    * Frees ownership of the selected port, if it is currently owned, back    * to the system.  This should only be called if the recently    * selected port does not have an adapter, or at the end of    * your application's use of the port.    *    * @throws OneWireException If port does not exist    */   public abstract void freePort ()      throws OneWireException;   /**    * Retrieves the name of the selected port as a <code>String</code>.    *    * @return  <code>String</code> of selected port    *    * @throws OneWireException if valid port not yet selected    */   public abstract String getPortName ()      throws OneWireException;   //--------   //-------- Adapter detection   //--------   /**    * Detects adapter presence on the selected port.    *    * @return  <code>true</code> if the adapter is confirmed to be connected to    * the selected port, <code>false</code> if the adapter is not connected.    *    * @throws OneWireIOException    * @throws OneWireException    */   public abstract boolean adapterDetected ()      throws OneWireIOException, OneWireException;   /**    * Retrieves the version of the adapter.    *    * @return  <code>String</code> of the adapter version.  It will return    * "<na>" if the adapter version is not or cannot be known.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         no device present.  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 String getAdapterVersion ()      throws OneWireIOException, OneWireException   {      return "<na>";   }   /**    * Retrieves the address of the adapter, if it has one.    *    * @return  <code>String</code> of the adapter address.  It will return "<na>" if    * the adapter does not have an address.  The address is a string representation of an    * 1-Wire address.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         no device present.  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    * @see    Address    */   public String getAdapterAddress ()      throws OneWireIOException, OneWireException   {      return "<na>";   }   //--------   //-------- Adapter features   //--------   /* The following interogative methods are provided so that client code    * can react selectively to underlying states without generating an    * exception.    */   /**    * Returns whether adapter can physically support overdrive mode.    *    * @return  <code>true</code> if this port adapter can do OverDrive,    * <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 boolean canOverdrive ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * Returns whether the adapter can physically support hyperdrive mode.    *    * @return  <code>true</code> if this port adapter can do HyperDrive,    * <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 boolean canHyperdrive ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * 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 boolean canFlex ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * 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 boolean canProgram ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * 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 boolean canDeliverPower ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * 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 boolean canDeliverSmartPower ()      throws OneWireIOException, OneWireException   {      return false;   }   /**    * 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 boolean canBreak ()      throws OneWireIOException, OneWireException   {      return false;   }   //--------   //-------- Finding iButtons and 1-Wire devices   //--------   /**    * Returns an enumeration of <code>OneWireContainer</code> objects corresponding    * to all of the iButtons or 1-Wire devices found on the 1-Wire Network.    * If no devices are found, then an empty enumeration will be returned.    * In most cases, all further communication with the device is done    * through the OneWireContainer.    *    * @return  <code>Enumeration</code> of <code>OneWireContainer</code> objects    * found on the 1-Wire Network.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public Enumeration getAllDeviceContainers ()      throws OneWireIOException, OneWireException   {      Vector           ibutton_vector = new Vector();      OneWireContainer temp_ibutton;      temp_ibutton = getFirstDeviceContainer();      if (temp_ibutton != null)      {         ibutton_vector.addElement(temp_ibutton);         // loop to get all of the ibuttons         do         {            temp_ibutton = getNextDeviceContainer();            if (temp_ibutton != null)               ibutton_vector.addElement(temp_ibutton);         }         while (temp_ibutton != null);      }      return ibutton_vector.elements();   }   /**    * Returns a <code>OneWireContainer</code> object corresponding to the first iButton    * or 1-Wire device found on the 1-Wire Network. If no devices are found,    * then a <code>null</code> reference will be returned. In most cases, all further    * communication with the device is done through the <code>OneWireContainer</code>.    *    * @return  The first <code>OneWireContainer</code> object found on the    * 1-Wire Network, or <code>null</code> if no devices found.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public OneWireContainer getFirstDeviceContainer ()      throws OneWireIOException, OneWireException   {      if (findFirstDevice() == true)      {         return getDeviceContainer();      }      else         return null;   }   /**    * Returns a <code>OneWireContainer</code> object corresponding to the next iButton    * or 1-Wire device found. The previous 1-Wire device found is used    * as a starting point in the search.  If no devices are found,    * then a <code>null</code> reference will be returned. In most cases, all further    * communication with the device is done through the <code>OneWireContainer</code>.    *    * @return  The next <code>OneWireContainer</code> object found on the    * 1-Wire Network, or <code>null</code> if no iButtons found.    *    * @throws OneWireIOException on a 1-Wire communication error    * @throws OneWireException on a setup error with the 1-Wire adapter    */   public OneWireContainer getNextDeviceContainer ()      throws OneWireIOException, OneWireException   {      if (findNextDevice() == true)      {         return getDeviceContainer();      }      else         return null;   }   /**    * 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 abstract boolean findFirstDevice ()      throws OneWireIOException, OneWireException;   /**    * 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 abstract boolean findNextDevice ()      throws OneWireIOException, OneWireException;   /**    * Copies the 'current' 1-Wire device 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 abstract void getAddress (byte[] address);   /**    * Gets the 'current' 1-Wire device address being used by the adapter as a long.    * This address is the last iButton or 1-Wire device found    * in a search (findNextDevice()...).    *    * @return <code>long</code> representation of the iButton address    * @see    Address    */   public long getAddressAsLong ()   {      byte[] address = new byte [8];      getAddress(address);      return Address.toLong(address);   }   /**    * Gets the 'current' 1-Wire device address being used by the adapter as a String.    * This address is the last iButton or 1-Wire device found    * in a search (findNextDevice()...).    *    * @return <code>String</code> representation of the iButton address    * @see    Address    */   public String getAddressAsString ()   {      byte[] address = new byte [8];      getAddress(address);

⌨️ 快捷键说明

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