Пример #1
0
        public void EnablePoll(byte NodeID, string ValueLabel)
        {
            ZWValueID id = GetValueID(m_nodeList[3], ValueLabel);

            if (id != null)
            {
                Log("Message", "Enabled poll on " + id.GetId().ToString());
                m_manager.EnablePoll(id);
            }
        }
Пример #2
0
        private void NotificationHandler()
        {
            switch (m_notification.GetType())
            {
            case ZWNotification.Type.ValueAdded:
            {
                Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.AddValue(m_notification.GetValueID());
                }
                break;
            }

            case ZWNotification.Type.ValueRemoved:
            {
                Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.RemoveValue(m_notification.GetValueID());
                }
                break;
            }

            case ZWNotification.Type.ValueChanged:
            {
/*						Console.WriteLine("Value Changed");
 *                                              ZWValueID v = m_notification.GetValueID();
 *                                              Console.WriteLine("  Node : " + v.GetNodeId().ToString());
 *                                              Console.WriteLine("  CC   : " + v.GetCommandClassId().ToString());
 *                                              Console.WriteLine("  Type : " + v.GetType().ToString());
 *                                              Console.WriteLine("  Index: " + v.GetIndex().ToString());
 *                                              Console.WriteLine("  Inst : " + v.GetInstance().ToString());
 *                                              Console.WriteLine("  Value: " + GetValue(v).ToString());
 *                                              Console.WriteLine("  Label: " + m_manager.GetValueLabel(v));
 *                                              Console.WriteLine("  Help : " + m_manager.GetValueHelp(v));
 *                                              Console.WriteLine("  Units: " + m_manager.GetValueUnits(v));
 */             break;
            }

            case ZWNotification.Type.Group:
            {
                break;
            }

            case ZWNotification.Type.NodeAdded:
            {
                // if this node was in zwcfg*.xml, this is the first node notification
                // if not, the NodeNew notification should already have been received
                if (GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()) == null)
                {
                    Node node = new Node();
                    node.ID     = m_notification.GetNodeId();
                    node.HomeID = m_notification.GetHomeId();
                    m_nodeList.Add(node);
                }
                break;
            }

            case ZWNotification.Type.NodeNew:
            {
                // Add the new node to our list (and flag as uninitialized)
                Node node = new Node();
                node.ID     = m_notification.GetNodeId();
                node.HomeID = m_notification.GetHomeId();
                m_nodeList.Add(node);
                break;
            }

            case ZWNotification.Type.NodeRemoved:
            {
                foreach (Node node in m_nodeList)
                {
                    if (node.ID == m_notification.GetNodeId())
                    {
                        m_nodeList.Remove(node);
                        break;
                    }
                }
                break;
            }

            case ZWNotification.Type.NodeProtocolInfo:
            {
                Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                }
                break;
            }

            case ZWNotification.Type.NodeNaming:
            {
                Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.Manufacturer = m_manager.GetNodeManufacturerName(m_homeId, node.ID);
                    node.Product      = m_manager.GetNodeProductName(m_homeId, node.ID);
                    node.Location     = m_manager.GetNodeLocation(m_homeId, node.ID);
                    node.Name         = m_manager.GetNodeName(m_homeId, node.ID);
                }
                break;
            }

            case ZWNotification.Type.NodeEvent:
            {
                break;
            }

            case ZWNotification.Type.PollingDisabled:
            {
                Console.WriteLine("Polling disabled notification");
                break;
            }

            case ZWNotification.Type.PollingEnabled:
            {
                Console.WriteLine("Polling enabled notification");
                break;
            }

            case ZWNotification.Type.DriverReady:
            {
                m_homeId = m_notification.GetHomeId();
                toolStripStatusLabel1.Text = "Initializing...driver with Home ID 0x" + m_homeId.ToString("X8") + " is ready.";
                break;
            }

            case ZWNotification.Type.NodeQueriesComplete:
            {
                // as an example, enable query of BASIC info (CommandClass = 0x20)
                Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    foreach (ZWValueID vid in node.Values)
                    {
//								if (vid.GetCommandClassId() == 0x84)	// remove this "if" to poll all values
                        m_manager.EnablePoll(vid);
                    }
                }
                toolStripStatusLabel1.Text = "Initializing...node " + node.ID + " query complete.";
                break;
            }

            case ZWNotification.Type.AllNodesQueried:
            {
                toolStripStatusLabel1.Text = "Ready:  All nodes queried.";
                break;
            }

            case ZWNotification.Type.AwakeNodesQueried:
            {
                toolStripStatusLabel1.Text = "Ready:  Awake nodes queried (but not some sleeping nodes).";
                break;
            }
            }

            //NodeGridView.Refresh();
            NodeGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            NodeGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
        }