1-Wire API for Compact.NET Version 4.00
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Events

PortAdapter Class Reference

Abstract base class for all 1-Wire Adapter objects. More...

Inherited by SerialAdapter, SerialAdapterX, and TMEXLibAdapter.

List of all members.

Public Member Functions

abstract void Dispose ()
 Gets or sets the ISite associated with this component.
abstract bool OpenPort (String PortName)
 Opens the specified port and verifies existance of the adapter.
void FreePort ()
 Closes the port and frees all resources from use.
bool BeginExclusive (bool blocking)
 Obtain exclusive control of this adapter object.
void EndExclusive ()
 Release exclusive control of this adapter object.
abstract OWResetResult Reset ()
 Sends a Reset to the 1-Wire Network.
abstract void PutBit (bool bitValue)
 Sends a bit to the 1-Wire Network.
abstract void PutByte (int byteValue)
 Sends a byte to the 1-Wire Network.
abstract bool GetBit ()
 Gets a bit from the 1-Wire Network.
abstract int GetByte ()
 Gets a byte from the 1-Wire Network.
abstract byte[] GetBlock (int len)
 Get a block of data from the 1-Wire Network.
abstract void GetBlock (byte[] arr, int len)
 Get a block of data from the 1-Wire Network and write it into the provided array.
abstract void GetBlock (byte[] arr, int off, int len)
 Get a block of data from the 1-Wire Network and write it into the provided array.
abstract void DataBlock (byte[] data, int offset, int length)
 Sends a block of data and returns the data received in the same array.
abstract void SetPowerDuration (OWPowerTime powerDur)
 Sets the duration to supply power to the 1-Wire Network.
abstract bool StartPowerDelivery (OWPowerStart changeCondition)
 Sets the 1-Wire Network voltage to supply power to an iButton device.
abstract void SetProgramPulseDuration (OWPowerTime pulseDur)
 Sets the duration for providing a program pulse on the 1-Wire Network.
abstract bool StartProgramPulse (OWPowerStart changeCondition)
 Sets the 1-Wire Network voltage to eprom programming level.
abstract void StartBreak ()
 Sets the 1-Wire Network voltage to 0 volts.
abstract void SetPowerNormal ()
 Sets the 1-Wire Network voltage to normal level.
abstract bool GetFirstDevice (byte[] address, int offset)
 Returns

true

if the first iButton or 1-Wire device is found on the 1-Wire Network.

abstract bool GetNextDevice (byte[] address, int offset)
 Returns

true

if the next iButton or 1-Wire device is found.

abstract bool IsPresent (byte[] address, int offset)
 Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.
abstract bool IsAlarming (byte[] address, int offset)
 Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.
virtual bool SelectDevice (byte[] address, int offset)
 Selects the specified iButton or 1-Wire device by broadcasting its address.
abstract void SetSearchOnlyAlarmingDevices ()
 Set the 1-Wire Network search to find only iButtons and 1-Wire devices that are in an 'Alarm' state that signals a need for attention.
abstract void SetNoResetSearch ()
 Set the 1-Wire Network search to not perform a 1-Wire reset before a search.
abstract void SetSearchAllDevices ()
 Set the 1-Wire Network search to find all iButtons and 1-Wire devices whether they are in an 'Alarm' state or not and restores the default setting of providing a 1-Wire reset command before each search.
virtual void TargetAllFamilies ()
 Removes any selectivity during a search for iButtons or 1-Wire devices by family type.
virtual void TargetFamily (int family)
 Takes an integer to selectively search for this desired family type.
virtual void TargetFamily (byte[] family)
 Takes an array of bytes to use for selectively searching for acceptable family codes.
virtual void ExcludeFamily (int family)
 Takes an integer family code to avoid when searching for iButtons.
virtual void ExcludeFamily (byte[] family)
 Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices.
override int GetHashCode ()
 Get Hash Code (proxies to .ToString().GetHashCode())
override bool Equals (System.Object o)
 Tells if objects are equal (proxies to .ToString().Equals())
