コード例 #1
0
ファイル: Lamp.cs プロジェクト: wuzhenda/HA4IoT
        private void SetStateInternal(PowerStateValue powerState, ColorState colorState, bool forceUpdate = false)
        {
            if (colorState == null)
            {
                if (!forceUpdate && _powerState == powerState)
                {
                    return;
                }
            }
            else if (!forceUpdate && _powerState == powerState && colorState.Equals(_colorState))
            {
                return;
            }

            var oldState = GetState();

            var parameters = forceUpdate ? new IHardwareParameter[] { HardwareParameter.ForceUpdateState } : new IHardwareParameter[0];

            if (powerState == PowerStateValue.On)
            {
                _adapter.SetState(AdapterPowerState.On, GenerateAdapterColor(colorState), parameters);
            }
            else if (powerState == PowerStateValue.Off)
            {
                _adapter.SetState(AdapterPowerState.Off, GenerateAdapterColor(colorState), parameters);
            }

            _powerState = powerState;
            _colorState = colorState;

            OnStateChanged(oldState);
        }
コード例 #2
0
 public void LeftButtonClick()
 {
     if (isCycling)
     {
         return;
     }
     else
     {
         if (state.Equals(ColorState.RED))
         {
             //        StartCoroutine(Move(true));
             anim.SetTrigger("Red_to_Green");
             state = ColorState.GREEN;
         }
         else if (state.Equals(ColorState.GREEN))
         {
             //       StartCoroutine(Move(true));
             anim.SetTrigger("Green_to_Blue");
             state = ColorState.BLUE;
         }
         else if (state.Equals(ColorState.BLUE))
         {
             //       StartCoroutine(Move(true));
             anim.SetTrigger("Blue_to_Red");
             state = ColorState.RED;
         }
     }
 }