public void TestSimulateToday() { FluxCalculate flux = new FluxCalculate(); DateTime time = DateTime.Today + TimeSpan.FromSeconds(1); DateTime stopTime = DateTime.Today + new TimeSpan(23, 59, 59); Primitives.ColorTemperature colorTemperaturePrevious = -1; int steps = 0; while (time < stopTime) { TimeSpan timeToSleep = flux.GetThreadSleepDuration(time); //Assert.IsTrue(timeToSleep.TotalSeconds > 1); Primitives.ColorTemperature colorTemperatureCurrent = flux.GetColorTemperature(time + timeToSleep); Assert.IsTrue(colorTemperaturePrevious != colorTemperatureCurrent); time += timeToSleep; Debug.WriteLine($"{time}, {colorTemperatureCurrent}, '{timeToSleep}'"); //Debug.WriteLine($"{time}, {colorTemperatureCurrent}"); //Debug.WriteLine($"{timeToSleep.TotalSeconds}, {time}"); //Debug.WriteLine($"{timeToSleep.TotalSeconds}, {colorTemperatureCurrent}"); //Debug.WriteLine($"{timeToSleep.TotalSeconds}"); //Debug.WriteLine($"{colorTemperatureCurrent}"); colorTemperaturePrevious = colorTemperatureCurrent; ++steps; } }
public void TestGetColorTemperatureSingle() { const int endDuration = 100; for (int i = 0; i < endDuration; i++) { Primitives.ColorTemperature value = FluxCalculate.GetColorTemperature(500, 0, i, endDuration); Debug.WriteLine($"{value}"); } }
public async Task HueModifyFluxSwitchScenes() { const byte brightnessDim = 5; const byte brightnessPrevious = 200; const byte brightnessNew = 225; Primitives.ColorTemperature colorTemperature = 400; using (ShimsContext.Create()) { IEnumerable <Light> lights = new List <Light>() { new Light() { Id = "Test 1", Name = "Test 1", Type = LightExtensions.LightTypeToNameMapping[LightType.WhiteAmbiance], State = new State() { On = true, Brightness = brightnessDim, ColorTemperature = colorTemperature } }, new Light() { Id = "Test 2", Name = "Test 2", Type = LightExtensions.LightTypeToNameMapping[LightType.WhiteAmbiance], State = new State() { On = true, Brightness = brightnessPrevious, ColorTemperature = colorTemperature } }, }; SetupDefaultShims(lights); HueClient hueClient = new LocalHueClient(null); Hue hue = new Hue(null); hue.UpdateFluxStatus(brightnessPrevious, colorTemperature); await hue.ModifyFluxSwitchScenes(hueClient, lights, colorTemperature, brightnessNew); } }
public void TestGetColorTemperatureCompleteDay() { FluxCalculate flux = new FluxCalculate(); DateTime time = DateTime.Today + TimeSpan.FromMinutes(1); DateTime stopTime = DateTime.Today + new TimeSpan(23, 59, 0); while (time < stopTime) { TimeSpan timeToSleep = flux.GetThreadSleepDuration(time); time += timeToSleep; Primitives.ColorTemperature colorTemperatureCurrent = flux.GetColorTemperature(time); while (timeToSleep.TotalMinutes > 0) { Debug.WriteLine($"{time}, {colorTemperatureCurrent}, '{timeToSleep}'"); timeToSleep -= TimeSpan.FromMinutes(1); } } }