override string ToString ()
 Returns a string representation of this adapter (i.e.

Protected Member Functions

abstract void Dispose (bool disposing)
 Dispose's all resources for this object.
virtual void onReset (OWResetResult rslt)
 onReset event, fires event for all listeners
virtual void onSpeedChange (OWSpeed OldSpeed, OWSpeed NewSpeed)
 onSpeedChange event, fires event for all listeners
virtual void onDataIO (bool isTransmit, byte[] data)
 onDataIO event, fires for all data IO
virtual internal bool isValidFamily (byte familyCode)
 Checks to see if the family found is in the desired include group.

Protected Attributes

internal byte[] exclude = null
 exclude family codes
internal byte[] include = null
 include family codes

Properties

abstract OWSpeed Speed [get, set]
 OWSpeed representing current speed of communication on 1-Wire network.
abstract bool CanOverdrive [get]
 Returns whether adapter can physically support overdrive mode.
abstract bool CanHyperdrive [get]
 Returns whether the adapter can physically support hyperdrive mode.
abstract bool CanFlex [get]
 Returns whether the adapter can physically support flex speed mode.
abstract bool CanProgram [get]
 Returns whether adapter can physically support 12 volt power mode.
abstract bool CanDeliverPower [get]
 Returns whether the adapter can physically support strong 5 volt power mode.
abstract bool CanDeliverSmartPower [get]
 Returns whether the adapter can physically support "smart" strong 5 volt power mode.
abstract bool CanBreak [get]
 Returns whether adapter can physically support 0 volt 'break' mode.
abstract string AdapterName [get]
 The name of this adapter type.
abstract string PortName [get]
 The port name for this adapter type (i.e.
abstract string PortTypeDescription [get]
 Detailed description for this port type.
abstract System.Collections.IList PortNames [get]
 Collection of valid port names for this port type.

Events

ResetEventHandler ResetEvent
 An event for indicating when a 1-Wire Reset occurs and what the result is.
SpeedChangeEventHandler SpeedChangeEvent
 An event for indicating when a 1-Wire Reset occurs and what the result is.
DataIOEventHandler DataIOEvent
 event for indicating when data is transmitted

Detailed Description

Abstract base class for all 1-Wire Adapter objects.


Member Function Documentation

bool BeginExclusive ( bool  blocking)

Obtain exclusive control of this adapter object.

Parameters:
blockingif true, blocks until available
Returns:
if true, exclusive control has been granted
abstract void DataBlock ( byte[]  data,
int  offset,
int  length 
) [pure virtual]

Sends a block of data and returns the data received in the same array.

This method is used when sending a block that contains reads and writes. The 'read' portions of the data block need to be pre-loaded with 0xFF's. It starts sending data from the index at offset 'off' for length 'len'.

Parameters:
dataarray of data to transfer to and from the 1-Wire Network.
offsetoffset into the array of data to start
lengthlength of data to send / receive starting at 'off'
abstract void Dispose ( ) [pure virtual]

Gets or sets the ISite associated with this component.

Represents the method that handles the Disposed event of a component. Dispose's all resources for this object

abstract void Dispose ( bool  disposing) [protected, pure virtual]

Dispose's all resources for this object.

void EndExclusive ( )

Release exclusive control of this adapter object.

override bool Equals ( System.Object  o)

Tells if objects are equal (proxies to .ToString().Equals())

Parameters:
o
Returns:
virtual void ExcludeFamily ( int  family) [virtual]

Takes an integer family code to avoid when searching for iButtons.

or 1-Wire devices. If this method is used, then no devices of this family will be found by any of the search methods.

Parameters:
familythe code of the family type NOT to target in searches
virtual void ExcludeFamily ( byte[]  family) [virtual]

Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices.

If used, then no devices with family codes in this array will be found by any of the search methods.

Parameters:
familyarray of family cods NOT to target for searches
void FreePort ( )

Closes the port and frees all resources from use.

abstract bool GetBit ( ) [pure virtual]

Gets a bit from the 1-Wire Network.

Returns:
the bit value recieved from the the 1-Wire Network.
abstract void GetBlock ( byte[]  arr,
int  len 
) [pure virtual]

Get a block of data from the 1-Wire Network and write it into the provided array.

Parameters:
arrarray in which to write the received bytes
lenlength of data bytes to receive
abstract void GetBlock ( byte[]  arr,
int  off,
int  len 
) [pure virtual]

Get a block of data from the 1-Wire Network and write it into the provided array.

Parameters:
arrarray in which to write the received bytes
offoffset into the array to start
lenlength of data bytes to receive
abstract byte [] GetBlock ( int  len) [pure virtual]

Get a block of data from the 1-Wire Network.

Parameters:
lenlength of data bytes to receive
Returns:
the data received from the 1-Wire Network.
abstract int GetByte ( ) [pure virtual]

Gets a byte from the 1-Wire Network.

Returns:
the byte value received from the the 1-Wire Network.
abstract bool GetFirstDevice ( byte[]  address,
int  offset 
) [pure virtual]

Returns

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.

Parameters:
addressdevice address found
offsetoffset into array where address begins
Returns:
true
if an iButton or 1-Wire device is found.
override int GetHashCode ( )

Get Hash Code (proxies to .ToString().GetHashCode())

Returns:
abstract bool GetNextDevice ( byte[]  address,
int  offset 
) [pure virtual]

Returns

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.

Parameters:
addressdevice address found
offsetoffset into array where address begins
Returns:
true
if an iButton or 1-Wire device is found.
abstract bool IsAlarming ( byte[]  address,
int  offset 
) [pure virtual]

Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.

This does not affect the 'current' device state information used in searches (findNextDevice...).

Parameters:
addressdevice address to verify is present and alarming
offsetoffset into array where address begins
Returns:
true
if device is present and alarming else
false
.
abstract bool IsPresent ( byte[]  address,
int  offset 
) [pure virtual]

Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.

This does not affect the 'current' device state information used in searches (findNextDevice...).

Parameters:
addressdevice address to verify is present
offsetoffset into array where address begins
Returns:
true
if device is present else
false
.
virtual internal bool isValidFamily ( byte  familyCode) [protected, virtual]

Checks to see if the family found is in the desired include group.

Returns:
true
if in include group
virtual void onDataIO ( bool  isTransmit,
byte[]  data 
) [protected, virtual]

onDataIO event, fires for all data IO

Parameters:
isTransmitif true, this is a transmit event, otherwise it is echo
dataThe data transmitted or received
virtual void onReset ( OWResetResult  rslt) [protected, virtual]

onReset event, fires event for all listeners

Parameters:
rsltthe result of the 1-Wire reset
virtual void onSpeedChange ( OWSpeed  OldSpeed,
OWSpeed  NewSpeed 
) [protected, virtual]

onSpeedChange event, fires event for all listeners

Parameters:
OldSpeedthe 1-Wire speed before change
NewSpeedthe 1-Wire speed after change
abstract bool OpenPort ( String  PortName) [pure virtual]

Opens the specified port and verifies existance of the adapter.

Returns:
true if adapter found on specified port
abstract void PutBit ( bool  bitValue) [pure virtual]

Sends a bit to the 1-Wire Network.

Parameters:
bitValuethe bit value to send to the 1-Wire Network.
abstract void PutByte ( int  byteValue) [pure virtual]

Sends a byte to the 1-Wire Network.

Parameters:
byteValuethe byte value to send to the 1-Wire Network.
abstract OWResetResult Reset ( ) [pure virtual]

Sends a Reset to the 1-Wire Network.

Returns:
the result of the reset.
virtual bool SelectDevice ( byte[]  address,
int  offset 
) [virtual]

Selects the specified iButton or 1-Wire device by broadcasting its address.

This operation is refered to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...).

Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).

