Ejemplo n.º 1
0
 private void SetBindingTable(List <BindingTable> bindingTable)
 {
     lock (BindingTable)
     {
         BindingTable.Clear();
         BindingTable.AddRange(bindingTable);
         _logger.Debug("{Address}: Binding table updated: {BindingTable}", IeeeAddress, bindingTable);
     }
 }
Ejemplo n.º 2
0
        public void SetDao(ZigBeeNodeDao dao)
        {
            IeeeAddress     = new IeeeAddress(dao.IeeeAddress);
            NetworkAddress  = dao.NetworkAddress;
            NodeDescriptor  = dao.NodeDescriptor;
            PowerDescriptor = dao.PowerDescriptor;
            if (dao.BindingTable != null)
            {
                BindingTable.AddRange(dao.BindingTable);
            }

            foreach (ZigBeeEndpointDao endpointDao in dao.Endpoints)
            {
                ZigBeeEndpoint endpoint = new ZigBeeEndpoint(this, endpointDao.EndpointId);
                endpoint.SetDao(endpointDao);
                Endpoints[endpoint.EndpointId] = endpoint;
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }