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; }
private void PressInternal(ButtonPressedDuration duration) { if (duration == ButtonPressedDuration.Short) { ((Trigger)PressedShortTrigger).Execute(); } else { ((Trigger)PressedLongTrigger).Execute(); } }
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(); } }
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; }
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; }
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); }
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); }
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(); } }
protected virtual void OnButtonPressed(IButton button, ButtonPressedDuration duration) { }