Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 7
0
 public void UpdateState(DeviceBase.DeviceState state)
 {
     // Replace internal state with the updated one.
     lock (mLock)
         mState = state;
 }