public BrightnessPowerAdapter(DigitalOutput2 device)
 {
     this.inputBrightness = Observer.Create<DoubleZeroToOne>(x =>
         {
             device.SetValue(x.Value > 0.1);
         });
 }
        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));
            });
        }
Beispiel #3
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));
            });
        }
Beispiel #4
0
        public BaseLight(DigitalOutput2 logicalDevice)
            : base(logicalDevice)
        {
            this.colorBrightness = new ColorBrightness(Color.White, 0.0);

            var sendsData = logicalDevice as ISendsData;
            if (sendsData != null)
            {
                sendsData.OutputChanged.Subscribe(x =>
                {
                    SetFromIData(logicalDevice, x);

                    Output();
                });

                SetFromIData(logicalDevice, sendsData.CurrentData);
            }
        }
Beispiel #5
0
        public BaseLight(DigitalOutput2 logicalDevice)
            : base(logicalDevice)
        {
            this.colorBrightness = new ColorBrightness(Color.White, 0.0);

            var sendsData = logicalDevice as ISendsData;

            if (sendsData != null)
            {
                sendsData.OutputChanged.Subscribe(x =>
                {
                    SetFromIData(logicalDevice, x);

                    Output();
                });

                SetFromIData(logicalDevice, sendsData.CurrentData);
            }
        }
Beispiel #6
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);
            });
        }
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(DigitalOutput2 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = logicalDevice.Name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var centerControl = new Control.CenterControl();

            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();

            control.On   = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                if (PendingClose)
                {
                    return;
                }

                Task.Run(() =>
                {
                    this.UIThread(delegate
                    {
                        control.On = x;
                    });
                });
            });

            device.Connect(logicalDevice);

            return(device);
        }
Beispiel #8
0
 public GenericDimmer(DigitalOutput2 logicalDevice, int dmxChannel)
     : base(logicalDevice)
 {
     this.baseDmxChannel = dmxChannel;
 }
Beispiel #9
0
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(DigitalOutput2 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = logicalDevice.Name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var centerControl = new Control.CenterControl();
            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();
            control.On = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                if (PendingClose)
                    return;

                Task.Run(() =>
                {
                    this.UIThread(delegate
                    {
                        control.On = x;
                    });
                });
            });

            device.Connect(logicalDevice);

            return device;
        }
        public FireProjector(
            DigitalOutput2 fire,
            [System.Runtime.CompilerServices.CallerMemberName] string name = "")
            : base(name)
        {
            this.inputTrigger1.Subscribe(x =>
            {
                if (x)
                {
                    if (this.inputTriggerBlock.Value)
                    {
                        this.log.Verbose("{Name} has been triggered on 1, but is blocked", Name);
                    }
                    else
                    {
                        if (Power)
                        {
                            this.log.Verbose("Trigger 1 for {Name}", Name);
                            Executor.Current.Execute(this.sub1);
                        }
                    }
                }
            });

            this.inputTrigger2.Subscribe(x =>
            {
                if (x)
                {
                    if (this.inputTriggerBlock.Value)
                    {
                        this.log.Verbose("{Name} has been triggered on 2, but is blocked", Name);
                    }
                    else
                    {
                        if (Power)
                        {
                            this.log.Verbose("Trigger 2 for {Name}", Name);
                            Executor.Current.Execute(this.sub2);
                        }
                    }
                }
            });

            this.inputTriggerBlock.Subscribe(x =>
            {
                this.log.Verbose("Trigger block for {Name} changed to {TriggerBlock}", Name, x);
            });

            OutputPower.Subscribe(x =>
            {
                if (x)
                {
                    LockDevices(fire);
                }
                else
                {
                    UnlockDevices();
                }
            });

            sub1.RunAction(ins =>
            {
                fire.SetValue(true, this.controlToken);
                ins.WaitFor(S(0.5));
            })
            .TearDown(ins =>
            {
                fire.SetValue(false, this.controlToken);
            });

            sub2.RunAction(ins =>
            {
                fire.SetValue(true, this.controlToken);
                ins.WaitFor(S(2.0));
            })
            .TearDown(ins =>
            {
                fire.SetValue(false, this.controlToken);
            });
        }
Beispiel #11
0
 public GenericDimmer(DigitalOutput2 logicalDevice, int dmxChannel)
     : base(logicalDevice)
 {
     this.baseDmxChannel = dmxChannel;
 }
Beispiel #12
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();
                });
        }
Beispiel #13
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));
            });
        }