Пример #1
0
        public override void ApplyState(DeviceBase.DeviceState state)
        {
            base.ApplyState(state);

            LampState currentState = (LampState)mState;
            LampState newState     = (LampState)state;

            // Make sure we don't try to change these values.
            newState.Dimmable = currentState.Dimmable;
            newState.Group    = currentState.Group;

            // Prioritize level changes which would indirectly affect Value changes.
            if (currentState.Dimmable &&
                Math.Abs(newState.Level - currentState.Level) > 0.001f)
            {
                DimDevice(newState.Level);
            }
            else if (newState.Value != currentState.Value)
            {
                SwitchDevice(newState.Value);
            }
            else if (ForceSwitching)
            {
                if (newState.Level > 0.0f && newState.Level < 1.0f)
                {
                    DimDevice(newState.Level);
                }
                else
                {
                    SwitchDevice(newState.Value);
                }
            }
        }
Пример #2
0
        public override void ApplyState(DeviceBase.DeviceState state)
        {
            lock (mLock)
                base.ApplyState(state);

            var currentState = (YamahaState)mState;
            var newState     = (YamahaState)state;

            if (newState.Power != currentState.Power)
            {
                SetPower(newState.Power);
            }

            if (newState.Input != currentState.Input)
            {
                SetInput(newState.Input);
            }

            if (newState.Mute != currentState.Mute)
            {
                Mute(newState.Mute);
            }

            if (newState.Volume != currentState.Volume)
            {
                SetVolume(newState.Volume);
            }
        }
Пример #3
0
        public override void ApplyState(DeviceBase.DeviceState state)
        {
            base.ApplyState(state);

            CurtainState currentState = (CurtainState)mState;
            CurtainState newState     = (CurtainState)state;

            Debug.Assert(newState.Channel == currentState.Channel);

            // FIXME - Disable prediction since we're getting out of sync somehow.
            //if (newState.Action != currentState.Action)
            {
                switch (newState.Action)
                {
                case Key.Up:
                    Up();
                    break;

                case Key.Stop:
                    Stop();
                    break;

                case Key.Down:
                    Down();
                    break;
                }
            }
        }
Пример #4
0
        public override void ApplyState(DeviceBase.DeviceState state)
        {
            base.ApplyState(state);

            NexaLampState currentState = (NexaLampState)mState;
            NexaLampState newState     = (NexaLampState)state;

            Debug.Assert(newState.Address == currentState.Address);
            Debug.Assert(newState.Unit == currentState.Unit);
        }
Пример #5
0
        public void DeviceBase_TestCopyState()
        {
            var device = CreateTestDevice();

            var copyState = device.CopyState();

            var testState = new DeviceBase.DeviceState();

            testState.Name        = "ProperDeviceName";
            testState.DisplayName = "ProperDisplayName";
            testState.Archetype   = "ProperArchetype";
            testState.Type        = device.GetType().ToString();

            Assert.AreEqual(testState.Name, copyState.Name);
            Assert.AreEqual(testState.DisplayName, copyState.DisplayName);
            Assert.AreEqual(testState.Archetype, copyState.Archetype);
            Assert.AreEqual(testState.Type, copyState.Type);
        }
Пример #6
0
        public override void ApplyState(DeviceBase.DeviceState state)
        {
            base.ApplyState(state);

            EpsonState currentState = (EpsonState)mState;
            EpsonState newState     = (EpsonState)state;

            if (newState.Power != currentState.Power)
            {
                if (newState.Power)
                {
                    PowerOn();
                }
                else
                {
                    PowerOff();
                }
            }
            else if (newState.Source != currentState.Source)
            {
                Source = newState.Source;
            }
        }
Пример #7
0
 public void UpdateState(DeviceBase.DeviceState state)
 {
     // Replace internal state with the updated one.
     lock (mLock)
         mState = state;
 }