-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathILightTransitionToggleConfigurator.cs
More file actions
183 lines (160 loc) · 11.5 KB
/
Copy pathILightTransitionToggleConfigurator.cs
File metadata and controls
183 lines (160 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using CodeCasa.AutomationPipelines.Lights.Timeline;
using CodeCasa.Lights;
using Occurify;
namespace CodeCasa.AutomationPipelines.Lights.Toggle;
/// <summary>
/// Configurator for time-based toggle behavior. Quick consecutive triggers advance through all states sequentially.
/// After a timeout period, the next trigger restarts from the beginning.
/// If the light is currently on, the first trigger will turn it off.
/// </summary>
/// <typeparam name="TLight">The specific type of light being controlled, which must implement <see cref="ILight"/>.</typeparam>
public interface ILightTransitionToggleConfigurator<TLight> where TLight : ILight
{
/// <summary>
/// Sets the timeout duration after which the toggle cycle restarts from the beginning.
/// </summary>
/// <param name="timeout">The timeout duration between triggers that determines when to restart the cycle.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> SetToggleTimeout(TimeSpan timeout);
/// <summary>
/// Includes the "off" state in the toggle cycle. When the light is off and toggled, it will advance to the first state in the cycle.
/// </summary>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> IncludeOffInToggleCycle();
/// <summary>
/// Excludes the "off" state from the toggle cycle. When the light is off and toggled, it will turn on to the first state but "off" won't be part of the sequential cycle.
/// </summary>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> ExcludeOffFromToggleCycle();
/// <summary>
/// Sets the grace period during which a manual interaction will use the light's
/// previous state instead of its current state.
/// </summary>
ILightTransitionToggleConfigurator<TLight> SetGracePeriod(TimeSpan gracePeriod);
/// <summary>
/// Adds an "off" state to the toggle sequence.
/// </summary>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddOff();
/// <summary>
/// Adds an "on" state to the toggle sequence.
/// </summary>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddOn();
/// <summary>
/// Adds light parameters to the toggle sequence. Quick consecutive triggers will advance through all added parameter sets.
/// </summary>
/// <param name="lightParameters">The light parameters to add to the toggle sequence.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(LightParameters lightParameters);
/// <summary>
/// Adds light parameters created by a factory to the toggle sequence.
/// </summary>
/// <param name="lightParametersFactory">A factory function that creates light parameters based on the pipeline context.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(Func<IServiceProvider, LightParameters?> lightParametersFactory);
/// <summary>
/// Adds light parameters created by a factory to the toggle sequence.
/// The factory receives both the pipeline context and the current light transition.
/// </summary>
/// <param name="lightParametersFactory">A factory function that creates light parameters based on the pipeline context and current transition.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?, LightParameters?> lightParametersFactory);
/// <summary>
/// Adds a light transition to the toggle sequence. Quick consecutive triggers will advance through all added transitions.
/// </summary>
/// <param name="lightTransition">The light transition to add to the toggle sequence.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(LightTransition lightTransition);
/// <summary>
/// Adds a light transition created by a factory to the toggle sequence.
/// </summary>
/// <param name="lightTransitionFactory">A factory function that creates a light transition based on the pipeline context.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?> lightTransitionFactory);
/// <summary>
/// Adds a light transition created by a factory to the toggle sequence.
/// The factory receives both the pipeline context and the current light transition.
/// </summary>
/// <param name="lightTransitionFactory">A factory function that creates a light transition based on the pipeline context and current transition.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?, LightTransition?> lightTransitionFactory);
/// <summary>
/// Adds a pipeline node of type <typeparamref name="TNode"/> to the toggle sequence.
/// The node is resolved from the service provider. Quick consecutive triggers will advance through all added nodes.
/// </summary>
/// <typeparam name="TNode">The type of the pipeline node to add to the toggle sequence.</typeparam>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add<TNode>() where TNode : IPipelineNode<LightTransition>;
/// <summary>
/// Adds a pipeline node created by a factory to the toggle sequence.
/// Quick consecutive triggers will advance through all added nodes.
/// </summary>
/// <param name="nodeFactory">A factory function that creates a pipeline node based on the pipeline context.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> Add(Func<IServiceProvider, IPipelineNode<LightTransition>> nodeFactory);
/// <summary>
/// Adds a pass-through state to the toggle sequence that maintains the current light state.
/// </summary>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddPassThrough();
/// <summary>
/// Adds a timeline to the toggle sequence. The node will drive its output from the given time-based
/// timeline, updating automatically as time progresses.
/// </summary>
/// <param name="timeline">The dictionary mapping timeline points to <see cref="LightParameters"/>.</param>
/// <param name="transitionTimeForTimelineState">
/// The duration of the initial fade from the current state. Defaults to 500ms if null.
/// </param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddTimeline(Dictionary<ITimeline, LightParameters> timeline, TimeSpan? transitionTimeForTimelineState = null);
/// <summary>
/// Adds a timeline to the toggle sequence using a factory function to build the timeline mapping.
/// The node will drive its output from the given time-based timeline, updating automatically as time progresses.
/// </summary>
/// <param name="timelineFactory">A factory function that creates the timeline mapping based on the pipeline context.</param>
/// <param name="transitionTimeForTimelineState">
/// The duration of the initial fade from the current state. Defaults to 500ms if null.
/// </param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddTimeline(Func<IServiceProvider, Dictionary<ITimeline, LightParameters>> timelineFactory, TimeSpan? transitionTimeForTimelineState = null);
/// <summary>
/// Adds a timeline to the toggle sequence using a configurator action to build the timeline mapping and transition time.
/// The node will drive its output from the given time-based timeline, updating automatically as time progresses.
/// </summary>
/// <param name="configure">An action to configure the timeline entries and optional transition time.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> AddTimeline(Action<ITimelineConfigurator> configure);
/// <summary>
/// Creates a scoped toggle configuration for a specific light identified by its entity ID.
/// </summary>
/// <param name="lightId">The entity ID of the light to configure.</param>
/// <param name="configure">An action to configure the toggle for this specific light.</param>
/// <param name="excludedLightBehaviour">Specifies the behavior for lights not included in this scoped configuration. Defaults to <see cref="ExcludedLightBehaviours.None"/>.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> ForLight(string lightId, Action<ILightTransitionToggleConfigurator<TLight>> configure, ExcludedLightBehaviours excludedLightBehaviour = ExcludedLightBehaviours.None);
/// <summary>
/// Creates a scoped toggle configuration for a specific light.
/// </summary>
/// <param name="light">The light to configure.</param>
/// <param name="configure">An action to configure the toggle for this specific light.</param>
/// <param name="excludedLightBehaviour">Specifies the behavior for lights not included in this scoped configuration. Defaults to <see cref="ExcludedLightBehaviours.None"/>.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> ForLight(TLight light, Action<ILightTransitionToggleConfigurator<TLight>> configure, ExcludedLightBehaviours excludedLightBehaviour = ExcludedLightBehaviours.None);
/// <summary>
/// Creates a scoped toggle configuration for multiple light entities identified by their entity IDs.
/// </summary>
/// <param name="lightIds">The entity IDs of the lights to configure.</param>
/// <param name="configure">An action to configure the toggle for these lights.</param>
/// <param name="excludedLightBehaviour">Specifies the behavior for lights not included in this scoped configuration. Defaults to <see cref="ExcludedLightBehaviours.None"/>.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> ForLights(IEnumerable<string> lightIds, Action<ILightTransitionToggleConfigurator<TLight>> configure, ExcludedLightBehaviours excludedLightBehaviour = ExcludedLightBehaviours.None);
/// <summary>
/// Creates a scoped toggle configuration for multiple light entities.
/// </summary>
/// <param name="lights">The light entities to configure.</param>
/// <param name="configure">An action to configure the toggle for these lights.</param>
/// <param name="excludedLightBehaviour">Specifies the behavior for lights not included in this scoped configuration. Defaults to <see cref="ExcludedLightBehaviours.None"/>.</param>
/// <returns>The configurator instance for method chaining.</returns>
ILightTransitionToggleConfigurator<TLight> ForLights(IEnumerable<TLight> lights, Action<ILightTransitionToggleConfigurator<TLight>> configure, ExcludedLightBehaviours excludedLightBehaviour = ExcludedLightBehaviours.None);
}