コード例 #1
0
        public override async void ButtonCallback(object sender, EventArgs e)
        {
            var menuCommand = sender as OleMenuCommand;
            if (menuCommand == null)
            {
                return;
            }
            if (!Deploying)
            {
                try
                {
                    Output.ProgressBarLabel = "Deploying Robot Code";
                    OutputWriter.Instance.Clear();
                    SettingsPageGrid page;
                    string teamNumber = Package.GetTeamNumber(out page);

                    if (teamNumber == null) return;

                    //Disable the deploy buttons
                    DisableAllButtons();
                    DeployManager m = new DeployManager(Package.PublicGetService(typeof (DTE)) as DTE);
                    bool success = await m.DeployCode(teamNumber, page, DebugButton, m_robotProject);
                    EnableAllButtons();
                    Output.ProgressBarLabel = success ? "Robot Code Deploy Successful" : "Robot Code Deploy Failed";
                }
                catch (SshConnectionException)
                {
                    Output.WriteLine("Connection to RoboRIO lost. Deploy aborted.");
                    EnableAllButtons();
                    Output.ProgressBarLabel = "Robot Code Deploy Failed";
                }
                catch (Exception ex)
                {
                    Output.WriteLine(ex.ToString());
                    EnableAllButtons();
                    Output.ProgressBarLabel = "Robot Code Deploy Failed";
                }

            }
        }
コード例 #2
0
        internal async Task DeployMono(OleMenuCommand menuCommand)
        {
            try
            {
                SettingsPageGrid page;
                string teamNumber = Package.GetTeamNumber(out page);

                if (teamNumber == null) return;



                //Disable Install Button
                m_installing = true;
                menuCommand.Visible = false;

                DeployManager m = new DeployManager(Package.PublicGetService(typeof(DTE)) as DTE);
                MonoDeploy deploy = new MonoDeploy(teamNumber, m, m_monoFile);

                await deploy.DeployMono();

                m_installing = false;
                menuCommand.Visible = true;

            }
            catch (Exception ex)
            {
                Output.WriteLine(ex.ToString());
                m_installing = false;
                menuCommand.Visible = true;
            }
        }
コード例 #3
0
 public MonoDeploy(string teamNumber, DeployManager deployManager, MonoFile monoFile)
 {
     m_deployManager = deployManager;
     m_teamNumber = teamNumber;
     m_monoFile = monoFile;
 }
コード例 #4
0
        public override async void ButtonCallback(object sender, EventArgs e)
        {
            var menuCommand = sender as OleMenuCommand;
            if (menuCommand == null)
            {
                return;
            }
            if (!m_killing)
            {
                try
                {
                    SettingsPageGrid page;
                    string teamNumber = Package.GetTeamNumber(out page);

                    if (teamNumber == null) return;

                    DeployManager m = new DeployManager(Package.PublicGetService(typeof (DTE)) as DTE);

                    var writer = OutputWriter.Instance;

                    menuCommand.Visible = false;
                    m_killing = true;

                    //Connect to RoboRIO
                    writer.WriteLine("Attempting to Connect to RoboRIO");

                    Task<bool> rioConnectionTask = m.StartConnectionTask(teamNumber);
                    Task delayTask = Task.Delay(10000);

                    //Successfully extracted files.

                    writer.WriteLine("Waiting for Connection to Finish");
                    if (await Task.WhenAny(rioConnectionTask, delayTask) == rioConnectionTask)
                    {
                        //Connected
                        if (rioConnectionTask.Result)
                        {
                            writer.WriteLine("Killing currently running robot code.");
                            await RoboRIOConnection.RunCommand(DeployProperties.KillOnlyCommand, ConnectionUser.LvUser);
                            writer.WriteLine("Done.");
                            m_killing = false;
                            menuCommand.Visible = true;
                        }
                        else
                        {
                            //Did not successfully connect
                            writer.WriteLine("Failed to Connect to RoboRIO. Exiting.");
                            m_killing = false;
                            menuCommand.Visible = true;
                        }
                    }
                    else
                    {
                        //Timedout
                        writer.WriteLine("RoboRIO connection timedout. Exiting.");
                        m_killing = false;
                        menuCommand.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    Output.WriteLine(ex.ToString());
                    m_killing = false;
                    menuCommand.Visible = true;
                    OutputWriter.Instance.WriteLine("Code Kill Failed");
                }
            }
        }