private void SetBindingTable(List <BindingTable> bindingTable) { lock (BindingTable) { BindingTable.Clear(); BindingTable.AddRange(bindingTable); _logger.Debug("{Address}: Binding table updated: {BindingTable}", IeeeAddress, bindingTable); } }
private void SetBindingTable(HashSet <BindingTable> bindingTable) { lock (BindingTable) { BindingTable.Clear(); BindingTable.UnionWith(bindingTable); Log.Debug("{Address}: Binding table updated: {BindingTable}", IeeeAddress, bindingTable); } }
/// <summary> /// Updates the node. This will copy data from another node into this node. Updated elements are checked for equality /// and the method will only return true if the node data has been changed. /// /// @param node the {@link ZigBeeNode} that contains the newer node data. /// @return true if there were changes made as a result of the update /// </summary> public bool UpdateNode(ZigBeeNode node) { if (!node.IeeeAddress.Equals(IeeeAddress)) { return(false); } bool updated = false; if (!NetworkAddress.Equals(node.NetworkAddress)) { updated = true; NetworkAddress = node.NetworkAddress; } if (!NodeDescriptor.Equals(node.NodeDescriptor)) { updated = true; NodeDescriptor = node.NodeDescriptor; } if (!PowerDescriptor.Equals(node.PowerDescriptor)) { updated = true; PowerDescriptor = node.PowerDescriptor; } lock (AssociatedDevices) { if (!AssociatedDevices.Equals(node.AssociatedDevices)) { updated = true; AssociatedDevices.Clear(); AssociatedDevices.AddRange(node.AssociatedDevices); } } lock (BindingTable) { if (!BindingTable.Equals(node.BindingTable)) { updated = true; BindingTable.Clear(); BindingTable.AddRange(node.BindingTable); } } lock (Neighbors) { if (!Neighbors.Equals(node.Neighbors)) { updated = true; Neighbors.Clear(); Neighbors.AddRange(node.Neighbors); } } lock (Routes) { if (!Routes.Equals(node.Routes)) { updated = true; Routes.Clear(); Routes.AddRange(node.Routes); } } // TODO: How to deal with endpoints return(updated); }
/// <summary> /// Updates the node. This will copy data from another node into this node. Updated elements are checked for equality /// and the method will only return true if the node data has been changed. /// /// <param name="node">the <see cref="ZigBeeNode"> that contains the newer node data.</param> /// <returns>true if there were changes made as a result of the update</returns> /// </summary> public bool UpdateNode(ZigBeeNode node) { if (!node.IeeeAddress.Equals(IeeeAddress)) { return(false); } bool updated = false; if (!NetworkAddress.Equals(node.NetworkAddress)) { updated = true; NetworkAddress = node.NetworkAddress; } if (!NodeDescriptor.Equals(node.NodeDescriptor)) { updated = true; NodeDescriptor = node.NodeDescriptor; } if (!PowerDescriptor.Equals(node.PowerDescriptor)) { updated = true; PowerDescriptor = node.PowerDescriptor; } lock (AssociatedDevices) { if (!AssociatedDevices.Equals(node.AssociatedDevices)) { updated = true; AssociatedDevices.Clear(); AssociatedDevices.AddRange(node.AssociatedDevices); } } lock (BindingTable) { if (!BindingTable.Equals(node.BindingTable)) { updated = true; BindingTable.Clear(); BindingTable.AddRange(node.BindingTable); } } lock (Neighbors) { if (!Neighbors.Equals(node.Neighbors)) { updated = true; Neighbors.Clear(); Neighbors.AddRange(node.Neighbors); } } lock (Routes) { if (!Routes.Equals(node.Routes)) { updated = true; Routes.Clear(); Routes.AddRange(node.Routes); } } // Endpoints are only copied over if they don't exist in the node // The assumption here is that endpoints are only set once, and not changed. // This should be valid as they are set through the SimpleDescriptor. foreach (var endpoint in node.Endpoints) { if (Endpoints.ContainsKey(endpoint.Key)) { continue; } updated = true; Endpoints[endpoint.Key] = endpoint.Value; } return(updated); }
/// <summary> /// Updates the node. This will copy data from another node into this node. Updated elements are checked for equality /// and the method will only return true if the node data has been changed. /// /// <param name="node">the <see cref="ZigBeeNode"> that contains the newer node data.</param> /// <returns>true if there were changes made as a result of the update</returns> /// </summary> public bool UpdateNode(ZigBeeNode node) { if (!node.IeeeAddress.Equals(IeeeAddress)) { Log.Debug("{IeeeAddress}: Ieee address inconsistent during update <>{NodeIeeeAddress}", IeeeAddress, node.IeeeAddress); return(false); } bool updated = false; if (NetworkAddress != 0 && !NetworkAddress.Equals(node.NetworkAddress)) { Log.Debug("{IeeeAddress}: Network address updated from {NetworkAddress} to {NodeNetworkAddress}", IeeeAddress, NetworkAddress, node.NetworkAddress); updated = true; NetworkAddress = node.NetworkAddress; } if (node.NodeDescriptor != null && (NodeDescriptor == null || !NodeDescriptor.Equals(node.NodeDescriptor))) { Log.Debug("{IeeeAddress}: Node descriptor updated", IeeeAddress); updated = true; NodeDescriptor = node.NodeDescriptor; } if (node.PowerDescriptor != null && (PowerDescriptor == null || !PowerDescriptor.Equals(node.PowerDescriptor))) { Log.Debug("{IeeeAddress}: Power descriptor updated", IeeeAddress); updated = true; PowerDescriptor = node.PowerDescriptor; } lock (AssociatedDevices) { if (!AssociatedDevices.SetEquals(node.AssociatedDevices)) { Log.Debug("{IeeeAddress}: Associated devices updated", IeeeAddress); updated = true; AssociatedDevices.Clear(); AssociatedDevices.UnionWith(node.AssociatedDevices); } } lock (BindingTable) { if (!BindingTable.SetEquals(node.BindingTable)) { Log.Debug("{IeeeAddress}: Binding table updated", IeeeAddress); updated = true; BindingTable.Clear(); BindingTable.UnionWith(node.BindingTable); } } lock (Neighbors) { if (!Neighbors.SetEquals(node.Neighbors)) { Log.Debug("{IeeeAddress}: Neighbors updated", IeeeAddress); updated = true; Neighbors.Clear(); Neighbors.UnionWith(node.Neighbors); } } lock (Routes) { if (!Routes.SetEquals(node.Routes)) { Log.Debug("{IeeeAddress}: Routes updated", IeeeAddress); updated = true; Routes.Clear(); Routes.UnionWith(node.Routes); } } // Endpoints are only copied over if they don't exist in the node // The assumption here is that endpoints are only set once, and not changed. // This should be valid as they are set through the SimpleDescriptor. foreach (var endpoint in node.Endpoints) { if (Endpoints.ContainsKey(endpoint.Key)) { continue; } Log.Debug("{IeeeAddress}: Endpoint {EndpointId} added", IeeeAddress, endpoint.Key); updated = true; Endpoints[endpoint.Key] = endpoint.Value; } return(updated); }