Parameters:
addressiButton to select
offsetoffset into array where address begins
Returns:
true
if device address was sent,
false
otherwise.
abstract void SetNoResetSearch ( ) [pure virtual]

Set the 1-Wire Network search to not perform a 1-Wire reset before a search.

This feature is chiefly used with the DS2409 1-Wire coupler. The normal reset before each search can be restored with the 'setSearchAllDevices()' method.

abstract void SetPowerDuration ( OWPowerTime  powerDur) [pure virtual]

Sets the duration to supply power to the 1-Wire Network.

This method takes a time parameter that indicates the program pulse length when the method startPowerDelivery().

Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.

Parameters:
powerDurtime factor
abstract void SetPowerNormal ( ) [pure virtual]

Sets the 1-Wire Network voltage to normal level.

This method is used to disable 1-Wire conditions created by startPowerDelivery and startProgramPulse. This method will automatically be called if a communication method is called while an outstanding power command is taking place.

Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter or the adapter does not support this operation
abstract void SetProgramPulseDuration ( OWPowerTime  pulseDur) [pure virtual]

Sets the duration for providing a program pulse on the 1-Wire Network.

This method takes a time parameter that indicates the program pulse length when the method startProgramPulse().

Note: to avoid getting an exception, use the canDeliverPower() method to check it's availability.

Parameters:
pulseDurtime factor
abstract void SetSearchAllDevices ( ) [pure virtual]

