aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-02-20 12:22:27 +0200
committerAvi Levkovich <avi@twine-s.com>2019-02-20 12:22:27 +0200
commita576283d2a9288938796491582dd9f575f3ff571 (patch)
treebba67d4b69f337fa209b5050fb69378e28e6f4eb /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup
parentb30e6dc276f95c9db3d500d267a273b6486e0dac (diff)
parent9646611a494ed9e1ef0673c881ffc66b997f7bb9 (diff)
downloadTango-a576283d2a9288938796491582dd9f575f3ff571.tar.gz
Tango-a576283d2a9288938796491582dd9f575f3ff571.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs34
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs14
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs28
4 files changed, 28 insertions, 51 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
index 896c7b921..4808252d0 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
@@ -27,8 +27,7 @@ namespace Tango.PPC.Common.MachineSetup
/// Performs a machine setup using the specified serial number and machine service address.
/// </summary>
/// <param name="serialNumber">The serial number.</param>
- /// <param name="machineServiceAddress">The machine service address.</param>
/// <returns></returns>
- Task<MachineSetupResult> Setup(String serialNumber, String machineServiceAddress);
+ Task<MachineSetupResult> Setup(String serialNumber);
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
index 488206590..369248c7b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
@@ -22,6 +22,7 @@ using Tango.PPC.Common.Connection;
using Tango.PPC.Common.OS;
using Tango.PPC.Common.RemoteAssistance;
using Tango.PPC.Common.UWF;
+using Tango.PPC.Common.Web;
using Tango.Settings;
using Tango.SharedUI.Helpers;
using Tango.SQLExaminer;
@@ -39,6 +40,7 @@ namespace Tango.PPC.Common.MachineSetup
private IRemoteAssistanceProvider _remoteAssistance;
private IUnifiedWriteFilterManager _uwf;
private IOperationSystemManager _windows_manager;
+ private PPCWebClient _client;
#region Events
@@ -71,8 +73,9 @@ namespace Tango.PPC.Common.MachineSetup
/// Initializes a new instance of the <see cref="MachineSetupManager"/> class.
/// </summary>
/// <param name="remoteAssistance">The remote assistance.</param>
- public MachineSetupManager(IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IOperationSystemManager operationSystemManager)
+ public MachineSetupManager(PPCWebClient ppcWebClient, IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IOperationSystemManager operationSystemManager)
{
+ _client = ppcWebClient;
_remoteAssistance = remoteAssistance;
_uwf = unifiedWriterFilterManager;
_windows_manager = operationSystemManager;
@@ -80,6 +83,23 @@ namespace Tango.PPC.Common.MachineSetup
#endregion
+ #region Private Methods
+
+ private Task Login(String serialNumber)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ return _client.Login(new LoginRequest()
+ {
+ Mode = LoginMode.Machine,
+ SerialNumber = serialNumber,
+ }).Result;
+
+ });
+ }
+
+ #endregion
+
#region Public Methods
/// <summary>
@@ -88,7 +108,7 @@ namespace Tango.PPC.Common.MachineSetup
/// <param name="serialNumber">The serial number.</param>
/// <param name="machineServiceAddress">The machine service address.</param>
/// <returns></returns>
- public async Task<MachineSetupResult> Setup(string serialNumber, string machineServiceAddress)
+ public async Task<MachineSetupResult> Setup(string serialNumber)
{
TaskCompletionSource<MachineSetupResult> result = new TaskCompletionSource<MachineSetupResult>();
@@ -96,6 +116,8 @@ namespace Tango.PPC.Common.MachineSetup
{
LogManager.Log($"Starting machine setup for serial number {serialNumber}...");
+ var machineServiceAddress = SettingsManager.Default.GetOrCreate<PPCSettings>().GetMachineServiceAddress();
+
IMachineOperator op = null;
var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
@@ -105,17 +127,15 @@ namespace Tango.PPC.Common.MachineSetup
LogManager.Log($"Connecting to machine service on {machineServiceAddress}...");
+ Login(serialNumber).Wait();
+
MachineSetupRequest request = new MachineSetupRequest();
- request.SerialNumber = serialNumber;
MachineSetupResponse setup_response = null;
try
{
- using (var http = new WebTransportClient())
- {
- setup_response = await http.PostJson<MachineSetupRequest, MachineSetupResponse>(machineServiceAddress + "/api/PPC/MachineSetup", request);
- }
+ setup_response = await _client.MachineSetup(request);
}
catch (Exception ex)
{
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs
deleted file mode 100644
index 4c8039544..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Transport.Web;
-
-namespace Tango.PPC.Common.MachineSetup
-{
- public class MachineSetupRequest : WebRequestMessage
- {
- public String SerialNumber { get; set; }
- }
-}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs
deleted file mode 100644
index 5e8885af7..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core;
-using Tango.Transport.Web;
-
-namespace Tango.PPC.Common.MachineSetup
-{
- public class MachineSetupResponse : WebResponseMessage
- {
- public String Version { get; set; }
-
- public String BlobAddress { get; set; }
-
- public DataSource DataSource { get; set; }
-
- public String OSKey { get; set; }
-
- public bool SetupActivation { get; set; }
- public bool SetupRemoteAssistance { get; set; }
- public bool SetupUWF { get; set; }
- public bool SetupFirmware { get; set; }
- public bool SetupFPGA { get; set; }
- public bool IsDemo { get; set; }
- }
-}