mirror of
https://github.com/Fishwaldo/open-zwave.git
synced 2025-03-15 11:31:40 +00:00
MultiChannel code: change wording instance -> endpoint (#1976)
Wherever posible, voriables, comments and log suggesting "instance" have been renamed to "endpoint". There is no functional change. It improves readability of the code. Rationale: When dealing with MultiInstance Devices, OpenZWave uses "Instance" to identify a subdevice. The public interface maps an Instance ID to an "End Point", which in turn gets used to build Z-Wave packets. Config files and by extension ozwcache store this map per CC, for example: <Instance index="1" endpoint="1" /> The Group aka Association commands, however, expect "End Points". It would make sense to change "Instance" to "End Point" in *all* related code but this is not possible, there is one exception: InstanceAssociation is exposed by the API, in Manager::GetAssociations. Because of its exposure, m_instance cannot be renamed to m_endPoint without breaking existing code.
This commit is contained in:
parent
8bd071ff57
commit
acce060e21
6 changed files with 64 additions and 47 deletions
|
@ -203,11 +203,11 @@ void Group::WriteXML(TiXmlElement* _groupElement)
|
|||
// <Group::Contains>
|
||||
// Whether a group contains a particular node
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Group::Contains(uint8 const _nodeId, uint8 const _instance)
|
||||
bool Group::Contains(uint8 const _nodeId, uint8 const _endPoint)
|
||||
{
|
||||
for (map<InstanceAssociation, AssociationCommandVec, classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it)
|
||||
{
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _instance))
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _endPoint))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ bool Group::Contains(uint8 const _nodeId, uint8 const _instance)
|
|||
// <Group::AddAssociation>
|
||||
// Associate a node with this group
|
||||
//-----------------------------------------------------------------------------
|
||||
void Group::AddAssociation(uint8 const _nodeId, uint8 const _instance)
|
||||
void Group::AddAssociation(uint8 const _nodeId, uint8 const _endPoint)
|
||||
{
|
||||
if (Driver* driver = Manager::Get()->GetDriver(m_homeId))
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ void Group::AddAssociation(uint8 const _nodeId, uint8 const _instance)
|
|||
Internal::CC::MultiChannelAssociation* cc = static_cast<Internal::CC::MultiChannelAssociation*>(node->GetCommandClass(Internal::CC::MultiChannelAssociation::StaticGetCommandClassId()));
|
||||
if (cc && IsMultiInstance())
|
||||
{
|
||||
cc->Set(m_groupIdx, _nodeId, _instance);
|
||||
cc->Set(m_groupIdx, _nodeId, _endPoint);
|
||||
cc->QueryGroup(m_groupIdx, 0);
|
||||
}
|
||||
else if (Internal::CC::Association* cc = static_cast<Internal::CC::Association*>(node->GetCommandClass(Internal::CC::Association::StaticGetCommandClassId())))
|
||||
|
@ -248,7 +248,7 @@ void Group::AddAssociation(uint8 const _nodeId, uint8 const _instance)
|
|||
// <Group:RemoveAssociation>
|
||||
// Remove a node from this group
|
||||
//-----------------------------------------------------------------------------
|
||||
void Group::RemoveAssociation(uint8 const _nodeId, uint8 const _instance)
|
||||
void Group::RemoveAssociation(uint8 const _nodeId, uint8 const _endPoint)
|
||||
{
|
||||
if (Driver* driver = Manager::Get()->GetDriver(m_homeId))
|
||||
{
|
||||
|
@ -257,7 +257,7 @@ void Group::RemoveAssociation(uint8 const _nodeId, uint8 const _instance)
|
|||
Internal::CC::MultiChannelAssociation* cc = static_cast<Internal::CC::MultiChannelAssociation*>(node->GetCommandClass(Internal::CC::MultiChannelAssociation::StaticGetCommandClassId()));
|
||||
if (cc && IsMultiInstance())
|
||||
{
|
||||
cc->Remove(m_groupIdx, _nodeId, _instance);
|
||||
cc->Remove(m_groupIdx, _nodeId, _endPoint);
|
||||
cc->QueryGroup(m_groupIdx, 0);
|
||||
}
|
||||
else if (Internal::CC::Association* cc = static_cast<Internal::CC::Association*>(node->GetCommandClass(Internal::CC::Association::StaticGetCommandClassId())))
|
||||
|
@ -432,11 +432,11 @@ uint32 Group::GetAssociations(InstanceAssociation** o_associations)
|
|||
// <Group::ClearCommands>
|
||||
// Clear all the commands for the specified node
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Group::ClearCommands(uint8 const _nodeId, uint8 const _instance)
|
||||
bool Group::ClearCommands(uint8 const _nodeId, uint8 const _endPoint)
|
||||
{
|
||||
for (map<InstanceAssociation, AssociationCommandVec, classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it)
|
||||
{
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _instance))
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _endPoint))
|
||||
{
|
||||
it->second.clear();
|
||||
return true;
|
||||
|
@ -450,11 +450,11 @@ bool Group::ClearCommands(uint8 const _nodeId, uint8 const _instance)
|
|||
// <Group::AddCommand>
|
||||
// Add a command to the list for the specified node
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Group::AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _instance)
|
||||
bool Group::AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _endPoint)
|
||||
{
|
||||
for (map<InstanceAssociation, AssociationCommandVec, classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it)
|
||||
{
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _instance))
|
||||
if ((it->first.m_nodeId == _nodeId) && (it->first.m_instance == _endPoint))
|
||||
{
|
||||
it->second.push_back(AssociationCommand(_length, _data));
|
||||
return true;
|
||||
|
|
|
@ -48,10 +48,22 @@ namespace OpenZWave
|
|||
|
||||
class Node;
|
||||
|
||||
// When dealing with MultiInstance Devices,
|
||||
// OpenZWave uses "Instance" to identify a subdevice.
|
||||
// The public interface maps an Instance ID to an "End Point", which in turn
|
||||
// gets used to build Z-Wave packets.
|
||||
// Config files and by extension ozwcache store this map per CC, for example:
|
||||
// <Instance index="1" endpoint="1" />
|
||||
// The Group Aka Association commands, however, expect "End Points"
|
||||
// It would make sense to change "Instance" to "End Point" in all related code but...
|
||||
// InstanceAssociation is exposed by the API in Manager::GetAssociations
|
||||
// Because of its exposure, m_instance cannot be renamed to m_endPoint without
|
||||
// breaking existing code.
|
||||
|
||||
typedef struct InstanceAssociation
|
||||
{
|
||||
uint8 m_nodeId;
|
||||
uint8 m_instance;
|
||||
uint8 m_instance; // "End Point" as defined in SDS13782-11B, Multi Channel Association Command Class.
|
||||
} InstanceAssociation;
|
||||
|
||||
/** \brief Manages a group of devices (various nodes associated with each other).
|
||||
|
@ -92,7 +104,7 @@ namespace OpenZWave
|
|||
{
|
||||
return m_groupIdx;
|
||||
}
|
||||
bool Contains(uint8 const _nodeId, uint8 const _instance = 0x00);
|
||||
bool Contains(uint8 const _nodeId, uint8 const _endPoint= 0x00);
|
||||
bool IsMultiInstance() const
|
||||
{
|
||||
return m_multiInstance;
|
||||
|
@ -114,8 +126,8 @@ namespace OpenZWave
|
|||
m_multiInstance = _state;
|
||||
}
|
||||
|
||||
void AddAssociation(uint8 const _nodeId, uint8 const _instance = 0x00);
|
||||
void RemoveAssociation(uint8 const _nodeId, uint8 const _instance = 0x00);
|
||||
void AddAssociation(uint8 const _nodeId, uint8 const endPoint = 0x00);
|
||||
void RemoveAssociation(uint8 const _nodeId, uint8 const _endPoint = 0x00);
|
||||
void OnGroupChanged(vector<uint8> const& _associations);
|
||||
void OnGroupChanged(vector<InstanceAssociation> const& _associations);
|
||||
|
||||
|
@ -123,8 +135,8 @@ namespace OpenZWave
|
|||
// Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION)
|
||||
//-----------------------------------------------------------------------------
|
||||
public:
|
||||
bool ClearCommands(uint8 const _nodeId, uint8 const _instance = 0x00);
|
||||
bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _instance = 0x00);
|
||||
bool ClearCommands(uint8 const _nodeId, uint8 const _endPoint = 0x00);
|
||||
bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _endPoint = 0x00);
|
||||
|
||||
private:
|
||||
class AssociationCommand
|
||||
|
|
|
@ -3571,6 +3571,8 @@ uint32 Manager::GetAssociations(uint32 const _homeId, uint8 const _nodeId, uint8
|
|||
//-----------------------------------------------------------------------------
|
||||
// <Manager::GetAssociations>
|
||||
// Gets the associations for a group
|
||||
// struct InstanceAssociation is defined in Group.h and contains
|
||||
// a (NodeID, End Point) pair.
|
||||
//-----------------------------------------------------------------------------
|
||||
uint32 Manager::GetAssociations(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, InstanceAssociation** o_associations)
|
||||
{
|
||||
|
@ -3627,11 +3629,11 @@ string Manager::GetGroupLabel(uint32 const _homeId, uint8 const _nodeId, uint8 c
|
|||
// <Manager::AddAssociation>
|
||||
// Adds a node to an association group
|
||||
//-----------------------------------------------------------------------------
|
||||
void Manager::AddAssociation(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance)
|
||||
void Manager::AddAssociation(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _endPoint)
|
||||
{
|
||||
if (Driver* driver = GetDriver(_homeId))
|
||||
{
|
||||
driver->AddAssociation(_nodeId, _groupIdx, _targetNodeId, _instance);
|
||||
driver->AddAssociation(_nodeId, _groupIdx, _targetNodeId, _endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3639,11 +3641,11 @@ void Manager::AddAssociation(uint32 const _homeId, uint8 const _nodeId, uint8 co
|
|||
// <Manager::RemoveAssociation>
|
||||
// Removes a node from an association group
|
||||
//-----------------------------------------------------------------------------
|
||||
void Manager::RemoveAssociation(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance)
|
||||
void Manager::RemoveAssociation(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _endPoint)
|
||||
{
|
||||
if (Driver* driver = GetDriver(_homeId))
|
||||
{
|
||||
driver->RemoveAssociation(_nodeId, _groupIdx, _targetNodeId, _instance);
|
||||
driver->RemoveAssociation(_nodeId, _groupIdx, _targetNodeId, _endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1673,6 +1673,9 @@ namespace OpenZWave
|
|||
/**
|
||||
* \brief Gets the associations for a group.
|
||||
* Makes a copy of the list of associated nodes in the group, and returns it in an array of InstanceAssociation's.
|
||||
* struct InstanceAssociation is defined in Group.h and contains
|
||||
* a (NodeID, End Point) pair. See SDS13783-11B Z-Wave Transport-Encapsulation Command Class Specification
|
||||
* chapter 2.3.1 Terminology for the definition of "End Point" and "Multi Channel Encapsulation"
|
||||
* The caller is responsible for freeing the array memory with a call to delete [].
|
||||
* \param _homeId The Home ID of the Z-Wave controller that manages the node.
|
||||
* \param _nodeId The ID of the node whose associations we are interested in.
|
||||
|
|
|
@ -127,12 +127,12 @@ namespace OpenZWave
|
|||
// <MultiChannelAssociation::RequestState>
|
||||
// Nothing to do for Association
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MultiChannelAssociation::RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue)
|
||||
bool MultiChannelAssociation::RequestState(uint32 const _requestFlags, uint8 const _endPoint, Driver::MsgQueue const _queue)
|
||||
{
|
||||
if ((_requestFlags & RequestFlag_Static) && HasStaticRequest(StaticRequest_Values))
|
||||
{
|
||||
// Request the supported group info
|
||||
return RequestValue(_requestFlags, 0, _instance, _queue);
|
||||
return RequestValue(_requestFlags, 0, _endPoint, _queue);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -143,11 +143,11 @@ namespace OpenZWave
|
|||
// Nothing to do for Association
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MultiChannelAssociation::RequestValue(uint32 const _requestFlags, uint16 const _dummy1, // = 0 (not used)
|
||||
uint8 const _instance, Driver::MsgQueue const _queue)
|
||||
uint8 const _endPoint, Driver::MsgQueue const _queue)
|
||||
{
|
||||
if (_instance != 1)
|
||||
if (_endPoint != 1)
|
||||
{
|
||||
// This command class doesn't work with multiple instances
|
||||
// This command class doesn't work with multiple End Points
|
||||
return false;
|
||||
}
|
||||
// Request the supported group info
|
||||
|
@ -188,7 +188,7 @@ namespace OpenZWave
|
|||
// <MultiChannelAssociation::HandleMsg>
|
||||
// Handle a message from the Z-Wave network
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MultiChannelAssociation::HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _instance // = 1
|
||||
bool MultiChannelAssociation::HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _endPoint // = 1
|
||||
)
|
||||
{
|
||||
bool handled = false;
|
||||
|
@ -201,7 +201,7 @@ namespace OpenZWave
|
|||
// Retrieve the number of groups this device supports.
|
||||
// The groups will be queried with the session data.
|
||||
m_numGroups = _data[1];
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "Received Multi Instance Association Groupings report from node %d. Number of groups is %d", GetNodeId(), m_numGroups);
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "Received MULTI_CHANNEL_ASSOCIATION_GROUPINGS_REPORT from node %d. Number of groups is %d", GetNodeId(), m_numGroups);
|
||||
ClearStaticRequest(StaticRequest_Values);
|
||||
handled = true;
|
||||
}
|
||||
|
@ -221,10 +221,10 @@ namespace OpenZWave
|
|||
// node B
|
||||
// 0x00 Marker
|
||||
// node C
|
||||
// instance #
|
||||
// End Point #
|
||||
// node D
|
||||
// instance #
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "Received Multi Instance Association report from node %d, group %d", GetNodeId(), groupIdx);
|
||||
// End Point #
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "Received MULTI_CHANNEL_ASSOCIATION_REPORT from node %d, group %d", GetNodeId(), groupIdx);
|
||||
Log::Write(LogLevel_Info, GetNodeId(), " The group contains:");
|
||||
bool pastMarker = false;
|
||||
for (i = 0; i < _length - 5; ++i)
|
||||
|
@ -245,7 +245,7 @@ namespace OpenZWave
|
|||
}
|
||||
else
|
||||
{
|
||||
Log::Write(LogLevel_Info, GetNodeId(), " Node %d instance %d", _data[i + 4], _data[i + 5]);
|
||||
Log::Write(LogLevel_Info, GetNodeId(), " Node %d End Point %d", _data[i + 4], _data[i + 5]);
|
||||
InstanceAssociation association;
|
||||
association.m_nodeId = _data[i + 4];
|
||||
association.m_instance = _data[i + 5];
|
||||
|
@ -348,18 +348,18 @@ namespace OpenZWave
|
|||
// <MultiChannelAssociation::Set>
|
||||
// Add an association between devices
|
||||
//-----------------------------------------------------------------------------
|
||||
void MultiChannelAssociation::Set(uint8 _groupIdx, uint8 _targetNodeId, uint8 _instance)
|
||||
void MultiChannelAssociation::Set(uint8 _groupIdx, uint8 _targetNodeId, uint8 _endPoint)
|
||||
{
|
||||
|
||||
/* for Qubino devices, we should always set a Instance if its the ControllerNode, so MultChannelEncap works. - See Bug #857 */
|
||||
if ((m_com.GetFlagBool(COMPAT_FLAG_MCA_FORCEINSTANCES) == true) && (_instance == 0) && (GetDriver()->GetControllerNodeId() == _targetNodeId))
|
||||
/* for Qubino devices, we should always set a End Point if its the ControllerNode, so MultChannelEncap works. - See Bug #857 */
|
||||
if ((m_com.GetFlagBool(COMPAT_FLAG_MCA_FORCEINSTANCES) == true) && (_endPoint == 0) && (GetDriver()->GetControllerNodeId() == _targetNodeId))
|
||||
{
|
||||
_instance = 0x01;
|
||||
_endPoint = 0x01;
|
||||
}
|
||||
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "MultiChannelAssociation::Set - Adding instance %d on node %d to group %d of node %d", _instance, _targetNodeId, _groupIdx, GetNodeId());
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "MultiChannelAssociation::Set - Adding End Point %d on node %d to group %d of node %d", _endPoint, _targetNodeId, _groupIdx, GetNodeId());
|
||||
|
||||
if (_instance == 0x00)
|
||||
if (_endPoint == 0x00)
|
||||
{
|
||||
Msg* msg = new Msg("MultiChannelAssociationCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true);
|
||||
msg->Append(GetNodeId());
|
||||
|
@ -381,7 +381,7 @@ namespace OpenZWave
|
|||
msg->Append(_groupIdx);
|
||||
msg->Append(0x00); // marker
|
||||
msg->Append(_targetNodeId);
|
||||
msg->Append(_instance);
|
||||
msg->Append(_endPoint);
|
||||
msg->Append(GetDriver()->GetTransmitOptions());
|
||||
GetDriver()->SendMsg(msg, Driver::MsgQueue_Send);
|
||||
}
|
||||
|
@ -391,11 +391,11 @@ namespace OpenZWave
|
|||
// <MultiChannelAssociation::Remove>
|
||||
// Remove an association between devices
|
||||
//-----------------------------------------------------------------------------
|
||||
void MultiChannelAssociation::Remove(uint8 _groupIdx, uint8 _targetNodeId, uint8 _instance)
|
||||
void MultiChannelAssociation::Remove(uint8 _groupIdx, uint8 _targetNodeId, uint8 _endPoint)
|
||||
{
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "MultiChannelAssociation::Remove - Removing instance %d on node %d from group %d of node %d", _instance, _targetNodeId, _groupIdx, GetNodeId());
|
||||
Log::Write(LogLevel_Info, GetNodeId(), "MultiChannelAssociation::Remove - Removing End Point %d on node %d from group %d of node %d", _endPoint, _targetNodeId, _groupIdx, GetNodeId());
|
||||
|
||||
if (_instance == 0x00)
|
||||
if (_endPoint == 0x00)
|
||||
{
|
||||
Msg* msg = new Msg("MultiChannelAssociationCmd_Remove", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true);
|
||||
msg->Append(GetNodeId());
|
||||
|
@ -417,7 +417,7 @@ namespace OpenZWave
|
|||
msg->Append(_groupIdx);
|
||||
msg->Append(0x00); // marker
|
||||
msg->Append(_targetNodeId);
|
||||
msg->Append(_instance);
|
||||
msg->Append(_endPoint);
|
||||
msg->Append(GetDriver()->GetTransmitOptions());
|
||||
GetDriver()->SendMsg(msg, Driver::MsgQueue_Send);
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ namespace OpenZWave
|
|||
// From CommandClass
|
||||
virtual void ReadXML(TiXmlElement const* _ccElement) override;
|
||||
virtual void WriteXML(TiXmlElement* _ccElement) override;
|
||||
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue) override;
|
||||
virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue) override;
|
||||
virtual bool RequestState(uint32 const _requestFlags, uint8 const _endPoint, Driver::MsgQueue const _queue) override;
|
||||
virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _endPoint, Driver::MsgQueue const _queue) override;
|
||||
virtual uint8 const GetCommandClassId() const override
|
||||
{
|
||||
return StaticGetCommandClassId();
|
||||
|
@ -77,11 +77,11 @@ namespace OpenZWave
|
|||
{
|
||||
return StaticGetCommandClassName();
|
||||
}
|
||||
virtual bool HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _instance = 1) override;
|
||||
virtual bool HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _endPoint = 1) override;
|
||||
|
||||
void RequestAllGroups(uint32 const _requestFlags);
|
||||
void Set(uint8 const _group, uint8 const _nodeId, uint8 const _instance);
|
||||
void Remove(uint8 const _group, uint8 const _nodeId, uint8 const _instance);
|
||||
void Set(uint8 const _group, uint8 const _nodeId, uint8 const _endPoint);
|
||||
void Remove(uint8 const _group, uint8 const _nodeId, uint8 const _endPoint);
|
||||
|
||||
private:
|
||||
MultiChannelAssociation(uint32 const _homeId, uint8 const _nodeId);
|
||||
|
|
Loading…
Add table
Reference in a new issue