Exemplo n.º 1
0
 private ZWValueID GetValueID(ZWaveNode node, string valueLabel)
 {
     foreach (ZWValueID valueID in node.Values)
     {
         if (m_manager.GetValueLabel(valueID) == valueLabel)
         {
             return(valueID);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
 private void SetValueID(ZWaveNode node, string valueLabel, byte value)
 {
     try
     {
         foreach (ZWValueID valueID in node.Values)
         {
             if (m_manager.GetValueLabel(valueID) == valueLabel)
             {
                 m_manager.SetValue(valueID, value);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Log("Error", ex.Message);
     }
 }
Exemplo n.º 3
0
        public List <NodeDetail> Nodes()
        {
            List <NodeDetail> nodeList = new List <NodeDetail>();
            ZWaveNode         n        = new ZWaveNode();

            ZWave.Log("WCFService", "Nodes");
            foreach (Byte nodeID in zwaveControl.ListOfNodeIDs())
            {
                nodeList.Add(new NodeDetail()
                {
                    NodeID     = nodeID
                    , Name     = zwaveControl.NodeName(nodeID)
                    , Type     = zwaveControl.NodeType(nodeID)
                    , Location = zwaveControl.NodeLocation(nodeID)
                    , Basic    = zwaveControl.NodeBasic(nodeID)
                    , Level    = zwaveControl.NodeLevel(nodeID)
                });
            }

            return(nodeList);
        }
Exemplo n.º 4
0
        public NodeDetail Node(string NodeID)
        {
            ZWave.Log("WCFService", "Node");
            byte       nodeID;
            ZWaveNode  n          = new ZWaveNode();
            NodeDetail nodeDetail = new NodeDetail();

            if (byte.TryParse(NodeID, out nodeID))
            {
                nodeDetail = new NodeDetail()
                {
                    NodeID     = nodeID
                    , Name     = zwaveControl.NodeName(nodeID)
                    , Type     = zwaveControl.NodeType(nodeID)
                    , Location = zwaveControl.NodeLocation(nodeID)
                    , Basic    = zwaveControl.NodeBasic(nodeID)
                    , Level    = zwaveControl.NodeLevel(nodeID)
                };
            }

            return(nodeDetail);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method which handles the events raised by the ZWave network
        /// </summary>
        /// <param name="m_notification"></param>
        private void NotificationHandler(ZWNotification m_notification)
        {
            if (m_notification == null)
            {
                return;
            }

            switch (m_notification.GetType())
            {
            case ZWNotification.Type.ValueAdded:
            {
                ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.AddValue(m_notification.GetValueID());
                    Log("Event", "Node ValueAdded, " + m_manager.GetValueLabel(m_notification.GetValueID()));
                }
                break;
            }

            case ZWNotification.Type.ValueRemoved:
            {
                ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.RemoveValue(m_notification.GetValueID());
                    Log("Event", "Node ValueRemoved, " + m_manager.GetValueLabel(m_notification.GetValueID()));
                }
                break;
            }

            case ZWNotification.Type.ValueChanged:
            {
                ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.SetValue(m_notification.GetValueID());

                    Log("Event", "Node ValueChanged, " + m_manager.GetValueLabel(m_notification.GetValueID()).ToString());
                }

                break;
            }

            case ZWNotification.Type.Group:
            {
                break;
            }

            case ZWNotification.Type.NodeAdded:
            {
                // Add the new node to our list
                ZWaveNode node = new ZWaveNode();
                node.ID     = m_notification.GetNodeId();
                node.HomeID = m_notification.GetHomeId();
                m_nodeList.Add(node);
                Log("Event", "Node added, " + m_notification.GetNodeId().ToString());
                break;
            }

            case ZWNotification.Type.NodeRemoved:
            {
                foreach (ZWaveNode node in m_nodeList)
                {
                    if (node.ID == m_notification.GetNodeId())
                    {
                        Log("Event", "Node removed, " + m_notification.GetNodeId().ToString());
                        m_nodeList.Remove(node);
                        break;
                    }
                }
                break;
            }

            case ZWNotification.Type.NodeProtocolInfo:
            {
                ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());
                if (node != null)
                {
                    node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                    Log("Event", "Node protocol info, " + node.Label.ToString());
                }
                break;
            }

            case ZWNotification.Type.NodeNaming:
            {
                ZWaveNode 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:
            {
                Log("Event", "Node event");
                break;
            }

            case ZWNotification.Type.PollingDisabled:
            {
                Log("Event", "Polling disabled notification");
                break;
            }

            case ZWNotification.Type.PollingEnabled:
            {
                Log("Event", "Polling disabled notification");
                break;
            }

            case ZWNotification.Type.DriverReady:
            {
                m_homeId = m_notification.GetHomeId();
                Log("Event", "Driver ready, with homeId " + m_homeId.ToString());
                break;
            }

            case ZWNotification.Type.NodeQueriesComplete:
            {
                break;
            }

            case ZWNotification.Type.AllNodesQueried:
            {
                Log("Event", "All nodes queried");
                m_nodesReady = true;
                break;
            }

            case ZWNotification.Type.AwakeNodesQueried:
            {
                Log("Event", "Awake nodes queried (but some sleeping nodes have not been queried)");
                break;
            }
            }
        }