Set the 1-Wire Network search to find all iButtons and 1-Wire devices whether they are in an 'Alarm' state or not and restores the default setting of providing a 1-Wire reset command before each search.

(see setNoResetSearch() method).

abstract void SetSearchOnlyAlarmingDevices ( ) [pure virtual]

Set the 1-Wire Network search to find only iButtons and 1-Wire devices that are in an 'Alarm' state that signals a need for attention.

Not all iButton types have this feature. Some that do: DS1994, DS1920, DS2407. This selective searching can be canceled with the 'setSearchAllDevices()' method.

abstract void StartBreak ( ) [pure virtual]

Sets the 1-Wire Network voltage to 0 volts.

This method is used rob all 1-Wire Network devices of parasite power delivery to force them into a hard reset.

abstract bool StartPowerDelivery ( OWPowerStart  changeCondition) [pure virtual]

Sets the 1-Wire Network voltage to supply power to an iButton device.

This method takes a time parameter that indicates whether the power delivery should be done immediately, or after certain conditions have been met.

Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.

Parameters:
changeConditionchange condition
Returns:
true
if the voltage change was successful,
false
otherwise.
abstract bool StartProgramPulse ( OWPowerStart  changeCondition) [pure virtual]

Sets the 1-Wire Network voltage to eprom programming level.

This method takes a time parameter that indicates whether the power delivery should be done immediately, or after certain conditions have been met.

Note: to avoid getting an exception, use the canProgram() method to check it's availability.

Parameters:
changeConditionchange condition
Returns:
true

if the voltage change was successful,

false

otherwise.

OneWireIOException on a 1-Wire communication error

OneWireException on a setup error with the 1-Wire adapter or the adapter does not support this operation

virtual void TargetAllFamilies ( ) [virtual]

Removes any selectivity during a search for iButtons or 1-Wire devices by family type.

The unique address for each iButton and 1-Wire device contains a family descriptor that indicates the capabilities of the device.

virtual void TargetFamily ( int  family) [virtual]

Takes an integer to selectively search for this desired family type.

If this method is used, then no devices of other families will be found by any of the search methods.

Parameters:
familythe code of the family type to target for searches
virtual void TargetFamily ( byte[]  family) [virtual]

Takes an array of bytes to use for selectively searching for acceptable family codes.

If used, only devices with family codes in this array will be found by any of the search methods.

Parameters:
familyarray of the family types to target for searches
override string ToString ( )

Returns a string representation of this adapter (i.e.

"DS9097U COM1")

Returns:

Member Data Documentation

internal byte [] exclude = null [protected]

exclude family codes

internal byte [] include = null [protected]

include family codes


Property Documentation

abstract string AdapterName [get]

The name of this adapter type.

abstract bool CanBreak [get]

Returns whether adapter can physically support 0 volt 'break' mode.

Returns:
true
if this port adapter can do break,
false
otherwise.
abstract bool CanDeliverPower [get]

Returns whether the adapter can physically support strong 5 volt power mode.

Returns:
true
if this port adapter can do strong 5 volt mode,
false
otherwise.
abstract bool CanDeliverSmartPower [get]

Returns whether the adapter can physically support "smart" strong 5 volt power mode.

"smart" power delivery is the ability to deliver power until it is no longer needed. The current drop it detected and power delivery is stopped.

Returns:
true
if this port adapter can do "smart" strong 5 volt mode,
false
otherwise.
abstract bool CanFlex [get]

Returns whether the adapter can physically support flex speed mode.

Returns:
true
if this port adapter can do flex speed,
false
otherwise.
abstract bool CanHyperdrive [get]

Returns whether the adapter can physically support hyperdrive mode.

Returns:
true
if this port adapter can do HyperDrive,
false
otherwise.
abstract bool CanOverdrive [get]

Returns whether adapter can physically support overdrive mode.

Returns:
true
if this port adapter can do OverDrive,
false
otherwise.
abstract bool CanProgram [get]

Returns whether adapter can physically support 12 volt power mode.

Returns:
true
if this port adapter can do Program voltage,
false
otherwise.
abstract string PortName [get]

The port name for this adapter type (i.e.

COM1, LPT1, etc)

abstract System.Collections.IList PortNames [get]

Collection of valid port names for this port type.

abstract string PortTypeDescription [get]

Detailed description for this port type.

abstract OWSpeed Speed [get, set]

OWSpeed representing current speed of communication on 1-Wire network.


Event Documentation

DataIOEventHandler DataIOEvent

event for indicating when data is transmitted


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