Esempio n. 1
0
        public void SetDeviceHandler(ZWaveNode node)
        {
            // Search handler in nodesConfig first
            for (int n = 0; n < nodesConfig.Count; n++)
            {
                var config = nodesConfig[n];
                if (config.NodeId == node.NodeId && config.DeviceHandler != null && !config.DeviceHandler.Contains(".Generic."))
                {
                    // set to last known handler
                    SetDeviceHandlerFromName(node, config.DeviceHandler);
                    break;
                }
            }
            // If no specific devicehandler could be found, then set a generic handler
            if (node.DeviceHandler == null)
            {
                IZWaveDeviceHandler deviceHandler = null;
                switch (node.GenericClass)
                {
                case 0x00:
                    // need to query node capabilities
                    //GetNodeCapabilities(node.NodeId);
                    break;

                case (byte)ZWaveLib.GenericType.SwitchBinary:
                    deviceHandler = new ProductHandlers.Generic.Switch();
                    break;

                case (byte)ZWaveLib.GenericType.SwitchMultilevel: // eg. dimmer
                    deviceHandler = new ProductHandlers.Generic.Dimmer();
                    break;

                case (byte)ZWaveLib.GenericType.Thermostat:
                    deviceHandler = new ProductHandlers.Generic.Thermostat();
                    break;

                // Fallback to generic Sensor driver if type is not directly supported.
                // The Generic.Sensor handler is currently used as some kind of multi-purpose driver
                default:
                    deviceHandler = new ProductHandlers.Generic.Sensor();
                    break;
                }
                if (deviceHandler != null)
                {
                    node.DeviceHandler = deviceHandler;
                    node.DeviceHandler.SetNodeHost(node);
                }
            }
        }
Esempio n. 2
0
        public void SetGenericHandler()
        {
            if (this.DeviceHandler == null)
            {
                //No specific devicehandler could be found. Use a generic handler
                IZWaveDeviceHandler deviceHandler = null;
                switch (this.GenericClass)
                {
                case 0x00:
                    // need to query node capabilities
                    byte[] message = new byte[] {
                        0x01,
                        0x04,
                        0x00,
                        (byte)Controller.ZWaveCommandClass.CMD_GET_NODE_PROTOCOL_INFO,
                        this.NodeId,
                        0x00
                    };
                    SendMessage(message);
                    break;

                case (byte)ZWaveLib.GenericType.SWITCH_BINARY:
                    deviceHandler = new ProductHandlers.Generic.Switch();
                    break;

                case (byte)ZWaveLib.GenericType.SWITCH_MULTILEVEL: // eg. dimmer
                    deviceHandler = new ProductHandlers.Generic.Dimmer();
                    break;

                case (byte)ZWaveLib.GenericType.THERMOSTAT:
                    deviceHandler = new ProductHandlers.Generic.Thermostat();
                    break;

                // Fallback to generic Sensor driver if type is not directly supported.
                // The Generic.Sensor handler is currently used as some kind of multi-purpose driver
                default:
                    deviceHandler = new ProductHandlers.Generic.Sensor();
                    break;
                }
                if (deviceHandler != null)
                {
                    this.DeviceHandler = deviceHandler;
                    this.DeviceHandler.SetNodeHost(this);
                }
            }
        }
Esempio n. 3
0
 public void SetGenericHandler()
 {
     if (this.DeviceHandler == null)
     {
         //No specific devicehandler could be found. Use a generic handler
         IZWaveDeviceHandler deviceHandler = null;
         switch (this.GenericClass)
         {
             case 0x00:
                 // need to query node capabilities
                 byte[] message = new byte[] { 0x01, 0x04, 0x00, (byte)Controller.ZWaveCommandClass.CMD_GET_NODE_PROTOCOL_INFO, this.NodeId, 0x00 };
                 SendMessage(message);
                 break;
             case (byte)ZWaveLib.GenericType.SWITCH_BINARY:
                 deviceHandler = new ProductHandlers.Generic.Switch();
                 break;
             case (byte)ZWaveLib.GenericType.SWITCH_MULTILEVEL: // eg. dimmer
                 deviceHandler = new ProductHandlers.Generic.Dimmer();
                 break;
             case (byte)ZWaveLib.GenericType.THERMOSTAT:
                 deviceHandler = new ProductHandlers.Generic.Thermostat();
                 break;
             // Fallback to generic Sensor driver if type is not directly supported.
             // The Generic.Sensor handler is currently used as some kind of multi-purpose driver
             default:
                 deviceHandler = new ProductHandlers.Generic.Sensor();
                 break;
         }
         if (deviceHandler != null)
         {
             this.DeviceHandler = deviceHandler;
             this.DeviceHandler.SetNodeHost(this);
         }
     }
 }