onewirecontainer37.java
来自「这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统」· Java 代码 · 共 968 行 · 第 1/3 页
JAVA
968 行
initMem(); } /** * 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, String newAddress) { super.setupContainer(sourceAdapter, newAddress); // initialize the memory banks initMem(); }// *****************************************************************************// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Container Functions// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// ***************************************************************************** /** * Gets an enumeration of memory bank instances that implement one or more * of the following interfaces: * {@link com.dalsemi.onewire.container.MemoryBank MemoryBank}, * {@link com.dalsemi.onewire.container.PagedMemoryBank PagedMemoryBank}, * and {@link com.dalsemi.onewire.container.OTPMemoryBank OTPMemoryBank}. * @return <CODE>Enumeration</CODE> of memory banks */ public Enumeration getMemoryBanks () { Vector v = new Vector(3); v.addElement(scratch); v.addElement(userDataMemory); v.addElement(register); return v.elements(); } /** * Returns the maximum speed this iButton device can * communicate at. * * @return maximum speed * @see DSPortAdapter#setSpeed */ public int getMaxSpeed () { return DSPortAdapter.SPEED_OVERDRIVE; } /** * Gets the Dallas Semiconductor part number of the iButton * or 1-Wire Device as a <code>java.lang.String</code>. * For example "DS1977". * * @return iButton or 1-Wire device name */ public String getName () { return partNumber; } /** * Retrieves the alternate Dallas Semiconductor part numbers or names. * A 'family' of MicroLAN devices may have more than one part number * depending on packaging. There can also be nicknames such as * "Crypto iButton". * * @return the alternate names for this iButton or 1-Wire device */ public String getAlternateNames () { return ""; } /** * Gets a short description of the function of this iButton * or 1-Wire Device type. * * @return device description */ public String getDescription () { return descriptionString; } /** * Directs the container to avoid the calls to doSpeed() in methods that communicate * with the Thermocron. To ensure that all parts can talk to the 1-Wire bus * at their desired speed, each method contains a call * to <code>doSpeed()</code>. However, this is an expensive operation. * If a user manages the bus speed in an * application, call this method with <code>doSpeedCheck</code> * as <code>false</code>. The default behavior is * to call <code>doSpeed()</code>. * * @param doSpeedCheck <code>true</code> for <code>doSpeed()</code> to be called before every * 1-Wire bus access, <code>false</code> to skip this expensive call * * @see OneWireContainer#doSpeed() */ public synchronized void setSpeedCheck (boolean doSpeedCheck) { doSpeedEnable = doSpeedCheck; }// *****************************************************************************// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Read/Write Password Functions// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// ***************************************************************************** /** * Retrieves the password length for the read-only password. * * @return the read-only password length * * @throws OneWireException */ public int getReadOnlyPasswordLength() throws OneWireException { return PASSWORD_LENGTH; } /** * Retrieves the password length for the read/write password. * * @return the read/write password length * * @throws OneWireException */ public int getReadWritePasswordLength() throws OneWireException { return PASSWORD_LENGTH; } /** * Retrieves the password length for the write-only password. * * @return the write-only password length * * @throws OneWireException */ public int getWriteOnlyPasswordLength() throws OneWireException { throw new OneWireException("The DS1977 does not have a write password."); } /** * Retrieves the address the read only password starts * * @return the address of the read only password */ public int getReadOnlyPasswordAddress() throws OneWireException { return READ_ACCESS_PASSWORD; } /** * Retrieves the address the read/write password starts * * @return the address of the read/write password */ public int getReadWritePasswordAddress() throws OneWireException { return READ_WRITE_ACCESS_PASSWORD; } /** * Retrieves the address the write only password starts * * @return the address of the write only password */ public int getWriteOnlyPasswordAddress() throws OneWireException { throw new OneWireException("The DS1977 does not have a write password."); } /** * Tells whether the device has a read only password. * * @return if the device has a read only password */ public boolean hasReadOnlyPassword() { return true; } /** * Tells whether the device has a read/write password. * * @return if the device has a read/write password */ public boolean hasReadWritePassword() { return true; } /** * Tells whether the device has a write only password. * * @return if the device has a write only password */ public boolean hasWriteOnlyPassword() { return false; } /** * Tells whether the read only password has been enabled. * * @return the enabled status of the read only password * * @throws OneWireException */ public boolean getDeviceReadOnlyPasswordEnable() throws OneWireException { return readOnlyPasswordEnabled; } /** * Tells whether the read/write password has been enabled. * * @return the enabled status of the read/write password * * @throws OneWireException */ public boolean getDeviceReadWritePasswordEnable() throws OneWireException { return readWritePasswordEnabled; } /** * Tells whether the write only password has been enabled. * * @return the enabled status of the write only password * * @throws OneWireException */ public boolean getDeviceWriteOnlyPasswordEnable() throws OneWireException { throw new OneWireException("The DS1977 does not have a Write Only Password."); } /** * Returns true if this device has the capability to enable one type of password * while leaving another type disabled. i.e. if the device has Read-Only password * protection and Write-Only password protection, this method indicates whether or * not you can enable Read-Only protection while leaving the Write-Only protection * disabled. * * @return <code>true</code> if the device has the capability to enable one type * of password while leaving another type disabled. */ public boolean hasSinglePasswordEnable() { return false; } /** * <p>Enables/Disables passwords for this device. If the part has more than one * type of password (Read-Only, Write-Only, or Read/Write), all passwords * will be enabled. This function is equivalent to the following: * <code> owc37.setDevicePasswordEnable( * owc37.hasReadOnlyPassword(), * owc37.hasReadWritePassword(), * owc37.hasWriteOnlyPassword() ); </code></p> * * <p>For this to be successful, either write-protect passwords must be disabled, * or the write-protect password(s) for this container must be set and must match * the value of the write-protect password(s) in the device's register.</P> * * <P><B> * WARNING: Enabling passwords requires that both the read password and the * read/write password be re-written to the part. Before calling this method, * you should set the container read password and read/write password values. * This will ensure that the correct value is written into the part. * </B></P> * * @param enableAll if <code>true</code>, all passwords are enabled. Otherwise, * all passwords are disabled. */ public void setDevicePasswordEnableAll(boolean enableAll) throws OneWireException, OneWireIOException { setDevicePasswordEnable(enableAll, enableAll, false); } /** * Attempts to change the value of the read password in the device's * register. For this to be successful, either passwords must be disabled, * or the read/write password for this container must be set and must match * the value of the read/write password in the device's register. * * <P><B> * WARNING: Setting the read password requires that both the read password * and the read/write password be written to the part. Before calling this * method, you should set the container read/write password value. * This will ensure that the correct value is written into the part. * </B></P> * * @param password the new value of 8-byte device read password, to be copied * into the devices register. * @param offset the offset to start copying the 8 bytes from the array */ public void setDeviceReadOnlyPassword(byte[] password, int offset) throws OneWireException, OneWireIOException
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?