public void LoggedErrorsCauseFailureDespiteExitCode0() { var cmdLine = NativeMethodsShared.IsWindows ? "echo myfile(88,37): error AB1234: thisisacanonicalerror" : "echo \"myfile(88,37): error AB1234: thisisacanonicalerror\""; // This will return 0 exit code, but emitted a canonical error Exec exec = PrepareExec(cmdLine); bool result = exec.Execute(); Assert.False(result); // Exitcode is set to -1 Assert.Equal(-1, exec.ExitCode); ((MockEngine)exec.BuildEngine).AssertLogContains("MSB3073"); }
public void Timeout() { Exec exec = PrepareExec(":foo \n goto foo"); exec.Timeout = 5; bool result = exec.Execute(); Assert.Equal(false, result); Assert.Equal(-1, exec.ExitCode); ((MockEngine)exec.BuildEngine).AssertLogContains("MSB5002"); Assert.Equal(1, ((MockEngine)exec.BuildEngine).Warnings); // ToolTask does not log an error on timeout. Assert.Equal(0, ((MockEngine)exec.BuildEngine).Errors); }
public void ErrorsAndWarningsWithIgnoreStandardErrorWarningFormatTrue() { var cmdLine = NativeMethodsShared.IsWindows ? "echo myfile(88,37): error AB1234: thisisacanonicalerror & echo foo: warning CDE1234: thisisacanonicalwarning" : "echo \"myfile(88,37): error AB1234: thisisacanonicalerror\" ; echo foo: warning CDE1234: thisisacanonicalwarning"; Exec exec = PrepareExec(cmdLine); exec.IgnoreStandardErrorWarningFormat = true; bool result = exec.Execute(); Assert.True(result); Assert.Equal(0, ((MockEngine)exec.BuildEngine).Errors); Assert.Equal(0, ((MockEngine)exec.BuildEngine).Warnings); }
public void CustomAndStandardErrorsAndWarnings() { var cmdLine = NativeMethodsShared.IsWindows ? "echo myfile(88,37): error AB1234: thisisacanonicalerror & echo foo: warning CDE1234: thisisacanonicalwarning & echo YOGI & echo BEAR & echo some content" : "echo \"myfile(88,37): error AB1234: thisisacanonicalerror\" ; echo foo: warning CDE1234: thisisacanonicalwarning ; echo YOGI ; echo BEAR ; echo some content"; Exec exec = PrepareExec(cmdLine); exec.CustomWarningRegularExpression = ".*BEAR.*"; exec.CustomErrorRegularExpression = ".*YOGI.*"; bool result = exec.Execute(); Assert.False(result); Assert.Equal(3, ((MockEngine)exec.BuildEngine).Errors); Assert.Equal(2, ((MockEngine)exec.BuildEngine).Warnings); }
public void NoDuplicateMessagesWhenCustomRegexAndRegularRegexBothMatch() { var cmdLine = NativeMethodsShared.IsWindows ? "echo myfile(88,37): error AB1234: thisisacanonicalerror & echo foo: warning CDE1234: thisisacanonicalwarning " : "echo \"myfile(88,37): error AB1234: thisisacanonicalerror\" ; echo foo: warning CDE1234: thisisacanonicalwarning "; Exec exec = PrepareExec(cmdLine); exec.CustomErrorRegularExpression = ".*canonicale.*"; exec.CustomWarningRegularExpression = ".*canonicalw.*"; bool result = exec.Execute(); Assert.False(result); Assert.Equal(2, ((MockEngine)exec.BuildEngine).Errors); Assert.Equal(1, ((MockEngine)exec.BuildEngine).Warnings); }
public void AnyExistingEnvVarCalledErrorLevelIsIgnored() { string oldValue = Environment.GetEnvironmentVariable("errorlevel"); try { Exec exec = PrepareExec("echo this is an innocuous successful command"); Environment.SetEnvironmentVariable("errorlevel", "1"); bool result = exec.Execute(); Assert.True(result); } finally { Environment.SetEnvironmentVariable("errorlevel", oldValue); } }
public void Timeout() { // On non-Windows the exit code of a killed process is SIGKILL (137) int expectedExitCode = NativeMethodsShared.IsWindows ? -1 : 137; Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done"); exec.Timeout = 5; bool result = exec.Execute(); Assert.False(result); Assert.Equal(expectedExitCode, exec.ExitCode); ((MockEngine)exec.BuildEngine).AssertLogContains("MSB5002"); Assert.Equal(1, ((MockEngine)exec.BuildEngine).Warnings); // ToolTask does not log an error on timeout. Assert.Equal(0, ((MockEngine)exec.BuildEngine).Errors); }
/// <summary> /// Runs the specified program or command using OS command interpreter. /// For linux it wil be run via <c>"/bin/bash -c"</c> on Windows via <c>cmd</c> /// </summary> /// <param name="command"> /// <para> /// The command(s) to run. These can be system commands, such as <c>attrib</c> (<c>chmod</c>), /// or an executable, such as <c>docker</c>, <c>run.bat</c>, or <c>setup.msi</c>. /// </para> /// <para>This parameter can contain multiple lines of commands.</para> /// </param> /// <param name="environmentVariables">The environment variables pairs to pass. Default is all vars defined within a process</param> /// <param name="workingDirectory">The working directory. Default is current directory</param> /// <param name="echoOff">if set to <c>true</c>disables echoing command output to std out</param> /// <param name="ignoreStdError">if set to <c>true</c> ignores errors logged to std out</param> /// <param name="ignoreExitCode">if set to <c>true</c> ignores exit code</param> /// <param name="captureOutput">set to <c>true</c> to capture the standard error and output</param> /// <param name="useCommandProcessor">if set to <c>true</c> the command(s) will be executed via the batch file using the command-processor, rather than executed directly.</param> /// <param name="quiet">if set to <c>true</c> completely disable any std out logging</param> /// <returns> /// <see cref="Result"/> object which could be further inspected /// for exit code and std out and error messages, if captured</returns> /// <exception cref="ApplicationException">If command fails</exception> public static Result Cmd( string command, string[] environmentVariables = null, string workingDirectory = null, bool echoOff = true, bool ignoreStdError = false, bool ignoreExitCode = false, bool captureOutput = false, bool useCommandProcessor = false, bool quiet = false) { if (string.IsNullOrWhiteSpace(command)) { throw new ArgumentException("command is null or contains whitespace only"); } var engine = new MSBuildEngineStub(quiet); var task = new Exec { Command = Prepare(command), EchoOff = echoOff, WorkingDirectory = workingDirectory ?? Location.CurrentDirectory, IgnoreExitCode = ignoreExitCode, LogStandardErrorAsError = !ignoreStdError, EnvironmentVariables = environmentVariables ?? Env.Var.All(), ConsoleToMSBuild = captureOutput, UseCommandProcessor = useCommandProcessor, BuildEngine = engine, }; if (!task.Execute()) { throw new ApplicationException($"{task.GetType()} failed"); } var output = task.ConsoleOutput.Select(x => x.ItemSpec).ToList(); // HACK: I can't find way for now to get error output cleanly separated var errors = new HashSet <string>(engine.StdError); var stdOut = output.Where(x => !errors.Contains(x)).ToList(); return(new Result(task.ExitCode, stdOut, engine.StdError, output)); }
public override bool Execute() { if (this.Frameworks == null) { return(true); } // TODO: I18N this.Log.LogMessage("Copying frameworks"); foreach (String name in this.Frameworks.Split(';')) { String path; // Probe system location path = String.Format("/System/Library/Frameworks/{0}.framework", name); if (Directory.Exists(path)) { goto copy; } path = String.Format("/Library/Frameworks/{0}.framework", name); if (Directory.Exists(path)) { goto copy; } path = String.Format("~/Library/Frameworks/{0}.framework", name); if (Directory.Exists(path)) { goto copy; } // TODO: I18N this.Log.LogError("Framework {0} not found", name); return(false); copy: Exec exec = new Exec(); exec.BuildEngine = this.BuildEngine; exec.Command = String.Format("rsync -rpl \"{0}\" \"{1}\"", path, this.ToDirectory.GetMetadata("FullPath")); exec.Execute(); } return(true); }
public void EscapeSpecifiedCharactersInPathToGeneratedBatchFile_DisabledUnderChangeWave16_10() { using (var testEnvironment = TestEnvironment.Create()) { ChangeWaves.ResetStateForTests(); testEnvironment.SetEnvironmentVariable("MSBUILDDISABLEFEATURESFROMVERSION", ChangeWaves.Wave16_10.ToString()); BuildEnvironmentHelper.ResetInstance_ForUnitTestsOnly(); var newTempPath = testEnvironment.CreateNewTempPathWithSubfolder("hello()w]o(rld)").TempPath; string tempPath = Path.GetTempPath(); Assert.StartsWith(newTempPath, tempPath); // Now run the Exec task on a simple command. Exec exec = PrepareExec("echo Hello World!"); exec.Execute().ShouldBeFalse(); ChangeWaves.ResetStateForTests(); } }
public void NoWorkingDirectorySet() { var cd = Directory.GetCurrentDirectory(); try { Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Windows)); Exec exec = PrepareExec("echo [%cd%]"); bool result = exec.Execute(); string expected = Directory.GetCurrentDirectory(); Assert.Equal(true, result); ((MockEngine)exec.BuildEngine).AssertLogContains("[" + expected + "]"); } finally { Directory.SetCurrentDirectory(cd); } }
public void NoWorkingDirectorySet() { var cd = Directory.GetCurrentDirectory(); try { Directory.SetCurrentDirectory(NativeMethodsShared.IsWindows ? Environment.GetFolderPath(Environment.SpecialFolder.Windows) : "/usr/lib"); Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? "echo [%cd%]" : "echo [$PWD]"); bool result = exec.Execute(); string expected = Directory.GetCurrentDirectory(); Assert.True(result); ((MockEngine)exec.BuildEngine).AssertLogContains("[" + expected + "]"); } finally { Directory.SetCurrentDirectory(cd); } }
public void NoTempFileLeaks() { // Get a count of how many temp files there are right now. string tempPath = Path.GetTempPath(); string[] tempFiles = Directory.GetFiles(tempPath); int originalTempFileCount = tempFiles.Length; // Now run the Exec task on a simple command. Exec exec = PrepareExec("echo Four days 'till ZBB!"); bool result = exec.Execute(); // Get the new count of temp files. tempFiles = Directory.GetFiles(tempPath); int newTempFileCount = tempFiles.Length; // Ensure that Exec succeeded. Assert.True(result); // Ensure the new temp file count equals the old temp file count. Assert.Equal(originalTempFileCount, newTempFileCount); }
public void NoTempFileLeaks() { string oldTmpPath = Environment.GetEnvironmentVariable("TMP"); var newTempPath = Path.GetFullPath(@"TempPathForNoTempFileLeaksTest"); try { // This test counts files in TEMP. If it uses the system TEMP, some // other process may interfere. Use a private TEMP instead. Directory.CreateDirectory(newTempPath); Environment.SetEnvironmentVariable("TMP", newTempPath); string tempPath = Path.GetTempPath(); Assert.StartsWith(newTempPath, tempPath); // Get a count of how many temp files there are right now. string[] tempFiles = Directory.GetFiles(tempPath); Assert.Empty(tempFiles); // Now run the Exec task on a simple command. Exec exec = PrepareExec("echo Four days 'till ZBB!"); bool result = exec.Execute(); // Get the new count of temp files. tempFiles = Directory.GetFiles(tempPath); // Ensure that Exec succeeded. Assert.True(result); // Ensure that no files linger in TEMP. Assert.Empty(tempFiles); } finally { FileUtilities.DeleteDirectoryNoThrow(newTempPath, true); Environment.SetEnvironmentVariable("TMP", oldTmpPath); } }
public void Timeout() { // On non-Windows the exit code of a killed sh should be // SIGTERM (15) + exited-due-to-signal (128) = 143. // On .NET Core 2.1 preview2 + High Sierra it's consistently // just 128 for some reason. int expectedExitCode = NativeMethodsShared.IsWindows ? -1 : (NativeMethodsShared.IsOSX && !NativeMethodsShared.IsMono) ? 128 : 143; Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done"); exec.Timeout = 5; bool result = exec.Execute(); Assert.Equal(false, result); Assert.Equal(expectedExitCode, exec.ExitCode); ((MockEngine)exec.BuildEngine).AssertLogContains("MSB5002"); Assert.Equal(1, ((MockEngine)exec.BuildEngine).Warnings); // ToolTask does not log an error on timeout. Assert.Equal(0, ((MockEngine)exec.BuildEngine).Errors); }
public void ExecTaskUnicodeCharacterInCommand() { string nonAnsiCharacters = "\u521B\u5EFA"; string folder = Path.Combine(Path.GetTempPath(), nonAnsiCharacters); string command = Path.Combine(folder, "test.cmd"); try { Directory.CreateDirectory(folder); File.WriteAllText(command, "echo [hello]"); Exec exec = PrepareExec(command); Assert.True(exec.Execute()); // "Task should have succeeded" ((MockEngine)exec.BuildEngine).AssertLogContains("[hello]"); } finally { if (Directory.Exists(folder)) { Directory.Delete(folder, true); } } }
public void TempPathContainsAmpersand4() { string directoryWithAmpersand = "foo & bar"; string newTmp = Path.Combine(Path.GetTempPath(), directoryWithAmpersand); string oldTmp = Environment.GetEnvironmentVariable("TMP"); try { Directory.CreateDirectory(newTmp); Environment.SetEnvironmentVariable("TMP", newTmp); Exec exec = PrepareExec("echo [hello]"); Assert.True(exec.Execute()); // "Task should have succeeded" ((MockEngine)exec.BuildEngine).AssertLogContains("[hello]"); } finally { Environment.SetEnvironmentVariable("TMP", oldTmp); if (Directory.Exists(newTmp)) { Directory.Delete(newTmp); } } }
public Halloween2017(IEnumerable <string> args) { mainSchedule.AddRange("5:00 pm", "9:00 pm", DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Sunday); mainSchedule.AddRange("5:00 pm", "9:00 pm", DayOfWeek.Friday, DayOfWeek.Saturday); string expFilesParam = args.FirstOrDefault(x => x.StartsWith("EXPFILES")); if (!string.IsNullOrEmpty(expFilesParam)) { string[] parts = expFilesParam.Split('='); if (parts.Length == 2) { Exec.ExpanderSharedFiles = parts[1]; } } //expanderServer.AddInstance("4ea781ef257442edb524493da8f52220", expanderAudio2); // rpi-eba6cbc7 expanderServer.AddInstance("ed86c3dc166f41ee86626897ba039ed2", expanderLedmx); // rpi-eb0092ca expanderServer.AddInstance("1583f686014345888c15d7fc9c55ca3c", expanderCat); // rpi-eb81c94e expanderServer.AddInstance("d6fc4e752af04022bf3c1a1166a557bb", expanderHifi); // rpi-eb428ef1 expanderServer.AddInstance("60023fcde5b549b89fa828d31741dd0c", expanderPicture); // rpi-eb91bc26 expanderServer.AddInstance("e41d2977931d4887a9417e8adcd87306", expanderGhost); // rpi-eb6a047c expanderServer.AddInstance("999861affa294fd7bbf0601505e9ae09", expanderMrPumpkin); // rpi-ebd43a38 expanderServer.AddInstance("992f8db68e874248b5ee667d23d74ac3", expanderSpider); // rpi-eb9b3145 expanderServer.AddInstance("db9b41a596cb4ed28e91f11a59afb95a", expanderRocking); // rpi-eb32e5f9 expanderServer.AddInstance("acbfada45c674077b9154f6a0e0df359", expanderFlying); // rpi-eb35666e expanderServer.AddInstance("2e105175a66549d4a0ab7f8d446c2e29", expanderPopper); // rpi-eb997095 masterVolume.ConnectTo(Exec.MasterVolume); grumpyCat = new Modules.HalloweenGrumpyCat( air: catAir, light: catLights, audioPlayer: audioCat, name: nameof(grumpyCat)); stateMachine.WhenStates(States.BackgroundFull, States.BackgroundSmall).Controls(grumpyCat.InputPower); pictureFrame = new Modules.HalloweenPictureFrame( medeaWizPlayer: pictureFrame1, name: nameof(pictureFrame)); stateMachine.WhenStates(States.BackgroundFull).Controls(pictureFrame.InputPower); flyingSkeleton = new Modules.HalloweenFlying( eyes: flyingSkeletonEyes, fogStairsLight1: fogStairsLight1, fogStairsLight2: fogStairsLight2, fogStairsPump1: fogStairsPump1, fogStairsPump2: fogStairsPump2, audioPlayer: audioFlying, name: nameof(flyingSkeleton)); stateMachine.WhenStates(States.BackgroundFull).Controls(flyingSkeleton.InputPower); firstBeam.Output.Controls(flyingSkeleton.InputTrigger); rockingChair = new Modules.HalloweenRocker( rockingMotor: rockingChairMotor, ladyEyes: ladyMovingEyes, strobeLight: rockingChairLight, audioPlayer: audioRocking, name: nameof(pictureFrame)); stateMachine.WhenStates(States.BackgroundFull).Controls(rockingChair.InputPower); rockingMotion.Output.Controls(rockingChair.InputTrigger); mrPumpkin = new Modules.HalloweenMrPumpkin( air: mrPumpkinAir, light: pumpkinLights, audioPlayer: audioPumpkin, name: nameof(mrPumpkin)); stateMachine.WhenStates(States.BackgroundFull, States.BackgroundSmall).Controls(mrPumpkin.InputPower); frankGhost = new Modules.HalloweenFrankGhost( air: frankGhostAir, light: pixelsFrankGhost, audioPlayer: audioFrankGhost, name: nameof(frankGhost)); stateMachine.WhenStates(States.BackgroundFull, States.BackgroundSmall).Controls(frankGhost.InputPower); spiderDrop = new Modules.HalloweenSpiderDrop( smallSpiderEyes: smallSpiderEyes, eyesLight: spiderEyes, drop: spiderDropRelease, venom: spiderVenom, strobeLight: flashUnderSpider, audioPlayer: audioSpider, name: nameof(spiderDrop)); stateMachine.WhenStates(States.BackgroundFull).Controls(spiderDrop.InputPower); fireProjector = new Modules.FireProjector( fire: fire, name: nameof(fireProjector)); stateMachine.WhenStates(States.BackgroundFull, States.Setup).Controls(fireProjector.InputPower); buttonOverrideHours.Output.Subscribe(x => { if (x) { mainSchedule.SetForced(true); } else { mainSchedule.SetForced(null); } }); flashBaby.Output.Subscribe(x => { // Flash if (x) { allLights.TakeAndHoldControl(100, "FlashBaby"); allLights.SetData(null, Utils.Data(1.0), Utils.Data(Color.White)); } else { allLights.ReleaseControl(); } }); testButton1.Output.Subscribe(x => { }); testButton2.Output.Subscribe(x => { }); testButton3.Output.Subscribe(x => { }); testButton4.Output.Subscribe(x => { }); setupMode.Output.Subscribe(x => { if (x) { stateMachine.GoToState(States.Setup); } else { stateMachine.GoToDefaultState(); } }); fullOn.Output.Subscribe(x => { if (x) { stateMachine.GoToState(States.BackgroundFull); } else { stateMachine.GoToDefaultState(); } }); floodLights.Output.Subscribe(x => { // Flash if (x) { allLights.TakeAndHoldControl(200, "FlashBaby"); allLights.SetData(null, Utils.Data(Color.White, 1.0)); } else { allLights.ReleaseControl(); } }); emergencyStop.Output.Subscribe(x => { if (x) { stateMachine.GoToState(States.EmergencyStop); } else { if (mainSchedule.IsOpen) { stateMachine.GoToDefaultState(); } else { stateMachine.GoToIdle(); } } }); mainSchedule.Output.Subscribe(x => { if (x) { stateMachine.SetDefaultState(States.BackgroundSmall); stateMachine.GoToDefaultState(); } else { stateMachine.GoToIdle(); stateMachine.SetDefaultState(null); } SetManualColor(); }); popOut1.ConnectTo(wall1Light); popOut1.ConnectTo(wall4Light); popOut1.ConnectTo(wall6Light); popOut1.ConnectTo(flashTree); popOut2.ConnectTo(wall2Light); //popOut2.ConnectTo(wall7Light); //popOut2.ConnectTo(flashUnderSpider); popOutAll.ConnectTo(wall1Light); popOutAll.ConnectTo(wall2Light); popOutAll.ConnectTo(wall3Light); popOutAll.ConnectTo(wall4Light); popOutAll.ConnectTo(wall5Light); popOutAll.ConnectTo(wall6Light); //popOutAll.ConnectTo(wall7Light); //popOutAll.ConnectTo(wall8Light); //popOutAll.ConnectTo(wall9Light); popOutAll.ConnectTo(flashTree); //popOutAll.ConnectTo(flashUnderSpider); popOutAll.ConnectTo(pixelsRoofEdge); popOutAll.ConnectTo(pixelsFrankGhost); // popOutAll.ConnectTo(pinSpot); allLights.Add( wall1Light, wall2Light, wall3Light, wall4Light, wall5Light, wall6Light, rockingChairLight, //wall7Light, //wall8Light, //wall9Light, flashTree, flashUnderSpider, pixelsRoofEdge, pixelsFrankGhost, // pinSpot, spiderLight, fogStairsLight1, fogStairsLight2, spiderWebLights, pumpkinLights); purpleLights.Add( wall1Light, wall2Light, wall3Light, wall4Light, wall5Light, wall6Light, //wall7Light, //wall8Light, //wall9Light, pixelsRoofEdge); flickerEffect.ConnectTo(stairs1Light); flickerEffect.ConnectTo(stairs2Light); flickerEffect.ConnectTo(gargoyleLightsEyes); //flickerEffect.ConnectTo(flyingSkeletonEyes); flickerEffect.ConnectTo(streetNumberEyes); flickerEffect.ConnectTo(bigSpiderEyes); pulsatingGargoyle.ConnectTo(gargoyleLightsCrystal); pulsatingGargoyle.ConnectTo(treeSkulls); //pulsatingGargoyle.ConnectTo(spiderEyes); //pulsatingEffect1.ConnectTo(pinSpot, Tuple.Create<DataElements, object>(DataElements.Color, Color.FromArgb(0, 255, 0))); //pulsatingEffect2.ConnectTo(pinSpot, Tuple.Create<DataElements, object>(DataElements.Color, Color.FromArgb(255, 0, 0))); pulsatingGargoyle.ConnectTo(spiderWebLights); stateMachine.For(States.Setup) .Controls(1, flickerEffect, pulsatingGargoyle) .Execute(ins => { ins.WaitUntilCancel(); }); stateMachine.For(States.BackgroundSmall) .Controls(1, flickerEffect, pulsatingGargoyle) .Execute(i => { treeGhosts.SetBrightness(1.0); treeSkulls.SetBrightness(1.0); audioHifi.SetBackgroundVolume(0.5); audioHifi.PlayBackground(); ladyMovingEyes.SetValue(true); var purpleColor = new ColorBrightness(HSV.ColorFromRGB(0.73333333333333328, 0, 1), 0.16470588235294117); purpleLights.SetData(null, Utils.Data(purpleColor.Brightness), Utils.Data(purpleColor.Color), Utils.Data(DataElements.ColorUltraViolet, 1.0)); i.WaitUntilCancel(); }) .TearDown(instance => { ladyMovingEyes.SetValue(false); Exec.Cancel(sub3dfxLady); audioHifi.PauseBackground(); purpleLights.SetBrightness(0.0); treeGhosts.SetBrightness(0.0); treeSkulls.SetBrightness(0.0); }); stateMachine.For(States.BackgroundFull) .Controls(1, flickerEffect, pulsatingGargoyle) .Execute(i => { treeGhosts.SetBrightness(1.0); treeSkulls.SetBrightness(1.0); audioHifi.PlayBackground(); audioHifi.SetBackgroundVolume(0.7); //Exec.Execute(sub3dfxLady); var purpleColor = new ColorBrightness(HSV.ColorFromRGB(0.73333333333333328, 0, 1), 0.16470588235294117); purpleLights.SetData(null, Utils.Data(purpleColor.Color, purpleColor.Brightness)); while (!i.IsCancellationRequested && stateMachine.CurrentState == States.BackgroundFull) { i.WaitFor(S(0.5)); if (!this.lastFogRun.HasValue || (DateTime.Now - this.lastFogRun.Value).TotalMinutes > 5) { // Run the fog for a little while lastFog.SetValue(true); i.WaitFor(S(4)); lastFog.SetValue(false); this.lastFogRun = DateTime.Now; } } }) .TearDown(instance => { purpleLights.SetBrightness(0.0); treeGhosts.SetBrightness(0.0); treeSkulls.SetBrightness(0.0); audioHifi.PauseBackground(); timelineThunder1.Stop(); timelineThunder2.Stop(); timelineThunder3.Stop(); timelineThunder4.Stop(); timelineThunder5.Stop(); timelineThunder6.Stop(); timelineThunder7.Stop(); timelineThunder8.Stop(); flickerEffect.Stop(); treeGhosts.SetBrightness(0.0); treeSkulls.SetBrightness(0.0); }); stateMachine.For(States.EmergencyStop) .Execute(i => { // Do nothing i.WaitUntilCancel(); }); stateMachine.For(States.Special1) .Execute(i => { //audio2.PlayNewEffect("640 The Demon Exorcised.wav"); i.WaitUntilCancel(); }); inputBrightness.Output.Subscribe(x => { // testLight1.SetBrightness(x); }); inputH.WhenOutputChanges(x => { // testLight1.SetColor(HSV.ColorFromHSV(x.GetByteScale(), inputS.Value, 1.0)); }); inputS.Output.Subscribe(x => { // testLight1.SetColor(HSV.ColorFromHSV(inputH.Value.GetByteScale(), x, 1.0)); }); expanderHifi.AudioTrackStart.Subscribe(x => { // Next track switch (x.Item2) { case "Thunder1.wav": timelineThunder1.Start(); audioHifi.PlayEffect("scream.wav"); break; case "Thunder2.wav": timelineThunder2.Start(); break; case "Thunder3.wav": timelineThunder3.Start(); break; case "Thunder4.wav": timelineThunder4.Start(); audioHifi.PlayEffect("424 Coyote Howling.wav"); break; case "Thunder5.wav": timelineThunder5.Start(); // audioEeebox.PlayEffect("sixthsense-deadpeople.wav"); break; case "Thunder6.wav": timelineThunder6.Start(); break; case "Thunder7.wav": timelineThunder7.Start(); break; case "Thunder8.wav": timelineThunder8.Start(); break; default: log.Debug("Unknown track {0}", x); break; } }); timelineThunder1.AddMs(500, "A"); timelineThunder1.AddMs(3500, "B"); timelineThunder1.AddMs(4500, "C"); timelineThunder1.TimelineTrigger += TriggerThunderTimeline; timelineThunder2.AddMs(500, "A"); timelineThunder2.AddMs(1500, "B"); timelineThunder2.AddMs(1600, "C"); timelineThunder2.AddMs(3700, "C"); timelineThunder2.TimelineTrigger += TriggerThunderTimeline; timelineThunder3.AddMs(100, "A"); timelineThunder3.AddMs(200, "B"); timelineThunder3.AddMs(300, "C"); timelineThunder3.TimelineTrigger += TriggerThunderTimeline; timelineThunder4.AddMs(0, "A"); timelineThunder4.AddMs(3500, "B"); timelineThunder4.AddMs(4500, "C"); timelineThunder4.TimelineTrigger += TriggerThunderTimeline; timelineThunder5.AddMs(1100, "A"); timelineThunder5.AddMs(3500, "B"); timelineThunder5.AddMs(4700, "C"); timelineThunder5.TimelineTrigger += TriggerThunderTimeline; timelineThunder6.AddMs(1000, "A"); timelineThunder6.AddMs(1800, "B"); timelineThunder6.AddMs(6200, "C"); timelineThunder6.TimelineTrigger += TriggerThunderTimeline; timelineThunder7.AddMs(0, "A"); timelineThunder7.AddMs(200, "B"); timelineThunder7.AddMs(300, "C"); timelineThunder7.TimelineTrigger += TriggerThunderTimeline; timelineThunder8.AddMs(500, "A"); timelineThunder8.AddMs(4000, "B"); timelineThunder8.AddMs(4200, "C"); timelineThunder8.TimelineTrigger += TriggerThunderTimeline; acnOutput.Connect(new Physical.Pixel1D(pixelsRoofEdge, 0, 50, true), SacnUniversePixel50, 1); acnOutput.Connect(new Physical.Pixel1D(pixelsRoofEdge, 50, 100), SacnUniversePixel100, 1); acnOutput.Connect(new Physical.Pixel1D(pixelsFrankGhost, 0, 5), SacnUniverseFrankGhost, 1); acnOutput.Connect(new Physical.FogMachineA(fogStairsPump1, fogStairsLight1, 1), SacnUniverseDMXFogA); acnOutput.Connect(new Physical.FogMachineA(fogStairsPump2, fogStairsLight2, 10), SacnUniverseDMXFogA); //acnOutput.Connect(new Physical.SmallRGBStrobe(spiderLight, 1), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.RGBStrobe(wall6Light, 60), SacnUniverseEdmx4A); //acnOutput.Connect(new Physical.RGBStrobe(wall9Light, 70), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.RGBStrobe(rockingChairLight, 40), SacnUniverseEdmx4A); //acnOutput.Connect(new Physical.RGBStrobe(wall7Light, 80), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.DMXCommandOutput(pictureFrame1, 1, TimeSpan.FromMilliseconds(500), 0), SacnUniverseEdmx4B); acnOutput.Connect(new Physical.DMXCommandOutput(lady3dfx, 1, TimeSpan.FromMilliseconds(500), 0), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.MarcGamutParH7(wall1Light, 340, 8), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.RGBStrobe(wall2Light, 80), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.MarcGamutParH7(wall3Light, 330, 8), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.MarcGamutParH7(wall4Light, 310, 8), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.MarcGamutParH7(wall5Light, 300, 8), SacnUniverseEdmx4A); // acnOutput.Connect(new Physical.MarcGamutParH7(wall6Light, 350, 8), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(stairs1Light, 66), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(stairs2Light, 51), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(treeGhosts, 67), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(treeSkulls, 131), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(spiderEyes, 128), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(popperEyes, 132), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(popper, 133), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.AmericanDJStrobe(flashTree, 100), SacnUniverseEdmx4A); acnOutput.Connect(new Physical.EliminatorFlash192(flashUnderSpider, 110), SacnUniverseDMXFogA); // acnOutput.Connect(new Physical.MonopriceRGBWPinSpot(pinSpot, 20), 1); acnOutput.Connect(new Physical.GenericDimmer(fire, 1), SacnUniverseFire); acnOutput.Connect(new Physical.GenericDimmer(frankGhostAir, 10), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(mrPumpkinAir, 11), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(spiderWebLights, 99), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(catAir, 64), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(catLights, 65), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(pumpkinLights, 50), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(gargoyleLightsCrystal, 128), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(gargoyleLightsEyes, 129), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(flyingSkeletonEyes, 134), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(smallSpiderEyes, 135), SacnUniverseDMXLedmx); acnOutput.Connect(new Physical.GenericDimmer(streetNumberEyes, 131), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(bigSpiderEyes, 132), SacnUniverseDMXCat); acnOutput.Connect(new Physical.GenericDimmer(hazerFanSpeed, 500), SacnUniverseDMXFogA); acnOutput.Connect(new Physical.GenericDimmer(hazerHazeOutput, 501), SacnUniverseDMXFogA); // acnOutput.Connect(new Physical.RGBIS(testLight1, 260), 1); expanderLedmx.DigitalInputs[4].Connect(frankGhostMotion, false); expanderLedmx.DigitalInputs[5].Connect(mrPumpkinMotion, false); expanderLedmx.DigitalInputs[6].Connect(rockingMotion, false); expanderCat.DigitalInputs[7].Connect(catMotion); expanderCat.DigitalInputs[6].Connect(secondBeam); expanderCat.DigitalInputs[5].Connect(spiderDropTrigger, inverted: true); expanderCat.DigitalInputs[4].Connect(firstBeam); expanderLedmx.DigitalInputs[7].Connect(lastBeam); //expanderMrPumpkin.DigitalOutputs[7].Connect(popper); expanderLedmx.DigitalOutputs[2].Connect(lastFog, inverted: true); expanderMrPumpkin.DigitalOutputs[7].Connect(rockingChairMotor); expanderMrPumpkin.DigitalOutputs[4].Connect(ladyMovingEyes); expanderLedmx.DigitalOutputs[0].Connect(spiderDropRelease); expanderLedmx.DigitalOutputs[1].Connect(spiderVenom); expanderCat.DigitalOutputs[6].Connect(spiderJump2); expanderLedmx.Connect(audioFrankGhost); expanderCat.Connect(audioCat); expanderHifi.Connect(audioHifi); expanderMrPumpkin.Connect(audioPumpkin); //expanderAudio2.Connect(audio2); expanderFlying.Connect(audioFlying); expanderSpider.Connect(audioSpider); expanderRocking.Connect(audioRocking); expanderPopper.Connect(audioPopper); expanderHifi.BackgroundAudioFiles = new string[] { "Thunder1.wav", "Thunder2.wav", "Thunder3.wav", "Thunder4.wav", "Thunder5.wav", "Thunder6.wav", "Thunder7.wav", "Thunder8.wav" }; expanderRocking.BackgroundAudioFiles = new string[] { "68 Creaky Wooden Floorboards.wav" }; blockMaster.WhenOutputChanges(x => UpdateOSC()); blockCat.WhenOutputChanges(x => UpdateOSC()); blockFirst.WhenOutputChanges(x => UpdateOSC()); blockPicture.WhenOutputChanges(x => UpdateOSC()); blockGhost.WhenOutputChanges(x => UpdateOSC()); blockLast.WhenOutputChanges(x => UpdateOSC()); blockPumpkin.WhenOutputChanges(x => UpdateOSC()); Utils.ReactiveOr(blockCat, blockMaster).Controls(grumpyCat.InputTriggerBlock); Utils.ReactiveOr(blockPumpkin, blockMaster).Controls(mrPumpkin.InputTriggerBlock); Utils.ReactiveOr(blockFrankGhost, blockMaster).Controls(frankGhost.InputTriggerBlock); Utils.ReactiveOr(blockSpiderDrop, blockMaster).Controls(spiderDrop.InputTriggerBlock); Utils.ReactiveOr(blockFire, blockMaster).Controls(fireProjector.InputTriggerBlock); Utils.ReactiveOr(blockPicture, blockMaster).Controls(pictureFrame.InputTriggerBlock); Utils.ReactiveOr(blockRocking, blockMaster).Controls(rockingChair.InputTriggerBlock); Utils.ReactiveOr(blockFirst, blockMaster).Controls(flyingSkeleton.InputTriggerBlock); catMotion.Controls(grumpyCat.InputTrigger); secondBeam.Controls(pictureFrame.InputTrigger); mrPumpkinMotion.Controls(mrPumpkin.InputTrigger); frankGhostMotion.Controls(frankGhost.InputTrigger); spiderDropTrigger.Controls(spiderDrop.InputTrigger); spiderDropTrigger.Output.Subscribe(x => { if (x) { Exec.Execute(sub3dfxLady); } }); lastBeam.Output.Subscribe(x => { UpdateOSC(); if (x && (stateMachine.CurrentState == States.BackgroundFull || stateMachine.CurrentState == States.Setup) && !emergencyStop.Value && !blockMaster.Value && !blockLast.Value) { subLast.Run(); } }); subFog .RunAction(i => { lastFog.SetValue(true); lastFogRun = DateTime.Now; i.WaitFor(S(4)); lastFog.SetValue(false); }); sub3dfxLady .RunAction(i => { i.WaitFor(S(1)); if (random.Next(2) == 0) { lady3dfx.SendCommand(null, 99); i.WaitFor(S(30)); } else { lady3dfx.SendCommand(null, (byte)(random.Next(4) + 1)); i.WaitFor(S(60 * 2.0)); } }) .TearDown(i => { lady3dfx.SendCommand(null, 255); }); subLast .RunAction(ins => { popperEyes.SetBrightness(1.0); lastFog.SetValue(true); lastFogRun = DateTime.Now; audioPopper.PlayEffect("Short Laugh.wav"); ins.WaitFor(S(1.0)); popper.SetValue(true); ins.WaitFor(S(2.0)); audioPopper.PlayEffect("Leave Now.wav"); ins.WaitFor(S(3.0)); var tsk = Exec.MasterEffect.Fade(popperEyes, 1.0, 0.0, 2000, token: ins.Token); popper.SetValue(false); tsk.Wait(); }) .TearDown(ins => { lastFog.SetValue(false); ins.WaitFor(S(1.0)); }); motionSeq.WhenExecuted .Execute(instance => { //video2.PlayVideo("DancingDead_Wall_HD.mp4"); // instance.WaitFor(S(10)); }) .TearDown(instance => { }); faderR.WhenOutputChanges(v => { SetManualColor(); }); faderG.WhenOutputChanges(v => { SetManualColor(); }); faderB.WhenOutputChanges(v => { SetManualColor(); }); faderBright.WhenOutputChanges(v => { SetManualColor(); }); manualFader.WhenOutputChanges(v => { if (v) { this.manualFaderToken = pixelsRoofEdge.TakeControl(200); } else { this.manualFaderToken?.Dispose(); this.manualFaderToken = null; } oscServer.SendAllClients("/ManualFader/x", v ? 1 : 0); SetManualColor(); }); ConfigureOSC(); ConfigureMIDI(); }
public override void Execute(string args) { Exec.Execute(args); }
public override void Run() { Exec.Execute(candyCane); }
public override void Start() { hoursSmall.AddRange("5:00 pm", "9:00 pm"); hoursFull.AddRange("5:00 pm", "9:00 pm"); //hoursFull.SetForced(true); //hoursSmall.SetForced(true); //hoursFull.SetForced(false); //hoursSmall.SetForced(false); #if !true hoursFull.SetForced(true); audioBeauty.SetSilent(true); audioCat.SetSilent(true); audioGeorge.SetSilent(true); audioSpider.SetSilent(true); georgeMotor.SetDisabled(true); #endif var backgroundSeq = new Controller.Sequence("BG Sequence"); backgroundSeq.WhenExecuted .SetUp(() => { audioGeorge.PlayBackground(); lightFloor.SetOnlyColor(Color.Orange); pulsatingEffect1.Start(); flickerEffect.Start(); }) .Execute(instance => { while (!instance.IsCancellationRequested) { instance.WaitFor(S(1)); if (!this.lastFogRun.HasValue || (DateTime.Now - this.lastFogRun.Value).TotalMinutes > 10) { // Run the fog for a little while switchFog.SetPower(true); instance.WaitFor(S(4)); switchFog.SetPower(false); this.lastFogRun = DateTime.Now; } } }) .TearDown(() => { audioGeorge.PauseBackground(); pulsatingEffect1.Stop(); flickerEffect.Stop(); }); var deadendSeq = new Controller.Sequence("Deadend dr"); deadendSeq.WhenExecuted .Execute(instance => { switchDeadendDrive.SetPower(true); Thread.Sleep(1000); switchDeadendDrive.SetPower(false); }); var stairSeq = new Controller.Sequence("Stair Sequence"); stairSeq.WhenExecuted .SetUp(() => { }) .Execute(instance => { switchFog.SetPower(true); this.lastFogRun = DateTime.Now; Executor.Current.Execute(deadendSeq); audioGeorge.PlayEffect("ghostly"); instance.WaitFor(S(0.5)); popOutEffect.Pop(1.0); instance.WaitFor(S(1.0)); audioSpider.PlayNewEffect("348 Spider Hiss"); switchSpider.SetPower(true); instance.WaitFor(S(0.5)); switchSpiderEyes1.SetPower(true); instance.WaitFor(S(2)); switchSpider.SetPower(false); switchSpiderEyes1.SetPower(false); instance.WaitFor(S(4)); stateMachine.NextState(); }) .TearDown(() => { switchFog.SetPower(false); audioGeorge.PauseFX(); }); var georgeReturnSeq = new Controller.Sequence("George Return Seq"); georgeReturnSeq.WhenExecuted .Execute(instance => { georgeMotor.WaitForVectorReached(); georgeMotor.SetVector(0.9, 0, S(15)); georgeMotor.WaitForVectorReached(); }); var georgeSeq = new Controller.Sequence("George Sequence"); georgeSeq.WhenExecuted .Execute(instance => { //Exec.WaitUntilFinished(georgeReturnSeq); audioGeorge.PlayEffect("laugh"); georgeMotor.SetVector(1.0, 350, S(10)); instance.WaitFor(TimeSpan.FromSeconds(0.8)); lightGeorge.SetColor(Color.Red); georgeMotor.WaitForVectorReached(instance); instance.WaitFor(TimeSpan.FromSeconds(2)); georgeMotor.SetVector(0.9, 0, S(15)); lightGeorge.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0)); instance.WaitFor(TimeSpan.FromSeconds(1)); lightFloor.SetOnlyColor(Color.Green); pulsatingEffect1.Start(); georgeMotor.WaitForVectorReached(instance); instance.WaitFor(S(15)); }) .TearDown(() => { Exec.Execute(georgeReturnSeq); pulsatingEffect1.Stop(); lightGeorge.TurnOff(); }); var spiderEyes2Seq = new Controller.Sequence("Spider Eyes 2"); spiderEyes2Seq.WhenExecuted .Execute(instance => { var rnd = new Random(); while (!instance.IsCancellationRequested) { switchSpiderEyes2.SetPower(true); instance.WaitFor(S(1.0 + rnd.Next(10))); switchSpiderEyes2.SetPower(false); instance.WaitFor(S(1.0 + rnd.Next(2))); } }); var popupSeq = new Controller.Sequence("Popup Sequence"); popupSeq.WhenExecuted .Execute(instance => { audioBeauty.PlayEffect("scream", 0.0, 1.0); switchPopEyes.SetPower(true); instance.WaitFor(TimeSpan.FromSeconds(1.0)); lightPopup.SetBrightness(1.0); switchPopUp.SetPower(true); instance.WaitFor(S(3)); lightPopup.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0)); switchPopEyes.TurnOff(); switchPopUp.TurnOff(); }); var beautySeq = new Controller.Sequence("Beauty Sequence"); beautySeq.WhenExecuted .Execute(instance => { flickerEffect2.Stop(); lightBeauty.SetColor(Color.Purple); switchHand.SetPower(true); instance.WaitFor(TimeSpan.FromSeconds(1)); audioBeauty.PlayEffect("gollum_precious1", 1.0, 0.0); instance.WaitFor(TimeSpan.FromSeconds(0.4)); switchHead.SetPower(true); instance.WaitFor(TimeSpan.FromSeconds(6)); switchHead.SetPower(false); switchHand.SetPower(false); instance.WaitFor(TimeSpan.FromSeconds(1.5)); lightBeauty.TurnOff(); instance.WaitFor(TimeSpan.FromSeconds(0.5)); switchDrawer1.SetPower(true); switchHead.SetPower(true); instance.WaitFor(TimeSpan.FromSeconds(0.5)); lightBeauty.SetColor(Color.Red, 1.0); audioBeauty.PlayEffect("my_pretty", 1.0, 0.0); instance.WaitFor(TimeSpan.FromSeconds(4)); switchDrawer2.SetPower(true); instance.WaitFor(TimeSpan.FromSeconds(2)); switchDrawer1.SetPower(false); instance.WaitFor(TimeSpan.FromSeconds(0.15)); switchDrawer2.SetPower(false); instance.WaitFor(TimeSpan.FromSeconds(1)); switchHead.SetPower(false); lightBeauty.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0)); if (hoursSmall.IsOpen) { flickerEffect2.Start(); } instance.WaitFor(TimeSpan.FromSeconds(5)); }); var catSeq = new Controller.Sequence("Cat Sequence"); catSeq.WhenExecuted .Execute(instance => { var maxRuntime = System.Diagnostics.Stopwatch.StartNew(); var random = new Random(); catLights.SetPower(true); while (true) { switch (random.Next(4)) { case 0: audioCat.PlayEffect("266 Monster Growl 7", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(2.0)); break; case 1: audioCat.PlayEffect("285 Monster Snarl 2", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(3.0)); break; case 2: audioCat.PlayEffect("286 Monster Snarl 3", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(2.5)); break; case 3: audioCat.PlayEffect("287 Monster Snarl 4", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(1.5)); break; default: instance.WaitFor(TimeSpan.FromSeconds(3.0)); break; } instance.CancelToken.ThrowIfCancellationRequested(); if (maxRuntime.Elapsed.TotalSeconds > 10) { break; } } }) .TearDown(() => { catLights.TurnOff(); }); var candyCane = new Controller.Sequence("Candy Cane"); candyCane .WhenExecuted .SetUp(() => allPixels.TurnOff()) .Execute(instance => { var cbList = new List <ColorBrightness>(); //cbList.Add(new ColorBrightness(Color.Green, 1.00)); //cbList.Add(new ColorBrightness(Color.Green, 0.70)); //cbList.Add(new ColorBrightness(Color.Green, 0.40)); //cbList.Add(new ColorBrightness(Color.White, 1.00)); //cbList.Add(new ColorBrightness(Color.White, 0.70)); //cbList.Add(new ColorBrightness(Color.White, 0.40)); //cbList.Add(new ColorBrightness(Color.Red, 1.00)); //cbList.Add(new ColorBrightness(Color.Red, 0.70)); //cbList.Add(new ColorBrightness(Color.Red, 0.40)); //cbList.Add(new ColorBrightness(Color.Black, 0.0)); //cbList.Add(new ColorBrightness(Color.Black, 0.0)); //cbList.Add(new ColorBrightness(Color.Black, 0.0)); //cbList.Add(new ColorBrightness(Color.Black, 0.0)); double b1 = 1.00; double b2 = 0.70; double b3 = 0.40; Color c1 = Color.Blue; Color c2 = Color.Yellow; Color c3 = Color.Blue; Color c4 = Color.Black; cbList.Add(new ColorBrightness(c1, b1)); cbList.Add(new ColorBrightness(c1, b2)); cbList.Add(new ColorBrightness(c1, b3)); cbList.Add(new ColorBrightness(c2, b1)); cbList.Add(new ColorBrightness(c2, b2)); cbList.Add(new ColorBrightness(c2, b3)); cbList.Add(new ColorBrightness(c3, b1)); cbList.Add(new ColorBrightness(c3, b2)); cbList.Add(new ColorBrightness(c3, b3)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); b1 = 1.00; b2 = 0.70; b3 = 0.40; c1 = Color.White; c2 = Color.Blue; c3 = Color.Red; c4 = Color.Black; cbList.Add(new ColorBrightness(c1, b1)); cbList.Add(new ColorBrightness(c1, b2)); cbList.Add(new ColorBrightness(c1, b3)); cbList.Add(new ColorBrightness(c2, b1)); cbList.Add(new ColorBrightness(c2, b2)); cbList.Add(new ColorBrightness(c2, b3)); cbList.Add(new ColorBrightness(c3, b1)); cbList.Add(new ColorBrightness(c3, b2)); cbList.Add(new ColorBrightness(c3, b3)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); b1 = 1.00; b2 = 0.70; b3 = 0.40; c1 = Color.Red; c2 = Color.White; c3 = Color.Blue; c4 = Color.Black; cbList.Add(new ColorBrightness(c1, b1)); cbList.Add(new ColorBrightness(c1, b2)); cbList.Add(new ColorBrightness(c1, b3)); cbList.Add(new ColorBrightness(c2, b1)); cbList.Add(new ColorBrightness(c2, b2)); cbList.Add(new ColorBrightness(c2, b3)); cbList.Add(new ColorBrightness(c3, b1)); cbList.Add(new ColorBrightness(c3, b2)); cbList.Add(new ColorBrightness(c3, b3)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); cbList.Add(new ColorBrightness(c4, 0.0)); while (true) { foreach (var cb in cbList) { allPixels.Inject(cb); instance.WaitFor(S(0.350), true); } } }) .TearDown(() => { allPixels.TurnOff(); }); stateMachine.ForFromSequence(States.Background, backgroundSeq); stateMachine.ForFromSequence(States.Stair, stairSeq); stateMachine.ForFromSequence(States.George, georgeSeq); stateMachine.ForFromSequence(States.Popup, popupSeq); hoursSmall.OpenHoursChanged += (sender, e) => { if (e.IsOpenNow) { pulsatingEffect2.Start(); flickerEffect.Start(); flickerEffect2.Start(); catFan.SetPower(true); lightEyes.SetPower(true); lightTreeGhost.SetBrightness(1.0); // Exec.Execute(candyCane); allPixels.SetAll(Color.FromArgb(255, 115, 0), 0.5); } else { pulsatingEffect2.Stop(); flickerEffect.Stop(); flickerEffect2.Stop(); catFan.SetPower(false); lightEyes.SetPower(false); lightTreeGhost.TurnOff(); allPixels.TurnOff(); } }; hoursFull.OpenHoursChanged += (sender, e) => { if (e.IsOpenNow) { Executor.Current.Execute(spiderEyes2Seq); stateMachine.SetBackgroundState(States.Background); stateMachine.SetState(States.Background); } else { Executor.Current.Cancel(spiderEyes2Seq); stateMachine.Hold(); stateMachine.SetBackgroundState(null); audioGeorge.PauseBackground(); } }; buttonMotionCat.ActiveChanged += (sender, e) => { #if CHECK_SENSOR_ALIGNMENT catLights.SetPower(e.NewState); #else if (e.NewState && hoursSmall.IsOpen) { Executor.Current.Execute(catSeq); } #endif }; buttonMotionBeauty.ActiveChanged += (sender, e) => { if (e.NewState && hoursFull.IsOpen) { Executor.Current.Execute(beautySeq); } }; buttonTriggerStairs.ActiveChanged += (sender, e) => { if (!hoursSmall.IsOpen) { lightFloor.SetColor(Color.Purple, e.NewState ? 0.6 : 0.0); } else { if (e.NewState && hoursFull.IsOpen) { if (!stateMachine.CurrentState.HasValue || stateMachine.CurrentState == States.Background) { stateMachine.SetState(States.Stair); } } } }; buttonTriggerPopup.ActiveChanged += (sender, e) => { if (!hoursSmall.IsOpen) { lightPopup.SetBrightness(e.NewState ? 0.5 : 0.0); } else { if (e.NewState) { if (stateMachine.CurrentState == States.George) { stateMachine.SetState(States.Popup); } } } }; flickerEffect.AddDevice(skullsLight); flickerEffect2.AddDevice(skullsLight2); lightFloor.SetColor(Color.Orange, 0); lightSign.SetColor(Color.Pink, 0); pulsatingEffect1.AddDevice(lightFloor); pulsatingEffect1.AddDevice(lightSpiderWeb); pulsatingEffect2.AddDevice(lightSign); popOutEffect.AddDevice(skullsLight); ForTest(); }
public override void Start() { testSeq .WhenExecuted .SetUp(() => allPixels.TurnOff()) .Execute(instance => { allPixels.SetAllOnlyColor(Color.Orange); allPixels.RunEffect(new Effect2.Pulse(0.0, 1.0), S(2.0)) .SetIterations(2) .Wait(); allPixels.StopEffect(); }) .TearDown(() => { allPixels.TurnOff(); Exec.Execute(candyCane); }); candyCane .WhenExecuted .SetUp(() => allPixels.TurnOff()) .Execute(instance => { const int spacing = 4; while (true) { for (int i = 0; i < spacing; i++) { allPixels.Inject((i % spacing) == 0 ? Color.Red : Color.White, 0.5); instance.WaitFor(S(0.30), true); } } }) .TearDown(() => { allPixels.TurnOff(); }); laserSeq .WhenExecuted .SetUp(() => { allPixels.TurnOff(); }) .Execute(instance => { var cb = new ColorBrightness[6]; cb[0] = new ColorBrightness(Color.Black, 1.0); cb[1] = new ColorBrightness(Color.Red, 1.0); cb[2] = new ColorBrightness(Color.Orange, 1.0); cb[3] = new ColorBrightness(Color.Yellow, 1.0); cb[4] = new ColorBrightness(Color.Blue, 1.0); cb[5] = new ColorBrightness(Color.White, 1.0); for (int i = -6; i < allPixels.Pixels; i++) { allPixels.SetColors(i, cb); System.Threading.Thread.Sleep(25); } instance.WaitFor(S(1)); }) .TearDown(() => { allPixels.TurnOff(); Exec.Execute(candyCane); }); // Test Button buttonTest.ActiveChanged += (sender, e) => { if (!e.NewState) { return; } Exec.Cancel(candyCane); allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); allPixels.SetAllOnlyColor(Color.Purple); allPixels.RunEffect(new Effect2.Fader(0.0, 1.0), S(2.0)).Wait(); allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); allPixels.SetAllOnlyColor(Color.Orange); allPixels.RunEffect(new Effect2.Fader(0.0, 1.0), S(2.0)).Wait(); allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); Exec.Execute(candyCane); }; }
public override void Start() { hours.AddRange("5:00 pm", "11:00 pm"); bool.TryParse(Exec.GetKey("InflatablesRunning", false.ToString()), out inflatablesRunning); buttonOverrideHours.ActiveChanged += (i, e) => { if (e.NewState) { hours.SetForced(true); } else { hours.SetForced(null); } }; candyCane .WhenExecuted .SetUp(() => allPixels.TurnOff()) .Execute(instance => { const int spacing = 4; while (true) { for (int i = 0; i < spacing; i++) { allPixels.Inject((i % spacing) == 0 ? Color.Red : Color.White, 0.5); instance.WaitFor(S(0.2), true); } } }) .TearDown(() => { allPixels.TurnOff(); }); twinkleSeq .WhenExecuted .SetUp(() => allPixels.TurnOff()) .Execute(instance => { var rnd = new Random(); while (!instance.IsCancellationRequested) { allPixels.SetAll(Color.White, 0.5); instance.WaitFor(S(1.0), true); int pixel1 = rnd.Next(allPixels.Pixels); int pixel2 = rnd.Next(allPixels.Pixels); var task1 = allPixels.FadeToAsync(instance, pixel1, Color.Red, 1.0, S(2.0)); var task2 = allPixels.FadeToAsync(instance, pixel2, Color.Red, 1.0, S(2.0)); Task.WaitAll(task1, task2); instance.WaitFor(S(1.0), true); task1 = allPixels.FadeToAsync(instance, pixel1, Color.White, 0.5, S(1.0)); task2 = allPixels.FadeToAsync(instance, pixel2, Color.White, 0.5, S(1.0)); Task.WaitAll(task1, task2); } }) .TearDown(() => allPixels.TurnOff()); backgroundLoop .WhenExecuted .SetUp(() => { pulsatingEffect1.Start(); flickerEffect.Start(); switchButtonBlue.SetPower(true); switchButtonRed.SetPower(true); lightTreeUp.SetOnlyColor(Color.Red); faderIn.Restart(); Executor.Current.Execute(twinkleSeq); }) .TearDown(() => { Executor.Current.Cancel(twinkleSeq); switchButtonBlue.SetPower(false); switchButtonRed.SetPower(false); EverythingOff(); }); offHours1Seq .WhenExecuted .Execute(instance => { audioPlayer.PlayEffect("force1"); instance.WaitFor(S(4)); }); offHours2Seq .WhenExecuted .Execute(instance => { audioPlayer.PlayEffect("darkside"); instance.WaitFor(S(4)); }); music1Seq .WhenExecuted .SetUp(() => { audioPlayer.CueTrack("21. Christmas Canon Rock"); // Make sure it's ready System.Threading.Thread.Sleep(800); EverythingOff(); }) .Execute(instance => { audioPlayer.ResumeTrack(); var task = timeline1.Start(); try { task.Wait(instance.CancelToken); instance.WaitFor(S(10)); } finally { timeline1.Stop(); audioPlayer.PauseTrack(); } if (!instance.IsCancellationRequested) { instance.WaitFor(S(2)); } EverythingOff(); instance.WaitFor(S(2)); }) .TearDown(() => { EverythingOff(); }); starwarsCane .WhenExecuted .SetUp(() => { allPixels.TurnOff(); starwarsPixels.TurnOff(); }) .Execute(instance => { const int spacing = 4; while (!instance.CancelToken.IsCancellationRequested) { for (int i = 0; i < spacing; i++) { switch (i % spacing) { case 0: case 1: starwarsPixels.InjectRev(Color.Yellow, 1.0); break; case 2: case 3: starwarsPixels.InjectRev(Color.Orange, 0.2); break; } instance.WaitFor(S(0.1)); if (instance.IsCancellationRequested) { break; } } } }) .TearDown(() => starwarsPixels.TurnOff()); fatherSeq .WhenExecuted .Execute(instance => { EverythingOff(); Executor.Current.Execute(starwarsCane); audioPlayer.PlayTrack("01. Star Wars - Main Title"); //lightCeiling1.SetOnlyColor(Color.Yellow); //lightCeiling2.SetOnlyColor(Color.Yellow); //lightCeiling3.SetOnlyColor(Color.Yellow); //pulsatingEffect2.Start(); instance.WaitFor(S(16)); //pulsatingEffect2.Stop(); audioPlayer.PauseTrack(); Executor.Current.Cancel(starwarsCane); allPixels.TurnOff(); instance.WaitFor(S(0.5)); elJesus.SetPower(true); pulsatingStar.Start(); lightJesus.SetColor(Color.White, 0.3); light3wise.SetOnlyColor(Color.LightYellow); light3wise.RunEffect(new Effect2.Fader(0.0, 1.0), S(1.0)); lightVader.SetOnlyColor(Color.LightYellow); lightVader.RunEffect(new Effect2.Fader(0.0, 1.0), S(1.0)); instance.WaitFor(S(2.5)); //elLightsaber.SetPower(true); audioPlayer.PlayEffect("saberon"); for (int sab = 0; sab < 60; sab++) { saberPixels.Inject(Color.Red, 0.5); instance.WaitFor(S(0.01)); } // lightVader.SetColor(Color.Red, 1.0); audioPlayer.PlayEffect("father"); instance.WaitFor(S(4)); lightVader.TurnOff(); light3wise.TurnOff(); lightJesus.TurnOff(); pulsatingStar.Stop(); elJesus.TurnOff(); audioPlayer.PlayEffect("force1"); instance.WaitFor(S(4)); lightVader.TurnOff(); audioPlayer.PlayEffect("saberoff"); instance.WaitFor(S(0.7)); for (int sab = 0; sab < 30; sab++) { saberPixels.InjectRev(Color.Black, 0); saberPixels.InjectRev(Color.Black, 0); instance.WaitFor(S(0.01)); } //elLightsaber.SetPower(false); instance.WaitFor(S(2)); //lightJesus.TurnOff(); //light3wise.TurnOff(); //elLightsaber.TurnOff(); //pulsatingStar.Stop(); //elJesus.TurnOff(); //instance.WaitFor(S(2)); }) .TearDown(() => { EverythingOff(); }); waveformSeq .WhenExecuted .SetUp(() => { audioPlayer.CueTrack("05. Frozen - Let It Go"); // Make sure it's ready System.Threading.Thread.Sleep(800); EverythingOff(); }) .Execute(i => { var timer = new Controller.HighPrecisionTimer(50, false); byte[] buffer; using (var fs = System.IO.File.OpenRead("Let It Go - Waveform 50ms.dat")) { buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); } var cb = new ColorBrightness[allPixels.Pixels]; for (int cb_pos = 0; cb_pos < cb.Length; cb_pos++) { cb[cb_pos] = new ColorBrightness(Color.Turquoise, 0.0); } double lastValue = 0; timer.Tick += (o, e) => { int pos = (int)e.TotalTicks; if (pos >= buffer.Length) { e.Cancel = true; return; } double curValue = buffer[pos].GetDouble(); if (curValue > lastValue) { lastValue = curValue; } double value = lastValue; lastValue = (lastValue - 0.02).Limit(0.0, 1.0); const double d1 = 0.00; const double d2 = 0.15; const double d3 = 0.20; const double d4 = 0.25; lightHat1.Brightness = value.LimitAndScale(d1, 0.2); lightHat2.Brightness = value.LimitAndScale(d1, 0.2); lightHat3.Brightness = value.LimitAndScale(d2, 0.2); lightHat4.Brightness = value.LimitAndScale(d2, 0.2); lightTreeUp.Brightness = value.LimitAndScale(d3, 0.2); lightGarland1.Brightness = value.LimitAndScale(d3, 0.2); lightGarland2.Brightness = value.LimitAndScale(d3, 0.2); lightGarland3.Brightness = value.LimitAndScale(d3, 0.2); lightGarland4.Brightness = value.LimitAndScale(d3, 0.2); lightNet1.Brightness = value.LimitAndScale(d2, 0.2); lightNet2.Brightness = value.LimitAndScale(d2, 0.2); lightSnow1.Brightness = value.LimitAndScale(d3, 0.2); lightSnow2.Brightness = value.LimitAndScale(d3, 0.2); lightStairs1.Brightness = value.LimitAndScale(d1, 0.2); lightStairs2.Brightness = value.LimitAndScale(d1, 0.2); lightDeerSmall.Brightness = curValue; lightTopperLarge.Brightness = curValue; lightDeerLarge.Brightness = curValue; lightTopperSmall.Brightness = curValue; lightString1.Brightness = value.LimitAndScale(d4, 0.2); lightString2.Brightness = value.LimitAndScale(d4, 0.2); lightXmasTree.Brightness = value.LimitAndScale(d4, 0.2); lightStar.Brightness = value.LimitAndScale(d4, 0.2); int vuPos = (int)(cb.Length * value); for (int cb_pos = 0; cb_pos < cb.Length; cb_pos++) { cb[cb_pos].Brightness = cb_pos < vuPos ? 1.0 : 0.2; } allPixels.SetColors(0, cb); }; timer.Start(); audioPlayer.ResumeTrack(); timer.WaitUntilFinished(i); }) .TearDown(() => { EverythingOff(); }); buttonStartInflatables.ActiveChanged += (o, e) => { if (e.NewState && hours.IsOpen) { InflatablesRunning = true; switchDeerHuge.SetPower(true); switchSanta.SetPower(true); } }; this.oscServer.RegisterAction <int>("/osc/button1", (msg, data) => { if (data.Any() && data.First() == 1) { stateMachine.SetState(States.Vader); } }); this.oscServer.RegisterAction <int>("/osc/button2", (msg, data) => { if (data.Any() && data.First() == 1) { stateMachine.SetState(States.Music1); } }); this.oscServer.RegisterAction <int>("/osc/button3", (msg, data) => { if (data.Any() && data.First() == 1) { stateMachine.SetState(States.Music2); } }); this.oscServer.RegisterAction <int>("/osc/button4", (msg, data) => { if (data.Any() && data.First() == 1) { stateMachine.SetState(States.Background); } }); this.oscServer.RegisterAction <int>("/osc/button5", (msg, data) => { if (data.Any() && data.First() == 1) { audioPlayer.PlayEffect("darkside"); } }); this.oscServer.RegisterAction <int>("/osc/button6", (msg, data) => { if (data.Any() && data.First() == 1) { audioPlayer.PlayEffect("Darth Breathing"); } }); // Test Button buttonTest.ActiveChanged += (sender, e) => { // lightGarland4.Brightness = e.NewState ? 1.0 : 0.0; if (e.NewState) { Exec.Execute(waveformSeq); } else { Exec.Cancel(waveformSeq); } if (!e.NewState) { return; } //Exec.Cancel(candyCane); //allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); //allPixels.SetAllOnlyColor(Color.Purple); //allPixels.RunEffect(new Effect2.Fader(0.0, 1.0), S(2.0)).Wait(); //allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); //allPixels.SetAllOnlyColor(Color.Orange); //allPixels.RunEffect(new Effect2.Fader(0.0, 1.0), S(2.0)).Wait(); //allPixels.RunEffect(new Effect2.Fader(1.0, 0.0), S(2.0)).Wait(); //Exec.Execute(candyCane); }; buttonBlue.ActiveChanged += (o, e) => { if (!e.NewState) { return; } if (mute.HasValue && (DateTime.Now - mute.Value).TotalSeconds < 30) { return; } if (hours.IsOpen) { if (stateMachine.CurrentState == States.Music1 || stateMachine.CurrentState == States.Music2) { // Stop //stateMachine.SetState(States.Background); return; } switch (this.whichMusic++ % 2) { case 0: stateMachine.SetState(States.Music1); break; case 1: stateMachine.SetState(States.Music2); break; } } else { Exec.Execute(offHours1Seq); } mute = DateTime.Now; }; buttonRed.ActiveChanged += (o, e) => { if (!e.NewState) { return; } if (mute.HasValue && (DateTime.Now - mute.Value).TotalSeconds < 30) { return; } if (hours.IsOpen) { if (stateMachine.CurrentState == States.Vader) { return; } //stateMachine.SetState(States.Background); else { stateMachine.SetState(States.Vader); } } else { Exec.Execute(offHours2Seq); } mute = DateTime.Now; }; audioPlayer.AudioTrackDone += (o, e) => { // switchButtonBlue.SetPower(false); }; pulsatingEffect1 .AddDevice(lightStar); pulsatingStar .AddDevice(lightStar); flickerEffect .AddDevice(lightHat1) .AddDevice(lightHat2) .AddDevice(lightHat3) .AddDevice(lightHat4); hours.OpenHoursChanged += (i, e) => { if (e.IsOpenNow) { stateMachine.SetBackgroundState(States.Background); stateMachine.SetState(States.Background); //lightTreeUp.SetColor(Color.Red, 1.0); //lightSnow1.SetBrightness(1.0); //lightSnow2.SetBrightness(1.0); if (InflatablesRunning) { switchDeerHuge.SetPower(true); switchSanta.SetPower(true); } } else { if (buttonOverrideHours.Active) { return; } stateMachine.Hold(); stateMachine.SetBackgroundState(null); EverythingOff(); System.Threading.Thread.Sleep(200); switchDeerHuge.TurnOff(); switchSanta.TurnOff(); InflatablesRunning = false; } }; faderIn .AddDevice(lightGarland1) .AddDevice(lightGarland2) .AddDevice(lightGarland3) .AddDevice(lightGarland4) .AddDevice(lightStairs1) .AddDevice(lightStairs2) .AddDevice(lightXmasTree) .AddDevice(lightDeerSmall) .AddDevice(lightDeerLarge) .AddDevice(lightTopperLarge) .AddDevice(lightTopperSmall) .AddDevice(lightNet1) .AddDevice(lightNet2) .AddDevice(lightString1) .AddDevice(lightString2) .AddDevice(lightSnow1) .AddDevice(lightSnow2) .AddDevice(lightTreeUp); stateMachine.ForFromSequence(States.Background, backgroundLoop); stateMachine.ForFromSequence(States.Music1, music1Seq); stateMachine.ForFromSequence(States.Music2, waveformSeq); stateMachine.ForFromSequence(States.Vader, fatherSeq); hatLightState.For(0).Execute(i => lightHat1.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); hatLightState.For(1).Execute(i => lightHat2.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); hatLightState.For(2).Execute(i => lightHat3.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); hatLightState.For(3).Execute(i => lightHat4.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); hatLightState.For(4).Execute(i => lightHat3.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); hatLightState.For(5).Execute(i => lightHat2.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5))); //lightGarland1.Follow(hours); //lightGarland2.Follow(hours); //lightGarland3.Follow(hours); //lightGarland4.Follow(hours); //lightGarland5.Follow(hours); //lightXmasTree.Follow(hours); //lightStairs1.Follow(hours); //lightDeerSmall.Follow(hours); //lightDeerLarge.Follow(hours); //lightTopperLarge.Follow(hours); //lightTopperSmall.Follow(hours); //lightNet1.Follow(hours); //lightNet2.Follow(hours); //lightString1.Follow(hours); //lightString2.Follow(hours); //light3wise.Follow(hours); //lightVader.Follow(hours); //switchButtonBlue.Follow(hours); //switchButtonRed.Follow(hours); ConfigureMusic1(); }
public Halloween2014(IEnumerable <string> args) { hoursSmall.AddRange("5:00 pm", "9:00 pm"); hoursInside.AddRange("6:00 pm", "10:00 pm"); hoursInside.SetForced(false); // Logging hoursSmall.Output.Log("Hours small"); hoursInside.Output.Log("Hours inside"); movingHead.OutputPan.Log("Pan"); movingHead.OutputTilt.Log("Tilt"); hoursSmall .ControlsMasterPower(catAir) .ControlsMasterPower(catLights) .ControlsMasterPower(eyes); hoursInside.Output.Subscribe(x => { lightInside.Brightness = x ? 1.0 : 0.0; lightMirrorSkeleton.Brightness = x ? 1.0 : 0.0; }); flickerEffect.ConnectTo(lightStairs1.InputBrightness); flickerEffect.ConnectTo(lightStairs2.InputBrightness); // pulsatingEffect1.ConnectTo(lightBehindHeads.InputBrightness); // pulsatingEffect1.ConnectTo(lightBehindSheet.InputBrightness); pulsatingEffect1.ConnectTo(candySpot.InputBrightness); pulsatingEffect2.ConnectTo(lightSpiderWeb.InputBrightness); // pulsatingEffect2.ConnectTo(lightMirrorSkeleton.InputBrightness); // pulsatingEffect2.ConnectTo(lightWindow.InputBrightness); // pulsatingEffect2.ConnectTo(lightInside.InputBrightness); // flickerEffect2.ConnectTo(lightInside.InputBrightness); // pulsatingEffect1.ConnectTo(movingHead.InputBrightness); // movingHead.InputBrightness.Log("Moving Head Brightness"); // popOut1.AddDevice(lightning1.InputBrightness); // popOut2.ConnectTo(light.InputBrightness); popOut1.ConnectTo(lightBehindHeads.InputBrightness); popOut1.ConnectTo(lightBehindSheet.InputBrightness); // popOut1 ConnectTo(lightFlash1.InputBrightness); // popOut2.ConnectTo(lightFlash1.InputBrightness); popOut2.ConnectTo(lightBehindSheet.InputBrightness); popOut2.ConnectTo(lightning1.InputBrightness); popOut3.ConnectTo(lightBehindHeads.InputBrightness); popOut3.ConnectTo(lightBehindSheet.InputBrightness); popOut3.ConnectTo(lightEntranceR.InputBrightness); popOut3.ConnectTo(lightEntranceL.InputBrightness); popOut3.ConnectTo(new BrightnessPowerAdapter(lightFlash1).InputBrightness); // popOut3.ConnectTo(lightFlash1.InputBrightness); // popOut4.ConnectTo(lightEntranceL.InputBrightness); popOut4.ConnectTo(new BrightnessPowerAdapter(lightFlash1).InputBrightness); popOut4.ConnectTo(new BrightnessPowerAdapter(lightFlash2).InputBrightness); popOutBehindHeads.ConnectTo(lightBehindHeads.InputBrightness); //popOut3.ConnectTo(movingHead.InputBrightness); raspberryReaper.DigitalInputs[7].Connect(finalBeam, false); raspberryReaper.DigitalOutputs[2].Connect(spiderEyes1); raspberryReaper.DigitalOutputs[3].Connect(spiderEyes2); raspberryCat.DigitalInputs[4].Connect(catMotion, true); raspberryCat.DigitalInputs[5].Connect(firstBeam, false); raspberryCat.DigitalOutputs[7].Connect(deadEnd); raspberryCat.Connect(audioCat); raspberryCat.Motor.Connect(georgeMotor); raspberryReaper.Connect(audioReaper); raspberryOla.Connect(audioOla); raspberryGeorge.DigitalOutputs[7].Connect(fog); raspberryGeorge.Connect(audioGeorge); inputBrightness.ConnectTo(movingHead); // Map Physical lights acnOutput.Connect(new Physical.SmallRGBStrobe(reaperLight, 1), 20); acnOutput.Connect(new Physical.MonopriceRGBWPinSpot(candySpot, 20), 20); acnOutput.Connect(new Physical.MonopriceMovingHeadLight12chn(movingHead, 200), 20); acnOutput.Connect(new Physical.GenericDimmer(catAir, 11), 20); acnOutput.Connect(new Physical.GenericDimmer(eyes, 12), 20); acnOutput.Connect(new Physical.GenericDimmer(catLights, 10), 20); //BROKEN acnOutput.Connect(new Physical.GenericDimmer(testLight3, 103), 20); // acnOutput.Connect(new Physical.GenericDimmer(lightning2, 100), 20); acnOutput.Connect(new Physical.GenericDimmer(lightStairs1, 101), 20); acnOutput.Connect(new Physical.GenericDimmer(lightStairs2, 102), 20); acnOutput.Connect(new Physical.AmericanDJStrobe(lightning1, 5), 20); acnOutput.Connect(new Physical.RGBStrobe(lightBehindHeads, 40), 20); acnOutput.Connect(new Physical.RGBStrobe(lightBehindSheet, 60), 20); acnOutput.Connect(new Physical.RGBStrobe(lightEntranceR, 70), 20); acnOutput.Connect(new Physical.RGBStrobe(lightEntranceL, 80), 20); acnOutput.Connect(new Physical.GenericDimmer(lightTree, 50), 20); acnOutput.Connect(new Physical.GenericDimmer(lightSpiderWeb, 2), 21); acnOutput.Connect(new Physical.GenericDimmer(lightMirrorSkeleton, 1), 22); acnOutput.Connect(new Physical.GenericDimmer(lightInside, 2), 22); acnOutput.Connect(new Physical.GenericDimmer(lightWindow, 3), 22); acnOutput.Connect(new Physical.GenericDimmer(lightFlash1, 1), 21); acnOutput.Connect(new Physical.GenericDimmer(lightFlash2, 4), 22); candySpot.SetOnlyColor(Color.Green); oscServer.RegisterAction <int>("/mrmr/pushbutton/0/Hakan-iPhone-6", (msg, data) => { if (data.First() != 0) { audioOla.PlayTrack("12 Fear of the Dark"); // popOut4.Pop(1.0); // stateMachine.SetState(States.Stair); // Exec.Execute(testSeq); // Exec.Execute(reaperSeq); // popOut4.Pop(1.0); // pulsatingEffect2.Start(); } }); oscServer.RegisterAction <int>("/mrmr/pushbutton/1/Hakan-iPhone-6", (msg, data) => { if (data.Any() && data.First() != 0) { audioOla.NextBackgroundTrack(); // stateMachine.SetState(States.George); // Exec.Execute(georgeSeq); } }); oscServer.RegisterAction <int>("/mrmr/pushbutton/2/Hakan-iPhone-6", (msg, data) => { if (data.First() != 0) { Exec.Execute(reaperPopSeq); } }); oscServer.RegisterAction <int>("/mrmr/pushbutton/3/Hakan-iPhone-6", (msg, data) => { if (data.First() != 0) { catLights.Value = true; switch (random.Next(3)) { case 0: audioCat.PlayEffect("386 Demon Creature Growls"); break; case 1: audioCat.PlayEffect("348 Spider Hiss"); break; case 2: audioCat.PlayEffect("death-scream"); break; } Thread.Sleep(2000); catLights.Value = false; } }); finalBeam.WhenOutputChanges(x => { if (x && hoursSmall.IsOpen) { Exec.Execute(finalSeq); } // lightning1.Brightness = x ? 1.0 : 0.0; //if (x) //{ // Exec.Execute(thunderSeq); //} }); firstBeam.WhenOutputChanges(x => { if (x && hoursSmall.IsOpen) { // Exec.Execute(reaperSeq); if (stateMachine.CurrentState == States.Background || stateMachine.CurrentState == States.StepForward) { stateMachine.SetState(States.Stair); } } }); buttonTest2.WhenOutputChanges(x => { if (x) { audioOla.NextBackgroundTrack(); // Exec.Execute(georgeSeq); } }); raspberryOla.AudioTrackStart.Subscribe(x => { // Next track switch (x) { case "12 Fear of the Dark": // Do nothing break; case "Thunder1": timelineThunder1.Start(); break; case "Thunder2": timelineThunder2.Start(); break; case "Thunder3": timelineThunder3.Start(); break; case "Thunder4": timelineThunder4.Start(); break; case "Thunder5": timelineThunder5.Start(); break; case "Thunder6": timelineThunder6.Start(); break; case "Thunder7": timelineThunder7.Start(); break; case "Thunder8": timelineThunder8.Start(); break; } }); buttonTest4.WhenOutputChanges(x => { if (x) { audioOla.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral"); } // Exec.Execute(reaperSeq); // lightning2.Brightness = x ? 1.0 : 0.0; // if (x) // popOut1.Pop(1.0); // if (x) // lightStairs1.Brightness = x ? 1.0 : 0.0; // testLight3.Brightness = x ? 1.0 : 0.0; // audioSpider.PlayEffect("348 Spider Hiss"); // Exec.Execute(thunderSeq); }); buttonTest3.WhenOutputChanges(x => { // fog.Power = x; if (x) { Exec.Execute(reaperPopSeq); //for (int i = 0; i < 100; i++) //{ // raspberryReaper.Test(i); //} } // audioGeorge.PlayEffect("242004__junkfood2121__fart-01"); }); raspberryReaper.DigitalOutputs[7].Connect(reaperPopUp); raspberryReaper.DigitalOutputs[6].Connect(reaperEyes); raspberryReaper.DigitalOutputs[5].Connect(skullEyes); forceOpen.WhenOutputChanges(x => { if (x) { hoursSmall.SetForced(true); } else { hoursSmall.SetForced(null); } }); inputH.WhenOutputChanges(x => { movingHead.SetOnlyColor(HSV.ColorFromHSV(x.Value.GetByteScale(), inputS.Value, 1.0)); }); inputS.Output.Subscribe(x => { movingHead.SetOnlyColor(HSV.ColorFromHSV(inputH.Value.GetByteScale(), x.Value, 1.0)); }); inputStrobe.Output.Controls(x => movingHead.StrobeSpeed = x); //midiInput.Controller(midiChannel, 1).Controls(inputBrightness.Control); //midiInput.Controller(midiChannel, 2).Controls(inputH.Control); //midiInput.Controller(midiChannel, 3).Controls(inputS.Control); //midiInput.Controller(midiChannel, 4).Controls(inputStrobe.Control); //midiInput.Controller(midiChannel, 5).Controls(Observer.Create<double>(x => // { // inputPan.Control.OnNext(new DoubleZeroToOne(x * 540)); // })); //midiInput.Controller(midiChannel, 6).Controls(Observer.Create<double>(x => //{ // inputTilt.Control.OnNext(new DoubleZeroToOne(x * 270)); //})); //midiInput.Note(midiChannel, 36).Controls(buttonTest1.Control); //midiInput.Note(midiChannel, 37).Controls(buttonTest2.Control); //midiInput.Note(midiChannel, 38).Controls(buttonTest3.Control); //midiInput.Note(midiChannel, 39).Controls(buttonTest4.Control); //midiInput.Note(midiChannel, 40).Controls(buttonCatTrigger.Control); //buttonTest4.Output.Subscribe(x => // { // if (x) // { // audioOla.NextBackgroundTrack(); // } // }); manualHeadMovement.Output.Subscribe(x => { if (x) { inputPan.Output.Controls(p => movingHead.Pan = p.Value); inputTilt.Output.Controls(t => movingHead.Tilt = t.Value); } else { // inputPan.Output.Dis } }); // buttonTest2.Output.Subscribe(reaperPopUp.PowerControl); catMotion.Output.Subscribe(catLights.Control); /* * finalBeam.Output.Subscribe(x => * { * lightning1.Brightness = x ? 1.0 : 0.0; * }); */ // buttonTest1.Output.Subscribe(pulsatingEffect2.InputRun); //buttonTest1.Output.Subscribe(x => // { // pulsatingEffect2.Start // if(x) // if (x) // { // movingHead.Brightness = 1; // movingHead.Color = Color.Red; // // testLight4.StrobeSpeed = 1.0; // } // else // { // movingHead.TurnOff(); // } // }); catMotion.Output.Subscribe(x => { if (x && hoursSmall.IsOpen) { Executor.Current.Execute(catSeq); } }); buttonCatTrigger.Output.Subscribe(x => { if (x) { catLights.Value = true; switch (random.Next(3)) { case 0: audioCat.PlayEffect("386 Demon Creature Growls"); break; case 1: audioCat.PlayEffect("348 Spider Hiss"); break; case 2: audioCat.PlayEffect("death-scream"); break; } Thread.Sleep(2000); catLights.Value = false; } }); buttonTest1.Output.Subscribe(x => { if (x) { audioOla.PlayTrack("12 Fear of the Dark"); } //if(x) // georgeMotor.SetVector(0.9, 0, S(15)); // deadEnd.Power = x; }); // hoursSmall.Output.Subscribe(catAir.InputPower); // hoursSmall.Output.Subscribe(flickerEffect.InputRun); //hoursSmall.Output.Subscribe(pulsatingEffect1.InputRun); //hoursSmall.Output.Subscribe(pulsatingEffect2.InputRun); hoursSmall.Output.Subscribe(lightTree.Control); hoursSmall.Output.Subscribe(x => { if (x) { stateMachine.SetBackgroundState(States.Background); stateMachine.SetState(States.Background); } else { stateMachine.Hold(); stateMachine.SetBackgroundState(null); } }); timelineThunder1.AddMs(500, "A"); timelineThunder1.AddMs(3500, "B"); timelineThunder1.AddMs(4500, "C"); timelineThunder1.TimelineTrigger += TriggerThunderTimeline; timelineThunder2.AddMs(500, "A"); timelineThunder2.AddMs(1500, "B"); timelineThunder2.AddMs(1600, "C"); timelineThunder2.AddMs(3700, "C"); timelineThunder2.TimelineTrigger += TriggerThunderTimeline; timelineThunder3.AddMs(100, "A"); timelineThunder3.AddMs(200, "B"); timelineThunder3.AddMs(300, "C"); timelineThunder3.TimelineTrigger += TriggerThunderTimeline; timelineThunder4.AddMs(0, "A"); timelineThunder4.AddMs(3500, "B"); timelineThunder4.AddMs(4500, "C"); timelineThunder4.TimelineTrigger += TriggerThunderTimeline; timelineThunder5.AddMs(1100, "A"); timelineThunder5.AddMs(3500, "B"); timelineThunder5.AddMs(4700, "C"); timelineThunder5.TimelineTrigger += TriggerThunderTimeline; timelineThunder6.AddMs(1000, "A"); timelineThunder6.AddMs(1800, "B"); timelineThunder6.AddMs(6200, "C"); timelineThunder6.TimelineTrigger += TriggerThunderTimeline; timelineThunder7.AddMs(0, "A"); timelineThunder7.AddMs(200, "B"); timelineThunder7.AddMs(300, "C"); timelineThunder7.TimelineTrigger += TriggerThunderTimeline; timelineThunder8.AddMs(500, "A"); timelineThunder8.AddMs(4000, "B"); timelineThunder8.AddMs(4200, "C"); timelineThunder8.TimelineTrigger += TriggerThunderTimeline; stateMachine.ForFromSequence(States.Background, backgroundSeq); stateMachine.ForFromSequence(States.Stair, reaperSeq); stateMachine.ForFromSequence(States.George, georgeSeq); stateMachine.ForFromSequence(States.StepForward, stepForwardSeq); georgeSeq.WhenExecuted .Execute(instance => { var controlPan = new Effect.Fader(S(3.8), 106, 150, false); var controlTilt = new Effect.Fader(S(3.8), 231.8823531, 168.3529407, false); controlPan.ConnectTo(x => movingHead.Pan = x); controlTilt.ConnectTo(x => movingHead.Tilt = x); controlPan.Prime(); controlTilt.Prime(); movingHead.Brightness = 0; // Make sure George isn't moving georgeMotor.WaitForVectorReached(); instance.WaitFor(S(1.5)); controlPan.Start(); controlTilt.Start(); georgeMotor.SetVector(1.0, 450, S(10)); instance.WaitFor(S(1.2)); movingHead.SetColor(Color.Red, 0.1); instance.WaitFor(S(1.0)); audioGeorge.PlayEffect("162 Blood Curdling Scream of Terror"); georgeMotor.WaitForVectorReached(); instance.WaitFor(S(4)); movingHead.Brightness = 0; georgeMotor.SetVector(0.9, 0, S(15)); movingHead.Pan = 106; movingHead.Tilt = 31; //georgeMotor.WaitForVectorReached(); // deadEnd.Power = true; instance.WaitFor(S(0.5)); // deadEnd.Power = false; // Exec.Execute(thunderSeq); stateMachine.NextState(); }); stepForwardSeq.WhenExecuted .SetUp(() => { audioOla.PlayTrack("152 Haunted Castle"); candySpot.SetOnlyColor(Color.Green); pulsatingEffect1.Start(); pulsatingEffect2.Start(); }) .Execute(i => { i.WaitFor(S(30.0)); }) .TearDown(() => { audioOla.PauseTrack(); pulsatingEffect1.Stop(); pulsatingEffect2.Stop(); }); reaperSeq.WhenExecuted .SetUp(() => { flickerEffect.Stop(); pulsatingEffect2.Stop(); }) .Execute(instance => { // switchFog.SetPower(true); // this.lastFogRun = DateTime.Now; // Executor.Current.Execute(deadendSeq); // audioGeorge.PlayEffect("ghostly"); // instance.WaitFor(S(0.5)); // popOutEffect.Pop(1.0); // instance.WaitFor(S(1.0)); movingHead.Pan = 106; movingHead.Tilt = 31; fog.Value = true; this.lastFogRun = DateTime.Now; instance.WaitFor(S(0.05)); audioReaper.PlayEffect("348 Spider Hiss", 1.0, 0.0); instance.WaitFor(S(0.05)); spiderEyes1.Value = true; instance.WaitFor(S(0.5)); movingHead.SetColor(Color.Turquoise, 0.2); movingHead.StrobeSpeed = 0.8; deadEnd.Value = true; instance.WaitFor(S(0.3)); deadEnd.Value = false; instance.WaitFor(S(2.5)); movingHead.StrobeSpeed = 0; movingHead.Brightness = 0; movingHead.Pan = 80; movingHead.Tilt = 26; instance.WaitFor(S(1.0)); audioReaper.PlayNewEffect("laugh", 0.0, 1.0); instance.WaitFor(S(0.1)); spiderEyes1.Value = false; reaperPopUp.Value = true; reaperLight.Color = Color.Red; reaperLight.Brightness = 1; reaperLight.StrobeSpeed = 1; instance.WaitFor(S(0.5)); reaperEyes.Value = true; instance.WaitFor(S(2.0)); reaperPopUp.Value = false; reaperEyes.Value = false; reaperLight.TurnOff(); instance.WaitFor(S(2.0)); audioOla.PlayEffect("424 Coyote Howling", 0.0, 1.0); audioGeorge.PlayEffect("424 Coyote Howling"); movingHead.SetColor(Color.Orange, 0.2); instance.WaitFor(S(2.0)); spiderEyes2.Value = true; popOut2.Pop(0.4); audioGeorge.PlayEffect("348 Spider Hiss"); audioReaper.PlayEffect("348 Spider Hiss"); movingHead.Brightness = 0.7; movingHead.Color = Color.Red; movingHead.StrobeSpeed = 0.8; movingHead.Pan = 51; movingHead.Tilt = 61; instance.WaitFor(S(2.0)); movingHead.StrobeSpeed = 0.0; movingHead.Brightness = 0; spiderEyes2.Value = false; instance.WaitFor(S(2.0)); movingHead.Pan = 106; movingHead.Tilt = 231; stateMachine.NextState(); }) .TearDown(() => { flickerEffect.Start(); pulsatingEffect2.Start(); fog.Value = false; }); reaperPopSeq.WhenExecuted .Execute(instance => { audioReaper.PlayNewEffect("laugh", 0.0, 1.0); instance.WaitFor(S(0.1)); reaperPopUp.Value = true; reaperLight.Color = Color.Red; reaperLight.Brightness = 1; reaperLight.StrobeSpeed = 1; instance.WaitFor(S(0.5)); reaperEyes.Value = true; instance.WaitFor(S(2.0)); reaperPopUp.Value = false; reaperEyes.Value = false; reaperLight.TurnOff(); instance.WaitFor(S(0.5)); }); finalSeq.WhenExecuted .SetUp(() => { audioOla.PauseTrack(); pulsatingEffect1.Stop(); pulsatingEffect2.Stop(); }) .Execute(i => { skullEyes.Value = true; candySpot.SetColor(Color.Red); i.WaitFor(S(1.0)); lightBehindHeads.SetOnlyColor(Color.White); popOutBehindHeads.Pop(1.0); audioOla.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral", 0.0, 0.7); i.WaitFor(S(10)); }) .TearDown(() => { audioOla.PlayBackground(); skullEyes.Value = false; candySpot.SetOnlyColor(Color.Green); pulsatingEffect1.Start(); pulsatingEffect2.Start(); // candySpot.SetColor(Color.Green); // audioOla.PlayBackground(); if (stateMachine.CurrentState == States.StepForward) { stateMachine.SetState(States.Background); } }); thunderSeq.WhenExecuted .SetUp(() => { audioOla.PauseBackground(); // movingHead.Pan = 0.25; // movingHead.Tilt = 0.5; Thread.Sleep(200); }) .Execute(i => { audioOla.PlayTrack("08 Weather-lightning-strike2"); // movingHead.SetOnlyColor(Color.White); popOut1.Pop(1.0); popOut2.Pop(1.0); popOut3.Pop(1.0); i.WaitFor(S(4)); }) .TearDown(() => { audioOla.PauseTrack(); audioOla.PlayBackground(); }); backgroundSeq.WhenExecuted .SetUp(() => { audioOla.NextBackgroundTrack(); flickerEffect.Start(); pulsatingEffect1.Start(); pulsatingEffect2.Start(); }) .Execute(i => { while (!i.IsCancellationRequested) { i.WaitFor(S(1)); if (!this.lastFogRun.HasValue || (DateTime.Now - this.lastFogRun.Value).TotalMinutes > 10) { // Run the fog for a little while fog.Value = true; i.WaitFor(S(4)); fog.Value = false; this.lastFogRun = DateTime.Now; } } }) .TearDown(() => { flickerEffect.Stop(); pulsatingEffect1.Stop(); pulsatingEffect2.Stop(); audioOla.PauseTrack(); audioOla.PauseBackground(); }); catSeq.WhenExecuted .Execute(instance => { var maxRuntime = System.Diagnostics.Stopwatch.StartNew(); catLights.Value = true; while (true) { switch (random.Next(4)) { case 0: audioCat.PlayEffect("266 Monster Growl 7", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(2.0)); break; case 1: audioCat.PlayEffect("285 Monster Snarl 2", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(3.0)); break; case 2: audioCat.PlayEffect("286 Monster Snarl 3", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(2.5)); break; case 3: audioCat.PlayEffect("287 Monster Snarl 4", 1.0, 1.0); instance.WaitFor(TimeSpan.FromSeconds(1.5)); break; default: instance.WaitFor(TimeSpan.FromSeconds(3.0)); break; } instance.CancelToken.ThrowIfCancellationRequested(); if (maxRuntime.Elapsed.TotalSeconds > 10) { break; } } }) .TearDown(() => { catLights.Value = false; }); }
public override bool Execute() { HashSet <string> activeIgnorableErrorMessages = new HashSet <string>(); // Add any "Ignore" messages that don't have conditionals to our active list. if (IgnoredErrorMessagesWithConditional != null) { foreach (var message in IgnoredErrorMessagesWithConditional) { string conditional = message.GetMetadata("ConditionalErrorMessage"); if (string.IsNullOrEmpty(conditional)) { activeIgnorableErrorMessages.Add(message.ItemSpec); } } } for (int i = 0; i < MaxAttempts; i++) { string attemptMessage = $"(attempt {i + 1}/{MaxAttempts})"; _runningExec = new Exec { BuildEngine = BuildEngine, Command = Command, LogStandardErrorAsError = false, IgnoreExitCode = true, ConsoleToMSBuild = true }; if (!_runningExec.Execute()) { Log.LogError("Child Exec task failed to execute."); break; } int exitCode = _runningExec.ExitCode; if (exitCode == 0 || FeedContainsIdenticalPackage()) { return(true); } if (_runningExec.ConsoleOutput != null && IgnoredErrorMessagesWithConditional != null && _runningExec.ConsoleOutput.Length > 0) { var consoleOutput = _runningExec.ConsoleOutput.Select(c => c.ItemSpec); // If the console output contains a "conditional" message, add the item to the active list. var conditionMessages = IgnoredErrorMessagesWithConditional.Where(m => consoleOutput.Any(n => n.Contains(m.GetMetadata("ConditionalErrorMessage")))); foreach (var condition in conditionMessages) { activeIgnorableErrorMessages.Add(condition.ItemSpec); } // If an active "ignore" message is present in the console output, then return true instead of retrying. foreach (var ignoreMessage in activeIgnorableErrorMessages) { if (consoleOutput.Any(c => c.Contains(ignoreMessage))) { Log.LogMessage(MessageImportance.High, $"Error detected, but error condition is valid, ignoring error \"{ignoreMessage}\""); return(true); } } } string message = $"Exec FAILED: exit code {exitCode} {attemptMessage}"; if (i + 1 == MaxAttempts || _cancelTokenSource.IsCancellationRequested) { Log.LogError(message); break; } Log.LogMessage(MessageImportance.High, message); TimeSpan delay = TimeSpan.FromSeconds( Math.Pow(RetryDelayBase, i) + RetryDelayConstant); Log.LogMessage(MessageImportance.High, $"Retrying after {delay}..."); try { Task.Delay(delay, _cancelTokenSource.Token).Wait(); } catch (AggregateException e) when(e.InnerException is TaskCanceledException) { break; } } return(false); }
public override void Run() { Exec.Execute(testSeq); }