Esempio n. 1
0
        public void SetDeviceHandlerFromName(string fullName)
        {
            var type = Assembly.GetExecutingAssembly().GetType(fullName); // full name - i.e. with namespace (perhaps concatenate)

            try
            {
                var deviceHandler = (IZWaveDeviceHandler)Activator.CreateInstance(type);
                //
                this.DeviceHandler = deviceHandler;
                this.DeviceHandler.SetNodeHost(this);
            }
            catch
            {
                // TODO: add error logging
            }
        }
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
        private void CheckDeviceHandler(ManufacturerSpecific manufacturerspecs)
        {
            //if (this.DeviceHandler == null)
            {
                var typeList = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "ZWaveLib.Devices.ProductHandlers.");
                for (int i = 0; i < typeList.Count; i++)
                {

                    //Console.WriteLine(typelist[i].FullName);
                    Type type = Assembly.GetExecutingAssembly().GetType(typeList[i].FullName); // full name - i.e. with namespace (perhaps concatenate)
                    try
                    {
                        IZWaveDeviceHandler deviceHandler = (IZWaveDeviceHandler)Activator.CreateInstance(type);
                        //
                        if (deviceHandler.CanHandleProduct(manufacturerspecs))
                        {
                            this.DeviceHandler = deviceHandler;
                            this.DeviceHandler.SetNodeHost(this);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        // TODO: add error logging
                        //                                        Console.WriteLine("ERROR!!!!!!! " + ex.Message + " : " + ex.StackTrace);
                    }
                }
            }
        }
Esempio n. 4
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. 5
0
 public void SetDeviceHandlerFromName(string fullName)
 {
     var type = Assembly.GetExecutingAssembly().GetType(fullName); // full name - i.e. with namespace (perhaps concatenate)
     try
     {
         var deviceHandler = (IZWaveDeviceHandler)Activator.CreateInstance(type);
         //
         this.DeviceHandler = deviceHandler;
         this.DeviceHandler.SetNodeHost(this);
     }
     catch (Exception ex)
     {
         // TODO: add error logging
     }
 }