Пример #1
0
        public ZWaveDevice(BaseNetwork network, BackingDevice backingDevice)
            : base(network)
        {
            BackingObject = backingDevice;

            BackingObject.PollEnabled = false;

            Address = backingDevice.NodeID.ToString();

            _toggleSwitch = new ZWaveToggleSwitch(this);
            _dimmerSwitch = new ZWaveDimmerSwitch(this);
            _thermostat = new ZWaveThermostat(this);
            _binarySensor = new ZWaveBinarySensor(this);
            _temperatureSensor = new ZWaveTemperatureSensor(this);

            if (Type == DeviceType.MultilevelSwitch || Type == DeviceType.Unknown)
            {
                _dimmerSwitch.MaxPower = 99;
            }
            else
            {
                _dimmerSwitch.MaxPower = 255;
            }

            BackingObject.LevelChanged += (sender, args) =>
                {
                    _dimmerSwitch.Power = args.Level;
                    IsConnected = true;
                    //TODO: device found event?
                    PowerChanged();
                };
        }
Пример #2
0
        public ZWaveDevice(BaseNetwork network, BackingDevice backingDevice)
            : base(network)
        {
            BackingObject = backingDevice;

            BackingObject.PollEnabled = false;

            Address = backingDevice.NodeID.ToString();

            _toggleSwitch      = new ZWaveToggleSwitch(this);
            _dimmerSwitch      = new ZWaveDimmerSwitch(this);
            _thermostat        = new ZWaveThermostat(this);
            _binarySensor      = new ZWaveBinarySensor(this);
            _temperatureSensor = new ZWaveTemperatureSensor(this);

            if (Type == DeviceType.MultilevelSwitch || Type == DeviceType.Unknown)
            {
                _dimmerSwitch.MaxPower = 99;
            }
            else
            {
                _dimmerSwitch.MaxPower = 255;
            }

            BackingObject.LevelChanged += (sender, args) =>
            {
                _dimmerSwitch.Power = args.Level;
                IsConnected         = true;
                //TODO: device found event?
                PowerChanged();
            };
        }