aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-12-15 13:12:20 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-12-15 13:12:20 +0200
commit13c57f7ccabadd3ed75ffaef195d35c15c2a8c68 (patch)
tree938bd6dd844cf2645510aa3d42f3bfbe24e52a7e /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parentd1859415972bb991cba6639482c1cd2a9e19e8d8 (diff)
parent957ca86b8e899eb488626c456d9c37dd4545bd80 (diff)
downloadTango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.tar.gz
Tango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs17
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs32
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs85
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs30
5 files changed, 159 insertions, 18 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs
new file mode 100644
index 000000000..29e6417f4
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PPC.Common;
+
+namespace Tango.PPC.UI.ViewModels
+{
+ public class InternalModuleViewVM : PPCViewModel
+ {
+ public override void OnApplicationStarted()
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
index 9e8a9fe34..e18354f89 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
@@ -10,6 +10,7 @@ using Tango.Integration.Operation;
using Tango.PPC.Common;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.UI.Views;
using Tango.PPC.UI.ViewsContracts;
using Tango.SharedUI;
@@ -121,6 +122,11 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public RelayCommand RestartApplicationCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the power off command.
+ /// </summary>
+ public RelayCommand PowerOffCommand { get; set; }
+
#endregion
#region Constructors
@@ -146,6 +152,7 @@ namespace Tango.PPC.UI.ViewModels
PowerCommand = new RelayCommand(() => IsPowerOpened = true);
RestartApplicationCommand = new RelayCommand(RestartApplication);
+ PowerOffCommand = new RelayCommand(PowerOffMachine);
}
#endregion
@@ -239,6 +246,12 @@ namespace Tango.PPC.UI.ViewModels
}
}
+ private async void PowerOffMachine()
+ {
+ IsMenuOpened = false;
+ await NavigationManager.NavigateTo<InternalModule>(nameof(PowerOffView));
+ }
+
#endregion
#region Override Methods
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 0371e94da..49b2aef89 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -10,6 +10,7 @@ using Tango.Core.Helpers;
using Tango.Explorer;
using Tango.PPC.Common;
using Tango.PPC.Common.MachineUpdate;
+using Tango.PPC.Common.Publish;
using Tango.PPC.Common.Web;
using Tango.PPC.UI.Dialogs;
using Tango.PPC.UI.Notifications.NotificationItems;
@@ -209,7 +210,7 @@ namespace Tango.PPC.UI.ViewModels
try
{
- _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, _checkUpdateResponse.SetupFirmware, _checkUpdateResponse.SetupFPGA);
+ _update_result = await MachineUpdateManager.Update(_checkUpdateResponse.SetupFirmware, _checkUpdateResponse.SetupFPGA);
LogManager.Log("Machine update completed.");
await NavigateTo(MachineUpdateView.UpdateCompletedView);
}
@@ -248,15 +249,15 @@ namespace Tango.PPC.UI.ViewModels
{
LogManager.Log("Completing machine update...");
- if (!IsDbUpdate)
+ if (IsDbUpdate || !_update_result.RequiresBinariesUpdate)
{
- String updater_exe = Path.Combine(_update_result.UpdatePackagePath, "Tango.PPC.Updater.exe");
- ApplicationManager.UpdateApplication(updater_exe, PathHelper.GetStartupPath());
+ LogManager.Log("Restarting Application...");
+ ApplicationManager.Restart();
}
else
{
- LogManager.Log("Restarting Application...");
- ApplicationManager.Restart();
+ String updater_exe = Path.Combine(_update_result.UpdatePackagePath, "Tango.PPC.Updater.exe");
+ ApplicationManager.UpdateApplication(updater_exe, PathHelper.GetStartupPath());
}
}
@@ -296,7 +297,7 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
- MachineUpdateManager.AutoCheckForUpdates = MachineProvider.Machine.AutoCheckForUpdates;
+ MachineUpdateManager.EnableAutoCheckForUpdates = true;
}
}
@@ -375,7 +376,7 @@ namespace Tango.PPC.UI.ViewModels
private async void HandleSoftwareUpdatePackageLoaded(ExplorerFileItem fileItem)
{
- UpdatePackageFile packageFile = null;
+ PublishInfo packageFile = null;
try
{
@@ -383,38 +384,33 @@ namespace Tango.PPC.UI.ViewModels
}
catch (Exception ex)
{
- LogManager.Log(ex, $"Error loading update package file from {fileItem.Path}.");
+ LogManager.Log(ex, $"Error loading publish info from {fileItem.Path}.");
await NotificationProvider.ShowError("An error occurred while trying to load the selected software update package. Please make sure the package is valid.");
return;
}
- if (ApplicationManager.Version <= packageFile.Version)
- {
- await NotificationProvider.ShowError($"The selected update package (v{packageFile.Version.ToString()}) contains an older software version.");
- return;
- }
-
UpdateFromFileViewVM vm = new UpdateFromFileViewVM();
- vm.Version = packageFile.Version.ToString();
+ vm.Version = packageFile.ApplicationVersion;
await NotificationProvider.ShowDialog(vm);
if (vm.DialogResult)
{
await NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView);
- await NavigateTo(MachineUpdateView.UpdateFromPackageView);
+ await NavigateTo(MachineUpdateView.UpdateProgressView);
LogManager.Log("Starting machine update from package...");
try
{
- _update_result = await MachineUpdateManager.UpdateFromTUP(fileItem.Path);
+ _update_result = await MachineUpdateManager.UpdateFromTUP(fileItem.Path, MachineProvider.Machine.SetupFirmware, MachineProvider.Machine.SetupFpga);
LogManager.Log("Machine update from package completed.");
await NavigateTo(MachineUpdateView.UpdateCompletedView);
}
catch (Exception ex)
{
LogManager.Log(ex, "Machine update from package failed.");
+ FailedError = ex.FlattenMessage();
await NavigateTo(MachineUpdateView.UpdateFailedFromPackageView);
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
index 01a47539e..8a4d20b76 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -4,6 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
+using Tango.BL;
+using Tango.BL.Builders;
+using Tango.BL.Entities;
using Tango.Core.DI;
using Tango.Integration.ExternalBridge;
using Tango.Integration.Operation;
@@ -17,6 +20,7 @@ using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.WatchDog;
using Tango.PPC.UI.Dialogs;
using Tango.SharedUI;
+using System.Data.Entity;
namespace Tango.PPC.UI.ViewModels
{
@@ -58,6 +62,7 @@ namespace Tango.PPC.UI.ViewModels
{
base.OnApplicationReady();
MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived;
+ MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted;
}
#region Event Handlers
@@ -92,6 +97,86 @@ namespace Tango.PPC.UI.ViewModels
});
}
+ private async void MachineOperator_PowerUpStarted(object sender, EventArgs e)
+ {
+ LogManager.Log("Power up detected, showing power up screen...");
+
+ if (!Settings.DisplayPowerUpScreen)
+ {
+ LogManager.Log("Power up screen disabled. skipping...");
+ return;
+ }
+
+ PowerUpViewVM vm;
+
+ try
+ {
+ LogManager.Log("Loading site rmls...");
+
+ List<Rml> rmls = new List<Rml>();
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildListAsync();
+ }
+
+ var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LastPowerUpSelectedRmlGuid);
+
+ vm = new PowerUpViewVM();
+ vm.Rmls = rmls;
+ vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault();
+ vm.IsSelectedRml = selectedRml != null;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error initializing power up screen.");
+ return;
+ }
+
+ InvokeUI(async () =>
+ {
+ await NotificationProvider.ShowDialog<PowerUpViewVM>(vm);
+
+ await Task.Factory.StartNew(() =>
+ {
+ LogManager.Log("Power up screen closed.");
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ List<ProcessParametersTable> processTables = new List<ProcessParametersTable>();
+
+ if (vm.IsSelectedRml)
+ {
+ LogManager.Log($"Selected rml '{vm.SelectedRml.Name}'...");
+ processTables = new RmlBuilder(db).Set(vm.SelectedRml.Guid).WithActiveParametersGroup().Build().GetActiveProcessGroup().ProcessParametersTables.ToList();
+ }
+ else
+ {
+ LogManager.Log("Selected minimal temperature...");
+ var rmlsToAvg = new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().Build();
+ processTables = rmlsToAvg.Select(x => x.GetActiveProcessGroup()).SelectMany(x => x.ProcessParametersTables).ToList();
+ }
+
+ var processToLoad = processTables.OrderBy(x => x.GetAverageTemperature()).First();
+
+ LogManager.Log($"Selected process parameters:\nRML: {processToLoad.ProcessParametersTablesGroup.Rml.Name}\nGroup: {processToLoad.ProcessParametersTablesGroup.Name}\nProcess Table: {processToLoad.Name}");
+ LogManager.Log("Uploading process parameters...");
+ var r = MachineProvider.MachineOperator.UploadProcessParameters(processToLoad).Result;
+
+ Settings.LastPowerUpSelectedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null;
+ Settings.Save();
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error occurred while trying to get and upload the proper process parameters after power screen closed.");
+ }
+ });
+ });
+ }
+
#endregion
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs
new file mode 100644
index 000000000..0d58b472f
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.PPC.Common;
+
+namespace Tango.PPC.UI.ViewModels
+{
+ public class PowerOffViewVM : PPCViewModel
+ {
+ public RelayCommand AbortCommand { get; set; }
+
+ public PowerOffViewVM()
+ {
+ AbortCommand = new RelayCommand(AbortPowerOff);
+ }
+
+ public override void OnApplicationStarted()
+ {
+
+ }
+
+ private void AbortPowerOff()
+ {
+ NavigationManager.NavigateBack();
+ }
+ }
+}