Exemplo n.º 1
0
        private void EverythingOff()
        {
            popOutPiano.Stop();
            popOutDrums.Stop();
            popOutDrumsFast.Stop();
            popOutChord.Stop();
            popOutSolo.Stop();
            popOutSolo2.Stop();
            popOutChoir.Stop();
            popOutVoice.Stop();
            popOutVocal2.Stop();
            popOutVocalLong.Stop();
            popOutEnd.Stop();

            pulsatingEffect1.Stop();
            pulsatingEffect2.Stop();
            lightGarlandLeft.TurnOff();
            lightGarlandRight.TurnOff();
            lightIcicles.TurnOff();
            lightTreesRight.TurnOff();
            lightNetLeft.TurnOff();
            lightNetRight.TurnOff();
            lightReindeers.TurnOff();
            lightHatsRight.TurnOff();
            lightTree.TurnOff();

            lightCeiling1.TurnOff();
            lightCeiling2.TurnOff();
            lightCeiling3.TurnOff();
            lightVader.TurnOff();
        }
        public HalloweenFrankGhost(
            IReceivesColor light,
            DigitalOutput2 air,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsatingLow.ConnectTo(light);
            levelsPlayback.Output.Controls(b => light.SetBrightness(b, this.controlToken));

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(air, light);

                    air.SetValue(true, this.controlToken);
                    light.SetColor(Color.Red, this.controlToken);
                    pulsatingLow.Start(token: this.controlToken);
                }
                else
                {
                    pulsatingLow.Stop();

                    UnlockDevices();
                }
            });

            PowerOn
            .SetLoop(true)
            .SetMaxRuntime(S(60))
            .SetUp(ins =>
            {
                pulsatingLow.Stop();
            })
            .RunAction(ins =>
            {
                audioPlayer.PlayEffect("Thriller2.wav", levelsPlayback);
                // The control token is optional since it's passed in via the Subroutine
                light.SetColor(Color.Purple);
                var cts = levelsPlayback.Start(this.controlToken);

                ins.WaitFor(S(45));
                cts.Cancel();
            })
            .TearDown(ins =>
            {
                light.SetColor(Color.Red);
                pulsatingLow.Start(token: this.controlToken);
            });

            PowerOff.RunAction(ins =>
            {
                audioPlayer.PlayEffect("Happy Halloween.wav", 0.15);
                ins.WaitFor(S(5));
            });
        }
Exemplo n.º 3
0
        public HalloweenFlying(
            Dimmer3 eyes,
            ThroughputDevice fogStairsPump1,
            ThroughputDevice fogStairsPump2,
            StrobeColorDimmer3 fogStairsLight1,
            StrobeColorDimmer3 fogStairsLight2,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsatingLow.ConnectTo(eyes);

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(eyes);

                    pulsatingLow.Start(token: this.controlToken);
                }
                else
                {
                    pulsatingLow.Stop();
                    UnlockDevices();
                }
            });

            PowerOn
            .RunAction(ins =>
            {
                pulsatingLow.Stop();

                eyes.SetBrightness(1);
                audioPlayer.PlayEffect("Who is that knocking.wav");

                ins.WaitFor(S(2.5));

                fogStairsPump1.SetThroughput(0.4);
                fogStairsLight1.SetColor(Color.Purple, 1.0);

                fogStairsPump2.SetThroughput(0.4);
                fogStairsLight2.SetColor(Color.Purple, 1.0);

                ins.WaitFor(S(1.0));

                fogStairsPump1.SetThroughput(0);
                fogStairsPump2.SetThroughput(0);

                ins.WaitFor(S(1.0));
                fogStairsLight1.SetBrightness(0);
                fogStairsLight2.SetBrightness(0);
            })
            .TearDown(ins =>
            {
                pulsatingLow.Start(token: this.controlToken);
            });
        }
Exemplo n.º 4
0
        private void EverythingOff()
        {
            Exec.Cancel(starwarsCane);
            audioPlayer.PauseTrack();
            audioPlayer.PauseFX();
            pulsatingEffect1.Stop();
            pulsatingStar.Stop();
            faderIn.Stop();
            flickerEffect.Stop();

            AllLightsOff();
        }
Exemplo n.º 5
0
        public HalloweenSpiderDrop(
            IReceivesBrightness eyesLight,
            IReceivesBrightness smallSpiderEyes,
            DigitalOutput2 drop,
            DigitalOutput2 venom,
            StrobeDimmer3 strobeLight,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsating.ConnectTo(smallSpiderEyes);

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(drop, venom, eyesLight, strobeLight, smallSpiderEyes);

                    pulsating.Start(token: this.controlToken);
                }
                else
                {
                    pulsating.Stop();
                    UnlockDevices();
                }
            });

            PowerOn.RunAction(ins =>
            {
                pulsating.Stop();
                audioPlayer.PlayNewEffect("348 Spider Hiss.wav", 0, 1);
                eyesLight.SetBrightness(1);
                drop.SetValue(true);
                ins.WaitFor(S(0.2));
                strobeLight.SetBrightnessStrobeSpeed(1, 1);
                venom.SetValue(true);
                ins.WaitFor(S(2.0));
                venom.SetValue(false);
                strobeLight.SetBrightnessStrobeSpeed(0, 0);
                ins.WaitFor(S(2.0));
            })
            .TearDown(ins =>
            {
                drop.SetValue(false);
                venom.SetValue(false);
                eyesLight.SetBrightness(0);
                strobeLight.SetBrightnessStrobeSpeed(0, 0);
                pulsating.Start(token: this.controlToken);
                ins.WaitFor(S(1.0));
            });
        }
Exemplo n.º 6
0
        public override void Start()
        {
            pressureMat.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    this.log.Information("Button press!");

                    pulsatingEffect.Stop();

                    spiderLift.SetPower(true);
                    georgeMotor.SetVector(1, 160, S(5));
                    georgeMotor.WaitForVectorReached();
                    this.log.Information("Motor done");
                    georgeMotor.SetVector(0.8, 0, S(5));
                    georgeMotor.WaitForVectorReached();
                    this.log.Information("Motor back");

                    pulsatingEffect.Start();
                    spiderLift.SetPower(false);
                }
            };

            spiderLight.SetColor(Color.Blue, 1);

            pulsatingEffect.AddDevice(spiderLight);

            flickerEffect.AddDevice(georgeStrobeLight);
        }
Exemplo n.º 7
0
        public HalloweenMrPumpkin(
            Dimmer3 light,
            DigitalOutput2 air,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsatingLow.ConnectTo(light);
            levelsPlayback.Output.Controls(b => light.SetBrightness(b, this.controlToken));

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(air, light);

                    air.SetValue(true, this.controlToken);
                    pulsatingLow.Start(token: this.controlToken);
                }
                else
                {
                    pulsatingLow.Stop();
                    UnlockDevices();
                }
            });

            PowerOn
            .RunAction(ins =>
            {
                pulsatingLow.Stop();

                audioPlayer.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral.wav", levelsPlayback);
                levelsPlayback.Start(this.controlToken);

                ins.WaitFor(S(8));
            })
            .TearDown(ins =>
            {
                pulsatingLow.Start(token: this.controlToken);
            });
        }
Exemplo n.º 8
0
        public IceBucket(IEnumerable <string> args)
        {
            stateMachine     = new Controller.EnumStateMachine <States>("Main");
            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.05, 1.0, false);
            lightSpot        = new StrobeColorDimmer("Spotlight");

            inputArm      = new DigitalInput("Arm");
            inputDisarm   = new DigitalInput("Disarm");
            inputDump     = new DigitalInput("Dump");
            inputNextSong = new DigitalInput("Next Song");
            inputReset    = new DigitalInput("Reset");
            relayStart    = new Switch("Relay Start");
            relayDirA     = new Switch("Relay Dir A");
            relayDirB     = new Switch("Relay Dir B");

            audioPlayer = new AudioPlayer("Audio Player");

            this.oscServer = new Expander.OscServer(9999);

            stateMachine.For(States.Armed)
            .SetUp(() =>
            {
                pulsatingEffect1.Start();
                audioPlayer.PlayEffect("Nuclear-alarm");
            })
            .Execute(instance =>
            {
                while (!instance.IsCancellationRequested)
                {
                    instance.WaitFor(S(1));
                }
            })
            .TearDown(() =>
            {
                audioPlayer.PauseFX();
                pulsatingEffect1.Stop();
            });

            stateMachine.For(States.Dumped)
            .Execute(instance =>
            {
                while (!instance.IsCancellationRequested)
                {
                    instance.WaitFor(S(1));
                }
            });
            ;

            stateMachine.SetBackgroundState(States.Idle);
        }
Exemplo n.º 9
0
        public IceBucket(IEnumerable<string> args)
        {
            stateMachine = new Controller.EnumStateMachine<States>("Main");
            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.05, 1.0, false);
            lightSpot = new StrobeColorDimmer("Spotlight");

            inputArm = new DigitalInput("Arm");
            inputDisarm = new DigitalInput("Disarm");
            inputDump = new DigitalInput("Dump");
            inputNextSong = new DigitalInput("Next Song");
            inputReset = new DigitalInput("Reset");
            relayStart = new Switch("Relay Start");
            relayDirA = new Switch("Relay Dir A");
            relayDirB = new Switch("Relay Dir B");

            audioPlayer = new AudioPlayer("Audio Player");

            this.oscServer = new Expander.OscServer(9999);

            stateMachine.For(States.Armed)
                .SetUp(() =>
                {
                    pulsatingEffect1.Start();
                    audioPlayer.PlayEffect("Nuclear-alarm");
                })
                .Execute(instance =>
                {
                    while (!instance.IsCancellationRequested)
                    {
                        instance.WaitFor(S(1));
                    }
                })
                .TearDown(() =>
                {
                    audioPlayer.PauseFX();
                    pulsatingEffect1.Stop();
                });

            stateMachine.For(States.Dumped)
                .Execute(instance =>
                {
                    while (!instance.IsCancellationRequested)
                    {
                        instance.WaitFor(S(1));
                    }
                });
            ;

            stateMachine.SetBackgroundState(States.Idle);
        }
Exemplo n.º 10
0
        public override void Start()
        {
            // Set color
            candyLight.SetColor(Color.Violet, 0);
            candyLight2.SetColor(Color.Green, 0);

            var testSequence = new Controller.Sequence("Test Sequence");

            testSequence
            .WhenExecuted
            .Execute(instance =>
            {
                pulsatingEffect.Start();

                instance.WaitFor(S(10));

                pulsatingEffect.Stop();

                candyLight.SetStrobe(1.0, Color.Yellow);

                instance.WaitFor(S(2));
                candyLight.TurnOff();
                candyLight.SetColor(Color.Violet, 0);
            });

            pressureMat.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    this.log.Information("Button press!");

//                    candyLight2.RunEffect(new Effect2.Fader(1.0, 0.0), S(0.5));
//                    Executor.Current.Execute(testSequence);
                }
            };


            pulsatingEffect.AddDevice(candyLight)
            .AddDevice(candyLight2);

//            candyLight.RunEffect(new Effect2.Pulse(0.0, 1.0), S(2));
        }
Exemplo n.º 11
0
        public DemoScene1(IEnumerable<string> args)
        {
            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.1, 1.0, false, "Pulse FX 1");
            light1 = new StrobeColorDimmer("Small RGB");
            buttonTestSound = new DigitalInput("Test sound");
            buttonPlayBackground = new DigitalInput("Play Background");
            buttonPauseBackground = new DigitalInput("Pause Background");
            buttonTrigger1 = new DigitalInput("Test seq");
            buttonTestLight1 = new DigitalInput("Test light");
            buttonTestLight2 = new DigitalInput("Test pulse");
            switchTest1 = new Switch("Switch test 1");

            audioPlayer = new AudioPlayer("Audio Player");

            raspberry.DigitalInputs[4].Connect(buttonTrigger1, true);
            raspberry.DigitalOutputs[7].Connect(switchTest1);

            raspberry.Connect(audioPlayer);

            var demoSeq = new Controller.Sequence("Demo Sequence");
            demoSeq.WhenExecuted
                .Execute(instance =>
                {
                    audioPlayer.PlayEffect("laugh");
                    switchTest1.SetPower(true);
                    light1.SetColor(Color.Orange, 1.0);
                    instance.WaitFor(TimeSpan.FromSeconds(1));
                    switchTest1.SetPower(false);
                    light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
                });

            buttonTestSound.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayEffect("sixthsense-deadpeople");
                }
            };

            buttonPlayBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayBackground();
                }
            };

            buttonPauseBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PauseBackground();
                }
            };

            buttonTestLight1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    light1.SetOnlyColor(Color.White);
                    light1.RunEffect(new Effect2.Fader(0.0, 1.0), S(1.0));
                    Thread.Sleep(S(1));
                    light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
                }
            };

            buttonTestLight2.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    pulsatingEffect1.Start();
                }
                else
                {
                    pulsatingEffect1.Stop();
                }
            };

            buttonTrigger1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    Executor.Current.Execute(demoSeq);
                }
            };

            pulsatingEffect1.AddDevice(light1);
        }
Exemplo n.º 12
0
        public HalloweenScene1(IEnumerable <string> args, System.Collections.Specialized.NameValueCollection settings)
        {
            hours             = new OperatingHours("Hours");
            georgeStrobeLight = new StrobeDimmer("George Strobe");
            spiderLight       = new StrobeColorDimmer("Spider Light");
            skullsLight       = new Dimmer("Skulls");
            cobWebLight       = new Dimmer("Cob Web");
            blinkyEyesLight   = new Switch("Blinky Eyes");
            rgbLightRight     = new StrobeColorDimmer("Light Right");
            georgeLight       = new StrobeColorDimmer("George Light");
            leftSkeletonLight = new StrobeColorDimmer("Skeleton Light");
            georgeMotor       = new MotorWithFeedback("George Motor");
            candyLight        = new StrobeColorDimmer("Candy Light");
            spiderLift        = new Switch("Slider Lift");
            smokeMachine      = new Switch("Smoke Machine");
            spiderEyes        = new Switch("Spider Eyes");
            pressureMat       = new DigitalInput("Pressure Mat");
            testButton        = new DigitalInput("Test");

            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.1, 0.4);
            pulsatingEffect2 = new Effect.Pulsating(S(2), 0.3, 0.5);
            candyPulse       = new Effect.Pulsating(S(3), 0.01, 0.1);
            flickerEffect    = new Effect.Flicker(0.4, 0.6);

            audioPlayer = new Physical.NetworkAudioPlayer(
                settings["NetworkAudioPlayerIP"],
                int.Parse(settings["NetworkAudioPlayerPort"]));

            hours.AddRange("6:00 pm", "10:00 pm");

            var testSequence = new Controller.Sequence("Test Sequence");

            testSequence
            .WhenExecuted
            .Execute(instance =>
            {
                candyPulse.Start();
                audioPlayer.PlayEffect("Laugh");
                georgeMotor.SetVector(1.0, 160, S(5));
                georgeStrobeLight.SetStrobe(0.55, 1.0);
                georgeLight.SetStrobe(0.78, Color.Brown);

                georgeMotor.WaitForVectorReached();
                instance.WaitFor(S(2));
                georgeStrobeLight.TurnOff();
                georgeLight.TurnOff();

                georgeMotor.SetVector(0.9, 0, S(6));
                georgeMotor.WaitForVectorReached();
                candyPulse.Stop();
            });

            var testSequence2 = new Controller.Sequence("Test Sequence 2");

            testSequence2.WhenExecuted
            .Execute(instance =>
            {
                audioPlayer.PlayEffect("348 Spider Hiss");
                spiderLight.SetStrobe(0.78, Color.Red);

                spiderLift.SetPower(true);

                instance.WaitFor(S(3));

                // Spider up
                audioPlayer.PlayEffect("Scream");
                spiderLift.SetPower(false);

                instance.WaitFor(S(2));
                spiderLight.TurnOff();
            });

            var testSequence3 = new Controller.Sequence("Test Sequence 3");

            testSequence3.WhenExecuted
            .Execute(instance =>
            {
                spiderEyes.SetPower(true);
                instance.WaitFor(S(10));
                spiderEyes.SetPower(false);
            });

            var mainSequence = new Controller.Sequence("Main Sequence");

            mainSequence.WhenExecuted
            .Execute(instance =>
            {
                pulsatingEffect1.Stop();
                pulsatingEffect2.Stop();
                flickerEffect.Stop();
                blinkyEyesLight.SetPower(false);
                candyLight.SetColor(Color.Red);

                audioPlayer.PauseBackground();
                audioPlayer.PlayEffect("Door-creak");
                instance.WaitFor(S(2));


                instance.WaitFor(S(2));
                candyPulse.Stop();
                candyLight.SetStrobe(1, Color.White);
                instance.WaitFor(S(0.5));
                candyLight.TurnOff();
                instance.WaitFor(S(1));

                audioPlayer.PlayEffect("348 Spider Hiss");
                instance.WaitFor(S(0.5));
                spiderLight.SetStrobe(0.78, Color.Red);

                spiderLift.SetPower(true);
                spiderEyes.SetPower(true);

                instance.WaitFor(S(1));
                audioPlayer.PlayEffect("348 Spider Hiss");
                instance.WaitFor(S(2));

                // Spider up
                audioPlayer.PlayEffect("Scream");
                spiderLift.SetPower(false);
                spiderEyes.SetPower(false);
                smokeMachine.SetPower(true);

                instance.WaitFor(S(2));
                spiderLight.TurnOff();
                audioPlayer.PlayEffect("Violin screech");
                instance.WaitFor(S(2));


                // Skeleton to the right
                //                    audioPlayer.PlayEffect("Ghostly");
                rgbLightRight.SetStrobe(0.78, Color.Violet);
                instance.WaitFor(MS(1000));
                rgbLightRight.SetColor(Color.Red);
                instance.WaitFor(MS(1000));
                rgbLightRight.SetColor(Color.Blue);
                instance.WaitFor(S(2));
                rgbLightRight.TurnOff();
                instance.WaitFor(S(1));


                // Skeleton to the left
                audioPlayer.PlayEffect("death-scream");
                instance.WaitFor(S(0.5));
                leftSkeletonLight.SetStrobe(0.78, Color.Pink);
                instance.WaitFor(S(3));
                smokeMachine.SetPower(false);
                instance.WaitFor(S(1));
                leftSkeletonLight.TurnOff();


                // George
                audioPlayer.PlayEffect("Laugh");
                instance.WaitFor(MS(800));
                georgeMotor.SetVector(1.0, 160, S(5));
                georgeStrobeLight.SetStrobe(0.55, 1.0);
                georgeLight.SetStrobe(0.78, Color.Brown);

                georgeMotor.WaitForVectorReached();
                instance.WaitFor(S(2));
                georgeStrobeLight.TurnOff();
                georgeLight.TurnOff();

                candyPulse.MinBrightness = 0.05;
                candyPulse.MaxBrightness = 1.0;
                candyLight.SetColor(Color.Violet);
                candyPulse.Start();
                georgeMotor.SetVector(0.9, 0, S(6));
                georgeMotor.WaitForVectorReached();


                blinkyEyesLight.SetPower(true);

                flickerEffect.Start();
                pulsatingEffect1.Start();

                instance.WaitFor(S(5));
                smokeMachine.SetPower(true);

                audioPlayer.PlayBackground();
                // Wait for reset
                instance.WaitFor(S(15));
                pulsatingEffect2.Start();
                candyPulse.MinBrightness = 0.01;
                candyPulse.MaxBrightness = 0.1;
                candyLight.SetColor(Color.Green);
                smokeMachine.SetPower(false);
            });

            pressureMat.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    if (hours.IsOpen)
                    {
                        Executor.Current.Execute(mainSequence);
                    }
                    else
                    {
                        audioPlayer.PlayEffect("Laugh");
                    }
                }
            };

            testButton.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    Executor.Current.Execute(mainSequence);
                }
            };

            hours.OpenHoursChanged += (sender, e) =>
            {
                if (e.IsOpenNow)
                {
                    pulsatingEffect1.Start();
                    pulsatingEffect2.Start();
                    flickerEffect.Start();
                    candyPulse.Start();
                    blinkyEyesLight.SetPower(true);
                    audioPlayer.PlayBackground();
                }
                else
                {
                    pulsatingEffect1.Stop();
                    pulsatingEffect2.Stop();
                    flickerEffect.Stop();
                    candyPulse.Stop();
                    blinkyEyesLight.SetPower(false);
                    audioPlayer.PauseBackground();
                }
            };

            // Have it turned off, but prepare it with blue color for the effect
            rgbLightRight.SetColor(Color.Blue, 0);
            candyLight.SetColor(Color.Green, 0);
            pulsatingEffect1.AddDevice(rgbLightRight);
            pulsatingEffect2.AddDevice(cobWebLight);
            candyPulse.AddDevice(candyLight);

            flickerEffect.AddDevice(skullsLight);
        }
