#include <LOW_netSegment.h>
Collaboration diagram for LOW_netSegment:
Public Types | |
typedef uint32_t | segmentID_t |
segment ID type. More... | |
typedef std::vector< LOW_netSegment *> | netSegPtrVec_t |
Vector type of class pointers. More... | |
Public Methods | |
LOW_link & | getLink () |
Get the LOW_link instance associated with this segment. More... | |
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> vector< devType *> | getDevices () const |
Get devices of a specific type. More... | |
template<class devType> vector< devType *> | searchDevices (const bool inOnlyAlarm=false) |
Search for devices on the segment. More... | |
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 | |
~LOW_netSegment () | |
Destructor. More... | |
void | unregisterDevice (const LOW_device *inDev) |
Indicate that a device instance is going to be deleted. More... | |
void | cmd_MatchROM (const LOW_device *inDevice) const |
Select a single device on a link. More... | |
void | cmd_SkipROM () const |
Select all devices on a link. More... | |
LOW_deviceID | cmd_ReadROM () const |
Read ID number from bus. More... | |
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... | |
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... | |
Private Methods | |
LOW_netSegment (LOW_link &inLink) | |
Constructor from link. More... | |
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... | |
void | buryDevice (const LOW_device *inDev) |
Move a device from the alive map to the graveyard. More... | |
void | revitalizeDevice (const LOW_device *inDev) |
Move a device from the graveyard to the alive map. More... | |
LOW_device * | addDevice (const LOW_deviceID inDevID) |
Add a device to the alive map. More... | |
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_link & | link |
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... | |
Static Private Attributes | |
segmentID_t | segmentCount = 0 |
Incremented on instance creation to get individual IDs. 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... |
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:
Definition at line 47 of file LOW_netSegment.h.
|
Vector type of class pointers.
Definition at line 72 of file LOW_netSegment.h. Referenced by LOW_network::addSegments(), LOW_network::getSegments(), LOW_network::network_error::network_error(), and newSegmentsFromLink(). |
|
segment ID type.
Definition at line 70 of file LOW_netSegment.h. |
|
Destructor. Destroys all objects of devices (in both maps). Definition at line 46 of file LOW_netSegment.cpp. References aliveDevMap, and graveyardMap. |
|
Constructor from link. Triggers initial search of devices on the segment.
Definition at line 36 of file LOW_netSegment.cpp. References LOW_link::getHasExternalPower(), hasExternalPower, and link. Referenced by newSegmentsFromLink(). |
|
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.
Definition at line 332 of file LOW_netSegment.cpp. References aliveDevMap, graveyardMap, LOW_deviceFactory::new_SpecificDevice(), and revitalizeDevice(). Referenced by searchDevices(), and verifyDevice(). |
|
Move a device from the alive map to the graveyard. If not in alive map, the method returns silently.
Definition at line 300 of file LOW_netSegment.cpp. References aliveDevMap, LOW_device::getID(), and graveyardMap. Referenced by searchDevices(). |
|
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.
Definition at line 147 of file LOW_netSegment.cpp. References 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(). |
|
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.
Definition at line 165 of file LOW_netSegment.cpp. References byteVec_t, LOW_deviceIDRaw::devRomID_t, link, LOW_link::readData(), LOW_device::ReadROM_COMMAND, LOW_link::resetBus(), and LOW_link::writeData(). |
|
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.
Definition at line 193 of file LOW_netSegment.cpp. References LOW_device::anyDev_famCode, LOW_deviceIDRaw::devFamCode_t, LOW_deviceID::deviceIDVec_t, LOW_link::doSearchSequence(), LOW_deviceIDRaw::getBit(), LOW_deviceIDRaw::getFamilyCode(), link, LOW_link::resetBus(), LOW_device::SearchAlarmROM_COMMAND, LOW_device::SearchROM_COMMAND, LOW_deviceIDRaw::setBit(), LOW_deviceIDRaw::setFamilyCode(), and LOW_link::writeData(). Referenced by searchDevices(). |
|
Scan the bus for a specific device.
Definition at line 267 of file LOW_netSegment.cpp. References LOW_link::doSearchSequence(), link, LOW_link::resetBus(), LOW_device::SearchAlarmROM_COMMAND, LOW_device::SearchROM_COMMAND, and LOW_link::writeData(). Referenced by verifyDevice(). |
|
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.
Definition at line 182 of file LOW_netSegment.cpp. References link, LOW_link::resetBus(), LOW_device::SkipROM_COMMAND, and LOW_link::writeData(). |
|
Safely cast a generic device pointer to a specific one. The type to cast to is specified by the template parameter.
Definition at line 464 of file LOW_netSegment.h. |
|
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.
Definition at line 400 of file LOW_netSegment.h. References aliveDevMap, LOW_device::anyDev_famCode, and LOW_deviceIDRaw::getFamilyCode(). |
|
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.
Definition at line 415 of file LOW_netSegment.h. References aliveDevMap, and LOW_device::anyDev_famCode. |
|
Get wether there is an external power line on the segment.
Definition at line 99 of file LOW_netSegment.cpp. References hasExternalPower. Referenced by LOW_compJalousieController::LOW_compJalousieController(), LOW_compTwinSwitch::LOW_compTwinSwitch(), and LOW_devDS1820::LOW_devDS1820(). |
|
Get the LOW_link instance associated with this segment.
Definition at line 93 of file LOW_netSegment.cpp. References link. Referenced by LOW_device::getLink(). |
|
Discovers network segments on a link.
Definition at line 62 of file LOW_netSegment.cpp. References LOW_netSegment(), and netSegPtrVec_t. Referenced by LOW_network::addSegments(). |
|
Comparison based on segmentID.
Definition at line 81 of file LOW_netSegment.cpp. References segmentID. |
|
Removes a device from either the alive map or the graveyard. If it does not exist, the method returns silently.
Definition at line 355 of file LOW_netSegment.cpp. References aliveDevMap, LOW_device::getID(), and graveyardMap. Referenced by unregisterDevice(). |
|
Move a device from the graveyard to the alive map. If not on graveyard, the method returns silently.
Definition at line 316 of file LOW_netSegment.cpp. References aliveDevMap, LOW_device::getID(), and graveyardMap. Referenced by addDevice(), and verifyDevice(). |
|
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.
Definition at line 429 of file LOW_netSegment.h. References addDevice(), buryDevice(), cmd_SearchROM(), LOW_deviceID::deviceIDVec_t, and LOW_device::devPtrVec_t. |
|
Indicate that a device instance is going to be deleted. Function mainly used by the destructor of LOW_device.
Definition at line 135 of file LOW_netSegment.cpp. References removeDevice(). Referenced by LOW_device::~LOW_device(). |
|
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.
Definition at line 105 of file LOW_netSegment.cpp. References addDevice(), cmd_SearchROMVerify(), and revitalizeDevice(). Referenced by LOW_device::verifyDevice(). |
|
Enable access to unregister a device on destruction.
Definition at line 166 of file LOW_netSegment.h. |
|
Enable access to static pseudo constructor and destructor.
Definition at line 165 of file LOW_netSegment.h. |
|
Map of currently present devices on the segment.
Definition at line 312 of file LOW_netSegment.h. Referenced by addDevice(), buryDevice(), getDevice(), getDevices(), removeDevice(), revitalizeDevice(), and ~LOW_netSegment(). |
|
Map of formerly present devices on the segment.
Definition at line 313 of file LOW_netSegment.h. Referenced by addDevice(), buryDevice(), removeDevice(), revitalizeDevice(), and ~LOW_netSegment(). |
|
Whether there is an additional line for external power supply available.
Definition at line 311 of file LOW_netSegment.h. Referenced by getHasExternalPower(), and LOW_netSegment(). |
|
Link this segment is present on.
Definition at line 310 of file LOW_netSegment.h. Referenced by cmd_MatchROM(), cmd_ReadROM(), cmd_SearchROM(), cmd_SearchROMVerify(), cmd_SkipROM(), getLink(), and LOW_netSegment(). |
|
Incremented on instance creation to get individual IDs.
Definition at line 28 of file LOW_netSegment.cpp. |
|
Identifier of the segment.
Definition at line 309 of file LOW_netSegment.h. Referenced by operator==(). |