Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LOW_netSegment Class Reference

Single segment of the 1-Wire net. More...

#include <LOW_netSegment.h>

Inheritance diagram for LOW_netSegment:

Inheritance graph
[legend]
Collaboration diagram for LOW_netSegment:

Collaboration graph
[legend]
List of all members.

Public Types

typedef LOW_objectIDFactory::objectID_t segmentID_t
 segment ID type. More...

typedef std::vector< LOW_netSegment *> netSegPtrVec_t
 Vector type of class pointers. More...


Public Methods

virtual LOW_linkgetLink ()
 Get the LOW_link instance associated with this segment. More...

virtual bool getHasExternalPower () const
 Get wether there is an external power line on the segment. More...

template<class devType> devType * getDevice (const LOW_deviceID inDevID)
 Get a specific device. More...

template<class devType> std::vector< devType *> getDevices () const
 Get devices of a specific type. More...

template<class devType> std::vector< devType *> searchDevices (const bool inOnlyAlarm=false)
 Search for devices on the segment. More...

virtual bool verifyDevice (const LOW_deviceID inDevID, const bool inOnlyAlarm=false, const bool inDoReset=true)
 Verify existance of a specific device on the segment. More...


Protected Methods

virtual ~LOW_netSegment ()
 Destructor. More...

virtual void unregisterDevice (const LOW_device *inDev)
 Indicate that a device instance is going to be deleted. More...

virtual void cmd_MatchROM (const LOW_device *inDevice) const
 Select a single device on a link. More...

virtual void cmd_SkipROM () const
 Select all devices on a link. More...

virtual LOW_deviceID cmd_ReadROM () const
 Read ID number from bus. More...

virtual LOW_deviceID::deviceIDVec_t cmd_SearchROM (const bool inOnlyAlarm=false, const LOW_deviceIDRaw::devFamCode_t inFamCode=LOW_device::anyDev_famCode) const
 Scan the bus for devices. More...

virtual bool cmd_SearchROMVerify (const LOW_deviceID inDevID, const bool inOnlyAlarm=false, const bool inDoReset=true) const
 Scan the bus for a specific device. More...


Static Protected Methods

netSegPtrVec_t newSegmentsFromLink (LOW_link &inLink)
 Discovers network segments on a link. More...


Static Protected Attributes

LOW_thread_rwlock__staticSyncRwlockSingleton = 0
LOW_platformMiscFactory::threadIdent_t __writeLockHolder = 0

Private Methods

 LOW_netSegment (LOW_link &inLink)
 Constructor from link. More...

virtual bool operator== (LOW_netSegment &inSegment) const
 Comparison based on segmentID. More...

template<class castType> castType * devicePtr_cast (LOW_device *inPtr) const
 Safely cast a generic device pointer to a specific one. More...

virtual void buryDevice (const LOW_device *inDev)
 Move a device from the alive map to the graveyard. More...

virtual void revitalizeDevice (const LOW_device *inDev)
 Move a device from the graveyard to the alive map. More...

virtual LOW_deviceaddDevice (const LOW_deviceID inDevID)
 Add a device to the alive map. More...

virtual void removeDevice (const LOW_device *inDev)
 Removes a device from either the alive map or the graveyard. More...


Private Attributes

const segmentID_t segmentID
 Identifier of the segment. More...

LOW_linklink
 Link this segment is present on. More...

bool hasExternalPower
 Whether there is an additional line for external power supply available. More...

LOW_device::deviceMap_t aliveDevMap
 Map of currently present devices on the segment. More...

LOW_device::deviceMap_t graveyardMap
 Map of formerly present devices on the segment. More...


Friends

class LOW_network
 Enable access to static pseudo constructor and destructor. More...

class LOW_device
 Enable access to unregister a device on destruction. More...


Detailed Description

Single segment of the 1-Wire net.

The class models a single segment reachable by a concrete link of the 1-Wire network.

Objects for devices are automatically instanciated via LOW_deviceFactory. The objects are cached in two maps:

This means, that once a device is not visible any more, the device object is not deleted but burried on the graveyard. Once the device is visible again, it is revitalized.

This class is thread-safe.

Author:
Harald Roelle , Parts of the documentation by Dallas Semiconductors / Maxim Integrated Products

Definition at line 55 of file LOW_netSegment.h.


Member Typedef Documentation

typedef std::vector<LOW_netSegment*> LOW_netSegment::netSegPtrVec_t
 

Vector type of class pointers.

