1-Wire API for .NET Version 4.00
Public Member Functions

SwitchContainer Interface Reference

Inherits com::dalsemi::onewire::container::OneWireSensor.

Inherited by OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

List of all members.

Public Member Functions

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)
 Gets 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.
void setLatchState (int channel, boolean latchState, boolean doSmart, byte[] state)
 Sets the latch state of the indicated channel.
void clearActivity () throws OneWireException

Detailed Description

Interface class for 1-Wire® switch devices. This class should be implemented for each switch type 1-Wire device.

Features

Usage

SwitchContainer extends OneWireSensor, so the general usage model applies to any SwitchContainer:

  1. readDevice()
  2. perform operations on the SwitchContainer
  3. writeDevice(byte[])

Consider this interaction with a SwitchContainer that toggles all of the switches on the device:


     //switchcontainer is a com.dalsemi.onewire.container.SwitchContainer
     byte[] state = switchcontainer.readDevice();
     int number_of_switches = switchcontainer.getNumberChannels(state);
     System.out.println("This device has "+number_of_switches+" switches");
     for (int i=0; i < number_of_switches; i++)
     {
          boolean switch_state = switchcontainer.getLatchState(i, state);
          System.out.println("Switch "+i+" is "+(switch_state ? "on" : "off"));
          switchcontainer.setLatchState(i,!switch_state,false,state);
     }
     switchcontainer.writeDevice(state);
 
See also:
OneWireSensor
ClockContainer
TemperatureContainer
PotentiometerContainer
ADContainer
Version:
0.00, 27 August 2000
Author:
DS, KLA

Member Function Documentation

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().

The activity latches will only be cleared once. With the DS2406/07, this means that only the first call to readDevice() will clear the activity latches. Subsequent calls to readDevice() will leave the activity latch states intact, unless this method has been invoked since the last call to readDevice().

Exceptions:
OneWireExceptionif this device does not support activity sensing
See also:
com.dalsemi.onewire.container.OneWireSensor.readDevice()
getSensedActivity(int,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

boolean getLatchState ( int  channel,
byte[]  state 
)

Checks the latch state of the indicated channel.

Parameters:
channelchannel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)]
statecurrent state of the device returned from readDevice()
Returns:
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.
See also:
com.dalsemi.onewire.container.OneWireSensor.readDevice()
isHighSideSwitch()
setLatchState(int,boolean,boolean,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Parameters:
channelchannel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)]
statecurrent state of the device returned from readDevice()
Returns:
true if level sensed is 'high' and false if level sensed is 'low'
See also:
com.dalsemi.onewire.container.OneWireSensor.readDevice()
hasLevelSensing()

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

int getNumberChannels ( byte[]  state)

Gets 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.

Parameters:
statecurrent state of the device returned from readDevice()
Returns:
the number of channels for this device

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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().

Parameters:
channelchannel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)]
statecurrent state of the device returned from readDevice()
Returns:
true if activity was detected and false if no activity was detected
Exceptions:
OneWireExceptionif this device does not have activity sensing
See also:
hasActivitySensing()
clearActivity()

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Returns:
true if channels support activity sensing
See also:
getSensedActivity(int,byte[])
clearActivity()

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Returns:
true if channels support level sensing
See also:
getLevel(int,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Returns:
true if channels support 'smart on'
See also:
setLatchState(int,boolean,boolean,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Returns:
true if the switch is a 'high side' switch, false if the switch is a 'low side' switch
See also:
getLatchState(int,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

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.

Returns:
true if only one channel can be on at a time.
See also:
setLatchState(int,boolean,boolean,byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.

void setLatchState ( int  channel,
boolean  latchState,
boolean  doSmart,
byte[]  state 
)

Sets the latch state of the indicated channel.

The method writeDevice() must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channelchannel to execute this operation, in the range [0 to (getNumberChannels(byte[]) - 1)]
latchStatetrue 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.
doSmartIf 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.
statecurrent state of the device returned from readDevice()
See also:
hasSmartOn()
getLatchState(int,byte[])
com.dalsemi.onewire.container.OneWireSensor.writeDevice(byte[])

Implemented in OneWireContainer05, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer29, OneWireContainer3A, and OneWireContainer42.


The documentation for this interface was generated from the following file: