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));
            });
        }
示例#2
0
        private void stopSearching()
        {
            readSnd.Stop();
            BaseMessage msgPoweroff = new PowerOff();

            msgPoweroff.IsReturn = false;
            bool ret = reader.Send(msgPoweroff);

            if (ret)
            {
                IsRunning           = false;
                ibScan.Text         = "Scan";
                ibScan.Tag          = "Start";
                this.timer1.Enabled = false;
                AddToStatusAsync("Stop Scan Tag");

                Update();
            }
            else
            {
            }
        }
示例#3
0
        /// <summary>
        /// 读取标签或停止读取
        /// </summary>
        private void ReadLoopRaw(object sender, EventArgs e)
        {
            try
            {
                AddToStatusAsync("");
                if ((string)ibScan.Tag == "Start")
                {
                    string err = "";
                    totalTimes = 0;
                    //totalTags = 0;
                    readMoment = Environment.TickCount;
                    try
                    {
                        QValue = Convert.ToUInt16(txtqvalue.Text.Trim());
                        //MessageBox.Show(QValue.ToString);
                    }
                    catch
                    {
                        AddToStatusAsync("Q Value Must Be Integer!");
                        return;
                    }
                    readSnd.Start();
                    ReadTag msg = msg = ReadTagBll.ConcreateReadTag((byte)TargetCodeArea, QValue);

                    if (reader.Send(msg))
                    {
                        if (!ReadTagBll.IsLoop)
                        {
                            readSnd.Stop(); return;
                        }
                        IsRunning   = true;
                        ibScan.Text = "Stop";
                        ibScan.Tag  = "Stop";
                        AddToStatusAsync("Scanning Tag!");
                        this.timer1.Enabled = true;
                    }
                    else
                    {
                        AddToStatusAsync("Scan Failure !");
                    }
                }
                else
                {
                    readSnd.Stop();
                    BaseMessage msgPoweroff = new PowerOff();
                    msgPoweroff.IsReturn = false;
                    bool ret = reader.Send(msgPoweroff);
                    if (ret)
                    {
                        IsRunning           = false;
                        ibScan.Text         = "Scan";
                        ibScan.Tag          = "Start";
                        this.timer1.Enabled = false;
                        AddToStatusAsync("Stop Scan Tag");

                        Update();
                    }
                    else
                    {
                        AddToStatusAsync(" Stop Failure");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#4
0
 void Awake()
 {
     button = GetComponent <UIButton> ();
     power  = GetComponent <PowerOff> ();
 }
示例#5
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));
            });
        }