Definition at line 80 of file LOW_netSegment.h.

Referenced by LOW_network::addSegments(), LOW_network::getSegments(), LOW_network::network_error::network_error(), and newSegmentsFromLink().

typedef LOW_objectIDFactory::objectID_t LOW_netSegment::segmentID_t
 

segment ID type.

Definition at line 78 of file LOW_netSegment.h.


Constructor & Destructor Documentation

LOW_netSegment::~LOW_netSegment   [protected, virtual]
 

Destructor.

Destroys all objects of devices (in both maps).

Definition at line 48 of file LOW_netSegment.cpp.

References aliveDevMap, and graveyardMap.

LOW_netSegment::LOW_netSegment LOW_link   inLink [private]
 

Constructor from link.

Triggers initial search of devices on the segment.

Parameters:
inLink  The link the segment resides on.

Definition at line 36 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, LOW_link::getHasExternalPower(), hasExternalPower, and link.

Referenced by newSegmentsFromLink().


Member Function Documentation

LOW_device * LOW_netSegment::addDevice const LOW_deviceID    inDevID [private, virtual]
 

Add a device to the alive map.

When the device is already in the alive map nothing is done. When it is on the graveyard, it is moved to the alive map. When it does not exist at all, a new instance is created.

Parameters:
inDevID  The ID of the device to add.
Returns:
The added device.

Definition at line 277 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, aliveDevMap, graveyardMap, LOW_deviceFactory::new_SpecificDevice(), and revitalizeDevice().

Referenced by searchDevices(), and verifyDevice().

void LOW_netSegment::buryDevice const LOW_device   inDev [private, virtual]
 

Move a device from the alive map to the graveyard.

If not in alive map, the method returns silently.

Parameters:
inDev  The device to move.

Definition at line 241 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, aliveDevMap, LOW_device::getID(), and graveyardMap.

Referenced by searchDevices().

void LOW_netSegment::cmd_MatchROM const LOW_device   inDevice const [protected, virtual]
 

Select a single device on a link.

The matchROM command followed by a 64-bit ROM code sequence allows the bus master to address a specific slave device on a multidrop or single-drop bus. Only the slave that exactly matches the 64-bit ROM code sequence will respond to the function command issued by the master; all other slaves on the bus will wait for a reset pulse.

Parameters:
inDevice  Device to select.
Exceptions:
noDevice_error  Thrown when no device was found on the bus.

Definition at line 160 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, byteVec_t, LOW_device::getID(), LOW_deviceIDRaw::getRomIDVec(), link, LOW_device::MatchROM_COMMAND, LOW_link::resetBus(), and LOW_link::writeData().

Referenced by LOW_device::cmd_MatchROM().

LOW_deviceID LOW_netSegment::cmd_ReadROM   const [protected, virtual]
 

Read ID number from bus.

The read ROM command allows the bus master to read the slave's 64-bit ROM code without using the Search ROM procedure.

Note: The read ROM command can only be used when there is one slave on the bus. If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time.

Returns:
ID of the found device.
Exceptions:
noDevice_error  Thrown when no device was found on the bus.

Definition at line 180 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ__, byteVec_t, LOW_deviceIDRaw::devRomID_t, link, LOW_link::readData(), LOW_device::ReadROM_COMMAND, LOW_link::resetBus(), and LOW_link::writeData().

LOW_deviceID::deviceIDVec_t LOW_netSegment::cmd_SearchROM const bool    inOnlyAlarm = false,
const LOW_deviceIDRaw::devFamCode_t    inFamCode = LOW_device::anyDev_famCode
const [protected, virtual]
 

Scan the bus for devices.

The searchROM command allows the master to determine the number of slaves and their device types. The master learns the ROM codes through a process of elimination that requires the master to perform a Search ROM cycle (i.e., Search ROM command followed by data exchange) as many times as necessary to identify all of the slave devices.

If there is only one slave on the bus, the simpler Read ROM command can be used in place of the Search ROM process.

The search can be narrowed to devices which their alarm flag set and/or to specific family codes.

Parameters:
inOnlyAlarm  Whether to look only for alarming devices.
inFamCode  Specific family code for narrowing search.
Returns:
List of found IDs.
Exceptions:
noDevice_error  Thrown when no device was found on the bus.

Definition at line 212 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, LOW_deviceIDRaw::devFamCode_t, LOW_deviceID::deviceIDVec_t, link, and LOW_link::searchDevices().

Referenced by searchDevices().

