1-Wire API for .NET Version 4.00
|
Inherits com::dalsemi::onewire::container::OneWireContainer, and com::dalsemi::onewire::container::SwitchContainer.
Public Member Functions | |
OneWireContainer1F () | |
Create an empty container that is not complete until after a call to setupContainer . | |
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, String newAddress) | |
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device. | |
String | getName () |
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string. | |
String | getAlternateNames () |
Gets the alternate Maxim Integrated Products part numbers or names. | |
String | getDescription () |
Gets a short description of the function of this iButton or 1-Wire Device type. | |
synchronized void | setSpeedCheck (boolean doSpeedCheck) |
Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron. | |
byte[] | readDevice () throws OneWireIOException, OneWireException |
Retrieves the 1-Wire device sensor state. | |
void | writeDevice (byte[] state) throws OneWireIOException, OneWireException |
Writes the 1-Wire device sensor state that have been changed by 'set' methods. | |
void | dischargeLines (int time) throws OneWireIOException, OneWireException |
boolean | isHighSideSwitch () |
Checks to see if the channels of this switch are 'high side' switches. | |
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 | onlySingleChannelOn () |
Checks to see if the channels of this switch require that only one channel is on at any one time. | |
int | getNumberChannels (byte[] state) |
Query to get the number of channels supported by this switch. | |
boolean | getLevel (int channel, byte[] state) throws OneWireException |
Checks the sensed level on the indicated channel. | |
boolean | getLatchState (int channel, byte[] state) |
Checks the latch state of the indicated channel. | |
boolean | getSensedActivity (int channel, byte[] state) throws OneWireException |
Checks if the indicated channel has experienced activity. | |
boolean | isModeAuto (byte[] state) |
Checks if the control I/O pin mode is automatic (see DS2409 data sheet). | |
int | getControlChannelAssociation (byte[] state) |
Checks the channel association of the control pin. | |
int | getControlData (byte[] state) |
Checks the control data value. | |
boolean | getLastSmartOnDeviceDetect () |
Gets flag that indicates if a device was present when doing the last smart on. | |
void | setLatchState (int channel, boolean latchState, boolean doSmart, byte[] state) |
Sets the latch state of the indicated channel. | |
void | clearActivity () throws OneWireException |
Clears the activity latches the next time possible. | |
void | setModeAuto (boolean makeAuto, byte[] state) |
Sets the control pin mode. | |
void | setControlChannelAssociation (int channel, byte[] state) throws OneWireException |
Sets the control pin channel association. | |
void | setControlData (boolean data, byte[] state) throws OneWireException |
Sets the control pin data to a value. | |
Static Public Attributes | |
static final int | CHANNEL_MAIN = 0 |
Main Channel number. | |
static final int | CHANNEL_AUX = 1 |
Aux Channel number. | |
Static Protected Attributes | |
static final int | BITMAP_OFFSET = 3 |
Offset of BITMAP in array returned from read state. | |
static final int | STATUS_OFFSET = 0 |
Offset of Status in array returned from read state. | |
static final int | MAIN_OFFSET = 1 |
Offset of Main channel flag in array returned from read state. | |
static final int | AUX_OFFSET = 2 |
Offset of Main channel flag in array returned from read state. | |
static final int | SWITCH_OFF = 0 |
Channel flag to indicate turn off. | |
static final int | SWITCH_ON = 1 |
Channel flag to indicate turn on. | |
static final int | SWITCH_SMART = 2 |
Channel flag to indicate smart on. | |
static final byte | READ_WRITE_STATUS_COMMAND = ( byte ) 0x5A |
Read Write Status register commmand. | |
static final byte | ALL_LINES_OFF_COMMAND = ( byte ) 0x66 |
All lines off command. | |
static final byte | DISCHARGE_COMMAND = ( byte ) 0x99 |
Discharge command. | |
static final byte | DIRECT_ON_MAIN_COMMAND = ( byte ) 0xA5 |
Direct on main command. | |
static final byte | SMART_ON_MAIN_COMMAND = ( byte ) 0xCC |
Smart on main command. | |
static final byte | SMART_ON_AUX_COMMAND = ( byte ) 0x33 |
Smart on aux command. |
1-Wire® container for 1-Wire(MicroLAN) Coupler, DS2409. This container encapsulates the functionality of the 1-Wire family type 1F (hex).
Setting the latch on the DS2409 to 'on' (see seLatchState) connects the channel [Main(0) or Auxillary(1)] to the 1-Wire data line. Note that this is the opposite of the DS2406 and DS2405 which connect thier I/O lines to ground.
See the usage example in SwitchContainer for basic switch operations.
http://pdfserv.maxim-ic.com/arpdf/DS2409.pdf
Create an empty container that is not complete until after a call to setupContainer
.
This is one of the methods to construct a container. The others are through creating a OneWireContainer with parameters.
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.
sourceAdapter | adapter instance used to communicate with this iButton |
newAddress | Address of this 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.
This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
sourceAdapter | adapter instance used to communicate with this 1-Wire device |
newAddress | Address of this 1-Wire device |
OneWireContainer1F | ( | DSPortAdapter | sourceAdapter, |
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.
sourceAdapter | adapter instance used to communicate with this 1-Wire device |
newAddress | Address of this 1-Wire device |
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 with readDevice()
.
OneWireException | if this device does not support activity sensing |
Implements SwitchContainer.
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.
time | number of milliseconds the lines are to be discharged for (minimum 100) |
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 |
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'.
Reimplemented from OneWireContainer.
int getControlChannelAssociation | ( | byte[] | state | ) |
Checks the channel association of the control pin.
This value only makes sense if the control mode is automatic (see isModeAuto
).
state | current state of the device returned from readDevice() |
int
the channel number that is associated with the control pin int getControlData | ( | byte[] | state | ) |
Checks the control data value.
This value only makes sense if the control mode is manual (see isModeAuto
). 0 = output transistor off, 1 = output transistor on
state | current state of the device returned from readDevice() |
int
the control output transistor state String getDescription | ( | ) |
Gets a short description of the function of this iButton or 1-Wire Device type.
Reimplemented from OneWireContainer.
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.
true
if device detected on branch boolean getLatchState | ( | int | channel, |
byte[] | state | ||
) |
Checks the latch state of the indicated channel.
channel | channel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)] |
state | current state of the device returned from readDevice() |
true
if channel latch is 'on' or conducting and false
if channel latch is 'off' and not conducting. Note that the actual output when the latch is 'on' is returned from the isHighSideSwitch()
method.Implements SwitchContainer.
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 the hasLevelSensing()
. Level sensing means that the device can sense the logic level on its PIO pin.
channel | channel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)] |
state | current state of the device returned from readDevice() |
true
if level sensed is 'high' and false
if level sensed is 'low'Implements SwitchContainer.
String getName | ( | ) |
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string.
For example 'DS1992'.
Reimplemented from OneWireContainer.
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.
state | current state of the device returned from readDevice() |
Implements SwitchContainer.
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, call clearActivity()
. To avoid an exception, verify that this device supports activity sensing by calling the method hasActivitySensing()
.
channel | channel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)] |
state | current state of the device returned from readDevice() |
true
if activity was detected and false
if no activity was detectedOneWireException | if this device does not have activity sensing |
Implements SwitchContainer.
boolean hasActivitySensing | ( | ) |
Checks to see if the channels of this switch support activity sensing.
If this method returns true
then the method getSensedActivity(int,byte[])
can be used.
true
if channels support activity sensingImplements SwitchContainer.
boolean hasLevelSensing | ( | ) |
Checks to see if the channels of this switch support level sensing.
If this method returns true
then the method getLevel(int,byte[])
can be used.
true
if channels support level sensingImplements SwitchContainer.
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 returns true
then the method setLatchState(int,boolean,boolean,byte[])
can be used with the doSmart
parameter true
.
true
if channels support 'smart on'Implements SwitchContainer.
boolean isHighSideSwitch | ( | ) |
Checks to see if the channels of this switch are 'high side' switches.
This indicates that when 'on' or true
, the switch output is connect to the 1-Wire data. If this method returns false
then when the switch is 'on' or true
, the switch is connected to ground.
true
if the switch is a 'high side' switch, false
if the switch is a 'low side' switchImplements SwitchContainer.
boolean isModeAuto | ( | byte[] | state | ) |
Checks if the control I/O pin mode is automatic (see DS2409 data sheet).
state | current state of the device returned from readDevice() |
true
if control mode is automatic 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 returns true
then the method setLatchState(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.
true
if only one channel can be on at a time.Implements SwitchContainer.
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.
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 |
Implements OneWireSensor.
void setControlChannelAssociation | ( | int | channel, |
byte[] | state | ||
) | throws OneWireException |
Sets the control pin channel association.
This only makes sense if the contol pin is in automatic mode. The method writeDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[])
.
channel | channel to associate with control pin |
state | current state of the device returned from readDevice() |
OneWireException | when trying to set channel association in manual mode |
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 method writeDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[])
.
data | true for on and false for off |
state | current state of the device returned from readDevice() |
OneWireException | when trying to set control data in automatic mode |
void setLatchState | ( | int | channel, |
boolean | latchState, | ||
boolean | doSmart, | ||
byte[] | state | ||
) |
Sets the latch state of the indicated channel.
The method writeDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[])
.
channel | channel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)] |
latchState | true to set the channel latch 'on' (conducting) and false to set the channel latch 'off' (not conducting). Note that the actual output when the latch is 'on' is returned from the isHighSideSwitch() 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 the hasSmartOn() method. |
state | current state of the device returned from readDevice() |
Implements SwitchContainer.
void setModeAuto | ( | boolean | makeAuto, |
byte[] | state | ||
) |
Sets the control pin mode.
The method writeDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[])
.
makeAuto | true to set to auto mode, false for manual mode |
state | current state of the device returned from readDevice() |
synchronized 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 to doSpeed()
. However, this is an expensive operation. If a user manages the bus speed in an application, call this method with doSpeedCheck
as false
. The default behavior is to call doSpeed()
.
doSpeedCheck | true for doSpeed() to be called before every 1-Wire bus access, false to skip this expensive call |
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.
state | 1-Wire device sensor state |
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 |
Implements OneWireSensor.
final byte ALL_LINES_OFF_COMMAND = ( byte ) 0x66 [static, protected] |
All lines off command.
final int AUX_OFFSET = 2 [static, protected] |
Offset of Main channel flag in array returned from read state.
final int BITMAP_OFFSET = 3 [static, protected] |
Offset of BITMAP in array returned from read state.
final int CHANNEL_AUX = 1 [static] |
Aux Channel number.
final int CHANNEL_MAIN = 0 [static] |
Main Channel number.
final byte DIRECT_ON_MAIN_COMMAND = ( byte ) 0xA5 [static, protected] |
Direct on main command.
final byte DISCHARGE_COMMAND = ( byte ) 0x99 [static, protected] |
Discharge command.
final int MAIN_OFFSET = 1 [static, protected] |
Offset of Main channel flag in array returned from read state.
final byte READ_WRITE_STATUS_COMMAND = ( byte ) 0x5A [static, protected] |
Read Write Status register commmand.
final byte SMART_ON_AUX_COMMAND = ( byte ) 0x33 [static, protected] |
Smart on aux command.
final byte SMART_ON_MAIN_COMMAND = ( byte ) 0xCC [static, protected] |
Smart on main command.
final int STATUS_OFFSET = 0 [static, protected] |
Offset of Status in array returned from read state.
final int SWITCH_OFF = 0 [static, protected] |
Channel flag to indicate turn off.
final int SWITCH_ON = 1 [static, protected] |
Channel flag to indicate turn on.
final int SWITCH_SMART = 2 [static, protected] |
Channel flag to indicate smart on.