Class OneWireContainer1F
- java.lang.Object
-
- com.dalsemi.onewire.container.OneWireContainer
-
- com.dalsemi.onewire.container.OneWireContainer1F
-
- All Implemented Interfaces:
OneWireSensor
,SwitchContainer
public class OneWireContainer1F extends OneWireContainer implements SwitchContainer
1-Wire® container for 1-Wire(MicroLAN) Coupler, DS2409. This container encapsulates the functionality of the 1-Wire family type 1F (hex).
Features
- Low impedance coupler to create large common-ground, multi-level MicroLAN networks
- Keeps inactive branches pulled high to 5V
- Simplifies network topology analysis by logically decoupling devices on active network segments
- Conditional search for fast event signaling
- Auxiliary 1-Wire TM line to connect a memory chip or to be used as digital input
- Programmable, general purpose open drain control output
- Operating temperature range from -40@htmlonly °C @endhtmlonly to +85@htmlonly °C @endhtmlonly
- Compact, low cost 6-pin TSOC surface mount package
Setting the latch on the DS2409 to 'on' (see
seLatchState
) connects the channel [Main(0) or Auxiliary(1)] to the 1-Wire data line. Note that this is the opposite of theDS2406
andDS2405
which connect their I/O lines to ground.Usage
- See the usage example in
SwitchContainer
for basic switch operations.
DataSheet
- See Also:
OneWireSensor
,SwitchContainer
,OneWireContainer05
,OneWireContainer12
-
-
Field Summary
Fields Modifier and Type Field Description protected static byte
ALL_LINES_OFF_COMMAND
All lines off command.protected static int
AUX_OFFSET
Offset of Main channel flag in array returned from read state.protected static int
BITMAP_OFFSET
Offset of BITMAP in array returned from read state.static int
CHANNEL_AUX
Aux Channel number.static int
CHANNEL_MAIN
Main Channel number.protected static byte
DIRECT_ON_MAIN_COMMAND
Direct on main command.protected static byte
DISCHARGE_COMMAND
Discharge command.protected static int
MAIN_OFFSET
Offset of Main channel flag in array returned from read state.protected static byte
READ_WRITE_STATUS_COMMAND
Read Write Status register command.protected static byte
SMART_ON_AUX_COMMAND
Smart on aux command.protected static byte
SMART_ON_MAIN_COMMAND
Smart on main command.protected static int
STATUS_OFFSET
Offset of Status in array returned from read state.protected static int
SWITCH_OFF
Channel flag to indicate turn off.protected static int
SWITCH_ON
Channel flag to indicate turn on.protected static int
SWITCH_SMART
Channel flag to indicate smart on.-
Fields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
-
-
Constructor Summary
Constructors Constructor Description OneWireContainer1F()
Create an empty container that is not complete until after a call tosetupContainer
.OneWireContainer1F(DSPortAdapter sourceAdapter, byte[] newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.OneWireContainer1F(DSPortAdapter sourceAdapter, long newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.OneWireContainer1F(DSPortAdapter sourceAdapter, java.lang.String newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearActivity()
Clears the activity latches the next time possible.void
dischargeLines(int time)
Force a power-on reset for parasitically powered 1-Wire devices connected to the main or auziliary output of the DS2409.java.lang.String
getAlternateNames()
Gets the alternate Maxim Integrated Products part numbers or names.int
getControlChannelAssociation(byte[] state)
Checks the channel association of the control pin.int
getControlData(byte[] state)
Checks the control data value.java.lang.String
getDescription()
Gets a short description of the function of this iButton or 1-Wire Device type.boolean
getLastSmartOnDeviceDetect()
Gets flag that indicates if a device was present when doing the last smart on.boolean
getLatchState(int channel, byte[] state)
Checks the latch state of the indicated channel.boolean
getLevel(int channel, byte[] state)
Checks the sensed level on the indicated channel.java.lang.String
getName()
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string.int
getNumberChannels(byte[] state)
Query to get the number of channels supported by this switch.boolean
getSensedActivity(int channel, byte[] state)
Checks if the indicated channel has experienced activity.boolean
hasActivitySensing()
Checks to see if the channels of this switch support activity sensing.boolean
hasLevelSensing()
Checks to see if the channels of this switch support level sensing.boolean
hasSmartOn()
Checks to see if the channels of this switch support 'smart on'.boolean
isHighSideSwitch()
Checks to see if the channels of this switch are 'high side' switches.boolean
isModeAuto(byte[] state)
Checks if the control I/O pin mode is automatic (see DS2409 data sheet).boolean
onlySingleChannelOn()
Checks to see if the channels of this switch require that only one channel is on at any one time.byte[]
readDevice()
Retrieves the 1-Wire device sensor state.void
setControlChannelAssociation(int channel, byte[] state)
Sets the control pin channel association.void
setControlData(boolean data, byte[] state)
Sets the control pin data to a value.void
setLatchState(int channel, boolean latchState, boolean doSmart, byte[] state)
Sets the latch state of the indicated channel.void
setModeAuto(boolean makeAuto, byte[] state)
Sets the control pin mode.void
setSpeedCheck(boolean doSpeedCheck)
Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron.void
writeDevice(byte[] state)
Writes the 1-Wire device sensor state that have been changed by 'set' methods.-
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
-
-
-
Field Detail
-
BITMAP_OFFSET
protected static final int BITMAP_OFFSET
Offset of BITMAP in array returned from read state.- See Also:
- Constant Field Values
-
STATUS_OFFSET
protected static final int STATUS_OFFSET
Offset of Status in array returned from read state.- See Also:
- Constant Field Values
-
MAIN_OFFSET
protected static final int MAIN_OFFSET
Offset of Main channel flag in array returned from read state.- See Also:
- Constant Field Values
-
AUX_OFFSET
protected static final int AUX_OFFSET
Offset of Main channel flag in array returned from read state.- See Also:
- Constant Field Values
-
SWITCH_OFF
protected static final int SWITCH_OFF
Channel flag to indicate turn off.- See Also:
- Constant Field Values
-
SWITCH_ON
protected static final int SWITCH_ON
Channel flag to indicate turn on.- See Also:
- Constant Field Values
-
SWITCH_SMART
protected static final int SWITCH_SMART
Channel flag to indicate smart on.- See Also:
- Constant Field Values
-
READ_WRITE_STATUS_COMMAND
protected static final byte READ_WRITE_STATUS_COMMAND
Read Write Status register command.- See Also:
- Constant Field Values
-
ALL_LINES_OFF_COMMAND
protected static final byte ALL_LINES_OFF_COMMAND
All lines off command.- See Also:
- Constant Field Values
-
DISCHARGE_COMMAND
protected static final byte DISCHARGE_COMMAND
Discharge command.- See Also:
- Constant Field Values
-
DIRECT_ON_MAIN_COMMAND
protected static final byte DIRECT_ON_MAIN_COMMAND
Direct on main command.- See Also:
- Constant Field Values
-
SMART_ON_MAIN_COMMAND
protected static final byte SMART_ON_MAIN_COMMAND
Smart on main command.- See Also:
- Constant Field Values
-
SMART_ON_AUX_COMMAND
protected static final byte SMART_ON_AUX_COMMAND
Smart on aux command.- See Also:
- Constant Field Values
-
CHANNEL_MAIN
public static final int CHANNEL_MAIN
Main Channel number.- See Also:
- Constant Field Values
-
CHANNEL_AUX
public static final int CHANNEL_AUX
Aux Channel number.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OneWireContainer1F
public OneWireContainer1F()
Create an empty container that is not complete until after a call tosetupContainer
.This is one of the methods to construct a container. The others are through creating a OneWireContainer with parameters.
- See Also:
super.setupContainer()
-
OneWireContainer1F
public OneWireContainer1F(DSPortAdapter sourceAdapter, byte[] newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this iButtonnewAddress
-Address
of this 1-Wire device- See Also:
OneWireContainer1F
,utils.Address
-
OneWireContainer1F
public OneWireContainer1F(DSPortAdapter sourceAdapter, long newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this 1-Wire devicenewAddress
-Address
of this 1-Wire device- See Also:
OneWireContainer1F
,utils.Address
-
OneWireContainer1F
public OneWireContainer1F(DSPortAdapter sourceAdapter, java.lang.String newAddress)
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this 1-Wire devicenewAddress
-Address
of this 1-Wire device- See Also:
OneWireContainer1F
,utils.Address
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string. For example 'DS1992'.- Overrides:
getName
in classOneWireContainer
- Returns:
- iButton or 1-Wire device name
-
getAlternateNames
public java.lang.String getAlternateNames()
Gets the alternate Maxim Integrated Products part numbers or names. A 'family' of 1-Wire Network devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.- Overrides:
getAlternateNames
in classOneWireContainer
- Returns:
- 1-Wire device alternate names
-
getDescription
public java.lang.String getDescription()
Gets a short description of the function of this iButton or 1-Wire Device type.- Overrides:
getDescription
in classOneWireContainer
- Returns:
- device description
-
setSpeedCheck
public void setSpeedCheck(boolean doSpeedCheck)
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 todoSpeed()
. However, this is an expensive operation. If a user manages the bus speed in an application, call this method withdoSpeedCheck
asfalse
. The default behavior is to calldoSpeed()
.- Parameters:
doSpeedCheck
-true
fordoSpeed()
to be called before every 1-Wire bus access,false
to skip this expensive call- See Also:
OneWireContainer.doSpeed()
-
readDevice
public byte[] readDevice() throws OneWireIOException, OneWireException
Retrieves the 1-Wire device sensor state. This state is returned as a byte array. Pass this byte array to the 'get' and 'set' methods. If the device state needs to be changed then call the 'writeDevice' to finalize the changes.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
- 1-Wire device sensor state
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. 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'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
writeDevice
public void writeDevice(byte[] state) throws OneWireIOException, OneWireException
Writes the 1-Wire device sensor state that have been changed by 'set' methods. Only the state registers that changed are updated. This is done by referencing a field information appended to the state data.- Specified by:
writeDevice
in interfaceOneWireSensor
- Parameters:
state
- 1-Wire device sensor state- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. 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'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
dischargeLines
public void dischargeLines(int time) throws OneWireIOException, OneWireException
Force a power-on reset for parasitically powered 1-Wire devices connected to the main or auziliary output of the DS2409.
IMPORTANT: the duration of the discharge time should be 100ms minimum.
- Parameters:
time
- number of milliseconds the lines are to be discharged for (minimum 100)- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. 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'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
isHighSideSwitch
public boolean isHighSideSwitch()
Checks to see if the channels of this switch are 'high side' switches. This indicates that when 'on' ortrue
, the switch output is connect to the 1-Wire data. If this method returnsfalse
then when the switch is 'on' ortrue
, the switch is connected to ground.- Specified by:
isHighSideSwitch
in interfaceSwitchContainer
- Returns:
true
if the switch is a 'high side' switch,false
if the switch is a 'low side' switch- See Also:
getLatchState(int,byte[])
-
hasActivitySensing
public boolean hasActivitySensing()
Checks to see if the channels of this switch support activity sensing. If this method returnstrue
then the methodgetSensedActivity(int,byte[])
can be used.- Specified by:
hasActivitySensing
in interfaceSwitchContainer
- Returns:
true
if channels support activity sensing- See Also:
getSensedActivity(int,byte[])
,clearActivity()
-
hasLevelSensing
public boolean hasLevelSensing()
Checks to see if the channels of this switch support level sensing. If this method returnstrue
then the methodgetLevel(int,byte[])
can be used.- Specified by:
hasLevelSensing
in interfaceSwitchContainer
- Returns:
true
if channels support level sensing- See Also:
getLevel(int,byte[])
-
hasSmartOn
public boolean hasSmartOn()
Checks to see if the channels of this switch support 'smart on'. Smart on is the ability to turn on a channel such that only 1-Wire device on this channel are awake and ready to do an operation. This greatly reduces the time to discover the device down a branch. If this method returnstrue
then the methodsetLatchState(int,boolean,boolean,byte[])
can be used with thedoSmart
parametertrue
.- Specified by:
hasSmartOn
in interfaceSwitchContainer
- Returns:
true
if channels support 'smart on'- See Also:
setLatchState(int,boolean,boolean,byte[])
-
onlySingleChannelOn
public boolean onlySingleChannelOn()
Checks to see if the channels of this switch require that only one channel is on at any one time. If this method returnstrue
then the methodsetLatchState(int,boolean,boolean,byte[])
will not only affect the state of the given channel but may affect the state of the other channels as well to insure that only one channel is on at a time.- Specified by:
onlySingleChannelOn
in interfaceSwitchContainer
- Returns:
true
if only one channel can be on at a time.- See Also:
setLatchState(int,boolean,boolean,byte[])
-
getNumberChannels
public int getNumberChannels(byte[] state)
Query to get the number of channels supported by this switch. Channel specific methods will use a channel number specified by an integer from [0 to (getNumberChannels(byte[])
- 1)]. Note that all devices of the same family will not necessarily have the same number of channels. The DS2406 comes in two packages--one that has a single channel, and one that has two channels.- Specified by:
getNumberChannels
in interfaceSwitchContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- the number of channels for this device
-
getLevel
public boolean getLevel(int channel, byte[] state) throws OneWireException
Checks the sensed level on the indicated channel. To avoid an exception, verify that this switch has level sensing with thehasLevelSensing()
. Level sensing means that the device can sense the logic level on its PIO pin.- Specified by:
getLevel
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if level sensed is 'high' andfalse
if level sensed is 'low'- Throws:
OneWireException
- See Also:
OneWireSensor.readDevice()
,hasLevelSensing()
-
getLatchState
public boolean getLatchState(int channel, byte[] state)
Checks the latch state of the indicated channel.- Specified by:
getLatchState
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if channel latch is 'on' or conducting andfalse
if channel latch is 'off' and not conducting. Note that the actual output when the latch is 'on' is returned from theisHighSideSwitch()
method.- See Also:
OneWireSensor.readDevice()
,isHighSideSwitch()
,setLatchState(int,boolean,boolean,byte[])
-
getSensedActivity
public boolean getSensedActivity(int channel, byte[] state) throws OneWireException
Checks if the indicated channel has experienced activity. This occurs when the level on the PIO pins changes. To clear the activity that is reported, callclearActivity()
. To avoid an exception, verify that this device supports activity sensing by calling the methodhasActivitySensing()
.- Specified by:
getSensedActivity
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if activity was detected andfalse
if no activity was detected- Throws:
OneWireException
- if this device does not have activity sensing- See Also:
hasActivitySensing()
,clearActivity()
-
isModeAuto
public boolean isModeAuto(byte[] state)
Checks if the control I/O pin mode is automatic (see DS2409 data sheet).- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
true
if control mode is automatic
-
getControlChannelAssociation
public int getControlChannelAssociation(byte[] state)
Checks the channel association of the control pin. This value only makes sense if the control mode is automatic (seeisModeAuto
).- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
int
the channel number that is associated with the control pin
-
getControlData
public int getControlData(byte[] state)
Checks the control data value. This value only makes sense if the control mode is manual (seeisModeAuto
). 0 = output transistor off, 1 = output transistor on- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
int
the control output transistor state
-
getLastSmartOnDeviceDetect
public boolean getLastSmartOnDeviceDetect()
Gets flag that indicates if a device was present when doing the last smart on. Note that this flag is only valid if the DS2409 flag was cleared with an ALL_LINES_OFF command and the last writeDevice performed a 'smart-on' on one of the channels.- Returns:
true
if device detected on branch
-
setLatchState
public void setLatchState(int channel, boolean latchState, boolean doSmart, byte[] state)
Sets the latch state of the indicated channel. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
.- Specified by:
setLatchState
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]latchState
-true
to set the channel latch 'on' (conducting) andfalse
to set the channel latch 'off' (not conducting). Note that the actual output when the latch is 'on' is returned from theisHighSideSwitch()
method.doSmart
- If latchState is 'on'/true
then doSmart indicates if a 'smart on' is to be done. To avoid an exception check the capabilities of this device using thehasSmartOn()
method.state
- current state of the device returned fromreadDevice()
- See Also:
hasSmartOn()
,getLatchState(int,byte[])
,OneWireSensor.writeDevice(byte[])
-
clearActivity
public void clearActivity() throws OneWireException
Clears the activity latches the next time possible. For example, on a DS2406/07, this happens the next time the status is read withreadDevice()
.- Specified by:
clearActivity
in interfaceSwitchContainer
- Throws:
OneWireException
- if this device does not support activity sensing- See Also:
OneWireSensor.readDevice()
,getSensedActivity(int,byte[])
-
setModeAuto
public void setModeAuto(boolean makeAuto, byte[] state)
Sets the control pin mode. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
.- Parameters:
makeAuto
-true
to set to auto mode, false for manual modestate
- current state of the device returned fromreadDevice()
-
setControlChannelAssociation
public void setControlChannelAssociation(int channel, byte[] state) throws OneWireException
Sets the control pin channel association. This only makes sense if the control pin is in automatic mode. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
.- Parameters:
channel
- channel to associate with control pinstate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- when trying to set channel association in manual mode
-
setControlData
public void setControlData(boolean data, byte[] state) throws OneWireException
Sets the control pin data to a value. Note this method only works if the control pin is in manual mode. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
.- Parameters:
data
-true
for on andfalse
for offstate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- when trying to set control data in automatic mode
-
-