diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-04 19:46:22 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-04 19:46:22 +0300 |
| commit | 77b37339decd9c023d4ced37e677797f5b72c3ae (patch) | |
| tree | 8a536eda6721abfb310b07cd4b645d1273ef5160 /Software | |
| parent | 24e5224eb41da3a736c46235567c8ba5484414e3 (diff) | |
| download | Tango-77b37339decd9c023d4ced37e677797f5b72c3ae.tar.gz Tango-77b37339decd9c023d4ced37e677797f5b72c3ae.zip | |
Implemented VSIX remote debugger!!!!
Diffstat (limited to 'Software')
17 files changed, 367 insertions, 164 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 1443bd4a4..cf8cacc34 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 996115adb..065a0002f 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Visual_Studio/Tango.Core/IO/TemporaryFile.cs b/Software/Visual_Studio/Tango.Core/IO/TemporaryFile.cs index 3e5bd579e..7cb720260 100644 --- a/Software/Visual_Studio/Tango.Core/IO/TemporaryFile.cs +++ b/Software/Visual_Studio/Tango.Core/IO/TemporaryFile.cs @@ -15,6 +15,14 @@ namespace Tango.Core.IO public class TemporaryFile : TemporaryItem { /// <summary> + /// Gets the name of the file. + /// </summary> + public String FileName + { + get { return System.IO.Path.GetFileName(Path); } + } + + /// <summary> /// Initializes a new instance of the <see cref="TemporaryFile"/> class. /// </summary> /// <param name="path">The temporary item path.</param> diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index e34b2e86d..4d058d1fb 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -69,7 +69,6 @@ namespace Tango.Logging Categories = new List<LogCategory>(); Categories.Add(LogCategory.Critical); - Categories.Add(LogCategory.Debug); Categories.Add(LogCategory.Error); Categories.Add(LogCategory.Info); Categories.Add(LogCategory.Warning); diff --git a/Software/Visual_Studio/Tango.Transport/Discovery/DiscoveredService.cs b/Software/Visual_Studio/Tango.Transport/Discovery/DiscoveredService.cs index a9626284f..27750492e 100644 --- a/Software/Visual_Studio/Tango.Transport/Discovery/DiscoveredService.cs +++ b/Software/Visual_Studio/Tango.Transport/Discovery/DiscoveredService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; @@ -24,12 +25,19 @@ namespace Tango.Transport.Discovery public String Address { get; set; } /// <summary> + /// Gets or sets the name of the host. + /// </summary> + public String HostName { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="DiscoveredService{DiscoveryMessage}"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="message">The message.</param> - public DiscoveredService(String address, DiscoveryMessage message) + /// <param name="hostName">The host name.</param> + public DiscoveredService(String address, String hostName, DiscoveryMessage message) { + HostName = hostName; Address = address; Message = message; } diff --git a/Software/Visual_Studio/Tango.Transport/Discovery/UdpDiscoveryClient.cs b/Software/Visual_Studio/Tango.Transport/Discovery/UdpDiscoveryClient.cs index 617aea61a..ee3f4cc58 100644 --- a/Software/Visual_Studio/Tango.Transport/Discovery/UdpDiscoveryClient.cs +++ b/Software/Visual_Studio/Tango.Transport/Discovery/UdpDiscoveryClient.cs @@ -60,7 +60,7 @@ namespace Tango.Transport.Discovery if (!IsStarted) { _timer = new Timer(); - _timer.Interval = Interval.TotalMilliseconds; + _timer.Interval = 10; _timer.Elapsed += _timer_Elapsed; _timer.Enabled = true; _timer.Start(); @@ -88,6 +88,10 @@ namespace Tango.Transport.Discovery /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> private void _timer_Elapsed(object sender, ElapsedEventArgs e) { + _timer.Interval = Interval.TotalMilliseconds; + + if (!IsStarted) return; + UdpClient udpClient = new UdpClient(Port); udpClient.Client.ReceiveTimeout = (int)_timer.Interval; var endPoint = new IPEndPoint(IPAddress.Any, 0); @@ -97,14 +101,19 @@ namespace Tango.Transport.Discovery var data = udpClient.Receive(ref endPoint); udpClient.Close(); + if (!IsStarted) return; + DiscoveryMessage message = Activator.CreateInstance<DiscoveryMessage>(); var parser = message.GetParser(); message = (DiscoveryMessage)parser.ParseFrom(data); + var host = Dns.GetHostEntry(endPoint.Address); + ServiceDiscovered?.Invoke(this, new DiscoveredService<DiscoveryMessage>( endPoint.Address.ToString(), + host != null ? host.HostName : "Unresolved", message)); } catch { } diff --git a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs index 21bdf3295..35248c862 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs @@ -20,7 +20,7 @@ namespace Tango.UnitTesting { [TestClass] [TestCategory("Remote Runner")] - public class RemoteRunner_TST + public class RemoteRunner_TST { [TestMethod] public void Run_Remote_Runner_Connect_Upload_And_Execute_Process() @@ -63,7 +63,7 @@ namespace Tango.UnitTesting long remaining = exeFile.Length - currentFilePosition; - byte[] buffer = new byte[uploadResponse.MaxChunkLength > remaining ? uploadResponse.MaxChunkLength : remaining]; + byte[] buffer = new byte[uploadResponse.MaxChunkLength < remaining ? uploadResponse.MaxChunkLength : remaining]; fs.Read(buffer, 0, buffer.Length); chunkRequest.Buffer = ByteString.CopyFrom(buffer); diff --git a/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/MainWindowVM.cs b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/MainWindowVM.cs index fd1b05e15..b25f79452 100644 --- a/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/MainWindowVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/MainWindowVM.cs @@ -29,7 +29,7 @@ namespace Tango.RemoteRunner.UI private UdpDiscoveryService<BasicDiscoveryMessage> _discoveryService; private const int PORT = 9595; private List<FileUpload> _uploads; - private const long MAX_CHUNK_LENGTH = 1024; + private const long MAX_CHUNK_LENGTH = 500000; //500kb private Action<String> _notificationAction; private ObservableCollection<RunningProcess> _runningProcesses; @@ -74,7 +74,7 @@ namespace Tango.RemoteRunner.UI _discoveryService = new UdpDiscoveryService<BasicDiscoveryMessage>(2018, new BasicDiscoveryMessage() { - ServiceName = "Tango Remote Debugger", + ServiceName = "Tango Remote Runner", Port = PORT, }); @@ -192,6 +192,11 @@ namespace Tango.RemoteRunner.UI RunningProcess process = new RunningProcess(); process.Process = Process.Start(Path.Combine(upload.Folder.Path, Path.GetFileName(request.Message.FileName))); + process.Process.Exited += (_, __) => + { + RunningProcesses.Remove(process); + }; + LogManager.Log("Process started " + process.ProcessName + ", " + process.ProcessID); InvokeUINow(() => diff --git a/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/Tango.RemoteRunner.UI.csproj b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/Tango.RemoteRunner.UI.csproj index 99921bdcb..cf48ecd39 100644 --- a/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/Tango.RemoteRunner.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/Tango.RemoteRunner.UI.csproj @@ -35,6 +35,9 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup> + <ApplicationIcon>process_big.ico</ApplicationIcon> + </PropertyGroup> <ItemGroup> <Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL"> <HintPath>..\..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath> @@ -153,6 +156,9 @@ <ItemGroup> <EmbeddedResource Include="process_task.ico" /> </ItemGroup> + <ItemGroup> + <Resource Include="process_big.ico" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('..\..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> diff --git a/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/process_big.ico b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/process_big.ico Binary files differnew file mode 100644 index 000000000..fb9f07af2 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.RemoteRunner.UI/process_big.ico diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs index 5b019eddc..2acc25187 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs @@ -12,6 +12,14 @@ using Microsoft.VisualStudio.Shell.Interop; using System.Linq; using System.IO; using System.Diagnostics; +using Tango.Transport; +using Tango.Transport.Adapters; +using Tango.Transport.Transporters; +using System.IO.Compression; +using Tango.Core.IO; +using Tango.PMR.IO; +using Google.Protobuf; +using EnvDTE; namespace Tango.BuildExtensions { @@ -20,7 +28,10 @@ namespace Tango.BuildExtensions /// </summary> internal sealed class RemoteDebugCommand : VSIXBase { - private const string SHARED_PATH = @"\\twine01\data\RemoteDebugging"; + private DebuggerEvents _dteDebuggerEvents; + private ITransporter transporter; + private bool _attached; + private string processId; /// <summary> /// Command ID. @@ -49,6 +60,10 @@ namespace Tango.BuildExtensions throw new ArgumentNullException("package"); } + _dteDebuggerEvents = DTE.Events.DebuggerEvents; + + _dteDebuggerEvents.OnEnterDesignMode += _dteDebuggerEvents_OnEnterDesignMode; + this.package = package; OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; @@ -60,6 +75,33 @@ namespace Tango.BuildExtensions } } + private async void _dteDebuggerEvents_OnEnterDesignMode(dbgEventReason Reason) + { + if (_attached) + { + if (Reason == dbgEventReason.dbgEventReasonStopDebugging) + { + _attached = false; + + if (transporter != null) + { + OpenVSProgress("Tango Remote Runner", "Closing remote process...", true); + + await transporter.SendRequest<KillProcessRequest, KillProcessResponse>(new KillProcessRequest() + { + ProcessID = processId, + }); + await transporter.Disconnect(); + transporter = null; + + await System.Threading.Tasks.Task.Delay(2000); + + CloseVSProgress(); + } + } + } + } + /// <summary> /// Gets the instance of the command. /// </summary> @@ -104,6 +146,8 @@ namespace Tango.BuildExtensions private void RunRemote() { + _attached = false; + try { String projectName = DTE.Solution.Properties.Item("StartupProject").Value.ToString(); @@ -112,56 +156,109 @@ namespace Tango.BuildExtensions if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - System.Threading.Tasks.Task.Factory.StartNew(() => + System.Threading.Tasks.Task.Factory.StartNew(async () => { - OpenProgressForm(); + try + { + OpenVSProgress("Tango Remote Runner", "Connecting to " + dlg.SelectedRemoteRunner.HostName + "...", true); + + ITransportAdapter adapter = new TcpTransportAdapter(dlg.SelectedRemoteRunner.Address, dlg.SelectedRemoteRunner.Port); + transporter = new BasicTransporter(adapter); + await transporter.Connect(); + + SetVSProgress("Building " + projectName + "..."); + + var project = GetSolutionProjects().SingleOrDefault(x => x.Name == projectName); + + String filePath = GetProjectOutputFilePath(project); + String folder = Path.GetDirectoryName(filePath); + String fileName = Path.GetFileName(filePath); + + DTE.Solution.SolutionBuild.BuildProject("Debug", project.FullName, true); + + var tempFolder = TemporaryManager.Default.CreateFolder(); + var zipFile = tempFolder.CreateFile(".zip"); + + await zipFile.DeleteAsync(); + SetVSProgress("Packaging project..."); + ZipFile.CreateFromDirectory(folder, zipFile.Path); + + FileInfo zipFileInfo = new FileInfo(zipFile); + + CloseVSProgress(); + + OpenVSProgress("Tango Remote Runner", "Uploading project...", false); + + var upResponse = await transporter.SendRequest<FileUploadRequest, FileUploadResponse>(new FileUploadRequest() + { + FileName = zipFile.FileName, + Length = zipFileInfo.Length, + }); + + var uploadResponse = upResponse.Message; + + int currentFilePosition = 0; + + do + { + using (FileStream fs = new FileStream(zipFileInfo.FullName, FileMode.Open)) + { + fs.Position = currentFilePosition; + + FileChunkUploadRequest chunkRequest = new FileChunkUploadRequest(); + chunkRequest.UploadID = uploadResponse.UploadID; + + long remaining = zipFileInfo.Length - currentFilePosition; + + byte[] buffer = new byte[uploadResponse.MaxChunkLength < remaining ? uploadResponse.MaxChunkLength : remaining]; + await fs.ReadAsync(buffer, 0, buffer.Length); + chunkRequest.Buffer = ByteString.CopyFrom(buffer); + + await transporter.SendRequest<FileChunkUploadRequest, FileChunkUploadResponse>(chunkRequest); + + currentFilePosition += buffer.Length; + + SetVSProgress("Uploading project...", "", currentFilePosition, (int)zipFileInfo.Length); + } + + } while (currentFilePosition < zipFileInfo.Length); - SetProgressText("Building " + projectName + "..."); + Wait(1000); - var project = GetSolutionProjects().SingleOrDefault(x => x.Name == projectName); + CloseVSProgress(); - String filePath = GetProjectOutputFilePath(project); - String folder = Path.GetDirectoryName(filePath); - String fileName = Path.GetFileName(filePath); - String remoteFolder = Path.Combine(dlg.SharedFolder, projectName); - String remoteFilePath = Path.Combine(remoteFolder, fileName); + OpenVSProgress("Tango Remote Runner", "Executing remote process...", true); - DTE.Solution.SolutionBuild.BuildProject("Debug", project.FullName, true); + var response = await transporter.SendRequest<ExecuteProcessRequest, ExecuteProcessResponse>(new ExecuteProcessRequest() + { + UploadID = uploadResponse.UploadID, + FileName = fileName, + }, TimeSpan.FromSeconds(30)); - Directory.CreateDirectory(remoteFolder); + processId = response.Message.ProcessID; - CopyDirectory(folder, remoteFolder, true, (file) => - { - SetProgressText("Copying " + Path.GetFileName(file) + "..."); - }); + SetVSProgress("Attaching Debugger..."); - String PsExecPath = GetFullPathToContentFile("PsExec.exe"); + var debugger = DTE.Debugger as EnvDTE80.Debugger2; + var transport = debugger.Transports.Item("Remote"); + var process = debugger.GetProcesses(transport, dlg.SelectedRemoteRunner.Address).Item(fileName) as EnvDTE80.Process2; + process.Attach(); + _attached = true; - SetProgressText("Executing remote process..."); - Process p = new Process(); - p.StartInfo.FileName = PsExecPath; - p.StartInfo.UseShellExecute = false; - p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - p.StartInfo.CreateNoWindow = true; - p.EnableRaisingEvents = true; - p.StartInfo.RedirectStandardError = true; - p.StartInfo.RedirectStandardOutput = false; - p.ErrorDataReceived += (x, e) => + CloseVSProgress(); + } + catch (Exception ex) { - SetProgressText("The process will start shortly, please wait..."); - Wait(20000); - CloseProgressForm(); - }; - p.StartInfo.Arguments = String.Format("-u {0} -p {1} -i {2} \"{3}\" -accepteula", dlg.UserName, dlg.Password, dlg.HostName, remoteFilePath); - p.Start(); - p.BeginErrorReadLine(); + CloseVSProgress(); + ShowMessage(ex.Message); + } }); } } catch (Exception ex) { - CloseProgressForm(); + CloseVSProgress(); ShowMessage(ex.Message); } } diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.Designer.cs b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.Designer.cs index f05bdc8e5..9a3ee1bc9 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.Designer.cs +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.Designer.cs @@ -29,20 +29,15 @@ private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); - this.label5 = new System.Windows.Forms.Label(); - this.txtPass = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.txtUserName = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); this.txtProjectName = new System.Windows.Forms.Label(); - this.txtHostName = new System.Windows.Forms.TextBox(); this.btnCancel = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.txtSharedFolder = new System.Windows.Forms.TextBox(); + this.listServices = new System.Windows.Forms.ListBox(); + this.label3 = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -50,15 +45,10 @@ // panel1 // this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panel1.Controls.Add(this.label6); - this.panel1.Controls.Add(this.txtSharedFolder); - this.panel1.Controls.Add(this.label5); - this.panel1.Controls.Add(this.txtPass); - this.panel1.Controls.Add(this.label4); - this.panel1.Controls.Add(this.txtUserName); + this.panel1.Controls.Add(this.progressBar1); this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.listServices); this.panel1.Controls.Add(this.txtProjectName); - this.panel1.Controls.Add(this.txtHostName); this.panel1.Controls.Add(this.btnCancel); this.panel1.Controls.Add(this.btnOK); this.panel1.Controls.Add(this.pictureBox1); @@ -70,84 +60,17 @@ this.panel1.Size = new System.Drawing.Size(561, 353); this.panel1.TabIndex = 2; // - // label5 - // - this.label5.AutoSize = true; - this.label5.Cursor = System.Windows.Forms.Cursors.Arrow; - this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(255, 218); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(68, 16); - this.label5.TabIndex = 18; - this.label5.Text = "Password"; - // - // txtPass - // - this.txtPass.BackColor = System.Drawing.Color.Black; - this.txtPass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtPass.ForeColor = System.Drawing.Color.White; - this.txtPass.Location = new System.Drawing.Point(258, 240); - this.txtPass.Name = "txtPass"; - this.txtPass.Size = new System.Drawing.Size(170, 20); - this.txtPass.TabIndex = 17; - this.txtPass.Text = "Aa123456"; - this.txtPass.UseSystemPasswordChar = true; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Cursor = System.Windows.Forms.Cursors.Arrow; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(98, 218); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(77, 16); - this.label4.TabIndex = 16; - this.label4.Text = "User Name"; - // - // txtUserName - // - this.txtUserName.BackColor = System.Drawing.Color.Black; - this.txtUserName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtUserName.ForeColor = System.Drawing.Color.White; - this.txtUserName.Location = new System.Drawing.Point(101, 240); - this.txtUserName.Name = "txtUserName"; - this.txtUserName.Size = new System.Drawing.Size(148, 20); - this.txtUserName.TabIndex = 15; - this.txtUserName.Text = "panel-pc"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Cursor = System.Windows.Forms.Cursors.Arrow; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(98, 154); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(76, 16); - this.label3.TabIndex = 14; - this.label3.Text = "Host Name"; - // // txtProjectName // this.txtProjectName.AutoSize = true; this.txtProjectName.Cursor = System.Windows.Forms.Cursors.Arrow; this.txtProjectName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtProjectName.Location = new System.Drawing.Point(255, 45); + this.txtProjectName.Location = new System.Drawing.Point(205, 45); this.txtProjectName.Name = "txtProjectName"; this.txtProjectName.Size = new System.Drawing.Size(87, 16); this.txtProjectName.TabIndex = 13; this.txtProjectName.Text = "Project name"; // - // txtHostName - // - this.txtHostName.BackColor = System.Drawing.Color.Black; - this.txtHostName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtHostName.ForeColor = System.Drawing.Color.White; - this.txtHostName.Location = new System.Drawing.Point(101, 173); - this.txtHostName.Name = "txtHostName"; - this.txtHostName.Size = new System.Drawing.Size(327, 20); - this.txtHostName.TabIndex = 12; - this.txtHostName.Text = "\\\\PANEL-PC"; - // // btnCancel // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -198,9 +121,9 @@ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(98, 45); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(151, 16); + this.label2.Size = new System.Drawing.Size(103, 16); this.label2.TabIndex = 1; - this.label2.Text = "Remote Debug Project: "; + this.label2.Text = "Remote Debug:"; // // label1 // @@ -216,27 +139,42 @@ this.label1.Text = "Run On Remote Machine"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // label6 + // listServices // - this.label6.AutoSize = true; - this.label6.Cursor = System.Windows.Forms.Cursors.Arrow; - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(99, 90); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(94, 16); - this.label6.TabIndex = 20; - this.label6.Text = "Shared Folder"; + this.listServices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listServices.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.listServices.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listServices.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.listServices.ForeColor = System.Drawing.Color.Gainsboro; + this.listServices.FormattingEnabled = true; + this.listServices.ItemHeight = 20; + this.listServices.Location = new System.Drawing.Point(101, 135); + this.listServices.Name = "listServices"; + this.listServices.Size = new System.Drawing.Size(447, 140); + this.listServices.TabIndex = 14; // - // txtSharedFolder + // label3 // - this.txtSharedFolder.BackColor = System.Drawing.Color.Black; - this.txtSharedFolder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtSharedFolder.ForeColor = System.Drawing.Color.White; - this.txtSharedFolder.Location = new System.Drawing.Point(102, 109); - this.txtSharedFolder.Name = "txtSharedFolder"; - this.txtSharedFolder.Size = new System.Drawing.Size(327, 20); - this.txtSharedFolder.TabIndex = 19; - this.txtSharedFolder.Text = "\\\\PANEL-PC\\Shared Build"; + this.label3.AutoSize = true; + this.label3.Cursor = System.Windows.Forms.Cursors.Arrow; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(98, 112); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(172, 15); + this.label3.TabIndex = 15; + this.label3.Text = "Scanning for remote runners..."; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(101, 277); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(447, 5); + this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; + this.progressBar1.TabIndex = 16; // // RemoteDebugForm // @@ -271,14 +209,9 @@ private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.TextBox txtHostName; - private System.Windows.Forms.Label label3; private System.Windows.Forms.Label txtProjectName; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox txtPass; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox txtUserName; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.TextBox txtSharedFolder; + private System.Windows.Forms.ListBox listServices; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ProgressBar progressBar1; } }
\ No newline at end of file diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.cs b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.cs index fe44ee664..99961cfcb 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.cs +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugForm.cs @@ -7,15 +7,30 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Tango.PMR.Discovery; +using Tango.Transport.Discovery; namespace Tango.BuildExtensions { public partial class RemoteDebugForm : Form { - public String HostName { get; set; } - public String UserName { get; set; } - public String Password { get; set; } - public String SharedFolder { get; set; } + private bool closed; + + public class RemoteRunnerService + { + public String Address { get; set; } + public String HostName { get; set; } + public int Port { get; set; } + + public override string ToString() + { + return String.Format("[{0}] - [{1}:{2}]", HostName, Address, Port); + } + } + + private UdpDiscoveryClient<BasicDiscoveryMessage> _discoveryClient; + + public RemoteRunnerService SelectedRemoteRunner { get; set; } public RemoteDebugForm(String projectName) { @@ -25,6 +40,40 @@ namespace Tango.BuildExtensions btnOK.Click += BtnOK_Click; btnCancel.Click += BtnCancel_Click; + + btnOK.Enabled = false; + + _discoveryClient = new UdpDiscoveryClient<BasicDiscoveryMessage>(2018); + _discoveryClient.ServiceDiscovered += _discoveryClient_ServiceDiscovered; + + listServices.SelectedIndexChanged += ListServices_SelectedIndexChanged; + } + + private void ListServices_SelectedIndexChanged(object sender, EventArgs e) + { + btnOK.Enabled = listServices.SelectedItem != null; + } + + private void _discoveryClient_ServiceDiscovered(object sender, DiscoveredService<BasicDiscoveryMessage> e) + { + if (!closed) + { + BeginInvoke(new Action(() => + { + if (e.Message.ServiceName == "Tango Remote Runner") + { + if (!listServices.Items.OfType<RemoteRunnerService>().ToList().Exists(x => x.Address == e.Address)) + { + listServices.Items.Add(new RemoteRunnerService() + { + Address = e.Address, + HostName = e.HostName, + Port = e.Message.Port, + }); + } + } + })); + } } private void BtnCancel_Click(object sender, EventArgs e) @@ -35,12 +84,24 @@ namespace Tango.BuildExtensions private void BtnOK_Click(object sender, EventArgs e) { - HostName = txtHostName.Text; - UserName = txtUserName.Text; - Password = txtPass.Text; - SharedFolder = txtSharedFolder.Text; - DialogResult = DialogResult.OK; - Close(); + if (listServices.SelectedItem != null) + { + SelectedRemoteRunner = listServices.SelectedItem as RemoteRunnerService; + DialogResult = DialogResult.OK; + Close(); + } + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + _discoveryClient.Start(); + } + + protected override void OnClosed(EventArgs e) + { + closed = true; + _discoveryClient.Stop(); } } } diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/Tango.BuildExtensions.csproj b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/Tango.BuildExtensions.csproj index 86c9bd2b8..b18d5c3d2 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/Tango.BuildExtensions.csproj +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/Tango.BuildExtensions.csproj @@ -24,7 +24,7 @@ <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup> - <SignAssembly>true</SignAssembly> + <SignAssembly>false</SignAssembly> </PropertyGroup> <PropertyGroup> <AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile> @@ -102,6 +102,7 @@ <Compile Include="WindowInfo.cs" /> </ItemGroup> <ItemGroup> + <None Include="app.config" /> <None Include="Key.snk" /> <None Include="packages.config" /> <None Include="source.extension.vsixmanifest"> @@ -141,6 +142,9 @@ <Reference Include="EnvDTE90, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <EmbedInteropTypes>False</EmbedInteropTypes> </Reference> + <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> + </Reference> <Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.VisualStudio.CommandBars, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <EmbedInteropTypes>False</EmbedInteropTypes> @@ -219,6 +223,8 @@ <Reference Include="System.Data" /> <Reference Include="System.Design" /> <Reference Include="System.Drawing" /> + <Reference Include="System.IO.Compression" /> + <Reference Include="System.IO.Compression.FileSystem" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> <Reference Include="TestStack.White, Version=0.13.0.0, Culture=neutral, PublicKeyToken=2672efbf3e161801, processorArchitecture=MSIL"> @@ -265,6 +271,24 @@ <Install>false</Install> </BootstrapperPackage> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.PMR\Tango.PMR.csproj"> + <Project>{E4927038-348D-4295-AAF4-861C58CB3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/VSIXBase.cs b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/VSIXBase.cs index 068268298..b5e5dd0a0 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/VSIXBase.cs +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/VSIXBase.cs @@ -15,12 +15,14 @@ using VSLangProj; using System.Runtime.InteropServices; using TestStack.White.WindowsAPI; using System.IO; +using Microsoft.VisualStudio.Threading; namespace Tango.BuildExtensions { public class VSIXBase { private SelectForm _form; + private IVsThreadedWaitDialog2 _vsProgress = null; public IServiceProvider BaseServiceProvider { get; private set; } @@ -195,6 +197,45 @@ namespace Tango.BuildExtensions #region Status Form + protected void OpenVSProgress(String title, String message, bool intermediate) + { + Microsoft.VisualStudio.Shell.ThreadHelper.Generic.Invoke(() => + { + _vsProgress = null; + IVsThreadedWaitDialogFactory dialogFactory = BaseServiceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory; + dialogFactory.CreateInstance(out _vsProgress); + + + if (intermediate) + { + _vsProgress.StartWaitDialog(title, message, "", null, null, 0, false, true); + } + else + { + _vsProgress.StartWaitDialogWithPercentageProgress(title, message, "", null, null, false, 0, 0, 100); + } + }); + } + + + + protected void SetVSProgress(String message, String progressText = null, int current = 0, int total = 0) + { + Microsoft.VisualStudio.Shell.ThreadHelper.Generic.Invoke(() => + { + bool c; + _vsProgress.UpdateProgress(message, progressText, null, current, total, true, out c); + }); + } + + protected void CloseVSProgress() + { + Microsoft.VisualStudio.Shell.ThreadHelper.Generic.Invoke(() => + { + _vsProgress.EndWaitDialog(); + }); + } + protected void OpenProgressForm() { System.Threading.Thread thread = new System.Threading.Thread(() => diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/app.config b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/app.config new file mode 100644 index 000000000..cacd4cd77 --- /dev/null +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/app.config @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/packages.config b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/packages.config index c81549d43..dad2d9162 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/packages.config +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/packages.config @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Castle.Core" version="3.3.0" targetFramework="net46" /> + <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> <package id="Microsoft.VisualStudio.CoreUtility" version="15.0.26201" targetFramework="net46" /> <package id="Microsoft.VisualStudio.Imaging" version="15.0.26201" targetFramework="net46" /> <package id="Microsoft.VisualStudio.OLE.Interop" version="7.10.6070" targetFramework="net46" /> |