bool LOW_netSegment::cmd_SearchROMVerify const LOW_deviceID    inDevID,
const bool    inOnlyAlarm = false,
const bool    inDoReset = true
const [protected, virtual]
 

Scan the bus for a specific device.

Parameters:
inDevID  Device to search for.
inOnlyAlarm  Whether to report as found only when alarming.
inDoReset  Whether to reset the bus afterwards.
Returns:
Indicated whether the device was found or not.
Exceptions:
noDevice_error  Thrown when no device was found on the bus.

Definition at line 221 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, LOW_device::anyDev_famCode, LOW_deviceID::deviceIDVec_t, link, and LOW_link::searchDevices().

Referenced by verifyDevice().

void LOW_netSegment::cmd_SkipROM   const [protected, virtual]
 

Select all devices on a link.

The master can use this command to address all devices on the bus simultaneously without sending out any ROM code information. For example, the master can make all DS18S20s on the bus perform simultaneous temperature conversions by issuing a Skip ROM command followed by a ConvertT command.

Exceptions:
noDevice_error  Thrown when no device was found on the bus.

Definition at line 199 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ__, link, LOW_link::resetBus(), LOW_device::SkipROM_COMMAND, and LOW_link::writeData().

template<class castType>
castType * LOW_netSegment::devicePtr_cast LOW_device   inPtr const [inline, private]
 

Safely cast a generic device pointer to a specific one.

The type to cast to is specified by the template parameter.

Parameters:
inPtr  Generic pointer to be casted.
Returns:
Casted pointer of the requested type.
Exceptions:
LOW_device::illegalCast_error  Thrown when type cast is not possible.

Definition at line 484 of file LOW_netSegment.h.

template<class devType>
devType * LOW_netSegment::getDevice const LOW_deviceID    inDevID
 

Get a specific device.

Devices are searched in the internal device list only. No bus actions are performed.

Note::The device type to look for is selected by the template parameter.

Parameters:
inDevID  ID of the device to get.
Returns:
Requested device.
Exceptions:
LOW_device::familyMismatch_error  Thrown when family code of selected class and the one in the ID don't match.
noDevice_error  Thrown when requested device is not present.

Definition at line 411 of file LOW_netSegment.h.

References __LOW_SYNCHRONIZE_METHOD_READ__, aliveDevMap, LOW_device::anyDev_famCode, LOW_deviceIDRaw::getFamilyCode(), and LOW_device::unknownDev_famCode.

template<class devType>
std::vector< devType *> LOW_netSegment::getDevices   const
 

Get devices of a specific type.

Devices are searched in the internal device list only. No bus actions are performed. Selecting any device type will result in the complete list of devices known to be present on the segment.

Note:: The device type to look for is selected by the template parameter. To select any device type use LOW_device.

Returns:
Vector of found devices.

Definition at line 429 of file LOW_netSegment.h.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, aliveDevMap, LOW_device::anyDev_famCode, and LOW_device::unknownDev_famCode.

bool LOW_netSegment::getHasExternalPower   const [virtual]
 

Get wether there is an external power line on the segment.

Returns:
Wether there is an external power line on the segment.

Definition at line 106 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, and hasExternalPower.

Referenced by LOW_compJalousieController::LOW_compJalousieController(), LOW_compTwinSwitch::LOW_compTwinSwitch(), and LOW_devDS1820::LOW_devDS1820().

LOW_link & LOW_netSegment::getLink   [virtual]
 

Get the LOW_link instance associated with this segment.

Returns:
Reference to the link instance.

Definition at line 98 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, and link.

Referenced by LOW_device::getLink().

LOW_netSegment::netSegPtrVec_t LOW_netSegment::newSegmentsFromLink LOW_link   inLink [static, protected]
 

Discovers network segments on a link.

Warning:
By now only a single segment is supported.
Parameters:
inLink  The link to be searched for network segments.

Definition at line 64 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_STATIC_WRITE__, LOW_netSegment(), and netSegPtrVec_t.

Referenced by LOW_network::addSegments().

bool LOW_netSegment::operator== LOW_netSegment &    inSegment const [private, virtual]
 

Comparison based on segmentID.

Warning:
By now only a single segment is supported
Todo:
Add support for multi-segment links

Definition at line 84 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ_WEAK__, and segmentID.

void LOW_netSegment::removeDevice const LOW_device   inDev [private, virtual]
 

Removes a device from either the alive map or the graveyard.

If it does not exist, the method returns silently.

