|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.adapter.DSPortAdapter | +--com.dalsemi.onewire.adapter.DumbAdapter
This DSPortAdapter
class was designed to be used for
the iB-IDE's emulator. The DumbAdapter
allows
programmers to add and remove OneWireContainer
objects that will be found in its search. The Java iButton
emulator works by creating a class that subclasses all of
OneWireContainer16
's relevant methods and redirecting them
to the emulation code. That object is then added to this class's
list of OneWireContainer
s.
Note that methods such as selectPort
and
beginExclusive
by default do nothing. This class is
mainly meant for debugging using an emulated iButton. It will do
a poor job of debugging any multi-threading, port-sharing issues.
DSPortAdapter
,
OneWireContainer
Fields inherited from class com.dalsemi.onewire.adapter.DSPortAdapter |
CONDITION_AFTER_BIT, CONDITION_AFTER_BYTE, CONDITION_NOW, DELIVERY_CURRENT_DETECT, DELIVERY_EPROM, DELIVERY_FOUR_SECONDS, DELIVERY_HALF_SECOND, DELIVERY_INFINITE, DELIVERY_ONE_SECOND, DELIVERY_SMART_DONE, DELIVERY_TWO_SECONDS, LEVEL_BREAK, LEVEL_NORMAL, LEVEL_POWER_DELIVERY, LEVEL_PROGRAM, RESET_ALARM, RESET_NOPRESENCE, RESET_PRESENCE, RESET_SHORT, SPEED_FLEX, SPEED_HYPERDRIVE, SPEED_OVERDRIVE, SPEED_REGULAR |
Constructor Summary | |
DumbAdapter()
|
Method Summary | |
boolean |
adapterDetected()
Detects adapter presence on the selected port. |
void |
addContainer(OneWireContainer c)
Adds a OneWireContainer to the list of containers that
this adapter object will find. |
boolean |
beginExclusive(boolean blocking)
This method does nothing in DumbAdapter . |
boolean |
canBreak()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canDeliverPower()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canDeliverSmartPower()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canFlex()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canHyperdrive()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canOverdrive()
Applications might check this method and not attempt operation unless this method returns true . |
boolean |
canProgram()
Applications might check this method and not attempt operation unless this method returns true . |
void |
dataBlock(byte[] dataBlock,
int off,
int len)
This method does nothing in DumbAdapter . |
void |
endExclusive()
This method does nothing in DumbAdapter . |
void |
excludeFamily(byte[] family)
This method does nothing in DumbAdapter . |
void |
excludeFamily(int family)
This method does nothing in DumbAdapter . |
boolean |
findFirstDevice()
Returns true if the first iButton or 1-Wire device
is found on the 1-Wire Network. |
boolean |
findNextDevice()
Returns true if the next iButton or 1-Wire device
is found. |
void |
freePort()
This method does nothing in DumbAdapter . |
String |
getAdapterName()
Retrieves the name of the port adapter as a string. |
void |
getAddress(byte[] address)
Copies the 'current' 1-Wire device address being used by the adapter into the array. |
long |
getAddressAsLong()
Gets the 'current' 1-Wire device address being used by the adapter as a long. |
String |
getAddressAsString()
Gets the 'current' 1-Wire device address being used by the adapter as a String. |
Enumeration |
getAllDeviceContainers()
Returns an enumeration of OneWireContainer objects corresponding
to all of the iButtons or 1-Wire devices found on the 1-Wire Network. |
boolean |
getBit()
Gets a bit from the 1-Wire Network. |
void |
getBlock(byte[] arr,
int len)
This method does nothing in DumbAdapter . |
void |
getBlock(byte[] arr,
int off,
int len)
This method does nothing in DumbAdapter . |
byte[] |
getBlock(int len)
This method does nothing in DumbAdapter . |
int |
getByte()
This method does nothing in DumbAdapter . |
String |
getClassVersion()
Retrieves a version string for this class. |
OneWireContainer |
getDeviceContainer()
Returns a OneWireContainer object using the current 1-Wire network address. |
OneWireContainer |
getDeviceContainer(byte[] address)
Gets the container from this adapter whose address matches the address of a container in the DumbAdapter 's internal java.util.Vector . |
OneWireContainer |
getDeviceContainer(long address)
Gets the container from this adapter whose address matches the address of a container in the DumbAdapter 's internal java.util.Vector . |
OneWireContainer |
getDeviceContainer(String address)
Gets the container from this adapter whose address matches the address of a container in the DumbAdapter 's internal java.util.Vector . |
OneWireContainer |
getFirstDeviceContainer()
Returns a OneWireContainer object corresponding to the first iButton
or 1-Wire device found on the 1-Wire Network. |
OneWireContainer |
getNextDeviceContainer()
Returns a OneWireContainer object corresponding to the next iButton
or 1-Wire device found. |
String |
getPortName()
Retrieves the name of the selected port as a String . |
Enumeration |
getPortNames()
Retrieves a list of the platform appropriate port names for this adapter. |
String |
getPortTypeDescription()
Retrieves a description of the port required by this port adapter. |
int |
getSpeed()
This method does nothing in DumbAdapter . |
boolean |
isAlarming(byte[] address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. |
boolean |
isAlarming(long address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. |
boolean |
isAlarming(String address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. |
boolean |
isPresent(byte[] address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. |
boolean |
isPresent(long address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. |
boolean |
isPresent(String address)
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. |
void |
putBit(boolean bitValue)
Sends a bit to the 1-Wire Network. |
void |
putByte(int byteValue)
This method does nothing in DumbAdapter . |
void |
registerOneWireContainerClass(int family,
Class OneWireContainerClass)
This method does nothing in DumbAdapter . |
void |
removeContainer(OneWireContainer c)
Removes a OneWireContainer from the list of containers that
this adapter object will find. |
int |
reset()
Sends a Reset to the 1-Wire Network. |
boolean |
select(byte[] address)
Selects the specified iButton or 1-Wire device by broadcasting its address. |
boolean |
select(long address)
Selects the specified iButton or 1-Wire device by broadcasting its address. |
boolean |
select(String address)
Selects the specified iButton or 1-Wire device by broadcasting its address. |
boolean |
selectPort(String portName)
This method does nothing in DumbAdapter . |
void |
setNoResetSearch()
This method does nothing in DumbAdapter . |
void |
setPowerDuration(int timeFactor)
This method does nothing in DumbAdapter . |
void |
setPowerNormal()
This method does nothing in DumbAdapter . |
void |
setProgramPulseDuration(int timeFactor)
This method does nothing in DumbAdapter . |
void |
setSearchAllDevices()
This method does nothing in DumbAdapter . |
void |
setSearchOnlyAlarmingDevices()
This method does nothing in DumbAdapter . |
void |
setSpeed(int speed)
This method does nothing in DumbAdapter . |
void |
startBreak()
This method does nothing in DumbAdapter . |
boolean |
startPowerDelivery(int changeCondition)
This method does nothing in DumbAdapter . |
boolean |
startProgramPulse(int changeCondition)
This method does nothing in DumbAdapter . |
void |
targetAllFamilies()
This method does nothing in DumbAdapter . |
void |
targetFamily(byte[] family)
This method does nothing in DumbAdapter . |
void |
targetFamily(int family)
This method does nothing in DumbAdapter . |
Methods inherited from class com.dalsemi.onewire.adapter.DSPortAdapter |
getAdapterAddress, getAdapterVersion |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DumbAdapter()
Method Detail |
public void addContainer(OneWireContainer c)
OneWireContainer
to the list of containers that
this adapter object will find.c
- represents a 1-Wire device that this adapter will report from a searchpublic void removeContainer(OneWireContainer c)
OneWireContainer
from the list of containers that
this adapter object will find.c
- represents a 1-Wire device that this adapter should no longer
report as found by a searchpublic String getAdapterName()
getAdapterName
in class DSPortAdapter
String
representation of the port adapter.public String getPortTypeDescription()
getPortTypeDescription
in class DSPortAdapter
String
description of the port type required.public String getClassVersion()
getClassVersion
in class DSPortAdapter
public Enumeration getPortNames()
OneWireException
exception.getPortNames
in class DSPortAdapter
Enumeration
of type String
that contains the port
namespublic void registerOneWireContainerClass(int family, Class OneWireContainerClass)
DumbAdapter
.registerOneWireContainerClass
in class DSPortAdapter
com.dalsemi.onewire.adapter.DSPortAdapter
family
- the code of the family type to associate with this class.OneWireContainerClass
- User provided classOneWireException
- If OneWireContainerClass
is not found.ClassCastException
- If user supplied OneWireContainer
does not
extend com.dalsemi.onewire.container.OneWireContainer
.public boolean selectPort(String portName)
DumbAdapter
.selectPort
in class DSPortAdapter
portName
- name of the target port, retrieved from
getPortNames()true
public void freePort()
DumbAdapter
.freePort
in class DSPortAdapter
com.dalsemi.onewire.adapter.DSPortAdapter
OneWireException
- If port does not existpublic String getPortName()
String
.getPortName
in class DSPortAdapter
String
"NULL0"public boolean adapterDetected()
DumbAdapter
,
the adapter is always detected.adapterDetected
in class DSPortAdapter
true
public boolean canOverdrive()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canOverdrive
in class DSPortAdapter
true
public boolean canHyperdrive()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canHyperdrive
in class DSPortAdapter
true
public boolean canFlex()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canFlex
in class DSPortAdapter
true
public boolean canProgram()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canProgram
in class DSPortAdapter
true
public boolean canDeliverPower()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canDeliverPower
in class DSPortAdapter
true
public boolean canDeliverSmartPower()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canDeliverSmartPower
in class DSPortAdapter
true
public boolean canBreak()
true
. To make sure that a wide variety of applications can use this class,
this method always returns true
.canBreak
in class DSPortAdapter
true
public Enumeration getAllDeviceContainers()
OneWireContainer
objects corresponding
to all of the iButtons or 1-Wire devices found on the 1-Wire Network. In the case of
the DumbAdapter
, this method returns a simple copy of the internal
java.util.Vector
that stores all the 1-Wire devices this class finds
in a search.getAllDeviceContainers
in class DSPortAdapter
Enumeration
of OneWireContainer
objects
found on the 1-Wire Network.public OneWireContainer getFirstDeviceContainer()
OneWireContainer
object corresponding to the first iButton
or 1-Wire device found on the 1-Wire Network. If no devices are found,
then a null
reference will be returned. In most cases, all further
communication with the device is done through the OneWireContainer
.getFirstDeviceContainer
in class DSPortAdapter
OneWireContainer
object found on the
1-Wire Network, or null
if no devices found.public OneWireContainer getNextDeviceContainer()
OneWireContainer
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 null
reference will be returned. In most cases, all further
communication with the device is done through the OneWireContainer
.getNextDeviceContainer
in class DSPortAdapter
OneWireContainer
object found on the
1-Wire Network, or null
if no iButtons found.public boolean findFirstDevice()
true
if the first iButton or 1-Wire device
is found on the 1-Wire Network.
If no devices are found, then false
will be returned.findFirstDevice
in class DSPortAdapter
true
if an iButton or 1-Wire device is found.public boolean findNextDevice()
true
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 false
will be returned.findNextDevice
in class DSPortAdapter
true
if an iButton or 1-Wire device is found.public void getAddress(byte[] address)
getAddress
in class DSPortAdapter
address
- An array to be filled with the current iButton address.Address
public long getAddressAsLong()
getAddressAsLong
in class DSPortAdapter
long
representation of the iButton addressAddress
public String getAddressAsString()
getAddressAsString
in class DSPortAdapter
String
representation of the iButton addressAddress
public boolean isPresent(byte[] address)
isPresent
in class DSPortAdapter
address
- device address to verify is presenttrue
if device is present, else
false
.Address
public boolean isPresent(long address)
isPresent
in class DSPortAdapter
address
- device address to verify is presenttrue
if device is present, else
false
.Address
public boolean isPresent(String address)
isPresent
in class DSPortAdapter
address
- device address to verify is presenttrue
if device is present, else
false
.Address
public boolean isAlarming(byte[] address)
DumbAdapter
.isAlarming
in class DSPortAdapter
address
- device address to verify is present and alarmingfalse
Address
public boolean isAlarming(long address)
DumbAdapter
.isAlarming
in class DSPortAdapter
address
- device address to verify is present and alarmingfalse
Address
public boolean isAlarming(String address)
DumbAdapter
.isAlarming
in class DSPortAdapter
address
- device address to verify is present and alarmingfalse
Address
public boolean select(byte[] address)
DumbAdapter
, this method simply
returns true.
Warning, this does not verify that the device is currently present
on the 1-Wire Network (See isPresent).select
in class DSPortAdapter
address
- address of iButton or 1-Wire device to selecttrue
if device address was sent, false
otherwise.isPresent(byte[])
,
Address
public boolean select(long address) throws OneWireIOException, OneWireException
DumbAdapter
, this method simply
returns true.
Warning, this does not verify that the device is currently present
on the 1-Wire Network (See isPresent).select
in class DSPortAdapter
address
- address of iButton or 1-Wire device to selecttrue
if device address was sent, false
otherwise.isPresent(byte[])
,
Address
public boolean select(String address) throws OneWireIOException, OneWireException
DumbAdapter
, this method simply
returns true.
Warning, this does not verify that the device is currently present
on the 1-Wire Network (See isPresent).select
in class DSPortAdapter
address
- address of iButton or 1-Wire device to selecttrue
if device address was sent, false
otherwise.isPresent(byte[])
,
Address
public void setSearchOnlyAlarmingDevices()
DumbAdapter
.setSearchOnlyAlarmingDevices
in class DSPortAdapter
setNoResetSearch()
public void setNoResetSearch()
DumbAdapter
.setNoResetSearch
in class DSPortAdapter
public void setSearchAllDevices()
DumbAdapter
.setSearchAllDevices
in class DSPortAdapter
setNoResetSearch()
public void targetAllFamilies()
DumbAdapter
.targetAllFamilies
in class DSPortAdapter
targetFamily(int)
,
targetFamily(byte[])
,
excludeFamily(int)
,
excludeFamily(byte[])
public void targetFamily(int family)
DumbAdapter
.targetFamily
in class DSPortAdapter
family
- the code of the family type to target for searchesAddress
,
targetAllFamilies()
public void targetFamily(byte[] family)
DumbAdapter
.targetFamily
in class DSPortAdapter
family
- array of the family types to target for searchesAddress
,
targetAllFamilies()
public void excludeFamily(int family)
DumbAdapter
.excludeFamily
in class DSPortAdapter
family
- the code of the family type NOT to target in searchesAddress
,
targetAllFamilies()
public void excludeFamily(byte[] family)
DumbAdapter
.excludeFamily
in class DSPortAdapter
family
- array of family cods NOT to target for searchesAddress
,
targetAllFamilies()
public boolean beginExclusive(boolean blocking)
DumbAdapter
.beginExclusive
in class DSPortAdapter
blocking
- true
if want to block waiting
for an excluse access to the adaptertrue
public void endExclusive()
DumbAdapter
.endExclusive
in class DSPortAdapter
public void putBit(boolean bitValue)
DumbAdapter
.putBit
in class DSPortAdapter
bitValue
- the bit value to send to the 1-Wire Network.public boolean getBit()
DumbAdapter
.getBit
in class DSPortAdapter
true
public void putByte(int byteValue)
DumbAdapter
.putByte
in class DSPortAdapter
byteValue
- the byte value to send to the 1-Wire Network.public int getByte()
DumbAdapter
.getByte
in class DSPortAdapter
public byte[] getBlock(int len)
DumbAdapter
.getBlock
in class DSPortAdapter
len
- length of data bytes to receivelen
public void getBlock(byte[] arr, int len)
DumbAdapter
.getBlock
in class DSPortAdapter
arr
- array in which to write the received byteslen
- length of data bytes to receivepublic void getBlock(byte[] arr, int off, int len)
DumbAdapter
.getBlock
in class DSPortAdapter
arr
- array in which to write the received bytesoff
- offset into the array to startlen
- length of data bytes to receivepublic void dataBlock(byte[] dataBlock, int off, int len)
DumbAdapter
.dataBlock
in class DSPortAdapter
dataBlock
- array of data to transfer to and from the 1-Wire Network.off
- offset into the array of data to startlen
- length of data to send / receive starting at 'off'public int reset()
reset
in class DSPortAdapter
DumbAdapter
, the only possible results are 0 and 1.public void setPowerDuration(int timeFactor)
DumbAdapter
.setPowerDuration
in class DSPortAdapter
timeFactor
- public boolean startPowerDelivery(int changeCondition)
DumbAdapter
.startPowerDelivery
in class DSPortAdapter
changeCondition
- true
public void setProgramPulseDuration(int timeFactor)
DumbAdapter
.setProgramPulseDuration
in class DSPortAdapter
timeFactor
- public boolean startProgramPulse(int changeCondition)
DumbAdapter
.startProgramPulse
in class DSPortAdapter
changeCondition
- true
public void startBreak()
DumbAdapter
.startBreak
in class DSPortAdapter
com.dalsemi.onewire.adapter.DSPortAdapter
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
or the adapter does not support this operationpublic void setPowerNormal()
DumbAdapter
.setPowerNormal
in class DSPortAdapter
com.dalsemi.onewire.adapter.DSPortAdapter
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
or the adapter does not support this operationpublic void setSpeed(int speed)
DumbAdapter
.setSpeed
in class DSPortAdapter
speed
- public int getSpeed()
DumbAdapter
.getSpeed
in class DSPortAdapter
public OneWireContainer getDeviceContainer(byte[] address)
DumbAdapter
's internal java.util.Vector
.getDeviceContainer
in class DSPortAdapter
address
- device address with which to find a containerOneWireContainer
object, or null
if no match could be found.Address
public OneWireContainer getDeviceContainer(long address)
DumbAdapter
's internal java.util.Vector
.getDeviceContainer
in class DSPortAdapter
address
- device address with which to find a containerOneWireContainer
object, or null
if no match could be found.Address
public OneWireContainer getDeviceContainer(String address)
DumbAdapter
's internal java.util.Vector
.getDeviceContainer
in class DSPortAdapter
address
- device address with which to find a containerOneWireContainer
object, or null
if no match could be found.Address
public OneWireContainer getDeviceContainer()
OneWireContainer
object using the current 1-Wire network address.
The internal state of the port adapter keeps track of the last
address found and is able to create container objects from this
state.getDeviceContainer
in class DSPortAdapter
OneWireContainer
object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |