Skip to content

Commit 4372452

Browse files
committed
Adds a clear to the output, and handles robot disconnects properly
Used to do giant stack trace, now spits out a proper error.
1 parent 6c48d98 commit 4372452

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

FRC-Extension/Buttons/DeployDebugButton.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using EnvDTE;
55
using EnvDTE80;
66
using Microsoft.VisualStudio.Shell;
7+
using Renci.SshNet.Common;
78
using VSLangProj;
89

910
namespace RobotDotNet.FRC_Extension.Buttons
@@ -52,19 +53,25 @@ public override async void ButtonCallback(object sender, EventArgs e)
5253
try
5354
{
5455
m_output.ProgressBarLabel = "Deploying Robot Code";
55-
56+
OutputWriter.Instance.Clear();
5657
SettingsPageGrid page;
5758
string teamNumber = m_package.GetTeamNumber(out page);
5859

5960
if (teamNumber == null) return;
6061

6162
//Disable the deploy buttons
6263
DisableAllButtons();
63-
DeployManager m = new DeployManager(m_package.PublicGetService(typeof(DTE)) as DTE);
64+
DeployManager m = new DeployManager(m_package.PublicGetService(typeof (DTE)) as DTE);
6465
await m.DeployCode(teamNumber, page, m_debugButton, m_robotProject);
6566
EnableAllButtons();
6667
m_output.ProgressBarLabel = "Robot Code Deploy Successful";
6768
}
69+
catch (SshConnectionException)
70+
{
71+
m_output.WriteLine("Connection to RoboRIO lost. Deploy aborted.");
72+
EnableAllButtons();
73+
m_output.ProgressBarLabel = "Robot Code Deploy Failed";
74+
}
6875
catch (Exception ex)
6976
{
7077
m_output.WriteLine(ex.ToString());

FRC-Extension/Buttons/InstallMonoButton.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using EnvDTE;
44
using Microsoft.VisualStudio.Shell;
55
using Microsoft.VisualStudio.Shell.Interop;
6+
using Renci.SshNet.Common;
67
using RobotDotNet.FRC_Extension.MonoCode;
78
using Task = System.Threading.Tasks.Task;
89

@@ -78,6 +79,13 @@ public override async void ButtonCallback(object sender, EventArgs e)
7879
}
7980
}
8081
}
82+
catch (SshConnectionException)
83+
{
84+
m_output.WriteLine("Connection to RoboRIO lost. Install aborted.");
85+
m_installing = false;
86+
menuCommand.Visible = true;
87+
m_output.ProgressBarLabel = "Mono Install Failed";
88+
}
8189
catch (Exception ex)
8290
{
8391
m_output.WriteLine(ex.ToString());

FRC-Extension/MonoCode/MonoDeploy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public MonoDeploy(string teamNumber, DeployManager deployManager, MonoFile monoF
2525
internal async Task DeployMono()
2626
{
2727
var writer = OutputWriter.Instance;
28+
writer.Clear();
2829

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

FRC-Extension/OutputWriter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ private void Initialize()
6060

6161
}
6262

63+
public void Clear()
64+
{
65+
if (!m_initialized)
66+
Initialize();
67+
if (!m_initialized) return;
68+
m_outputPane.Clear();
69+
}
70+
6371
public void Write(string value)
6472
{
6573
if (!m_initialized)

0 commit comments

Comments
 (0)