|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.dalsemi.onewire.container.OneWireContainer
|
+--com.dalsemi.onewire.container.OneWireContainer05
1-Wire® container for a Single Addressable Switch, DS2405. This container encapsulates the functionality of the 1-Wire family type 05 (hex)
The DS2405 has no memory beyond its 64-bit registration number.
The DS2405 supports level sensing, but not activity sensing. The code below reads the state of the DS2405, extracting the latch state and the sensed level of the PIO pin, then in the loop it toggles the latch state.
// "ID" is a byte array of size 8 with an address of a part we
// have already found with family code 05 hex
// "access" is a DSPortAdapter
int i=0;
OneWireContainer05 ds2405 = (OneWireContainer05) access.getDeviceContainer(ID);
ds2405.setupContainer(access,ID);
byte[] state = ds2405.readDevice();
// I know that the 2405 only has one channel (one switch)
// and it doesn't support 'Smart On'
boolean latch_state = ds2405.getLatchState(0,state);
System.out.println("Current state of switch: "+latch_state);
System.out.println("Current output level: "+ds2405.getLevel(0,state));
while (++i < 100)
{
System.out.println("Toggling switch");
ds2405.setLatchState(0,!latch_state,false,state);
ds2405.writeDevice(state);
state = ds2405.readDevice();
latch_state = ds2405.getLatchState(0,state);
System.out.println("Current state of switch: "+latch_state);
System.out.println("Current output level: "+ds2405.getLevel(0,state));
Thread.sleep(500);
}
Also see the usage example in the SwithContainer
interface.
DS2406, a dual addressable switch (OneWireContainer12).
OneWireSensor,
SwitchContainer,
OneWireContainer12| Constructor Summary | |
OneWireContainer05()
Creates a new OneWireContainer for communication with a DS2405. |
|
OneWireContainer05(DSPortAdapter sourceAdapter,
byte[] newAddress)
Creates a new OneWireContainer for communication with a DS2405. |
|
OneWireContainer05(DSPortAdapter sourceAdapter,
long newAddress)
Creates a new OneWireContainer for communication with a DS2405. |
|
OneWireContainer05(DSPortAdapter sourceAdapter,
String newAddress)
Creates a new OneWireContainer for communication with a DS2405. |
|
| Method Summary | |
void |
clearActivity()
Clears the activity latches the next time possible. |
String |
getAlternateNames()
Retrieves the alternate Dallas Semiconductor part numbers or names. |
String |
getDescription()
Gets a short description of the function of this iButton or 1-Wire Device type. |
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. |
String |
getName()
Gets the Dallas Semiconductor part number of the iButton or 1-Wire Device as a java.lang.String. |
int |
getNumberChannels(byte[] state)
Gets 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 if the channels of this switch support activity sensing. |
boolean |
hasLevelSensing()
Checks if the channels of this switch support level sensing. |
boolean |
hasSmartOn()
Checks if the channels of this switch support 'smart on'. |
boolean |
isHighSideSwitch()
Checks if the channels of this switch are 'high side' switches. |
boolean |
onlySingleChannelOn()
Checks 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 |
setLatchState(int channel,
boolean latchState,
boolean doSmart,
byte[] state)
Sets the latch state of the indicated channel. |
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, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public OneWireContainer05()
OneWireContainer for communication with a DS2405.
Note that the method setupContainer(com.dalsemi.onewire.adapter.DSPortAdapter,byte[])
must be called to set the correct DSPortAdapter device address.setupContainer(DSPortAdapter,byte[]),
OneWireContainer05(DSPortAdapter,byte[]),
OneWireContainer05(DSPortAdapter,long),
OneWireContainer05(DSPortAdapter,String)
public OneWireContainer05(DSPortAdapter sourceAdapter,
byte[] newAddress)
OneWireContainer for communication with a DS2405.sourceAdapter - adapter object required to communicate with
this 1-Wire devicenewAddress - address of this DS2405OneWireContainer05(),
OneWireContainer05(DSPortAdapter,long),
OneWireContainer05(DSPortAdapter,String)
public OneWireContainer05(DSPortAdapter sourceAdapter,
long newAddress)
OneWireContainer for communication with a DS2405.sourceAdapter - adapter object required to communicate with
this 1-Wire devicenewAddress - address of this DS2405OneWireContainer05(),
OneWireContainer05(DSPortAdapter,byte[]),
OneWireContainer05(DSPortAdapter,String)
public OneWireContainer05(DSPortAdapter sourceAdapter,
String newAddress)
OneWireContainer for communication with a DS2405.sourceAdapter - adapter object required to communicate with
this 1-Wire devicenewAddress - address of this DS2405OneWireContainer05(),
OneWireContainer05(DSPortAdapter,byte[]),
OneWireContainer05(DSPortAdapter,long)| Method Detail |
public String getName()
java.lang.String.
For example "DS1992".getName in class OneWireContainerpublic String getAlternateNames()
getAlternateNames in class OneWireContainerpublic String getDescription()
getDescription in class OneWireContainerpublic int getNumberChannels(byte[] state)
getNumberChannels(byte[]) - 1)]. Note that
all devices of the same family will not necessarily have the
same number of channels.getNumberChannels in interface SwitchContainerstate - current state of the device returned from readDevice()OneWireSensor.readDevice()public boolean isHighSideSwitch()
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.isHighSideSwitch in interface SwitchContainertrue if the switch is a 'high side' switch,
false if the switch is a 'low side' switchgetLatchState(int,byte[])public boolean hasActivitySensing()
true then the
method getSensedActivity(int,byte[]) can be used.hasActivitySensing in interface SwitchContainertrue if channels support activity sensinggetSensedActivity(int,byte[]),
clearActivity()public boolean hasLevelSensing()
true then the
method getLevel(int,byte[]) can be used.hasLevelSensing in interface SwitchContainertrue if channels support level sensinggetLevel(int,byte[])public boolean hasSmartOn()
true then the
method setLatchState(int,boolean,boolean,byte[])
can be used with the doSmart parameter true.hasSmartOn in interface SwitchContainertrue if channels support 'smart on'setLatchState(int,boolean,boolean,byte[])public boolean onlySingleChannelOn()
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.onlySingleChannelOn in interface SwitchContainertrue if only one channel can be on at a time.setLatchState(int,boolean,boolean,byte[])
public boolean getLevel(int channel,
byte[] state)
hasLevelSensing().
Level sensing means that the device can sense the logic
level on its PIO pin.getLevel in interface SwitchContainerchannel - 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'OneWireSensor.readDevice(),
hasLevelSensing()
public boolean getLatchState(int channel,
byte[] state)
getLatchState in interface SwitchContainerchannel - 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.OneWireSensor.readDevice(),
isHighSideSwitch(),
setLatchState(int,boolean,boolean,byte[])
public boolean getSensedActivity(int channel,
byte[] state)
throws OneWireException
clearActivity().
To avoid an exception, verify that this device supports activity
sensing by calling the method hasActivitySensing().getSensedActivity in interface SwitchContainerchannel - 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 sensinghasActivitySensing(),
clearActivity()
public void clearActivity()
throws OneWireException
readDevice().clearActivity in interface SwitchContainerOneWireException - if this device does not support activity sensingOneWireSensor.readDevice(),
getSensedActivity(int,byte[])
public void setLatchState(int channel,
boolean latchState,
boolean doSmart,
byte[] state)
writeDevice() must be called to finalize
changes to the device. Note that multiple 'set' methods can
be called before one call to writeDevice().setLatchState in interface SwitchContainerchannel - 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()hasSmartOn(),
getLatchState(int,byte[]),
OneWireSensor.writeDevice(byte[])
public byte[] readDevice()
throws OneWireIOException,
OneWireException
readDevice in interface OneWireSensorOneWireIOException - 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
public void writeDevice(byte[] state)
throws OneWireIOException,
OneWireException
writeDevice in interface OneWireSensorstate - 1-Wire device sensor stateOneWireIOException - 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||