コード例 #1
0
        protected override void OnButtonPressed(IButton button, ButtonPressedDuration duration)
        {
            JsonObject data = CreateDataPackage(button.Id, EventType.ButtonPressed);
            data.SetNamedValue("kind", JsonValue.CreateStringValue(duration.ToString()));

            Task.Run(() => SendToAzureEventHubAsync(data));
        }
コード例 #2
0
        protected override void OnButtonPressed(IButton button, ButtonPressedDuration duration)
        {
            JsonObject data = CreateDataPackage(button.Id, EventType.ButtonPressed);

            data.SetNamedValue("kind", JsonValue.CreateStringValue(duration.ToString()));

            Task.Run(() => SendToAzureEventHubAsync(data));
        }
        public static IButton ConnectToggleActionWith(this IButton button, IStateMachine actuator, ButtonPressedDuration pressedDuration = ButtonPressedDuration.Short)
        {
            if (actuator == null) throw new ArgumentNullException(nameof(actuator));
            if (button == null) throw new ArgumentNullException(nameof(button));

            ConnectToggleAction(button, actuator, pressedDuration);

            return button;
        }
        public static IBinaryStateOutputActuator ConnectToggleActionWith(this IBinaryStateOutputActuator actuator, IButton button, ButtonPressedDuration pressedDuration = ButtonPressedDuration.Short)
        {
            if (actuator == null) throw new ArgumentNullException(nameof(actuator));
            if (button == null) throw new ArgumentNullException(nameof(button));

            ConnectToggleAction(button, actuator, pressedDuration);

            return actuator;
        }
コード例 #5
0
 private void PressInternal(ButtonPressedDuration duration)
 {
     if (duration == ButtonPressedDuration.Short)
     {
         ((Trigger)PressedShortTrigger).Execute();
     }
     else
     {
         ((Trigger)PressedLongTrigger).Execute();
     }
 }
コード例 #6
0
ファイル: Button.cs プロジェクト: wuzhenda/HA4IoT
 private void PressInternal(ButtonPressedDuration duration)
 {
     if (duration == ButtonPressedDuration.Short)
     {
         _messageBroker.Publish(Id, new ButtonPressedShortEvent());
     }
     else
     {
         _messageBroker.Publish(Id, new ButtonPressedLongEvent());
     }
 }
 private static void ConnectToggleAction(IButton button, IStateMachine actuator, ButtonPressedDuration pressedDuration)
 {
     if (pressedDuration == ButtonPressedDuration.Short)
     {
         button.GetPressedShortlyTrigger().Attach(actuator.GetSetNextStateAction());
     }
     else if (pressedDuration == ButtonPressedDuration.Long)
     {
         button.GetPressedLongTrigger().Attach(actuator.GetSetNextStateAction());
     }
     else
     {
         throw new NotSupportedException();
     }
 }
 private static void ConnectToggleAction(IButton button, IBinaryStateOutputActuator actuator, ButtonPressedDuration pressedDuration)
 {
     if (pressedDuration == ButtonPressedDuration.Short)
     {
         button.PressedShort += (s, e) => actuator.Toggle();
     }
     else if (pressedDuration == ButtonPressedDuration.Long)
     {
         button.PressedLong += (s, e) => actuator.Toggle();
     }
     else
     {
         throw new NotSupportedException();
     }
 }
コード例 #9
0
        public LogicalBinaryStateActuator ConnectToggleActionWith(IButton button, ButtonPressedDuration pressedDuration = ButtonPressedDuration.Short)
        {
            if (button == null) throw new ArgumentNullException(nameof(button));

            if (pressedDuration == ButtonPressedDuration.Short)
            {
                button.GetPressedShortlyTrigger().Attach(() => ToggleState());
            }
            else if (pressedDuration == ButtonPressedDuration.Long)
            {
                button.GetPressedLongTrigger().Attach(() => ToggleState());
            }
            else
            {
                throw new NotSupportedException();
            }

            return this;
        }
コード例 #10
0
        public AutomaticTurnOnAndOffAutomation WithTrigger(IButton button, ButtonPressedDuration duration = ButtonPressedDuration.Short, params IParameter[] parameters)
        {
            if (button == null) throw new ArgumentNullException(nameof(button));
            if (parameters == null) throw new ArgumentNullException(nameof(parameters));

            if (duration == ButtonPressedDuration.Short)
            {
                button.PressedShort += HandleButtonPressed;
            }
            else if (duration == ButtonPressedDuration.Long)
            {
                button.PressedLong += HandleButtonPressed;
            }
            else
            {
                throw new NotSupportedException();
            }
            
            return this;
        }
コード例 #11
0
        public LogicalBinaryStateActuator ConnectToggleActionWith(IButton button, ButtonPressedDuration pressedDuration = ButtonPressedDuration.Short)
        {
            if (button == null)
            {
                throw new ArgumentNullException(nameof(button));
            }

            if (pressedDuration == ButtonPressedDuration.Short)
            {
                button.GetPressedShortlyTrigger().Attach(() => ToggleState());
            }
            else if (pressedDuration == ButtonPressedDuration.Long)
            {
                button.GetPressedLongTrigger().Attach(() => ToggleState());
            }
            else
            {
                throw new NotSupportedException();
            }

            return(this);
        }
コード例 #12
0
 private static void ConnectToggleAction(IButton button, IStateMachine actuator, ButtonPressedDuration pressedDuration)
 {
     if (pressedDuration == ButtonPressedDuration.Short)
     {
         button.GetPressedShortlyTrigger().Attach(actuator.GetSetNextStateAction());
     }
     else if (pressedDuration == ButtonPressedDuration.Long)
     {
         button.GetPressedLongTrigger().Attach(actuator.GetSetNextStateAction());
     }
     else
     {
         throw new NotSupportedException();
     }
 }
コード例 #13
0
        public static IButton ConnectToggleActionWith(this IButton button, IStateMachine actuator, ButtonPressedDuration pressedDuration = ButtonPressedDuration.Short)
        {
            if (actuator == null)
            {
                throw new ArgumentNullException(nameof(actuator));
            }
            if (button == null)
            {
                throw new ArgumentNullException(nameof(button));
            }

            ConnectToggleAction(button, actuator, pressedDuration);

            return(button);
        }
コード例 #14
0
 private static void ConnectToggleAction(IButton button, IBinaryStateOutputActuator actuator, ButtonPressedDuration pressedDuration)
 {
     if (pressedDuration == ButtonPressedDuration.Short)
     {
         button.GetPressedShortlyTrigger().Attach(() => actuator.Toggle());
     }
     else if (pressedDuration == ButtonPressedDuration.Long)
     {
         button.GetPressedLongTrigger().Attach(() => actuator.Toggle());
     }
     else
     {
         throw new NotSupportedException();
     }
 }
コード例 #15
0
 protected virtual void OnButtonPressed(IButton button, ButtonPressedDuration duration)
 {
 }
コード例 #16
0
 protected virtual void OnButtonPressed(IButton button, ButtonPressedDuration duration)
 {
 }