Exemplo n.º 13
0
        public DemoScene1(IEnumerable <string> args)
        {
            pulsatingEffect1      = new Effect.Pulsating(S(2), 0.1, 1.0, false, "Pulse FX 1");
            light1                = new StrobeColorDimmer("Small RGB");
            buttonTestSound       = new DigitalInput("Test sound");
            buttonPlayBackground  = new DigitalInput("Play Background");
            buttonPauseBackground = new DigitalInput("Pause Background");
            buttonTrigger1        = new DigitalInput("Test seq");
            buttonTestLight1      = new DigitalInput("Test light");
            buttonTestLight2      = new DigitalInput("Test pulse");
            switchTest1           = new Switch("Switch test 1");

            audioPlayer = new AudioPlayer("Audio Player");

            raspberry.DigitalInputs[4].Connect(buttonTrigger1, true);
            raspberry.DigitalOutputs[7].Connect(switchTest1);

            raspberry.Connect(audioPlayer);


            var demoSeq = new Controller.Sequence("Demo Sequence");

            demoSeq.WhenExecuted
            .Execute(instance =>
            {
                audioPlayer.PlayEffect("laugh");
                switchTest1.SetPower(true);
                light1.SetColor(Color.Orange, 1.0);
                instance.WaitFor(TimeSpan.FromSeconds(1));
                switchTest1.SetPower(false);
                light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
            });

            buttonTestSound.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayEffect("sixthsense-deadpeople");
                }
            };

            buttonPlayBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayBackground();
                }
            };

            buttonPauseBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PauseBackground();
                }
            };

            buttonTestLight1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    light1.SetOnlyColor(Color.White);
                    light1.RunEffect(new Effect2.Fader(0.0, 1.0), S(1.0));
                    Thread.Sleep(S(1));
                    light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
                }
            };

            buttonTestLight2.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    pulsatingEffect1.Start();
                }
                else
                {
                    pulsatingEffect1.Stop();
                }
            };

            buttonTrigger1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    Executor.Current.Execute(demoSeq);
                }
            };

            pulsatingEffect1.AddDevice(light1);
        }
Exemplo n.º 14
0
        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;
            });
        }
