Exemple #1
0
        public int Connect(object sender)
        {
            active_controller = new HoltEnv.LEDController(
                "controller1",
                ip_address,
                port
                );

            TestConnection(sender);

            if (is_connected)
            {
                MessageAndroid temp = new MessageAndroid();
                temp.ShortAlert("Success");
                ThreadPool.QueueUserWorkItem(state => StartConnectionCheck(sender));
                return(0);
            }
            else
            {
                App.Current.MainPage.DisplayAlert("Oops!", "Connection failed. Check that connection info is correct and that device is on and connected to the same network.", "OK");
                return(-1);
            }
        }
Exemple #2
0
        /*
         * Should be used for all times that a button is clicked
         *
         * Need to figure out why status not being 0 causes the
         * child thread for checking connection to crash
         */
        public void OnButtonClicked(object sender, System.EventArgs e)
        {
            string command = GetViewElementName(sender);
            int    status  = 0;

            Debug.WriteLine("MainPage::OnButtonClicked - Command from button click is " + command);
            Debug.WriteLine("MainPage::OnButtonClicked - Command is 'ConnectToDevice': " + (command == "ConnectToDevice"));

            if (command == "ConnectToDevice")
            {
                if (!is_connected)
                {
                    Connect(sender);
                }
                else
                {
                    SetDisconnected(sender);
                }
            }
            else if (is_connected)
            {
                switch (command)
                {
                case "InputToDVI":
                    status = active_controller.SetInputToDVI();
                    break;

                case "InputToHDMI":
                    status = active_controller.SetInputToHDMI();
                    break;

                case "InputToVGA1":
                    status = active_controller.SetInputToVGA1();
                    break;

                case "InputToVGA2":
                    status = active_controller.SetInputToVGA2();
                    break;

                case "InputToSDI":
                    if ((status = active_controller.SetInputToSDI()) != 0)
                    {
                        MessageAndroid temp = new MessageAndroid();
                        temp.LongAlert("Failed. SDI not connected to device");
                        status = 0;
                    }
                    break;

                case "InputToDP":
                    status = active_controller.SetInputToDP();
                    break;
                }
            }
            else
            {
                App.Current.MainPage.DisplayAlert("Oops!", "Connect to device.", "OK");
            }

            if (status != 0)
            {
                Debug.WriteLine(status);
                App.Current.MainPage.DisplayAlert("Oops!", "An error occured in the HoltEnv LEDController library. LEDController was forced to disconnect.", "OK");
            }
        }