示例#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";
            }
        }
        public static async Task <ProjectorInfo> create(PJLinkConnection c)
        {
            ProjectorInfo pi = new ProjectorInfo();

            pi._projectorHostName = c.HostName;
            ProjectorNameCommand pnc = new ProjectorNameCommand();

            if (await c.sendCommand(pnc) == Command.Response.SUCCESS)
            {
                pi._projectorHostName = pnc.Name;
            }

            ManufacturerNameCommand mnc = new ManufacturerNameCommand();

            if (await c.sendCommand(mnc) == Command.Response.SUCCESS)
            {
                pi._projectorManufacturerName = mnc.Manufacturer;
            }

            ProductNameCommand prnc = new ProductNameCommand();

            if (await c.sendCommand(prnc) == Command.Response.SUCCESS)
            {
                pi._projectorProductName = prnc.ProductName;
            }

            ErrorStatusCommand esc = new ErrorStatusCommand();

            if (await c.sendCommand(esc) == Command.Response.SUCCESS)
            {
                pi._fanStatus    = esc.FanStatus;
                pi._lampStatus   = esc.LampStatus;
                pi._coverStatus  = esc.CoverStatus;
                pi._filterStatus = esc.FilterStatus;
                pi._otherStatus  = esc.OtherStatus;
            }

            PowerCommand pc = new PowerCommand(PowerCommand.Power.QUERY);

            if (await c.sendCommand(pc) == Command.Response.SUCCESS)
            {
                pi._powerStatus = pc.Status;
            }

            LampStatusCommand lsc = new LampStatusCommand();

            if (await c.sendCommand(lsc) == Command.Response.SUCCESS)
            {
                pi._multiLampStatus = lsc.StatusList;
                pi._multiLampHours  = lsc.HoursList;
                pi._numOfLamps      = lsc.NumOfLamps;
            }

            InputCommand ic = new InputCommand();

            if (await c.sendCommand(ic) == Command.Response.SUCCESS)
            {
                pi._input     = ic.Input;
                pi._inputPort = ic.Port;
            }

            return(pi);
        }
        public static ProjectorInfo create(PJLinkConnection c)
        {
            ProjectorInfo pi = new ProjectorInfo();
            pi._projectorHostName = c.HostName;
            ProjectorNameCommand pnc = new ProjectorNameCommand();
            if (c.sendCommand(pnc) == Command.Response.SUCCESS)
                pi._projectorHostName = pnc.Name;

            ManufacturerNameCommand mnc = new ManufacturerNameCommand();
            if (c.sendCommand(mnc) == Command.Response.SUCCESS)
                pi._projectorManufacturerName = mnc.Manufacturer;

            ProductNameCommand prnc = new ProductNameCommand();
            if (c.sendCommand(prnc) == Command.Response.SUCCESS)
                pi._projectorProductName = prnc.ProductName;

            ErrorStatusCommand esc = new ErrorStatusCommand();
            if (c.sendCommand(esc) == Command.Response.SUCCESS)
            {
                pi._fanStatus = esc.FanStatus;
                pi._lampStatus = esc.LampStatus;
                pi._coverStatus = esc.CoverStatus;
                pi._filterStatus = esc.FilterStatus;
                pi._otherStatus = esc.OtherStatus;
            }

            PowerCommand pc = new PowerCommand(PowerCommand.Power.QUERY);
            if (c.sendCommand(pc) == Command.Response.SUCCESS)
                pi._powerStatus = pc.Status;

            LampStatusCommand lsc = new LampStatusCommand();
            if (c.sendCommand(lsc) == Command.Response.SUCCESS)
            {
                pi._multiLampStatus = lsc.StatusList;
                pi._multiLampHours = lsc.HoursList;
                pi._numOfLamps = lsc.NumOfLamps;
            }

            InputCommand ic = new InputCommand();
            if (c.sendCommand(ic) == Command.Response.SUCCESS)
            {
                pi._input = ic.Input;
                pi._inputPort = ic.Port;
            }

            return pi;
        }