Exemplo n.º 15
0
        public Xmas2015(IEnumerable <string> args)
        {
            hours.AddRange("4:00 pm", "10:00 pm");

            string expFilesParam = args.FirstOrDefault(x => x.StartsWith("EXPFILES"));

            if (!string.IsNullOrEmpty(expFilesParam))
            {
                string[] parts = expFilesParam.Split('=');
                if (parts.Length == 2)
                {
                    Exec.ExpanderSharedFiles = parts[1];
                }
            }

            pulsatingEffect1.ConnectTo(lightOlaf);
            pulsatingEffect2.ConnectTo(lightR2D2);
            pulsatingEffect3.ConnectTo(pixelsRoofEdge, Utils.Data(Color.Red));
            pulsatingEffect4.ConnectTo(lightBlueButton);
            pulsatingEffect4.ConnectTo(lightRedButton);

            expanderServer.AddInstance("ec30b8eda95b4c5cab46bf630d74810e", expanderLocal);
            expanderServer.AddInstance("ed86c3dc166f41ee86626897ba039ed2", expander1);      // rpi-eb0092ca
            expanderServer.AddInstance("10520fdcf14d47cba31da8b6e05d01d8", expander2);      // rpi-eb428ef1
            expanderServer.AddInstance("59ebb8e925c94182a0f6e0ef09180200", expander3);      // rpi-eba6cbc7
            expanderServer.AddInstance("1583f686014345888c15d7fc9c55ca3c", expander4);      // rpi-eb81c94e

            expander1.DigitalInputs[5].Connect(inR2D2);
            expander1.DigitalInputs[4].Connect(inOlaf);
            expander1.DigitalInputs[6].Connect(inShowMachine);
            expander1.DigitalOutputs[7].Connect(out1);
            expander4.DigitalOutputs[7].Connect(snowMachine);

            expander4.DigitalInputs[5].Connect(inBlueButton);
            expander4.DigitalInputs[4].Connect(inRedButton);

            expander1.Connect(audio1);
            expander2.Connect(audioMain);
            expander3.Connect(video3);
            expander4.Connect(audioDarthVader);

            blackOut.ConnectTo(Exec.Blackout);
            whiteOut.ConnectTo(Exec.Whiteout);

            midiAkai.Controller(midiChannel, 1).Subscribe(x => blackOut.Value = x.Value);
            midiAkai.Controller(midiChannel, 2).Subscribe(x => whiteOut.Value = x.Value);

            dmxPlayback.Load(Path.Combine(Exec.ExpanderSharedFiles, "Seq", "XmasLoop.bin"), 15);
            dmxPlayback.Loop = true;

            var pixelMapping = Framework.Utility.PixelMapping.GeneratePixelMappingFromGlediatorPatch(
                Path.Combine(Exec.ExpanderSharedFiles, "Glediator", "ArtNet 14-15 20x10.patch.glediator"));

            dmxPlayback.SetOutput(pixelsMatrix, pixelMapping);

            buttonOverrideHours.Output.Subscribe(x =>
            {
                if (x)
                {
                    hours.SetForced(true);
                }
                else
                {
                    hours.SetForced(null);
                }
            });

            inflatablesRunning.Subscribe(x =>
            {
                airReindeer.SetValue(x);

                Exec.SetKey("InflatablesRunning", x.ToString());
            });

            // Read from storage
            inflatablesRunning.OnNext(Exec.GetSetKey("InflatablesRunning", false));

            //            hours.Output.Log("Hours inside");

            stateMachine.ForFromSubroutine(States.Background, subBackground);
            stateMachine.ForFromSubroutine(States.Music1, subMusic1);
            stateMachine.ForFromSubroutine(States.Music2, subMusic2);
            stateMachine.ForFromSubroutine(States.SantaVideo, subSantaVideo);
            stateMachine.ForFromSubroutine(States.DarthVader, subStarWars);

            airR2D2.SetValue(true);
            airSanta1.SetValue(true);
            airOlaf.SetValue(true);
            laser.SetValue(true);

            hours
            //    .ControlsMasterPower(packages)
            //    .ControlsMasterPower(airSnowman)
            .ControlsMasterPower(airOlaf)
            .ControlsMasterPower(laser)
            .ControlsMasterPower(airSanta1)
            .ControlsMasterPower(airR2D2);
            //    .ControlsMasterPower(airSanta);

            buttonStartInflatables.Output.Subscribe(x =>
            {
                if (x && hours.IsOpen)
                {
                    inflatablesRunning.OnNext(true);
                }
            });

            acnOutput.Connect(new Physical.Pixel1D(pixelsRoofEdge, 0, 50), SacnUniverse6, 1);
            acnOutput.Connect(new Physical.Pixel1D(pixelsRoofEdge, 50, 100), SacnUniverse5, 1);

            var pixelMapping2D = Framework.Utility.PixelMapping.GeneratePixelMapping(20, 10, pixelOrder: Framework.Utility.PixelOrder.HorizontalSnakeBottomLeft);

            acnOutput.Connect(new Physical.Pixel2D(pixelsMatrix, pixelMapping2D), SacnUniverse10, 1);

            acnOutput.Connect(new Physical.Pixel1D(saberPixels, 0, 32), SacnUniverse12, 1);

            acnOutput.Connect(new Physical.GenericDimmer(airOlaf, 10), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(airReindeer, 12), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(airR2D2, 11), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightHat1, 96), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightHat2, 97), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightHat3, 98), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightHat4, 99), SacnUniverseDMX);
            acnOutput.Connect(new Physical.RGBStrobe(lightVader, 60), SacnUniverseDMX);
            acnOutput.Connect(new Physical.RGBStrobe(lightWall1, 70), SacnUniverseDMX);
            acnOutput.Connect(new Physical.RGBStrobe(lightWall2, 40), SacnUniverseDMX);
            acnOutput.Connect(new Physical.RGBStrobe(lightWall3, 80), SacnUniverseDMX);

            acnOutput.Connect(new Physical.GenericDimmer(laser, 4), SacnUniverseRenardBig);

            acnOutput.Connect(new Physical.GenericDimmer(lightOlaf, 128), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightSanta, 131), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightSnowman, 132), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightSnowman, 132), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightBlueButton, 262), SacnUniverseDMX);
            acnOutput.Connect(new Physical.GenericDimmer(lightRedButton, 263), SacnUniverseDMX);

            acnOutput.Connect(new Physical.GenericDimmer(lightR2D2, 16), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightRail2, 10), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet5, 11), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet6, 19), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(airSanta1, 20), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet7, 22), SacnUniverseRenardBig);

            acnOutput.Connect(new Physical.GenericDimmer(lightStairs2, 25), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightXmasTree, 26), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightReindeer2, 29), SacnUniverseRenardBig);
            acnOutput.Connect(new Physical.GenericDimmer(lightReindeer1, 32), SacnUniverseRenardBig);

            acnOutput.Connect(new Physical.GenericDimmer(lightStairs1, 1), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet2, 2), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet1, 3), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet3, 4), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightNet4, 5), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightRail1, 6), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightTopper1, 7), SacnUniverseRenardSmall);
            acnOutput.Connect(new Physical.GenericDimmer(lightTopper2, 8), SacnUniverseRenardSmall);

            hours.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToDefaultState();
                }
                else
                {
                    //if (buttonOverrideHours.Active)
                    //    return;

                    stateMachine.GoToIdle();

                    // Needed?
                    System.Threading.Thread.Sleep(200);

                    inflatablesRunning.OnNext(false);
                }
            });

            subBackground
            .LockWhenRunning(
                lightNet1,
                lightNet2,
                lightNet3,
                lightNet4,
                lightNet5,
                lightNet6,
                lightNet7,
                lightNet8,
                lightTopper1,
                lightTopper2,
                lightXmasTree,
                lightStairs1,
                lightStairs2,
                lightRail1,
                lightRail2,
                lightSanta,
                lightSnowman,
                lightHat1,
                lightHat2,
                lightHat3,
                lightHat4,
                lightReindeer1,
                lightReindeer2,
                lightVader,
                lightWall1,
                lightWall2,
                lightWall3,
                lightR2D2,
                lightOlaf,
                saberPixels)
            .RunAction(i =>
            {
                pulsatingEffect4.Start();
                lightR2D2.SetBrightness(1, i.Token);
                lightOlaf.SetBrightness(1, i.Token);
                lightNet1.SetBrightness(1, i.Token);
                lightNet2.SetBrightness(1, i.Token);
                lightNet3.SetBrightness(1, i.Token);
                lightNet4.SetBrightness(1, i.Token);
                lightNet5.SetBrightness(1, i.Token);
                lightNet6.SetBrightness(1, i.Token);
                lightNet7.SetBrightness(1, i.Token);
                lightNet8.SetBrightness(1, i.Token);
                lightTopper1.SetBrightness(1, i.Token);
                lightTopper2.SetBrightness(1, i.Token);
                lightXmasTree.SetBrightness(1, i.Token);
                lightStairs1.SetBrightness(1, i.Token);
                lightStairs2.SetBrightness(1, i.Token);
                lightRail1.SetBrightness(1, i.Token);
                lightRail2.SetBrightness(1, i.Token);
                lightSanta.SetBrightness(1, i.Token);
                lightSnowman.SetBrightness(1, i.Token);
                lightHat1.SetBrightness(1, i.Token);
                lightHat2.SetBrightness(1, i.Token);
                lightHat3.SetBrightness(1, i.Token);
                lightHat4.SetBrightness(1, i.Token);
                lightReindeer1.SetBrightness(1, i.Token);
                lightReindeer2.SetBrightness(1, i.Token);
                lightVader.SetColor(Color.Red, 1, i.Token);
                lightWall1.SetColor(Color.Red, 1, i.Token);
                lightWall2.SetColor(Color.Red, 1, i.Token);
                lightWall3.SetColor(Color.Red, 1, i.Token);

                saberPixels.SetColor(Color.Red, 0.4, i.Token);

                subCandyCane.Run();
                dmxPlayback.Run();

                i.WaitUntilCancel();

                dmxPlayback.Stop();
                Exec.Cancel(subCandyCane);
                pulsatingEffect4.Stop();
            });

            subCandyCane
            .LockWhenRunning(pixelsRoofEdge)
            .RunAction(i =>
            {
                const int spacing = 4;

                while (true)
                {
                    for (int x = 0; x < spacing; x++)
                    {
                        pixelsRoofEdge.Inject((x % spacing) == 0 ? Color.Red : Color.White, 0.5, i.Token);

                        i.WaitFor(S(0.30), true);
                    }
                }
            });

            subSnow
            .RunAction(ins =>
            {
                snowMachine.SetValue(true);

                ins.WaitFor(S(30));
            })
            .TearDown(i =>
            {
                snowMachine.SetValue(false);
            });

            subStarWarsCane
            .LockWhenRunning(
                pixelsRoofEdge,
                pixelsMatrix)
            .RunAction(instance =>
            {
                const int spacing = 4;

                while (!instance.CancelToken.IsCancellationRequested)
                {
                    for (int i = 0; i < spacing; i++)
                    {
                        switch (i % spacing)
                        {
                        case 0:
                        case 1:
                            pixelsRoofEdge.InjectRev(Color.Yellow, 1.0, instance.Token);
                            break;

                        case 2:
                        case 3:
                            pixelsRoofEdge.InjectRev(Color.Orange, 0.2, instance.Token);
                            break;
                        }

                        instance.WaitFor(S(0.1));

                        if (instance.IsCancellationRequested)
                        {
                            break;
                        }
                    }
                }
            });

            subMusic1
            .RunAction(ins =>
            {
                audioMain.PlayTrack("08 Feel the Light.wav");
                ins.WaitFor(S(240));
            }).TearDown(i =>
            {
                lorFeelTheLight.Stop();
                audioMain.PauseTrack();
            });

            subMusic2
            .RunAction(ins =>
            {
                snowMachine.SetValue(true);
                audioMain.PlayTrack("T.P.E. - 04 - Josh Groban - Believe.flac");
                ins.WaitFor(S(260));
            }).TearDown(i =>
            {
                snowMachine.SetValue(false);
                lorBelieve.Stop();
                audioMain.PauseTrack();
            });

            subSantaVideo
            .RunAction(i =>
            {
                pulsatingEffect3.Start();
                switch (random.Next(6))
                {
                case 0:
                    video3.PlayVideo("NBC_DeckTheHalls_Holl_H.mp4");
                    break;

                case 1:
                    video3.PlayVideo("NBC_AllThruHouse_Part1_Holl_H.mp4");
                    break;

                case 2:
                    video3.PlayVideo("NBC_AllThruHouse_Part2_Holl_H.mp4");
                    break;

                case 3:
                    video3.PlayVideo("NBC_AllThruHouse_Part3_Holl_H.mp4");
                    break;

                case 4:
                    video3.PlayVideo("NBC_JingleBells_Holl_H.mp4");
                    break;

                case 5:
                    video3.PlayVideo("NBC_WeWishYou_Holl_H.mp4");
                    break;
                }

                i.WaitFor(S(120), false);
                pulsatingEffect3.Stop();
            });

            subOlaf
            .RunAction(i =>
            {
                pulsatingEffect1.Start();
                audio1.PlayNewEffect("WarmHugs.wav", 0.0, 1.0);
                i.WaitFor(S(10));
                pulsatingEffect1.Stop();
            });

            subR2D2
            .RunAction(i =>
            {
                pulsatingEffect2.Start();
                audio1.PlayNewEffect("Im C3PO.wav", 1.0, 0.0);
                i.WaitFor(S(4));
                audio1.PlayNewEffect("Processing R2D2.wav", 0.5, 0.0);
                i.WaitFor(S(5));
                pulsatingEffect2.Stop();
            });

            subStarWars
            .LockWhenRunning(
                saberPixels,
                lightVader,
                lightR2D2)
            .RunAction(instance =>
            {
                //Exec.Cancel(subCandyCane);
                subStarWarsCane.Run();
                lightR2D2.SetBrightness(1.0, instance.Token);

                audioMain.PlayTrack("01. Star Wars - Main Title.wav");

                instance.WaitFor(S(16));

                /*
                 *  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));*/

                Exec.MasterEffect.Fade(lightVader, 0.0, 1.0, 1000, token: instance.Token, additionalData: Utils.Data(Color.Red));
                instance.WaitFor(S(2.5));

                Exec.Cancel(subStarWarsCane);
                instance.WaitFor(S(0.5));

                audioDarthVader.PlayEffect("saberon.wav");
                for (int sab = 00; sab < 32; sab++)
                {
                    saberPixels.Inject(Color.Red, 0.5, instance.Token);
                    instance.WaitFor(S(0.01));
                }
                instance.WaitFor(S(1));
                audioMain.PauseTrack();

                lightVader.SetColor(Color.Red, 1.0, instance.Token);
                audioDarthVader.PlayEffect("father.wav");
                instance.WaitFor(S(5));

                lightVader.SetBrightness(0.0, instance.Token);
                //light3wise.TurnOff();
                //lightJesus.TurnOff();
                //pulsatingStar.Stop();
                //elJesus.TurnOff();

                audioDarthVader.PlayEffect("force1.wav");
                instance.WaitFor(S(4));

                audioDarthVader.PlayEffect("saberoff.wav");
                instance.WaitFor(S(0.7));
                for (int sab = 0; sab < 16; sab++)
                {
                    saberPixels.InjectRev(Color.Black, 0, instance.Token);
                    saberPixels.InjectRev(Color.Black, 0, instance.Token);
                    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(i =>
            {
                audioMain.PauseTrack();
            });


            midiAkai.Note(midiChannel, 36).Subscribe(x =>
            {
                if (x)
                {
                    subOlaf.Run();
                }
            });

            midiAkai.Note(midiChannel, 37).Subscribe(x =>
            {
                if (x)
                {
                    subR2D2.Run();
                }
            });

            midiAkai.Note(midiChannel, 38).Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToState(States.Music1);
                }
                //                    audio2.PlayTrack("08 Feel the Light.wav");
            });

            midiAkai.Note(midiChannel, 39).Subscribe(x =>
            {
                if (x)
                {
                    lorFeelTheLight.Stop();
                    audioMain.PauseTrack();
                }
            });

            midiAkai.Note(midiChannel, 40).Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToState(States.SantaVideo);
                }
            });

            inOlaf.Output.Subscribe(x =>
            {
                if (x && hours.IsOpen)
                {
                    subOlaf.Run();
                }
            });

            inR2D2.Output.Subscribe(x =>
            {
                if (x && hours.IsOpen)
                {
                    subR2D2.Run();
                }
            });

            inRedButton.Output.Subscribe(x =>
            {
                if (x)
                {
                    if (hours.IsOpen)
                    {
                        if (stateMachine.CurrentState == States.Background)
                        {
                            stateMachine.GoToState(States.DarthVader);
                        }
                    }
                    else
                    {
                        audioDarthVader.PlayEffect("darthvader_lackoffaith.wav");
                    }
                }
            });

            inBlueButton.Output.Subscribe(x =>
            {
                if (x)
                {
                    if (hours.IsOpen)
                    {
                        subSnow.Run();
                        if (stateMachine.CurrentState == States.Background)
                        {
                            stateMachine.GoToState(States.Music2);
                        }
                    }
                    else
                    {
                        audioDarthVader.PlayEffect("darkside.wav");
                    }
                }
            });

            audioMain.AudioTrackStart += (o, e) =>
            {
                switch (e.FileName)
                {
                case "08 Feel the Light.wav":
                    lorFeelTheLight.Start(27830);
                    break;

                case "T.P.E. - 04 - Josh Groban - Believe.flac":
                    lorBelieve.Start();
                    break;
                }
            };

            audioMain.AudioTrackDone += (o, e) =>
            {
                //                Thread.Sleep(5000);
                //    audio2.PlayTrack("08 Feel the Light.wav");
            };

            inShowMachine.Output.Subscribe(x =>
            {
                snowMachine.SetValue(x);
                //                lightRedButton.SetBrightness(x ? 1.0 : 0.0);
                //if (x)
                //    stateMachine.GoToState(States.Music1);
            });

            in2.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToIdle();
                }
            });

            in3.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToDefaultState();
                }
            });

            ImportAndMapFeelTheLight();
            ImportAndMapBelieve();
        }
