public void CreateTwoProgramSets_WorksWithSync() { var zlm = new ZLM(loadZoneModules: false, loadZonesFromConfig: false, loadProgramSetsFromConfig: false); var leftWing = zlm.Zones.Add(new Zone("LeftWing")); var center = zlm.Zones.Add(new Zone("Center")); var rightWing = zlm.Zones.Add(new Zone("RightWing")); //create program set zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing, center, }); //create program set zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { rightWing }); TestHelpers.ValidateSteppersInSync( new BetterList <Zone> { leftWing, center }.Select(z => z.ZoneProgram).Cast <IStepper>(), 100); TestHelpers.ValidateSteppersRunning( new BetterList <Zone> { rightWing }.Select(z => z.ZoneProgram).Cast <IStepper>(), 10); //cleanup zlm.Dispose(); }
public void AvailableZones_ReturnsZonesOnWhichNoProgramSetWasCreated() { var zlm = new ZLM(loadZoneModules: false, loadZonesFromConfig: false, loadProgramSetsFromConfig: false); var leftWing = zlm.Zones.Add(new Zone("LeftWing")); var center = zlm.Zones.Add(new Zone("Center")); var rightWing = zlm.Zones.Add(new Zone("RightWing")); //check if zones and availablezones are the same, since no program sets have been created yet Assert.AreEqual(zlm.Zones, zlm.AvailableZones); //create program set with all but one zone zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing, center }); //the zone on which no program set was created should be the only one available Assert.True(zlm.AvailableZones.Count == 1); Assert.True(zlm.AvailableZones[0] == rightWing); //cleanup zlm.Dispose(); }
public void ScrollTrail_FourRandomColorsSquareTrails_Works(int?sleepSeconds, float darkenFactor, int delayTime) { //act var zlm = new ZLM(false, false, false, zlmInner => { var isv = new ISV(); isv.Add("DarkenFactor", (float)darkenFactor); isv.Add("DelayTime", delayTime); isv.Add("ShareShape", true); isv.Add("TrailShapes", new List <TrailShape>() { new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(0, 1, 2, 3, 11, 19, 27, 26, 25, 24, 16, 8)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(27, 26, 25, 24, 16, 8, 0, 1, 2, 3, 11, 19)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(4, 5, 6, 7, 15, 23, 31, 30, 29, 28, 20, 12)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(31, 30, 29, 28, 20, 12, 4, 5, 6, 7, 15, 23)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(32, 33, 34, 35, 43, 51, 59, 58, 57, 56, 48, 40)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(59, 58, 57, 56, 48, 40, 32, 33, 34, 35, 43, 51)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(36, 37, 38, 39, 47, 55, 63, 62, 61, 60, 52, 44)), new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(63, 62, 61, 60, 52, 44, 36, 37, 38, 39, 47, 55)), }); var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1); zlmInner.CreateSingularProgramSet("", new ScrollTrail(), isv, neomatrix); }, Config.Get("NeoMatrixOneZone")); //Thread.Sleep(Timeout.Infinite); Thread.Sleep((int)(sleepSeconds != null ? sleepSeconds * 1000 : Timeout.Infinite)); //cleanup zlm.Dispose(); }
public void RaindropsOnScrollTrail_Works(int?sleepSeconds) { //act var zlm = new ZLM(false, false, false, zlmInner => { var isv = new ISV(); isv.Add("DarkenFactor", (float)0.7); isv.Add("DelayTime", 70); isv.Add("ShareShape", false); isv.Add("TrailShapes", new List <TrailShape>() { new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(0, 1, 2, 3, 4, 5, 6, 7)), new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(8, 9, 10, 11, 12, 13, 14, 15)), new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(16, 17, 18, 19, 20, 21, 22, 23)), new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(24, 25, 26, 27, 28, 29, 30, 31)), new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(32, 33, 34, 35, 36, 37, 38, 39)), new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(40, 41, 42, 43, 44, 45, 46, 47)), new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(48, 49, 50, 51, 52, 53, 54, 55)), new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(56, 57, 58, 59, 60, 61, 62, 63)), }); var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1); zlmInner.CreateSingularProgramSet("", new ScrollTrail(), isv, neomatrix); }, Config.Get("NeoMatrixOneZone")); //Thread.Sleep(Timeout.Infinite); Thread.Sleep((int)(sleepSeconds != null ? sleepSeconds * 1000 : Timeout.Infinite)); //cleanup zlm.Dispose(); }
public void MidiTwoDimensionalFade_Works(int sleepSeconds, bool random) { ZLM zlm = null; var deviceID = 0; try { //act zlm = new ZLM(false, false, false, zlmInner => { var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1); var midiTwoDimensionalFade = new MidiTwoDimensionalFade(); dynamic startingParameters = new ExpandoObject(); startingParameters.DeviceID = deviceID; neomatrix.Run(midiTwoDimensionalFade, startingParameters: startingParameters); }, Config.Get("NeoMatrixOneZone")); Thread.Sleep(sleepSeconds * 1000); } catch (Exception ex) { zlm?.Dispose(); Thread.Sleep(10000); } }
public void Raindrops_Works(int sleepSeconds, int trailLengthAvg, int trailLengthVariability, int intervalAvg, int intervalVariability) { IntervalAvg = intervalAvg; IntervalVariability = intervalVariability; var zlm = new ZLM(false, false, false, zlmInner => { dynamic startingParams = new ExpandoObject(); startingParams.ClockedTrailShapes = new List <dynamic>(); for (int i = 0; i < 64; i += 8) { dynamic clockedTrailShape = new ExpandoObject(); var trailLength = ProgramCommon.RandomIntBetween(trailLengthAvg - trailLengthVariability, trailLengthAvg + trailLengthVariability); var interval = ProgramCommon.RandomIntBetween(intervalAvg - intervalVariability, intervalAvg + intervalVariability); var darkenFactor = (float)0.7; clockedTrailShape.TrailShape = new TrailShape(new Trail(trailLength, Color.Green.Darken(0.5)), new Shape(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7)); clockedTrailShape.TrailShape.DarkenFactor = darkenFactor; clockedTrailShape.Interval = interval; clockedTrailShape.GetNewInterval = (Func <int>)GetNewInterval; clockedTrailShape.AutoTrail = true; //todo: implement autotrail clockedTrailShape.AutoSpeed = true; //todo: implement autospeed startingParams.ClockedTrailShapes.Add(clockedTrailShape); } //startingParams.ClockedTrailShapes.Add(new ExpandoObject() )}; //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(8, 9, 10, 11, 12, 13, 14, 15))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(16, 17, 18, 19, 20, 21, 22, 23))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(24, 25, 26, 27, 28, 29, 30, 31))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(32, 33, 34, 35, 36, 37, 38, 39))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(40, 41, 42, 43, 44, 45, 46, 47))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(48, 49, 50, 51, 52, 53, 54, 55))); //startingParams.TrailShapes.Add(new TrailShape(new Trail(4, ProgramCommon.GetRandomColor()), // new Shape(56, 57, 58, 59, 60, 61, 62, 63))); var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1); zlmInner.CreateSingularProgramSet("", new Raindrops(), null, neomatrix, startingParams); }, Config.Get("NeoMatrixOneZone")); //Thread.Sleep(Timeout.Infinite); Thread.Sleep((int)(sleepSeconds != null ? sleepSeconds * 1000 : Timeout.Infinite)); //cleanup zlm.Dispose(); }
public void Dispose_Works() { //arrange var zlm = new ZLM(false, false, false, TestHelpers.AddFourZonesAndStepperProgramSetWithSyncToZLM); //act zlm.Dispose(); //assert Assert.That(zlm.ProgramSets, Is.Null); Assert.That(zlm.Zones, Is.Null); //TODO: Assert that all lighting controllers are unintialized Assert.That(ZoneScaffolder.Instance.Initialized, Is.False); }
public void MicroClockBlink_Works(int sleepSeconds, int interval) { //act var zlm = new ZLM(false, false, false, zlmInner => { var neomatrix = RunnerHelpers.CreateNeoMatrixZone(zlmInner); var isv = new ISV(); isv.Add("Interval", interval); zlmInner.CreateSingularProgramSet("MicroClockBlinkSet", new MicroClockBlink(), isv, neomatrix); }, Config.Get("NeoMatrixOneZone")); Thread.Sleep(sleepSeconds * 1000); //cleanup zlm.Dispose(); }
public void MidiPlay_Works(int sleepSeconds) { //act var zlm = new ZLM(false, false, false, zlmInner => { var livingRoom = RunnerHelpers.CreateLivingRoomZone(zlmInner); dynamic startingParameters = new ExpandoObject(); startingParameters.DeviceID = int.Parse(Config.Get("MIDIDeviceID", "Please set the value of MIDIDeviceID in configuration.")); zlmInner.CreateSingularProgramSet("MidiPlaySet", new LivingRoomMidiPlay(), null, livingRoom, startingParameters); }, Config.Get("LivingRoomZone")); Thread.Sleep(sleepSeconds * 1000); //cleanup zlm.Dispose(); }
public void Constructor_JustInitActionProvided_Works() { //act var zlm = new ZLM(false, false, false, TestHelpers.AddFourZonesAndStepperProgramSetWithSyncToZLM); //assert TestHelpers.ValidateSteppersInSync( zlm.ProgramSets.SelectMany(ps => ((ITestProgramSet)ps).ZoneProgramsTest).Cast <IStepper>(), 100); zlm.Zones.ForEach(zone => { Assert.That(zone.Running, Is.True); Assert.That(zone.ZoneProgram.State == ProgramState.Started, Is.True); }); //cleanup zlm.Dispose(); }
public void Shimmer_Works(int sleepSeconds, bool random) { //act var zlm = new ZLM(false, false, false, zlmInner => { var isv = new ISV(); isv.Add("MaxFadeSpeed", 1); isv.Add("MaxFadeDelay", 20); isv.Add("Density", 0.5); isv.Add("Brightness", 0.5); isv.Add("Random", random); var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1); zlmInner.CreateSingularProgramSet("", new Shimmer(), isv, neomatrix); }, Config.Get("NeoMatrixOneZone")); Thread.Sleep(sleepSeconds * 1000); //cleanup zlm.Dispose(); }
public void CreateProgramSet_CreatesAndRunsProgramOnZones() { var zlm = new ZLM(loadZoneModules: false, loadZonesFromConfig: false, loadProgramSetsFromConfig: false); var leftWing = zlm.Zones.Add(new Zone("LeftWing")); var center = zlm.Zones.Add(new Zone("Center")); var rightWing = zlm.Zones.Add(new Zone("RightWing")); //create program set zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing, center, rightWing }); //check that steppers are running TestHelpers.ValidateSteppersRunning(zlm.Zones.Select(z => z.ZoneProgram).Cast <IStepper>(), 100); //cleanup zlm.Dispose(); }
public void CreateProgramSet_PassInUnavailableZone_ThrowsException() { var zlm = new ZLM(loadZoneModules: false, loadZonesFromConfig: false, loadProgramSetsFromConfig: false); var leftWing = zlm.Zones.Add(new Zone("LeftWing")); var center = zlm.Zones.Add(new Zone("Center")); //create program set zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing, center, }); Assert.Throws <Exception>(() => zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing })); //cleanup zlm.Dispose(); }
public void CreateProgramSet_TwoZonesOutOfThree_TwoZonesRunning_OneZoneNotRunning() { var zlm = new ZLM(loadZoneModules: false, loadZonesFromConfig: false, loadProgramSetsFromConfig: false); var leftWing = zlm.Zones.Add(new Zone("LeftWing")); var center = zlm.Zones.Add(new Zone("Center")); var rightWing = zlm.Zones.Add(new Zone("RightWing")); //create program set zlm.CreateProgramSet("", "Stepper", true, null, new List <Zone>() { leftWing, center, }); //check that steppers are running Assert.False(rightWing.Running); TestHelpers.ValidateSteppersRunning(new BetterList <Zone> { leftWing, center }.Select(z => z.ZoneProgram).Cast <IStepper>(), 100); //cleanup zlm.Dispose(); }