public static List <GroupModel> GetAll(EntertainmentLayer layer = null) { if (layer == null) { layer = StreamingSetup.Layers.First(); } var center = EffectSettings.LocationCenter; var allLightsOrdered = layer.OrderBy(x => x.LightLocation.X).ThenBy(x => x.LightLocation.Y).ToList(); var leftRight = new[] { allLightsOrdered.GetLeft(), allLightsOrdered.GetRight() }.ToList(); var frontBack = new[] { allLightsOrdered.GetFront(), allLightsOrdered.GetBack() }.ToList(); var quarter = new[] { layer.GetLeft().GetFront(), layer.GetLeft().GetBack(), layer.GetRight().GetBack(), layer.GetRight().GetFront() }.ToList(); var alternating = allLightsOrdered.ChunkByGroupNumber(2); var alternatingFour = allLightsOrdered.ChunkByGroupNumber(4); var orderedByDistance = layer.OrderBy(x => x.LightLocation.Distance(center.X, center.Y)).ChunkByGroupNumber(3); var orderedByAngle = layer.OrderBy(x => x.LightLocation.Angle(center.X, center.Y)).ChunkBy(6); var leftToRight = allLightsOrdered.GroupBy(x => (int)(((x.LightLocation.X + 1) / 2) * 50)).OrderBy(x => x.Key); var fronToBack = allLightsOrdered.GroupBy(x => (int)(((x.LightLocation.Y + 1) / 2) * 50)).OrderBy(x => x.Key); var ring = allLightsOrdered.GroupBy(x => (int)((x.LightLocation.Distance(center.X, center.Y) / 1.5) * 2)); var tentacles = allLightsOrdered.GroupBy(x => (int)((x.LightLocation.Angle(center.X, center.Y) / 3.6 / 3))).OrderBy(x => x.Key); var result = new List <GroupModel>() { //new GroupModel("All", allLightsOrdered.To2DGroup()), new GroupModel("Left/Right", leftRight), new GroupModel("Left To Right", leftToRight, 2), new GroupModel("Front/Back", frontBack), new GroupModel("Front To Back", fronToBack, 2), new GroupModel("Quarter", quarter, 2), new GroupModel("Alternating", alternating), new GroupModel("Alternating by 4", alternatingFour), //new GroupModel("Distance from center", orderedByDistance), //new GroupModel("Order by Angle from center", orderedByAngle), new GroupModel("Ring", ring, 2), new GroupModel("Tentacles", tentacles), new GroupModel("Random", GetRandomGroup()), }; if (StreamingSetup.CurrentConnection.Name == "Ster" || StreamingSetup.CurrentConnection.Name == "DEMO Ster") { result.Add(new GroupModel("Tentacles (alternating 2)", tentacles.ChunkByGroupNumber(2).Select(x => x.SelectMany(l => l)), 2)); result.Add(new GroupModel("Tentacles (alternating 3)", tentacles.ChunkByGroupNumber(3).Select(x => x.SelectMany(l => l)), 3)); result.Add(new GroupModel("Tentacles (alternating 4)", tentacles.ChunkByGroupNumber(4).Select(x => x.SelectMany(l => l)), 4)); } return(result); }
public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { var allLightsOrdered = layer.OrderBy(x => x.LightLocation.X).ThenBy(x => x.LightLocation.Y).ToList(); var leftToRight = allLightsOrdered.GroupBy(x => (int)(((x.LightLocation.X + 1) / 2) * 50)).Select(x => x.Select(s => s)).ToList(); var effectGroups = leftToRight.ChunkByGroupNumber(2).ToList(); while (!cancellationToken.IsCancellationRequested) { bool skip = false; CancellationTokenSource tempCancel = new CancellationTokenSource(); var nextColor = RGBColor.Random(); foreach (var group in effectGroups) { if (!skip) { group.SelectMany(x => x).SetState(cancellationToken, nextColor, 1); } else { group.SelectMany(x => x).SetBrightness(cancellationToken, 0); group.FlashQuick(tempCancel.Token, null, IteratorEffectMode.AllIndividual, IteratorEffectMode.Random); } skip = !skip; } await Task.Delay(waitTime()); tempCancel.Cancel(); effectGroups = effectGroups.Skip(1).Union(effectGroups.Take(1)).ToList(); } }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { if (!color.HasValue) { color = RGBColor.Random(); } var groupCount = layer.Count / 3; Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 2) / groupCount); return(layer.OrderBy(x => Guid.NewGuid()).ChunkByGroupNumber(groupCount).FlashQuick(cancellationToken, color, IteratorEffectMode.Random, waitTime: customWaitMS)); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { if (!color.HasValue) { color = RGBColor.Random(); } var center = EffectSettings.LocationCenter; var orderedByAngle = layer.OrderBy(x => x.LightLocation.Angle(center.X, center.Y)); Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 2) / layer.Count); Func <TimeSpan> customOnTime = () => customWaitMS() / 2; Func <TimeSpan> customOffTime = () => customWaitMS() * 2; return(orderedByAngle.To2DGroup().Flash(cancellationToken, color, IteratorEffectMode.Cycle, waitTime: customWaitMS, transitionTimeOn: customOnTime, transitionTimeOff: customOffTime, waitTillFinished: false)); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { //Non repeating effects should not run on baselayer if (layer.IsBaseLayer) { return(Task.CompletedTask); } if (!color.HasValue) { color = RGBColor.Random(); } var groupCount = layer.Count / 3; Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds) / groupCount); return(layer.OrderBy(x => Guid.NewGuid()).ChunkByGroupNumber(groupCount).FlashQuick(cancellationToken, color, IteratorEffectMode.AllIndividual, IteratorEffectMode.RandomOrdered, waitTime: customWaitMS, duration: waitTime())); }
public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { //Non repeating effects should not run on baselayer if (layer.IsBaseLayer) { return; } var center = EffectSettings.LocationCenter; var orderedByDistance = layer.OrderBy(x => x.LightLocation.Distance(center.X, center.Y, center.Z)); if (!color.HasValue) { color = RGBColor.Random(); } Func <TimeSpan> customWaitTime = () => waitTime() / layer.Count; await orderedByDistance.To2DGroup().SetColor(cancellationToken, color.Value, IteratorEffectMode.Single, IteratorEffectMode.All, customWaitTime); layer.SetBrightness(cancellationToken, 0, transitionTime: TimeSpan.FromMilliseconds(0)); }