Exemplo n.º 16
0
        public Halloween2015(IEnumerable <string> args)
        {
            hoursSmall.AddRange("5:00 pm", "7:00 pm");
            //            hoursFull.AddRange("5:00 pm", "7:00 pm");

            // Logging
            hoursSmall.Output.Log("Hours small");
            hoursFull.Output.Log("Hours full");

            hoursSmall
            .ControlsMasterPower(catAir);
            hoursFull
            .ControlsMasterPower(catAir);
            //                .ControlsMasterPower(eyes);

            buttonOverrideHours.Output.Subscribe(x =>
            {
                if (x)
                {
                    hoursFull.SetForced(true);
                }
                else
                {
                    hoursFull.SetForced(false);
                }
            });


            emergencyStop.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.GoToState(States.EmergencyStop);
                }
                else
                {
                    if (hoursFull.IsOpen)
                    {
                        stateMachine.GoToState(States.Background);
                    }
                    else
                    {
                        stateMachine.GoToIdle();
                    }
                }
            });

            hoursFull.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.SetDefaultState(States.Background);

                    if (emergencyStop.Value)
                    {
                        stateMachine.GoToState(States.EmergencyStop);
                    }
                    else
                    {
                        stateMachine.GoToState(States.Background);
                    }
                }
                else
                {
                    stateMachine.GoToIdle();
                    stateMachine.SetDefaultState(null);
                }
                SetPixelColor();
            });

            popOut1.ConnectTo(wall1Light);
            popOut1.ConnectTo(wall4Light);
            popOut2.ConnectTo(wall2Light);
            popOutAll.ConnectTo(wall1Light);
            popOutAll.ConnectTo(wall2Light);
            popOutAll.ConnectTo(wall3Light);
            popOutAll.ConnectTo(wall4Light);
            popOutAll.ConnectTo(underGeorge);
            popOutAll.ConnectTo(pixelsRoofEdge);
            popOutAll.ConnectTo(pinSpot);

            allLights.Add(wall1Light, wall2Light, wall3Light, wall4Light, underGeorge, pixelsRoofEdge, pinSpot, spiderLight);
            purpleLights.Add(wall1Light, wall2Light, wall3Light, wall4Light, pixelsRoofEdge);

            flickerEffect.ConnectTo(stairs1Light);
            flickerEffect.ConnectTo(stairs2Light);
            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)));

            stateMachine.For(States.Background)
            .Execute(i =>
            {
                subVideo.Run();
                flickerEffect.Start();
                treeGhosts.SetBrightness(1.0);
                audioMain.PlayBackground();
                audioEeebox.SetBackgroundVolume(0.6);
                audioEeebox.PlayBackground();

                ColorBrightness 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.Background)
                {
                    i.WaitFor(S(0.5));
                    if (!this.lastFogRun.HasValue || (DateTime.Now - this.lastFogRun.Value).TotalMinutes > 5)
                    {
                        // Run the fog for a little while
                        fog.SetValue(true);
                        i.WaitFor(S(4));
                        fog.SetValue(false);
                        this.lastFogRun = DateTime.Now;
                    }
                }
            })
            .TearDown(instance =>
            {
                purpleLights.SetBrightness(0.0);

                Exec.Cancel(subVideo);
                audioMain.PauseBackground();
                audioEeebox.PauseBackground();

                timelineThunder1.Stop();
                timelineThunder2.Stop();
                timelineThunder3.Stop();
                timelineThunder4.Stop();
                timelineThunder5.Stop();
                timelineThunder6.Stop();
                timelineThunder7.Stop();
                timelineThunder8.Stop();

                flickerEffect.Stop();
                treeGhosts.SetBrightness(0.0);
            });

            stateMachine.For(States.EmergencyStop)
            .Execute(i =>
            {
                // Do nothing
                i.WaitUntilCancel();
            });

            stateMachine.For(States.Special1)
            .Execute(i =>
            {
                audioEeebox.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));
            });

            midiInput.Controller(midiChannel, 1).Controls(inputBrightness.Control);
            midiInput.Controller(midiChannel, 2).Controls(inputH.Control);
            midiInput.Controller(midiChannel, 3).Controls(inputS.Control);

            raspberryLocal.AudioTrackStart.Subscribe(x =>
            {
                // Next track
                switch (x)
                {
                case "Thunder1.wav":
                    timelineThunder1.Start();
                    audioEeebox.PlayEffect("scream.wav");
                    break;

                case "Thunder2.wav":
                    timelineThunder2.Start();
                    break;

                case "Thunder3.wav":
                    timelineThunder3.Start();
                    break;

                case "Thunder4.wav":
                    timelineThunder4.Start();
                    audioEeebox.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), 6, 1);
            acnOutput.Connect(new Physical.Pixel1D(pixelsRoofEdge, 50, 100), 5, 1);

            acnOutput.Connect(new Physical.SmallRGBStrobe(spiderLight, 1), 1);
            acnOutput.Connect(new Physical.RGBStrobe(wall1Light, 60), 1);
            acnOutput.Connect(new Physical.RGBStrobe(wall2Light, 70), 1);
            acnOutput.Connect(new Physical.RGBStrobe(wall3Light, 40), 1);
            acnOutput.Connect(new Physical.RGBStrobe(wall4Light, 80), 1);
            acnOutput.Connect(new Physical.GenericDimmer(stairs1Light, 50), 1);
            acnOutput.Connect(new Physical.GenericDimmer(stairs2Light, 51), 1);
            acnOutput.Connect(new Physical.GenericDimmer(treeGhosts, 52), 1);
            acnOutput.Connect(new Physical.AmericanDJStrobe(underGeorge, 100), 1);
            acnOutput.Connect(new Physical.MonopriceRGBWPinSpot(pinSpot, 20), 1);

            //            acnOutput.Connect(new Physical.RGBIS(testLight1, 260), 1);


            raspberryCat.DigitalInputs[4].Connect(catMotion, false);
            raspberryCat.DigitalInputs[5].Connect(firstBeam, false);
            raspberryCat.DigitalInputs[6].Connect(finalBeam, false);
            raspberryCat.DigitalOutputs[7].Connect(spiderCeilingDrop);
            raspberryCat.Connect(audioCat);
            raspberryLocal.Connect(audioMain);
            monoExpanderEeebox.Connect(audioEeebox);
            raspberry3dfx.Connect(video3dfx);
            raspberryVideo2.Connect(video2);
            raspberryPop.Connect(audioPop);
            raspberryDIN.Connect(audioDIN);
            raspberryDIN.DigitalInputs[4].Connect(motion2);
            raspberryCat.DigitalOutputs[6].Connect(fog);
            raspberryDIN.DigitalOutputs[1].Connect(candyEyes);
            raspberryPop.DigitalOutputs[7].Connect(george1);
            raspberryPop.DigitalOutputs[6].Connect(george2);
            raspberryPop.DigitalOutputs[5].Connect(popper);
            raspberryPop.DigitalOutputs[2].Connect(dropSpiderEyes);

            acnOutput.Connect(new Physical.GenericDimmer(catAir, 10), 1);
            acnOutput.Connect(new Physical.GenericDimmer(catLights, 11), 1);

            oscServer.RegisterAction <int>("/3/multipush1/6/1", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("sixthsense-deadpeople.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/6/2", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("162 Blood Curdling Scream of Terror.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/6/3", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("424 Coyote Howling.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/6/4", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/6/5", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("242004__junkfood2121__fart-01.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/5/1", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("death-scream.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/5/2", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("scream.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/5/3", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("door-creak.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/5/4", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("violin screech.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/5/5", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("gollum_precious1.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/4/1", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayNewEffect("640 The Demon Exorcised.wav");
            });

            oscServer.RegisterAction <int>("/3/multipush1/4/2", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("266 Monster Growl 7.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/3/multipush1/4/3", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("285 Monster Snarl 2.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/3/multipush1/4/4", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("286 Monster Snarl 3.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/3/multipush1/4/5", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("287 Monster Snarl 4.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/3/multipush1/3/1", d => d.First() != 0, (msg, data) =>
            {
                audioEeebox.PlayEffect("180 Babbling Lunatic.wav");
            });

            oscServer.RegisterAction <int>("/1/eStop", (msg, data) =>
            {
                emergencyStop.Control.OnNext(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push2", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("285 Monster Snarl 2.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/1/push3", d => d.First() != 0, (msg, data) =>
            {
                audioCat.PlayEffect("286 Monster Snarl 3.wav", 1.0, 1.0);
            });

            oscServer.RegisterAction <int>("/1/push4", (msg, data) =>
            {
                // Flash
                if (data.First() != 0)
                {
                    allLights.TakeAndHoldControl();
                    allLights.SetData(null, Utils.Data(Color.White, 1.0));
                }
                else
                {
                    allLights.ReleaseControl();
                }
            });

            oscServer.RegisterAction <int>("/1/push5", (msg, data) =>
            {
                george1.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push6", (msg, data) =>
            {
                george2.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push7", (msg, data) =>
            {
                popper.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push8", d => d.First() != 0, (msg, data) =>
            {
                audioPop.PlayEffect("laugh.wav", 1.0, 0.0);
            });

            oscServer.RegisterAction <int>("/1/spiderEyes", (msg, data) =>
            {
                dropSpiderEyes.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push10", d => d.First() != 0, (msg, data) =>
            {
                audioPop.PlayEffect("348 Spider Hiss.wav", 0.0, 1.0);
            });

            oscServer.RegisterAction <int>("/1/push11", (msg, data) =>
            {
                spiderCeilingDrop.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/push12", (msg, data) =>
            {
                fog.SetValue(data.First() != 0);
            });

            oscServer.RegisterAction <int>("/1/special1", (msg, data) =>
            {
                if (data.First() != 0)
                {
                    stateMachine.GoToMomentaryState(States.Special1);
                }
                else
                {
                    stateMachine.StopCurrentJob();
                }
            });

            oscServer.RegisterAction <int>("/1/push13", d => d.First() != 0, (msg, data) =>
            {
                //                Exec.MasterEffect.Fade(stairs1Light, 1.0, 0.0, 2000, token: testToken);
                //popOut1.Pop();
                //popOut2.Pop();
                //popOut3.Pop();
                popOutAll.Pop(color: Color.White);
            });

            oscServer.RegisterAction <int>("/1/toggle1", (msg, data) =>
            {
                //                candyEyes.Value = data.First() != 0;
                if (data.First() != 0)
                {
                    audioMain.PlayBackground();
                }
                else
                {
                    audioMain.PauseBackground();
                }
            });

            oscServer.RegisterAction <int>("/1/toggle2", (msg, data) =>
            {
                //                pinSpot.SetBrightness(data.First());
            });

            oscServer.RegisterAction <int>("/1/toggle3", (msg, data) =>
            {
                if (data.First() != 0)
                {
                    audioEeebox.PlayBackground();
                }
                else
                {
                    audioEeebox.PauseBackground();
                }
            });

            oscServer.RegisterAction <int>("/1/toggle4", (msg, data) =>
            {
                block.Value = data.First() != 0;
                //                treeGhosts.SetBrightness(data.First() != 0 ? 1.0 : 0.0);
            });

            oscServer.RegisterAction <int>("/1/push14", (msg, data) =>
            {
                //                flickerEffect.Start();
                //double brightness = data.First();

                //spiderLight.SetColor(Color.Red, brightness);
                //pinSpot.SetColor(Color.Purple, brightness);
                //underGeorge.SetBrightness(brightness);
                //wall1Light.SetColor(Color.Purple, brightness);
                //wall2Light.SetColor(Color.Purple, brightness);
                //wall3Light.SetColor(Color.Purple, brightness);
                //wall4Light.SetColor(Color.Purple, brightness);
                //                audioDIN.PlayEffect("gollum_precious1.wav");
            });

            oscServer.RegisterAction <int>("/1/push20", d => d.First() != 0, (msg, data) =>
            {
                video3dfx.PlayVideo("PHA_Wraith_StartleScare_3DFX_H.mp4");
            });

            oscServer.RegisterAction <int>("/1/push21", d => d.First() != 0, (msg, data) =>
            {
                //               video2.PlayVideo("SkeletonSurprise_Door_Horz_HD.mp4");
                video2.PlayVideo("Beauty_Startler_TVHolo_Hor_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/5/1", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("Beauty_Startler_TVHolo_Hor_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/5/2", d => d.First() != 0, (msg, data) =>
            {
            });

            oscServer.RegisterAction <int>("/4/multipush2/5/3", d => d.First() != 0, (msg, data) =>
            {
            });

            oscServer.RegisterAction <int>("/4/multipush2/5/4", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("FearTheReaper_Door_Horz_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/4/1", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("GatheringGhouls_Door_Horz_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/4/2", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("Girl_Startler_TVHolo_Hor_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/4/3", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("HeadOfHouse_Startler_TVHolo_Hor_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/4/4", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("JitteryBones_Door_Horz_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/3/1", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("PHA_Poltergeist_StartleScare_Holl_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/3/2", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("PHA_Siren_StartleScare_Holl_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/3/3", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("PHA_Spinster_StartleScare_Holl_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/3/4", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("PHA_Wraith_StartleScare_Holl_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/2/1", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("PopUpPanic_Door_Horz_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/2/2", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("SkeletonSurprise_Door_Horz_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/2/3", d => d.First() != 0, (msg, data) =>
            {
                video2.PlayVideo("Wraith_Startler_TVHolo_Hor_HD.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/2/4", d => d.First() != 0, (msg, data) =>
            {
            });

            oscServer.RegisterAction <int>("/4/multipush2/1/1", d => d.First() != 0, (msg, data) =>
            {
                video3dfx.PlayVideo("PHA_Wraith_StartleScare_3DFX_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/1/2", d => d.First() != 0, (msg, data) =>
            {
                video3dfx.PlayVideo("PHA_Spinster_StartleScare_3DFX_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/1/3", d => d.First() != 0, (msg, data) =>
            {
                video3dfx.PlayVideo("PHA_Siren_StartleScare_3DFX_H.mp4");
            });

            oscServer.RegisterAction <int>("/4/multipush2/1/4", d => d.First() != 0, (msg, data) =>
            {
                video3dfx.PlayVideo("PHA_Poltergeist_StartleScare_3DFX_H.mp4");
            });


            oscServer.RegisterAction("/1", msg =>
            {
                this.log.Information("Page 1");
                //                manualFader.Value = false;

                SetPixelColor();
            });

            oscServer.RegisterAction("/2", msg =>
            {
                this.log.Information("Page 2");
                //                manualFader.Value = true;

                SetPixelColor();
            });

            oscServer.RegisterAction <float>("/2/faderBright", (msg, data) =>
            {
                faderBright.Value = data.First();

                SetPixelColor();
            });

            oscServer.RegisterAction <float>("/2/faderR", (msg, data) =>
            {
                faderR.Value = data.First();

                SetPixelColor();
            });

            oscServer.RegisterAction <float>("/2/faderG", (msg, data) =>
            {
                faderG.Value = data.First();

                SetPixelColor();
            });

            oscServer.RegisterAction <float>("/2/faderB", (msg, data) =>
            {
                faderB.Value = data.First();

                SetPixelColor();
            });



            midiInput.Note(midiChannel, 36).Subscribe(x =>
            {
                if (x)
                {
                    audioCat.PlayEffect("266 Monster Growl 7", 1.0, 1.0);
                }
            });

            midiInput.Note(midiChannel, 37).Subscribe(x =>
            {
                if (x)
                {
                    audioCat.PlayEffect("285 Monster Snarl 2", 1.0, 1.0);
                }
            });

            midiInput.Note(midiChannel, 38).Subscribe(x =>
            {
                if (x)
                {
                    audioCat.PlayEffect("286 Monster Snarl 3", 1.0, 1.0);
                }
            });

            midiInput.Note(midiChannel, 39).Subscribe(x =>
            {
                if (x)
                {
                    audioCat.PlayEffect("287 Monster Snarl 4", 1.0, 1.0);
                }
            });

            midiInput.Note(midiChannel, 40).Subscribe(x =>
            {
                if (x)
                {
                    allLights.TakeAndHoldControl();
                    allLights.SetData(null, Utils.Data(Color.White, 1.0));
                }
                else
                {
                    allLights.ReleaseControl();
                }
            });

            midiInput.Note(midiChannel, 41).Subscribe(x =>
            {
                if (x)
                {
                    audioEeebox.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral.wav");
                }
            });

            midiInput.Note(midiChannel, 42).Subscribe(x =>
            {
                if (x)
                {
                    audioEeebox.PlayEffect("180 Babbling Lunatic.wav");
                }
            });

            midiInput.Note(midiChannel, 43).Subscribe(x =>
            {
                if (x)
                {
                    audioEeebox.PlayEffect("162 Blood Curdling Scream of Terror.wav");
                }
            });

            catMotion.Output.Subscribe(x =>
            {
                if (x && (hoursFull.IsOpen || hoursSmall.IsOpen))
                {
                    Executor.Current.Execute(catSeq);
                }

                touchOSC.Send("/1/led1", x ? 1 : 0);
            });

            firstBeam.Output.Subscribe(x =>
            {
                touchOSC.Send("/1/led2", x ? 1 : 0);

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !block.Value)
                {
                    subFirst.Run();
                }
            });

            finalBeam.Output.Subscribe(x =>
            {
                touchOSC.Send("/1/led3", x ? 1 : 0);

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !block.Value)
                {
                    subFinal.Run();
                }
            });

            motion2.Output.Subscribe(x =>
            {
                //if (x && hoursFull.IsOpen)
                //    Executor.Current.Execute(motionSeq);

                touchOSC.Send("/1/led4", x ? 1 : 0);
            });

            welcomeSeq.WhenExecuted
            .Execute(i =>
            {
                audioPop.PlayEffect("100471__robinhood76__01886-welcome-spell.wav");

                i.WaitFor(S(3));
            });

            subFirst
            .LockWhenRunning(10, spiderLight)
            .RunAction(i =>
            {
                fog.SetValue(true);
                this.lastFogRun = DateTime.Now;
                pulsatingEffect2.Start();
                i.WaitFor(S(5.0));

                spiderLight.SetColor(Color.Red, token: i.Token);
                dropSpiderEyes.SetValue(true);
                spiderCeilingDrop.SetValue(true);
                audioPop.PlayEffect("348 Spider Hiss.wav", 1.0, 0.0);

                i.WaitFor(S(2.0));
                dropSpiderEyes.SetValue(false);
                spiderLight.SetBrightness(0.0, i.Token);
                switch (random.Next(4))
                {
                case 0:
                    video3dfx.PlayVideo("PHA_Wraith_StartleScare_3DFX_H.mp4");
                    break;

                case 1:
                    video3dfx.PlayVideo("PHA_Spinster_StartleScare_3DFX_H.mp4");
                    break;

                case 2:
                    video3dfx.PlayVideo("PHA_Siren_StartleScare_3DFX_H.mp4");
                    break;

                case 3:
                    video3dfx.PlayVideo("PHA_Poltergeist_StartleScare_3DFX_H.mp4");
                    break;
                }
                fog.SetValue(false);
                i.WaitFor(S(2.0));
                spiderCeilingDrop.SetValue(false);
                i.WaitFor(S(3.0));
            })
            .TearDown(i =>
            {
                pulsatingEffect2.Stop();
                Thread.Sleep(S(5));
            });

            subVideo
            .RunAction(i =>
            {
                while (!i.IsCancellationRequested)
                {
                    string videoFile;
                    while (true)
                    {
                        videoFile = videoFiles[random.Next(videoFiles.Length)];
                        if (videoFiles.Length == 1 || videoFile != currentVideoFile)
                        {
                            break;
                        }
                    }

                    currentVideoFile = videoFile;
                    video2.PlayVideo(videoFile);
                    i.WaitFor(S(60));
                }
            });

            subFinal
            .LockWhenRunning(10, candyEyes, underGeorge)
            .RunAction(i =>
            {
                pulsatingEffect2.Stop();
                pulsatingEffect1.Start();
                candyEyes.SetValue(true);
                underGeorge.SetStrobeSpeed(0.5, i.Token);
                underGeorge.SetBrightness(1.0, i.Token);
                audioPop.PlayEffect("laugh.wav", 1.0, 0.0);
                for (int r = 0; r < 2; r++)
                {
                    george1.SetValue(true);
                    i.WaitFor(S(0.2));
                    george1.SetValue(false);
                    i.WaitFor(S(0.2));
                }
                i.WaitFor(S(1));
                audioDIN.PlayEffect("125919__klankbeeld__horror-what-are-you-doing-here-cathedral.wav");
                underGeorge.SetStrobeSpeed(0.0, i.Token);
                underGeorge.SetBrightness(0.0, i.Token);
                i.WaitFor(S(1));

                popper.SetValue(true);
                audioPop.PlayEffect("180 Babbling Lunatic.wav", 0.0, 1.0);
                i.WaitFor(S(3));
                popper.SetValue(false);

                i.WaitFor(S(8));

                Exec.MasterEffect.Fade(underGeorge, 0.5, 0.0, 1000, token: i.Token);
                //                    underGeorge.SetBrightness(0.3, i.Token);
                i.WaitFor(S(0.5));
                george2.SetValue(true);
                i.WaitFor(S(1.0));
                george2.SetValue(false);
                i.WaitFor(S(1.0));
                //                    underGeorge.SetBrightness(0.0, i.Token);
            })
            .TearDown(i =>
            {
                candyEyes.SetValue(false);
                pulsatingEffect1.Stop();
                Thread.Sleep(S(5));
            });


            catSeq.WhenExecuted
            .Execute(instance =>
            {
                var maxRuntime = System.Diagnostics.Stopwatch.StartNew();

                catLights.SetValue(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(instance =>
            {
                catLights.SetValue(false);
            });

            motionSeq.WhenExecuted
            .Execute(instance =>
            {
                //video2.PlayVideo("DancingDead_Wall_HD.mp4");

                //                    instance.WaitFor(S(10));
            })
            .TearDown(instance =>
            {
            });
        }
Exemplo n.º 17
0
        public Halloween2016(IEnumerable <string> args)
        {
            hoursSmall.AddRange("6:00 pm", "8:30 pm",
                                DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday);
            hoursSmall.AddRange("5:00 pm", "9:00 pm",
                                DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday);

            hoursFull.AddRange("6:00 pm", "8:30 pm");
            //hoursFull.Disabled = true;
            hoursSmall.Disabled = true;

            // Logging
            hoursSmall.Output.Log("Hours small");
            hoursFull.Output.Log("Hours full");

            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("ed86c3dc166f41ee86626897ba039ed2", expanderLedmx);      // rpi-eb0092ca
            expanderServer.AddInstance("1583f686014345888c15d7fc9c55ca3c", expanderCat);        // rpi-eb81c94e
            expanderServer.AddInstance("4ea781ef257442edb524493da8f52220", expanderAudio2);     // rpi-eba6cbc7
            expanderServer.AddInstance("76d09e6032d54e77aafec90e1fc4b35b", expanderHifi);       // rpi-eb428ef1
            expanderServer.AddInstance("60023fcde5b549b89fa828d31741dd0c", expanderPicture);    // rpi-eb91bc26
            expanderServer.AddInstance("e41d2977931d4887a9417e8adcd87306", expanderGhost);      // rpi-eb6a047c
            expanderServer.AddInstance("999861affa294fd7bbf0601505e9ae09", expanderPop);        // rpi-ebd43a38

            masterVolume.ConnectTo(Exec.MasterVolume);

            hoursSmall
            .ControlsMasterPower(catAir)
            .ControlsMasterPower(mrPumpkinAir);
            hoursFull
            .ControlsMasterPower(catAir)
            .ControlsMasterPower(mrPumpkinAir);

            buttonOverrideHours.Output.Subscribe(x =>
            {
                if (x)
                {
                    hoursFull.SetForced(true);
                }
                else
                {
                    hoursFull.SetForced(null);
                }
            });


            flashBaby.Output.Subscribe(x =>
            {
                // Flash
                if (x)
                {
                    allLights.TakeAndHoldControl(100, "FlashBaby");
                    allLights.SetData(null, Utils.Data(Color.White, 1.0));
                }
                else
                {
                    allLights.ReleaseControl();
                }
            });

            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 (hoursFull.IsOpen || hoursSmall.IsOpen)
                    {
                        stateMachine.GoToDefaultState();
                    }
                    else
                    {
                        stateMachine.GoToIdle();
                    }
                }
            });

            hoursFull.Output.Subscribe(x =>
            {
                if (x)
                {
                    stateMachine.SetDefaultState(States.BackgroundFull);

                    if (emergencyStop.Value)
                    {
                        stateMachine.GoToState(States.EmergencyStop);
                    }
                    else
                    {
                        stateMachine.GoToDefaultState();
                    }
                }
                else
                {
                    stateMachine.GoToIdle();
                    stateMachine.SetDefaultState(null);
                }
                SetManualColor();
            });

            hoursSmall.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(flash1);
            popOut2.ConnectTo(wall2Light);
            popOut2.ConnectTo(wall7Light);
            popOut2.ConnectTo(flash2);
            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(flash1);
            popOutAll.ConnectTo(flash2);
            popOutAll.ConnectTo(pixelsRoofEdge);
            //            popOutAll.ConnectTo(pinSpot);

            allLights.Add(
                wall1Light,
                wall2Light,
                wall3Light,
                wall4Light,
                wall5Light,
                wall6Light,
                wall7Light,
                wall8Light,
                wall9Light,
                flash1,
                flash2,
                pixelsRoofEdge,
                //                pinSpot,
                spiderLight,
                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)));

            pulsatingCatLow.ConnectTo(catLights);
            pulsatingCatHigh.ConnectTo(catLights);
            pulsatingPumpkinLow.ConnectTo(pumpkinLights);
            pulsatingPumpkinHigh.ConnectTo(pumpkinLights);
            pulsatingGargoyle.ConnectTo(spiderWebLights);

            stateMachine.For(States.BackgroundSmall)
            .Controls(1, flickerEffect, pulsatingGargoyle, pulsatingCatLow, pulsatingPumpkinLow)
            .Execute(i =>
            {
                treeGhosts.SetBrightness(1.0);
                treeSkulls.SetBrightness(1.0);
                audio2.SetBackgroundVolume(0.5);

                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 =>
            {
                purpleLights.SetBrightness(0.0);
                treeGhosts.SetBrightness(0.0);
                treeSkulls.SetBrightness(0.0);
            });

            stateMachine.For(States.BackgroundFull)
            .Controls(1, flickerEffect, pulsatingGargoyle, pulsatingCatLow, pulsatingPumpkinLow)
            .Execute(i =>
            {
                treeGhosts.SetBrightness(1.0);
                treeSkulls.SetBrightness(1.0);
                audioHifi.PlayBackground();
                audio2.SetBackgroundVolume(0.5);
                audio2.PlayBackground();

                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
                        fog.SetValue(true);
                        i.WaitFor(S(4));
                        fog.SetValue(false);
                        this.lastFogRun = DateTime.Now;
                    }
                }
            })
            .TearDown(instance =>
            {
                purpleLights.SetBrightness(0.0);
                treeGhosts.SetBrightness(0.0);
                treeSkulls.SetBrightness(0.0);

                audioHifi.PauseBackground();
                audio2.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();
                    audio2.PlayEffect("scream.wav");
                    break;

                case "Thunder2.wav":
                    timelineThunder2.Start();
                    break;

                case "Thunder3.wav":
                    timelineThunder3.Start();
                    break;

                case "Thunder4.wav":
                    timelineThunder4.Start();
                    audio2.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.SmallRGBStrobe(spiderLight, 1), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.RGBStrobe(wall6Light, 60), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.RGBStrobe(wall9Light, 70), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.RGBStrobe(wall8Light, 40), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.RGBStrobe(wall7Light, 80), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.MarcGamutParH7(wall1Light, 310, 8), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.MarcGamutParH7(wall2Light, 300, 8), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.MFL7x10WPar(wall3Light, 320), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.MarcGamutParH7(wall4Light, 330, 8), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.MarcGamutParH7(wall5Light, 340, 8), SacnUniverseDMXLedmx);
            //            acnOutput.Connect(new Physical.MarcGamutParH7(wall6Light, 350, 8), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(stairs1Light, 97), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(stairs2Light, 98), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(treeGhosts, 52), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(treeSkulls, 263), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(spiderEyes, 262), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(popperEyes, 259), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.AmericanDJStrobe(flash1, 100), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.EliminatorFlash192(flash2, 110), SacnUniverseDMXLedmx);
            //            acnOutput.Connect(new Physical.MonopriceRGBWPinSpot(pinSpot, 20), 1);

            acnOutput.Connect(new Physical.GenericDimmer(catAir, 10), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(mrPumpkinAir, 50), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(catLights, 96), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(spiderWebLights, 99), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(pumpkinLights, 51), SacnUniverseDMXLedmx);
            acnOutput.Connect(new Physical.GenericDimmer(gargoyleLightsCrystal, 128), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(gargoyleLightsEyes, 129), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(flyingSkeletonEyes, 130), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(streetNumberEyes, 131), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(bigSpiderEyes, 132), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(hazerFanSpeed, 500), SacnUniverseDMXCat);
            acnOutput.Connect(new Physical.GenericDimmer(hazerHazeOutput, 501), SacnUniverseDMXCat);
            //            acnOutput.Connect(new Physical.RGBIS(testLight1, 260), 1);


            expanderLedmx.DigitalInputs[4].Connect(pumpkinMotion, false);
            expanderCat.DigitalInputs[4].Connect(catMotion, false);
            expanderCat.DigitalInputs[5].Connect(secondBeam);
            expanderCat.DigitalInputs[6].Connect(firstBeam);
            expanderLedmx.DigitalInputs[5].Connect(ghostBeam);
            expanderLedmx.DigitalInputs[6].Connect(lastBeam);
            expanderPop.DigitalOutputs[7].Connect(popper);
            expanderPop.DigitalOutputs[6].Connect(fog);
            expanderCat.DigitalOutputs[7].Connect(spiderJump1);
            expanderCat.DigitalOutputs[6].Connect(spiderJump2);
            expanderLedmx.Connect(audioPumpkin);
            expanderCat.Connect(audioCat);
            expanderHifi.Connect(audioHifi);
            expanderPop.Connect(audioPop);
            expanderAudio2.Connect(audio2);
            expanderPicture.Connect(audioFlying);


            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());


            catMotion.Output.Subscribe(x =>
            {
                if (x && (hoursFull.IsOpen || hoursSmall.IsOpen) && !blockMaster.Value && !blockCat.Value)
                {
                    Executor.Current.Execute(catSeq);
                }

                oscServer.SendAllClients("/1/led1", x ? 1 : 0);
            });

            pumpkinMotion.Output.Subscribe(x =>
            {
                if (x && (hoursFull.IsOpen || hoursSmall.IsOpen) && !blockMaster.Value && !blockPumpkin.Value)
                {
                    Executor.Current.Execute(pumpkinSeq);
                }

                //                oscServer.SendAllClients("/1/led1", x ? 1 : 0);
            });

            firstBeam.Output.Subscribe(x =>
            {
                UpdateOSC();

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !blockMaster.Value && !blockFirst.Value)
                {
                    subFirst.Run();
                }
            });

            secondBeam.Output.Subscribe(x =>
            {
                UpdateOSC();

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !blockMaster.Value && !blockPicture.Value)
                {
                    subPicture.Run();
                }
            });

            ghostBeam.Output.Subscribe(x =>
            {
                UpdateOSC();

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !blockMaster.Value && !blockGhost.Value)
                {
                    subGhost.Run();
                }
            });

            lastBeam.Output.Subscribe(x =>
            {
                UpdateOSC();

                if (x && hoursFull.IsOpen && !emergencyStop.Value && !blockMaster.Value && !blockLast.Value)
                {
                    subLast.Run();
                }
            });

            subFog
            .RunAction(i =>
            {
                fog.SetValue(true);
                lastFogRun = DateTime.Now;
                i.WaitFor(S(6));
                fog.SetValue(false);
            });

            subFirst
            .AutoAddDevices(lockPriority: 100)
            .RunAction(i =>
            {
                flyingSkeletonEyes.SetBrightness(1.0);
                wall3Light.SetColor(Color.FromArgb(255, 0, 100), 0.5);
                wall3Light.SetStrobeSpeed(1.0, i.Token);

                //                    audioPicture.PlayEffect("162 Blood Curdling Scream of Terror.wav");
                //audioFlying.PlayEffect("05 I'm a Little Teapot.wav", 0.05);
                audioFlying.PlayEffect("Who is that knocking.wav");
                i.WaitFor(S(3.0));
                audioFlying.PlayEffect("Evil-Laugh.wav");

                i.WaitFor(S(2.0));
            })
            .TearDown(i =>
            {
                Exec.MasterEffect.Fade(wall3Light, 0.5, 0.0, 2000, token: i.Token).Wait();
            });

            subPicture
            .RunAction(i =>
            {
                if (bigSpiderEyesToken != null)
                {
                    bigSpiderEyesToken.Dispose();
                }

                wall8Light.SetColor(Color.White, 1, bigSpiderEyesToken);
                wall8Light.SetStrobeSpeed(1, bigSpiderEyesToken);
                bigSpiderEyesToken = bigSpiderEyes.TakeControl(100);
                bigSpiderEyes.SetBrightness(0, bigSpiderEyesToken);
                audioHifi.PlayNewEffect("Happy Halloween.wav");
                expanderPicture.SendSerial(0, new byte[] { 0x02 });
                i.WaitFor(S(4.0));
                sub3dfxRandom.Run();
                i.WaitFor(S(10.0));
                wall8Light.SetBrightness(0);
                subSpiderJump.Run();
                i.WaitFor(S(4.0));
            })
            .TearDown(i =>
            {
            });

            subSpiderJump
            .RunAction(i =>
            {
                if (bigSpiderEyesToken == null)
                {
                    bigSpiderEyesToken = bigSpiderEyes.TakeControl(100);
                }

                audio2.PlayNewEffect("348 Spider Hiss.wav", 0, 1);
                bigSpiderEyes.SetBrightness(1, bigSpiderEyesToken);
                spiderJump1.SetValue(true);
                i.WaitFor(S(0.5));
                spiderJump2.SetValue(true);
                i.WaitFor(S(2.0));
                spiderJump1.SetValue(false);
                spiderJump2.SetValue(false);
            })
            .TearDown(i =>
            {
                bigSpiderEyesToken?.Dispose();
                bigSpiderEyesToken = null;
            });

            sub3dfxRandom
            .RunAction(i =>
            {
                byte video;
                do
                {
                    video = (byte)(random.Next(3) + 1);
                } while (video == last3dfxVideo);
                last3dfxVideo = video;

                expanderLedmx.SendSerial(0, new byte[] { video });
                i.WaitFor(S(12.0));
            })
            .TearDown(i =>
            {
            });

            sub3dfxLady
            .RunAction(i =>
            {
                expanderLedmx.SendSerial(0, new byte[] { 0x02 });
                i.WaitFor(S(12.0));
            })
            .TearDown(i =>
            {
            });

            sub3dfxMan
            .RunAction(i =>
            {
                expanderLedmx.SendSerial(0, new byte[] { 0x03 });
                i.WaitFor(S(12.0));
            })
            .TearDown(i =>
            {
            });

            sub3dfxKids
            .RunAction(i =>
            {
                expanderLedmx.SendSerial(0, new byte[] { 0x01 });
                i.WaitFor(S(12.0));
            })
            .TearDown(i =>
            {
            });

            subGhost
            .RunAction(i =>
            {
                expanderGhost.SendSerial(0, new byte[] { 0x01 });
                i.WaitFor(S(12.0));
            })
            .TearDown(i =>
            {
            });

            subLast
            .RunAction(i =>
            {
                popperEyes.SetBrightness(1.0);
                fog.SetValue(true);
                lastFogRun = DateTime.Now;
                audioPop.PlayEffect("Short Laugh.wav");
                i.WaitFor(S(1.0));
                popper.SetValue(true);
                i.WaitFor(S(2.0));
                audioPop.PlayEffect("Leave Now.wav");
                i.WaitFor(S(3.0));
                var tsk = Exec.MasterEffect.Fade(popperEyes, 1.0, 0.0, 2000, token: i.Token);
                popper.SetValue(false);
                tsk.Wait();
            })
            .TearDown(i =>
            {
                fog.SetValue(false);
                i.WaitFor(S(1.0));
            });

            catSeq.WhenExecuted
            .Execute(instance =>
            {
                var maxRuntime = System.Diagnostics.Stopwatch.StartNew();

                pulsatingCatLow.Stop();
                pulsatingCatHigh.Start();
                //                catLights.SetBrightness(1.0, instance.Token);

                while (true)
                {
                    switch (random.Next(4))
                    {
                    case 0:
                        audioCat.PlayEffect("266 Monster Growl 7.wav", 1.0, 1.0);
                        instance.WaitFor(TimeSpan.FromSeconds(2.0));
                        break;

                    case 1:
                        audioCat.PlayEffect("285 Monster Snarl 2.wav", 1.0, 1.0);
                        instance.WaitFor(TimeSpan.FromSeconds(3.0));
                        break;

                    case 2:
                        audioCat.PlayEffect("286 Monster Snarl 3.wav", 1.0, 1.0);
                        instance.WaitFor(TimeSpan.FromSeconds(2.5));
                        break;

                    case 3:
                        audioCat.PlayEffect("287 Monster Snarl 4.wav", 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(instance =>
            {
                //                Exec.MasterEffect.Fade(catLights, 1.0, 0.0, 1000, token: instance.Token);
                //TODO: Fade out
                pulsatingCatHigh.Stop();
                pulsatingCatLow.Start();
            });

            pumpkinSeq.WhenExecuted
            .Execute(instance =>
            {
                pulsatingPumpkinLow.Stop();
                pulsatingPumpkinHigh.Start();
                if (hoursFull.IsOpen)
                {
                    audioPumpkin.PlayEffect("Thriller2.wav");
                }
                else
                {
                    audioPumpkin.PlayEffect("Happy Halloween.wav");
                }
                instance.CancelToken.WaitHandle.WaitOne(40000);
            })
            .TearDown(instance =>
            {
                pulsatingPumpkinHigh.Stop();
                pulsatingPumpkinLow.Start();
            });

            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 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();
        }
Exemplo n.º 19
0
        public HalloweenGrumpyCat(
            Dimmer3 light,
            DigitalOutput2 air,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsatingLow.ConnectTo(light);
            pulsatingHigh.ConnectTo(light);

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(air, light);

                    air.SetValue(true, this.controlToken);
                    pulsatingLow.Start(token: this.controlToken);
                }
                else
                {
                    pulsatingLow.Stop();
                    UnlockDevices();
                }
            });

            PowerOn
            .SetLoop(true)
            .SetMaxRuntime(S(20))
            .SetUp(ins =>
            {
                pulsatingLow.Stop();
                pulsatingHigh.Start(token: this.controlToken);
            })
            .RunAction(ins =>
            {
                switch (random.Next(5))
                {
                case 0:
                    audioPlayer.PlayEffect("266 Monster Growl 7.wav", 1.0, 1.0);
                    ins.WaitFor(S(2.0));
                    break;

                case 1:
                    audioPlayer.PlayEffect("285 Monster Snarl 2.wav", 1.0, 1.0);
                    ins.WaitFor(S(3.0));
                    break;

                case 2:
                    audioPlayer.PlayEffect("286 Monster Snarl 3.wav", 1.0, 1.0);
                    ins.WaitFor(S(2.5));
                    break;

                case 3:
                    audioPlayer.PlayEffect("287 Monster Snarl 4.wav", 1.0, 1.0);
                    ins.WaitFor(S(1.5));
                    break;

                default:
                    ins.WaitFor(S(3.0));
                    break;
                }
            })
            .TearDown(ins =>
            {
                //TODO: Fade out
                pulsatingHigh.Stop();
                pulsatingLow.Start(token: this.controlToken);
            });


            PowerOff
            .RunAction(ins =>
            {
                audioPlayer.PlayEffect("How you doing.wav", 0.15);
                ins.WaitFor(S(5));
            });
        }
Exemplo n.º 20
0
        public HalloweenRocker(
            DigitalOutput2 rockingMotor,
            DigitalOutput2 ladyEyes,
            StrobeColorDimmer3 strobeLight,
            AudioPlayer audioPlayer,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            pulsatingRocking.ConnectTo(strobeLight, Utils.Data(DataElements.Color, Color.HotPink));

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(rockingMotor, ladyEyes, strobeLight);
                    audioPlayer.SetBackgroundVolume(0.2);
                    audioPlayer.PlayBackground();
                    sub.Run();
                }
                else
                {
                    audioPlayer.PauseBackground();
                    UnlockDevices();
                    Exec.Cancel(sub);
                }
            });

            sub
                .SetUp(ins =>
                {
                    ladyEyes.SetValue(true, this.controlToken);
                    rockingMotor.SetValue(true, this.controlToken);
                })
                .RunAction(ins =>
                {
                    while (!ins.IsCancellationRequested)
                    {
                        isRockingLadyTalking = true;
                        audioPlayer.PlayEffect("A conversation with Mother.wav");
                        ins.WaitFor(S(42), true);
                        isRockingLadyTalking = false;

                        ins.WaitFor(S(15.0));
                    }
                })
                .TearDown(ins =>
                {
                    audioPlayer.PauseFX();
                    ladyEyes.SetValue(false, this.controlToken);
                    rockingMotor.SetValue(false, this.controlToken);
                });

            PowerOn.RunAction(ins =>
                {
                    pulsatingRocking.Start(token: this.controlToken);
                    if (!isRockingLadyTalking)
                    {
                        switch (random.Next(3))
                        {
                            case 0:
                                audioPlayer.PlayEffect("032495843-old-woman-cough.wav");
                                break;

                            case 1:
                                audioPlayer.PlayEffect("049951942-grampy-old-woman-cackle.wav");
                                break;

                            case 2:
                                audioPlayer.PlayEffect("053851373-old-ungly-female-laughter.wav");
                                break;
                        }
                    }

                    ins.WaitFor(S(7));
                })
                .TearDown(ins =>
                {
                    pulsatingRocking.Stop();
                });
        }