powerQuery() public method

Check power state of Projector. Returns unknown in case of an error
public powerQuery ( ) : PowerCommand.PowerStatus
return PowerCommand.PowerStatus
コード例 #1
0
        private void connect_Click(object sender, EventArgs e)
        {
            System.Net.IPAddress address = null;

            if (System.Net.IPAddress.TryParse(ipAddress.Text, out address))
            {
                Status.Text = "Connecting to " + address.ToString();
                c = new PJLinkConnection(ipAddress.Text, "JBMIAProjectorLink");

                LampStatusCommand l = new LampStatusCommand();
                int hours = l.getHoursOfLamp(1);
                string status = l.getStatusOfLamp(1).ToString();
                string power = c.powerQuery().ToString();
                ProjectorInfo pi = new ProjectorInfo();
                Status.Text = "Connected. \n Projector is now: " + power + "\n" + "\nstatus: " + status + "\nlamphours: " + hours;
                Status.Text += "\nFan:" + pi.FanStatus;
                Status.Text += " Lamp:" + pi.LampStatus;
                Status.Text += " Input:" + pi.Input;
                Status.Text += "\nCover:" + pi.CoverStatus;
                Status.Text += " Filter:" + pi.FilterStatus;
                Status.Text += " NumLamps:" + pi.NumOfLamps;
                Status.Text += "\nOthers:" + pi.PowerStatus;

            }
            else
            {
                Status.Text = "Invalid IP Address Entered";
            }
        }
コード例 #2
0
        async void _timerPowerCheck_Elapsed(object source, object e)
        {
            await Task.Run(async() =>
            {
                try
                {
                    rv.PJLinkConnection c            = connectBeamer();
                    PowerCommand.PowerStatus powStat = PowerCommand.PowerStatus.UNKNOWN;
                    try
                    {
                        powStat = await c.powerQuery();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            powStat = await c.powerQuery();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    switch (powStat)
                    {
                    case PowerCommand.PowerStatus.OFF:
                    case PowerCommand.PowerStatus.COOLING:
                    case PowerCommand.PowerStatus.UNKNOWN:
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            this.btnPwr.Background = btndefBack;
                            this.btnMute.IsEnabled = false;
                            _startupRoundCntr++;
                            if (_timerPowerCheck.Interval == new TimeSpan(0, 0, 5) && powStat != PowerCommand.PowerStatus.UNKNOWN)
                            {
                                _timerPowerCheck.Interval = new TimeSpan(0, 1, 0);     // 1min
                                _startupRoundCntr         = 0;
                                _timerPowerBlink.Stop();
                                this.btnPwr.Background = btndefBack;
                            }
                        });
                        break;

                    case PowerCommand.PowerStatus.ON:
                    case PowerCommand.PowerStatus.WARMUP:
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                        {
                            this._timerPowerBlink.Stop();
                            this.btnPwr.Background = new SolidColorBrush(Colors.LawnGreen);
                            this.btnMute.IsEnabled = true;
                            AVMuteCommand qcmd     = new AVMuteCommand(AVMuteCommand.Action.QUERYSTATE);
                            if (await c.sendCommand(qcmd) == Command.Response.SUCCESS)
                            {
                                if (qcmd.Status == AVMuteCommand.Action.MUTE)
                                {
                                    _timerMuteBlink.Start();
                                }
                                else
                                {
                                    _timerMuteBlink.Stop();
                                    btnMute.Background = btndefBack;
                                }
                            }
                            _startupRoundCntr++;
                            if (_timerPowerCheck.Interval == new TimeSpan(0, 0, 5) && _startupRoundCntr == 10)
                            {
                                _timerPowerCheck.Interval = new TimeSpan(0, 1, 0);     // 1min
                                _startupRoundCntr         = 0;
                                _timerPowerBlink.Stop();
                                this.btnPwr.Background = new SolidColorBrush(Colors.LawnGreen);
                            }
                        });
                        break;
                    }
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        if (_timerPowerCheck.Interval == new TimeSpan(0, 0, 5) && _startupRoundCntr == 10)
                        {
                            _timerPowerCheck.Interval = new TimeSpan(0, 1, 0); // 1min
                            _startupRoundCntr         = 0;
                            _timerPowerBlink.Stop();
                            this.btnPwr.Background = btndefBack;
                        }
                    });
                }
                catch (Exception)
                {
                }
            });
        }