Parameters:
inDev  The device to remove.

Definition at line 302 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, aliveDevMap, LOW_device::getID(), and graveyardMap.

Referenced by unregisterDevice().

void LOW_netSegment::revitalizeDevice const LOW_device   inDev [private, virtual]
 

Move a device from the graveyard to the alive map.

If not on graveyard, the method returns silently.

Parameters:
inDev  The device to move.

Definition at line 259 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, aliveDevMap, LOW_device::getID(), and graveyardMap.

Referenced by addDevice(), and verifyDevice().

template<class devType>
std::vector< devType *> LOW_netSegment::searchDevices const bool    inOnlyAlarm = false
 

Search for devices on the segment.

Selecting any device type will result in searching the whole segment.

Note:: The device type to look for is selected by the template parameter. To select any device type use LOW_device.

Note:: The bus will be actively searched. Newly found devices will be added to the internal device list.

Parameters:
inOnlyAlarm  Determines whether to look only for alarming devices of the requested type.
Returns:
Vector of found devices.

Definition at line 447 of file LOW_netSegment.h.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, addDevice(), buryDevice(), cmd_SearchROM(), LOW_deviceID::deviceIDVec_t, and LOW_device::devPtrVec_t.

void LOW_netSegment::unregisterDevice const LOW_device   inDev [protected, virtual]
 

Indicate that a device instance is going to be deleted.

Function mainly used by the destructor of LOW_device.

Parameters:
inDev  Device to unregister.

Definition at line 146 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, and removeDevice().

Referenced by LOW_device::~LOW_device().

bool LOW_netSegment::verifyDevice const LOW_deviceID    inDevID,
const bool    inOnlyAlarm = false,
const bool    inDoReset = true
[virtual]
 

Verify existance of a specific device on the segment.

Note:: In case you already own a reference to the device, use the corresponding method from LOW_device.

Note:: The bus will be actively searched. Newly found devices will be added to the internal device list.

Parameters:
inDevID  ID of the device to verify.
inOnlyAlarm  Determines whether to report existance only when the device is alarming.
inDoReset  Whether to reset the bus afterwards.
Returns:
Boolean indicates wheter the device could be found or not.

Definition at line 114 of file LOW_netSegment.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, addDevice(), cmd_SearchROMVerify(), and revitalizeDevice().

Referenced by LOW_device::verifyDevice().


Friends And Related Function Documentation

friend class LOW_device [friend]
 

Enable access to unregister a device on destruction.

Definition at line 174 of file LOW_netSegment.h.

friend class LOW_network [friend]
 

Enable access to static pseudo constructor and destructor.

Definition at line 173 of file LOW_netSegment.h.


Member Data Documentation

LOW_thread_rwlock * LOW_netSegment::__staticSyncRwlockSingleton = 0 [static, protected]
 

Definition at line 28 of file LOW_netSegment.cpp.

LOW_platformMiscFactory::threadIdent_t LOW_netSegment::__writeLockHolder = 0 [static, protected]
 

Definition at line 28 of file LOW_netSegment.cpp.

LOW_device::deviceMap_t LOW_netSegment::aliveDevMap [private]
 

Map of currently present devices on the segment.

Definition at line 323 of file LOW_netSegment.h.

Referenced by addDevice(), buryDevice(), getDevice(), getDevices(), removeDevice(), revitalizeDevice(), and ~LOW_netSegment().

LOW_device::deviceMap_t LOW_netSegment::graveyardMap [private]
 

Map of formerly present devices on the segment.

Definition at line 324 of file LOW_netSegment.h.

Referenced by addDevice(), buryDevice(), removeDevice(), revitalizeDevice(), and ~LOW_netSegment().

bool LOW_netSegment::hasExternalPower [private]
 

Whether there is an additional line for external power supply available.

Definition at line 322 of file LOW_netSegment.h.

Referenced by getHasExternalPower(), and LOW_netSegment().

LOW_link& LOW_netSegment::link [private]
 

Link this segment is present on.

Definition at line 321 of file LOW_netSegment.h.

Referenced by cmd_MatchROM(), cmd_ReadROM(), cmd_SearchROM(), cmd_SearchROMVerify(), cmd_SkipROM(), getLink(), and LOW_netSegment().

const segmentID_t LOW_netSegment::segmentID [private]
 

Identifier of the segment.

Definition at line 320 of file LOW_netSegment.h.

Referenced by operator==().


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 10:32:49 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001