aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-10-15 17:03:53 +0300
committerAvi Levkovich <avi@twine-s.com>2020-10-15 17:03:53 +0300
commitfd4f2d63b097dc9e189c9d30682bd6d5cc584d48 (patch)
tree8b911df6ec6f7c29ac85aa1dd8e331ed86f1e6bf /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent6a3361f3a9e08b63b39589add64f5802932022f3 (diff)
parent1b2dfd51ae086f40bba2934e550d9d4b8cca9cce (diff)
downloadTango-fd4f2d63b097dc9e189c9d30682bd6d5cc584d48.tar.gz
Tango-fd4f2d63b097dc9e189c9d30682bd6d5cc584d48.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs130
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs67
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs8
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs6
4 files changed, 177 insertions, 34 deletions
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 2bb4e9286..65df72878 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
@@ -3,11 +3,16 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
using System.Windows.Threading;
+using Tango.Core;
using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.Integration.Operation;
+using Tango.PMR.IFS;
using Tango.PPC.Common;
+using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
using Tango.PPC.UI.Views;
@@ -31,6 +36,86 @@ namespace Tango.PPC.UI.ViewModels
[TangoInject]
public IPPCModuleLoader ModuleLoader { get; set; }
+ #region Classes
+
+ public class CartridgeModel : ExtendedObject
+ {
+ private IMachineProvider _machineProvider;
+
+ public CartridgeStatus Status { get; set; }
+
+ public bool InProgress
+ {
+ get { return Status.State == CartridgeState.Filling || Status.State == CartridgeState.Emptying; }
+ }
+
+ public String Message
+ {
+ get { return Status.Cartridge.Slot == PMR.Diagnostics.CartridgeSlot.Ink ? "Ink filling is in progress..." : "Waste emptying is in progress..."; }
+ }
+
+ public Brush Brush
+ {
+ get
+ {
+ if (Status.Cartridge.Slot == PMR.Diagnostics.CartridgeSlot.Ink)
+ {
+ try
+ {
+ int index = Status.Cartridge.Index;
+
+ var idsPack = _machineProvider.Machine.Configuration.IdsPacks.FirstOrDefault(x => x.PackIndex == index);
+
+ if (idsPack != null)
+ {
+ switch (idsPack.LiquidType.Type)
+ {
+ case BL.Enumerations.LiquidTypes.Cyan:
+ return Application.Current.Resources["TangoCyanInkBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.Magenta:
+ return Application.Current.Resources["TangoMagentaInkBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.Yellow:
+ return Application.Current.Resources["TangoYellowInkBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.Black:
+ return Application.Current.Resources["TangoBlackInkBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.Lubricant:
+ return Application.Current.Resources["TangoLubricantBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.Cleaner:
+ return Application.Current.Resources["TangoCleanerBrush"] as Brush;
+ case BL.Enumerations.LiquidTypes.TransparentInk:
+ return Application.Current.Resources["TangoTransparentInkBrush"] as Brush;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error generating ink filling brush.");
+ }
+
+ return Application.Current.Resources["TangoPrimaryAccentBrush"] as Brush;
+ }
+ else
+ {
+ return Application.Current.Resources["TangoWasteBrush"] as Brush;
+ }
+ }
+ }
+
+ public CartridgeModel(IMachineProvider machineProvider)
+ {
+ _machineProvider = machineProvider;
+ Status = new CartridgeStatus();
+ }
+
+ public void Invalidate()
+ {
+ RaisePropertyChanged(nameof(InProgress));
+ RaisePropertyChanged(nameof(Status));
+ }
+ }
+
+ #endregion
+
#region Properties
private bool _isMenuOpened;
@@ -74,6 +159,23 @@ namespace Tango.PPC.UI.ViewModels
set { _isPowerOpened = value; RaisePropertyChangedAuto(); }
}
+ private bool _isInkFillingOrWasteEmptying;
+ /// <summary>
+ /// Gets or sets a value indicating whether ink filling or waste emptying is active.
+ /// </summary>
+ public bool IsInkFillingOrWasteEmptying
+ {
+ get { return _isInkFillingOrWasteEmptying; }
+ set { _isInkFillingOrWasteEmptying = value; RaisePropertyChangedAuto(); }
+ }
+
+ private List<CartridgeModel> _cartridges;
+ public List<CartridgeModel> Cartridges
+ {
+ get { return _cartridges; }
+ set { _cartridges = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -312,6 +414,34 @@ namespace Tango.PPC.UI.ViewModels
{
base.OnApplicationStarted();
MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted;
+ MachineProvider.MachineOperator.InkFillingStatusChanged += MachineOperator_InkFillingStatusChanged;
+ }
+
+ private void MachineOperator_InkFillingStatusChanged(object sender, InkFillingStatusChangedEventArgs e)
+ {
+ if (Cartridges == null)
+ {
+ Cartridges = MachineProvider.MachineOperator.InkFillingStatus.CartridgesStatuses.Select(x => new CartridgeModel(MachineProvider) { Status = x }).ToList();
+ }
+ else
+ {
+ foreach (var cartridgeStatus in e.Status.CartridgesStatuses)
+ {
+ var model = Cartridges.SingleOrDefault(x => x.Status == cartridgeStatus);
+
+ if (model != null)
+ {
+ model.Status = cartridgeStatus;
+ }
+ }
+ }
+
+ foreach (var cartridgeModel in Cartridges)
+ {
+ cartridgeModel.Invalidate();
+ }
+
+ IsInkFillingOrWasteEmptying = Cartridges.Any(x => x.Status.State == CartridgeState.Filling || x.Status.State == CartridgeState.Emptying);
}
/// <summary>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
index e280d5f9d..38dd569e1 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
@@ -74,39 +74,46 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public async override void OnApplicationStarted()
{
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- var machine = await db.Machines.FirstAsync();
+ //We don't use authentication!
- if (db.Users.Count() == 1 || machine.AutoLogin)
- {
- var user = await new UserBuilder(db).SetFirst().WithRolesAndPermissions().BuildAsync();
+ //using (ObservablesContext db = ObservablesContext.CreateDefault())
+ //{
+ // var machine = await db.Machines.FirstAsync();
- if (!user.HasRole(Roles.PPCUser))
- {
- var role = db.Roles.Single(x => x.Code == (int)Roles.PPCUser);
- user.Roles.Add(role);
- db.UsersRoles.Add(new BL.Entities.UsersRole()
- {
- User = user,
- Role = role,
- });
- await db.SaveChangesAsync();
- }
+ // if (db.Users.Count() == 1 || machine.AutoLogin)
+ // {
+ // var user = await new UserBuilder(db).SetFirst().WithRolesAndPermissions().BuildAsync();
- LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView...");
- await AuthenticationProvider.Login(user.Email, user.Password, false);
- await Task.Delay(1000);
- IsLoading = false;
- }
- else
- {
- LogManager.Log("Application started. Navigating to LoginView...");
- await NavigationManager.NavigateTo(NavigationView.LoginView);
- await Task.Delay(1000);
- IsLoading = false;
- }
- }
+ // if (!user.HasRole(Roles.PPCUser))
+ // {
+ // var role = db.Roles.Single(x => x.Code == (int)Roles.PPCUser);
+ // user.Roles.Add(role);
+ // db.UsersRoles.Add(new BL.Entities.UsersRole()
+ // {
+ // User = user,
+ // Role = role,
+ // });
+ // await db.SaveChangesAsync();
+ // }
+
+ // LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView...");
+ // await AuthenticationProvider.Login(user.Email, user.Password, false);
+ // await Task.Delay(1000);
+ // IsLoading = false;
+ // }
+ // else
+ // {
+ // LogManager.Log("Application started. Navigating to LoginView...");
+ // await NavigationManager.NavigateTo(NavigationView.LoginView);
+ // await Task.Delay(1000);
+ // IsLoading = false;
+ // }
+ //}
+
+ LogManager.Log($"Application started with no authentication mode...");
+ await AuthenticationProvider.Login();
+ await Task.Delay(1000);
+ IsLoading = false;
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
index aa9689ef3..ec316989f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
@@ -92,7 +92,13 @@ namespace Tango.PPC.UI.ViewModels
await Task.Delay(500);
- if (AuthenticationProvider.CurrentUser != null && AuthenticationProvider.CurrentUser.HasPermission(Permissions.RunPPC))
+ if (!AuthenticationProvider.AuthenticationRequired)
+ {
+ LogManager.Log("Application is ready! Navigating to home module...");
+ await NavigationManager.NavigateTo(NavigationView.HomeModule);
+ IsLoading = false;
+ }
+ else if (AuthenticationProvider.CurrentUser != null && AuthenticationProvider.CurrentUser.HasPermission(Permissions.RunPPC))
{
LogManager.Log("Application is ready! Navigating to home module...");
await NavigationManager.NavigateTo(NavigationView.HomeModule);
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 d4d78dac6..23ec956a0 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -167,7 +167,7 @@ namespace Tango.PPC.UI.ViewModels
return;
}
- var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber);
+ var response = await MachineUpdateManager.CheckForUpdate();
try
{
@@ -208,7 +208,7 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
- _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber);
+ _db_compare_result = await MachineUpdateManager.UpdateDBCheck();
if (_db_compare_result.RequiresUpdate)
{
@@ -261,7 +261,7 @@ namespace Tango.PPC.UI.ViewModels
try
{
- await MachineUpdateManager.UpdateDB(_db_compare_result, MachineProvider.Machine.SerialNumber);
+ await MachineUpdateManager.UpdateDB(_db_compare_result);
LogManager.Log("Database update completed.");
await NavigateTo(MachineUpdateView.UpdateCompletedView);
}