コード例 #3
0
        private async void btnPwr_Click(object sender, RoutedEventArgs e)
        {
            await Task.Run(async() =>
            {
                try
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        this.btnPwr.Background = new SolidColorBrush(Colors.LawnGreen);
                        this.btnMute.IsEnabled = false;
                        _timerPowerBlink.Start();
                    });

                    rv.PJLinkConnection c            = connectBeamer();
                    PowerCommand.PowerStatus powStat = PowerCommand.PowerStatus.UNKNOWN;
                    try
                    {
                        powStat = await c.powerQuery();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            powStat = await c.powerQuery();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    switch (powStat)
                    {
                    case PowerCommand.PowerStatus.OFF:
                    case PowerCommand.PowerStatus.COOLING:
                    case PowerCommand.PowerStatus.UNKNOWN:
                        await c.turnOn();
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            _timerPowerCheck.Interval = new TimeSpan(0, 0, 5);     //10 sec;
                        });

                        break;

                    case PowerCommand.PowerStatus.ON:
                    case PowerCommand.PowerStatus.WARMUP:
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            this.btnPwr.Background = btndefBack;
                            this.btnMute.IsEnabled = false;
                            _timerMuteBlink.Stop();
                            _timerPowerBlink.Stop();
                            btnMute.Background = btndefBack;
                        });
                        await c.turnOff();
                        break;
                    }
                }
                catch (Exception)
                {
                }
            });
        }
コード例 #4
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (!LoadConfig())
            {
                tmrTimer.Stop();
                txtTime.Text       = "Invalid Config";
                btnMute.Visibility = Visibility.Collapsed;
                btnPwr.Visibility  = Visibility.Collapsed;
                btnInfo.Visibility = Visibility.Collapsed;
            }
            btndefBack = btnPwr.Background;

            // Hook up the Elapsed event for the timer.
            _timerMuteBlink.Tick += _timerMuteBlink_Elapsed;

            // Set the Interval to 0.5 seconds (500 milliseconds).
            _timerMuteBlink.Interval = new TimeSpan(0, 0, 0, 0, 500);

            _timerPowerCheck.Tick    += _timerPowerCheck_Elapsed;
            _timerPowerCheck.Interval = new TimeSpan(0, 1, 0); // 1min
            _timerPowerCheck.Start();

            _timerPowerBlink.Tick    += _timerPowerBlink_Elapsed;
            _timerPowerBlink.Interval = new TimeSpan(0, 0, 0, 0, 500); // 0.5sec

            rv.PJLinkConnection      c       = connectBeamer();
            PowerCommand.PowerStatus powStat = PowerCommand.PowerStatus.UNKNOWN;
            try
            {
                powStat = await c.powerQuery();
            }
            catch (Exception)
            {
                try
                {
                    powStat = await c.powerQuery();
                }
                catch (Exception)
                {
                }
            }
            switch (powStat)
            {
            case PowerCommand.PowerStatus.OFF:
            case PowerCommand.PowerStatus.COOLING:
            case PowerCommand.PowerStatus.UNKNOWN:
                this.btnPwr.Background = btndefBack;
                this.btnMute.IsEnabled = false;
                break;

            case PowerCommand.PowerStatus.ON:
            case PowerCommand.PowerStatus.WARMUP:
                this.btnPwr.Background = new SolidColorBrush(Colors.LawnGreen);
                this.btnMute.IsEnabled = true;
                try
                {
                    AVMuteCommand qcmd = new AVMuteCommand(AVMuteCommand.Action.QUERYSTATE);
                    if (await c.sendCommand(qcmd) == Command.Response.SUCCESS)
                    {
                        if (qcmd.Status == AVMuteCommand.Action.MUTE)
                        {
                            _timerMuteBlink.Start();
                        }
                        else
                        {
                            _timerMuteBlink.Stop();
                        }
                    }
                }
                catch (Exception)
                {
                }
                break;
            }
        }