aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-13 03:41:41 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-13 03:41:41 +0300
commit76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9 (patch)
treed1043332c085a2624187b77b37c63a37505cdad2 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parentd26e810aa206bf850622ded5a0da76293cb12f13 (diff)
downloadTango-76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9.tar.gz
Tango-76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9.zip
FSE TUP
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs110
1 files changed, 107 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
index 3942a1b84..8a8b87c97 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -5,24 +5,29 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using Tango.BL;
using Tango.Core.Commands;
using Tango.Core.ExtensionMethods;
using Tango.Core.Helpers;
+using Tango.Core.Threading;
using Tango.Explorer;
+using Tango.Integration.ExternalBridge;
using Tango.PMR.FirmwareUpgrade;
using Tango.PPC.Common;
+using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.MachineUpdate;
using Tango.PPC.Common.Publish;
using Tango.PPC.Common.Web;
+using Tango.PPC.Shared.RemoteUpgrade;
using Tango.PPC.UI.Dialogs;
using Tango.PPC.UI.Notifications.NotificationItems;
using Tango.PPC.UI.ViewsContracts;
namespace Tango.PPC.UI.ViewModels
{
- public class MachineUpdateViewVM : PPCViewModel<IMachineUpdateView>
+ public class MachineUpdateViewVM : PPCViewModel<IMachineUpdateView>, IExternalBridgeRequestHandler
{
public enum MachineUpdateView
{
@@ -114,9 +119,10 @@ namespace Tango.PPC.UI.ViewModels
#region Constructors
- public MachineUpdateViewVM(IMachineUpdateManager machineUpdateManager)
+ public MachineUpdateViewVM(IMachineUpdateManager machineUpdateManager, IPPCExternalBridgeService externalBridge)
{
MachineUpdateManager = machineUpdateManager;
+ externalBridge.RegisterRequestHandler(this);
CompleteCommand = new RelayCommand(CompleteUpdate);
UpdateCommand = new RelayCommand(Update);
@@ -491,7 +497,7 @@ namespace Tango.PPC.UI.ViewModels
LogManager.Log("Firmware upgrade from package completed.");
_update_result = new MachineUpdateResult()
{
- RequiresBinariesUpdate = false,
+ RequiresBinariesUpdate = false,
};
await NavigateTo(MachineUpdateView.UpdateCompletedView);
}
@@ -540,5 +546,103 @@ namespace Tango.PPC.UI.ViewModels
}
#endregion
+
+ #region External Bridge Handler
+
+ [ExternalBridgeRequestHandlerMethod(typeof(StartRemoteApplicationRemoteUpgradeRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnStartRemoteApplicationRemoteUpgradeRequest(StartRemoteApplicationRemoteUpgradeRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ await receiver.SendGenericResponse(new StartRemoteApplicationRemoteUpgradeResponse(), token);
+
+ bool stopReporting = false;
+
+ try
+ {
+ ThreadFactory.StartNew(async () =>
+ {
+ while (!stopReporting)
+ {
+ if (MachineUpdateManager.Status != null)
+ {
+ try
+ {
+ await receiver.SendGenericResponse(new StartRemoteApplicationRemoteUpgradeResponse()
+ {
+ Message = MachineUpdateManager.Status.Message,
+ IsIndeterminate = MachineUpdateManager.Status.IsIntermediate,
+ Maximum = MachineUpdateManager.Status.Total,
+ Progress = MachineUpdateManager.Status.Progress
+ }, token);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error sending remote upgrade progress.");
+ }
+ }
+
+ Thread.Sleep(500);
+ }
+ });
+
+ InvokeUI(() =>
+ {
+ NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView);
+ NavigateTo(MachineUpdateView.UpdateProgressView);
+ });
+
+ LogManager.Log("Starting machine update from package...");
+
+ try
+ {
+ _update_result = await MachineUpdateManager.UpdateFromTUP(request.RemoteTupFilePath, request.SetupFirmware, request.SetupFPGA);
+ LogManager.Log("Machine update from package completed.");
+
+ InvokeUI(() =>
+ {
+ NavigateTo(MachineUpdateView.UpdateCompletedView);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Machine update from package failed.");
+ FailedError = ex.FlattenMessage();
+
+ InvokeUI(() =>
+ {
+ NavigateTo(MachineUpdateView.UpdateFailedFromPackageView);
+ });
+ }
+
+ await receiver.SendGenericResponse(new StartRemoteApplicationRemoteUpgradeResponse()
+ {
+ IsIndeterminate = false,
+ Maximum = 100,
+ Progress = 100,
+ Message = "Completed"
+ }, token, new Transport.TransportResponseConfig()
+ {
+ Completed = true
+ });
+ }
+ catch (Exception ex)
+ {
+ await receiver.SendErrorResponse(ex, token);
+ }
+ finally
+ {
+ try
+ {
+ File.Delete(request.RemoteTupFilePath);
+ }
+ catch { }
+ }
+ }
+
+ public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
+ {
+
+ }
+
+ #endregion
}
}