From 499f4facfe296d984a44e9ce0b6e1eb23ba8d644 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 5 Mar 2019 14:53:49 +0200 Subject: Improvements and bug fixes on PPC. --- .../Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index d29323412..c87d3585b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -271,7 +271,7 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Job '{job.Name}' selected."); - if (!directlyToEdit) + if (!directlyToEdit && MachineProvider.MachineOperator.Status == Integration.Operation.MachineStatuses.ReadyToDye) { await NavigationManager.NavigateTo(nameof(JobSummeryView)); } -- cgit v1.3.1 From a4d52e6779fc90934c22b94e53d41d42bef3626e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 5 Mar 2019 16:58:38 +0200 Subject: Some improvements to PPC. Fixed issue with database constraint of dispensers <=> IDS_PACKS. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Messages/NavigatedToJobsModuleMessage.cs | 12 +++++++++++ .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 1 + .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 22 +++++++++++++++------ .../Tango.PPC.Jobs/ViewModels/MainViewVM.cs | 7 +++++++ .../PPC/Tango.PPC.Common/PPCViewModel.cs | 9 +++++++++ 9 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/NavigatedToJobsModuleMessage.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 423acaa6c..5768eaa67 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 35837b2a1..12d1a3ae4 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 6d661b5a7..27d18b496 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 404861144..da70c2ef1 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/NavigatedToJobsModuleMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/NavigatedToJobsModuleMessage.cs new file mode 100644 index 000000000..3f2be3f89 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/NavigatedToJobsModuleMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Jobs.Messages +{ + public class NavigatedToJobsModuleMessage + { + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 25d4507f6..e9ec35811 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -187,6 +187,7 @@ + Code diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index c87d3585b..961901d2c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -225,6 +225,7 @@ namespace Tango.PPC.Jobs.ViewModels RegisterForMessage(HandleJobRemovedMessage); RegisterForMessage(HandleJobSavedMessage); + RegisterForMessage((x) => Filter = null); } #endregion @@ -529,13 +530,16 @@ namespace Tango.PPC.Jobs.ViewModels /// private void OnFilterChanged() { - if (SelectedCategory == JobsCategory.Draft) + if (DraftJobsCollectionView != null && HistoryJobsCollectionView != null) { - DraftJobsCollectionView.Refresh(); - } - else if (SelectedCategory == JobsCategory.History) - { - HistoryJobsCollectionView.Refresh(); + if (SelectedCategory == JobsCategory.Draft) + { + DraftJobsCollectionView.Refresh(); + } + else if (SelectedCategory == JobsCategory.History) + { + HistoryJobsCollectionView.Refresh(); + } } } @@ -590,6 +594,12 @@ namespace Tango.PPC.Jobs.ViewModels StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Job.Extension, HandleJobFileLoaded); } + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + Filter = null; + } + #endregion #region Job Export diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs index 5b4a3e403..7026a6ebc 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs @@ -9,6 +9,7 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Notifications.NotificationItems; +using Tango.PPC.Jobs.Messages; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.Views; @@ -79,5 +80,11 @@ namespace Tango.PPC.Jobs.ViewModels })); } } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + RaiseMessage(); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index b9a0d8483..5e584f891 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -176,6 +176,15 @@ namespace Tango.PPC.Common TangoMessenger.Default.Send(message); } + /// + /// Raises the specified message using the default . + /// + /// + protected void RaiseMessage() where T : class + { + TangoMessenger.Default.Send(Activator.CreateInstance()); + } + /// /// Registers a message handle for the specified message type T. /// -- cgit v1.3.1 From db5c4418d90840ec033a8eacc948419b72755857 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 12 Mar 2019 15:26:36 +0200 Subject: Machine Studio v4.0.10 PPC v1.0.6 --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Integration/ExternalBridgeLoginIntent.proto | 6 +- .../Notifications/DefaultNotificationProvider.cs | 399 ++++++++++++--------- .../Notifications/DialogWindow.xaml | 2 +- .../Notifications/MessageBoxWindow.xaml | 2 +- .../Notifications/TextInputBoxWindow.xaml | 2 +- .../Tango.MachineStudio.UI/ViewModelLocator.cs | 2 - .../ViewModels/MachineConnectionViewVM.cs | 46 ++- .../ViewModels/MachineLoginViewVM.cs | 7 + .../ViewModels/MainViewVM.cs | 32 +- .../Views/MachineLoginView.xaml | 23 +- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 1 + .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../ViewModels/ExternalBridgeViewVM.cs | 14 +- .../Tango.Core/ExtensionMethods/EnumExtensions.cs | 13 + .../ExternalBridge/ExternalBridgeScanner.cs | 2 +- .../ExternalBridge/ExternalBridgeService.cs | 202 +++++++---- .../ExternalBridge/ExternalBridgeTcpClient.cs | 2 +- .../Tango.Integration/Operation/MachineOperator.cs | 11 + .../Visual_Studio/Tango.PMR/ExtensionMethods.cs | 68 ++-- .../Integration/ExternalBridgeLoginIntent.cs | 12 +- .../Tango.Transport/TransporterBase.cs | 5 +- 25 files changed, 543 insertions(+), 310 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 5474d352a..e88a5f3bd 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 5c2d42e86..0d682e1a5 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 49b53bdea..bc0ad0be8 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 4f8a38dec..5743a4d12 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Integration/ExternalBridgeLoginIntent.proto b/Software/PMR/Messages/Integration/ExternalBridgeLoginIntent.proto index 43887ebc5..8e7def71e 100644 --- a/Software/PMR/Messages/Integration/ExternalBridgeLoginIntent.proto +++ b/Software/PMR/Messages/Integration/ExternalBridgeLoginIntent.proto @@ -5,7 +5,7 @@ option java_package = "com.twine.tango.pmr.integration"; enum ExternalBridgeLoginIntent { - Basic = 0; - Override = 1; - Diagnostics = 2; + ColorProfile = 0; + Diagnostics = 1; + FullControl = 2; } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 161177bf1..7c56115e3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -105,109 +105,148 @@ namespace Tango.MachineStudio.UI.Notifications } /// - /// Creates a new instance of the specified View type and displays it as a modal dialog. + /// Shows the specified view with the specified view model as it's data context. /// + /// The type of the mm. /// The type of the view. - /// The type of the view model. - /// Accept button callback. - /// Cancel button callback. - public void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + /// The view model. + /// The view. + /// The accept action. + /// The cancel action. + public void ShowModalDialog(VM vm, View view, Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM { - var view = Activator.CreateInstance(); - DialogWindow dialog = new DialogWindow(); - dialog.Owner = Application.Current.MainWindow; - dialog.InnerContent = view; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - view.Loaded += (x, y) => + try { - VM context = view.DataContext as VM; - dialog.DataContext = context; + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + try + { + VM context = vm; + dialog.DataContext = context; - Action onAcceptAction = null; - Action onCancelAction = null; + Action onAcceptAction = null; + Action onCancelAction = null; - onAcceptAction = new Action(() => - { - dialog.Close(); - onAccept(context); - context.Accepted -= onAcceptAction; - context.Canceled -= onCancelAction; - }); + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + context.Canceled -= onCancelAction; + }); - onCancelAction = new Action(() => - { - dialog.Close(); + onCancelAction = new Action(() => + { + dialog.Close(); - if (onCancel != null) - { - onCancel(); - } + if (onCancel != null) + { + onCancel(); + } - context.Accepted -= onAcceptAction; - context.Canceled -= onCancelAction; - }); + context.Canceled -= onCancelAction; + context.Accepted -= onAcceptAction; + }); - context.Accepted += onAcceptAction; - context.Canceled += onCancelAction; + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; - context.OnShow(); - }; - dialog.ShowDialog(); - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + context.OnShow(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + }; + + dialog.ShowDialog(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + finally + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } } /// - /// Shows the specified view with the specified view model as it's data context. + /// Creates a new instance of the specified View type and displays it as a modal dialog. /// - /// The type of the mm. /// The type of the view. - /// The view model. - /// The view. - /// The accept action. - /// The cancel action. - public void ShowModalDialog(VM vm, Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + /// The type of the view model. + /// Accept button callback. + /// Cancel button callback. + public void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM { - var view = Activator.CreateInstance(); - DialogWindow dialog = new DialogWindow(); - dialog.Owner = Application.Current.MainWindow; - dialog.InnerContent = view; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - view.Loaded += (x, y) => + try { - VM context = vm; - dialog.DataContext = context; + var view = Activator.CreateInstance(); + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + try + { + VM context = view.DataContext as VM; + dialog.DataContext = context; - Action onAcceptAction = null; - Action onCancelAction = null; + Action onAcceptAction = null; + Action onCancelAction = null; - onAcceptAction = new Action(() => - { - dialog.Close(); - onAccept(context); - context.Accepted -= onAcceptAction; - context.Canceled -= onCancelAction; - }); + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + context.Canceled -= onCancelAction; + }); - onCancelAction = new Action(() => - { - dialog.Close(); + onCancelAction = new Action(() => + { + dialog.Close(); - if (onCancel != null) - { - onCancel(); - } + if (onCancel != null) + { + onCancel(); + } - context.Accepted -= onAcceptAction; - context.Canceled -= onCancelAction; - }); + context.Accepted -= onAcceptAction; + context.Canceled -= onCancelAction; + }); - context.Accepted += onAcceptAction; - context.Canceled += onCancelAction; + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; - context.OnShow(); - }; - dialog.ShowDialog(); - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + context.OnShow(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + }; + dialog.ShowDialog(); + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + finally + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } } /// @@ -219,48 +258,68 @@ namespace Tango.MachineStudio.UI.Notifications /// The view. /// The accept action. /// The cancel action. - public void ShowModalDialog(VM vm, View view, Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + public void ShowModalDialog(VM vm, Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM { - DialogWindow dialog = new DialogWindow(); - dialog.Owner = Application.Current.MainWindow; - dialog.InnerContent = view; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - view.Loaded += (x, y) => + try { - VM context = vm; - dialog.DataContext = context; + var view = Activator.CreateInstance(); + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + try + { + VM context = vm; + dialog.DataContext = context; - Action onAcceptAction = null; - Action onCancelAction = null; + Action onAcceptAction = null; + Action onCancelAction = null; - onAcceptAction = new Action(() => - { - dialog.Close(); - onAccept(context); - context.Accepted -= onAcceptAction; - context.Canceled -= onCancelAction; - }); + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + context.Canceled -= onCancelAction; + }); - onCancelAction = new Action(() => - { - dialog.Close(); + onCancelAction = new Action(() => + { + dialog.Close(); - if (onCancel != null) - { - onCancel(); - } + if (onCancel != null) + { + onCancel(); + } - context.Canceled -= onCancelAction; - context.Accepted -= onAcceptAction; - }); + context.Accepted -= onAcceptAction; + context.Canceled -= onCancelAction; + }); - context.Accepted += onAcceptAction; - context.Canceled += onCancelAction; + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; - context.OnShow(); - }; - dialog.ShowDialog(); - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + context.OnShow(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + }; + dialog.ShowDialog(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + finally + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } } /// @@ -272,67 +331,87 @@ namespace Tango.MachineStudio.UI.Notifications /// Could not locate view " + viewName public void ShowModalDialog(Action onAccept, Action onCancel) where VM : DialogViewVM { - String viewName = typeof(VM).Name.Replace("VM", ""); - - if (viewTypes == null) - { - viewTypes = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains("MachineStudio")).SelectMany(x => x.GetTypes()).ToList(); - } - - var viewType = viewTypes.SingleOrDefault(x => x.Name == viewName); - - if (viewType == null) + try { - throw new NullReferenceException("Could not locate view " + viewName); - } + String viewName = typeof(VM).Name.Replace("VM", ""); - var view = Activator.CreateInstance(viewType) as FrameworkElement; - DialogWindow dialog = new DialogWindow(); - dialog.Owner = Application.Current.MainWindow; - dialog.InnerContent = view; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - view.Loaded += (x, y) => - { - VM context = view.DataContext as VM; - if (context == null) + if (viewTypes == null) { - context = Activator.CreateInstance(); + viewTypes = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains("MachineStudio")).SelectMany(x => x.GetTypes()).ToList(); } - dialog.DataContext = context; - Action onCancelAction = null; - Action onAcceptAction = null; + var viewType = viewTypes.SingleOrDefault(x => x.Name == viewName); - onAcceptAction = new Action(() => + if (viewType == null) { - dialog.Close(); - onAccept(context); - - context.Canceled -= onCancelAction; - context.Accepted -= onAcceptAction; - }); + throw new NullReferenceException("Could not locate view " + viewName); + } - onCancelAction = new Action(() => + var view = Activator.CreateInstance(viewType) as FrameworkElement; + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => { - dialog.Close(); - - if (onCancel != null) + try { - onCancel(); + VM context = view.DataContext as VM; + if (context == null) + { + context = Activator.CreateInstance(); + } + dialog.DataContext = context; + + Action onCancelAction = null; + Action onAcceptAction = null; + + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + + context.Canceled -= onCancelAction; + context.Accepted -= onAcceptAction; + }); + + onCancelAction = new Action(() => + { + dialog.Close(); + + if (onCancel != null) + { + onCancel(); + } + + context.Canceled -= onCancelAction; + context.Accepted -= onAcceptAction; + }); + + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; + + context.OnShow(); } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + return; + } + }; - context.Canceled -= onCancelAction; - context.Accepted -= onAcceptAction; - }); - - context.Accepted += onAcceptAction; - context.Canceled += onCancelAction; - - context.OnShow(); - }; - - dialog.ShowDialog(); - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + dialog.ShowDialog(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error display modal dialog. {typeof(VM).Name}"); + onCancel?.Invoke(); + } + finally + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } } /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml index c11e2e11b..2eb1080cb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Windows" mc:Ignorable="d" - Title="Machine Studio" MinHeight="220" SizeToContent="WidthAndHeight" MinWidth="600" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent"> + Title="Machine Studio" MinHeight="220" SizeToContent="WidthAndHeight" MinWidth="600" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent" ShowInTaskbar="False"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml index a89f8eeca..8f9512236 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml @@ -8,7 +8,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" mc:Ignorable="d" - Title="Machine Studio" MinHeight="220" MaxHeight="600" SizeToContent="Height" Width="570" Opacity="0" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent"> + Title="Machine Studio" MinHeight="220" MaxHeight="600" SizeToContent="Height" Width="570" Opacity="0" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent" ShowInTaskbar="False"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml index d2aad7cee..5e27071ec 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml @@ -8,7 +8,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" mc:Ignorable="d" - Title="Machine Studio" MinHeight="220" MaxHeight="600" SizeToContent="Height" Width="570" Opacity="0" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent"> + Title="Machine Studio" MinHeight="220" MaxHeight="600" SizeToContent="Height" Width="570" Opacity="0" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent" ShowInTaskbar="False"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 7fbb0008c..3fffd69fd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -61,7 +61,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); - TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); @@ -79,7 +78,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs index 7737911e0..ce49d805e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -19,18 +19,16 @@ namespace Tango.MachineStudio.UI.ViewModels /// public class MachineConnectionViewVM : DialogViewVM { - private EmulatorExternalBridge _emulator; - - private ExternalBridgeScanner _scanner; - /// - /// Gets or sets the machine scanner. - /// + private static ExternalBridgeScanner _scanner; public ExternalBridgeScanner Scanner { get { return _scanner; } set { _scanner = value; RaisePropertyChangedAuto(); } } + + private EmulatorExternalBridge _emulator; + private IExternalBridgeClient _selectedMachine; /// /// Gets or sets the selected machine. @@ -50,11 +48,15 @@ namespace Tango.MachineStudio.UI.ViewModels /// Initializes a new instance of the class. /// /// The scanner. - public MachineConnectionViewVM(ExternalBridgeScanner scanner) + public MachineConnectionViewVM() { + if (_scanner == null) + { + _scanner = new ExternalBridgeScanner(); + } + EnableDiagnostics = true; UploadHardwareConfiguration = true; - Scanner = scanner; ConnectCommand = new RelayCommand(Connect, (x) => SelectedMachine != null); } @@ -65,7 +67,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (SelectedMachine != null) { - Scanner.Stop(); + _scanner.Stop(); Accept(); } } @@ -75,7 +77,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// protected override void Cancel() { - Scanner.Stop(); + _scanner.Stop(); base.Cancel(); } @@ -85,19 +87,27 @@ namespace Tango.MachineStudio.UI.ViewModels public override void OnShow() { base.OnShow(); - Scanner.AvailableMachines.Clear(); - if (SettingsManager.Default.GetOrCreate().UseExternalBridgeEmulator) + try { - if (_emulator != null) + _scanner.AvailableMachines.Clear(); + + if (SettingsManager.Default.GetOrCreate().UseExternalBridgeEmulator) { - _emulator.Disconnect(); + if (_emulator != null) + { + _emulator.Disconnect(); + } + _emulator = new EmulatorExternalBridge(); } - _emulator = new EmulatorExternalBridge(); - } - Scanner.AvailableMachines.Add(_emulator); - Scanner.Start(); + _scanner.AvailableMachines.Add(_emulator); + _scanner.Start(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error starting external bridge scanner."); + } } private bool _enableDiagnostics; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs index 2b1acdbe6..7584617ed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; +using Tango.PMR.Integration; using Tango.SharedUI; namespace Tango.MachineStudio.UI.ViewModels @@ -20,6 +21,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// public String Password { get; set; } + /// + /// Gets or sets the intent. + /// + public ExternalBridgeLoginIntent Intent { get; set; } + /// /// Gets or sets the login command. /// @@ -35,6 +41,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// public MachineLoginViewVM() { + Intent = ExternalBridgeLoginIntent.FullControl; LoginCommand = new RelayCommand(Login); CancelCommand = new RelayCommand(Cancel); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 986bf483f..3f69ff771 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Media; using Tango.BL; using Tango.BL.Builders; @@ -467,7 +468,7 @@ namespace Tango.MachineStudio.UI.ViewModels HostName = Environment.MachineName, Password = login.Password, UserGuid = AuthenticationProvider.CurrentUser.Guid, - Intent = PMR.Integration.ExternalBridgeLoginIntent.Override, + Intent = login.Intent, }); ApplicationManager.SetConnectedMachine(x.SelectedMachine); @@ -892,25 +893,28 @@ namespace Tango.MachineStudio.UI.ViewModels { if (!IsApplicationReady) { - var settings = SettingsManager.Default.GetOrCreate(); - - foreach (var item in settings.StudioModulesBounds) + if (!Keyboard.IsKeyDown(Key.LeftCtrl)) { - var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); + var settings = SettingsManager.Default.GetOrCreate(); - if (module != null && !module.InNewWindow) + foreach (var item in settings.StudioModulesBounds) { - OpenModuleInWindow(module, item.Bounds, item.State); - } - } + var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); - if (settings.LastMainModuleName != null) - { - var m = StudioModuleLoader.UserModules.SingleOrDefault(x => x.Name == settings.LastMainModuleName); + if (module != null && !module.InNewWindow) + { + OpenModuleInWindow(module, item.Bounds, item.State); + } + } - if (m != null) + if (settings.LastMainModuleName != null) { - StartModule(m); + var m = StudioModuleLoader.UserModules.SingleOrDefault(x => x.Name == settings.LastMainModuleName); + + if (m != null) + { + StartModule(m); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml index 04f787c41..14967686f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml @@ -5,9 +5,16 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:pmr="clr-namespace:Tango.PMR.Integration;assembly=Tango.PMR" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" d:DesignHeight="200" d:DesignWidth="550" Background="White" DataContext="{Binding MachineLoginViewVM, Source={StaticResource Locator}}"> + + + + + @@ -26,12 +33,18 @@ - - - - Enter machine password - + + + + Enter machine password + + + + Intent + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 961901d2c..cc9202b30 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -420,6 +420,7 @@ namespace Tango.PPC.Jobs.ViewModels job.CreationDate = DateTime.UtcNow; job.JobStatus = JobStatuses.Draft; job.JobType = vm.SelectedJobType; + job.EnableLubrication = true; job.ColorSpaceGuid = Adapter.ColorSpaces.FirstOrDefault(x => x.Code == vm.SelectedColorSpace.ToInt32()).Guid; job.MachineGuid = MachineProvider.Machine.Guid; job.UserGuid = AuthenticationProvider.CurrentUser.Guid; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index 19e758a19..fa54f491e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.0.5.0")] +[assembly: AssemblyVersion("1.0.6.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs index a8faeea7b..83f629159 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs @@ -7,6 +7,7 @@ using Tango.BL.Entities; using Tango.Core.Commands; using Tango.Core.DI; using Tango.Integration.ExternalBridge; +using Tango.PMR.Integration; using Tango.PPC.Common; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Navigation; @@ -132,7 +133,7 @@ namespace Tango.PPC.UI.ViewModels { LogManager.Log($"External bridge connection request received.\n{e.ToJsonString()}"); - if (e.Request.Password == Settings.ExternalBridgePassword) + if (!e.Request.Intent.RequiresPassword() || e.Request.Password == Settings.ExternalBridgePassword) { e.Confirmed = true; @@ -145,11 +146,14 @@ namespace Tango.PPC.UI.ViewModels LogManager.Log($"External bridge connection user has been identified as {User.Contact.FullName}"); } - LogManager.Log("Navigating to external bridge view..."); - InvokeUI(() => + if (e.Request.Intent == ExternalBridgeLoginIntent.FullControl) { - NavigationManager.NavigateTo(NavigationView.ExternalBridgeView, false); - }); + LogManager.Log("Navigating to external bridge view..."); + InvokeUI(() => + { + NavigationManager.NavigateTo(NavigationView.ExternalBridgeView, false); + }); + } } else { diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs index db3f7dc3d..97256faa5 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs @@ -44,4 +44,17 @@ public static class EnumExtensions { return (int)((object)value); } + + /// + /// Gets all the flags from a bitwise enumeration. + /// + /// + /// The enum. + /// + public static IEnumerable GetFlags(this Enum input) + { + foreach (Enum value in Enum.GetValues(input.GetType())) + if (input.HasFlag(value)) + yield return (T)(object)value; + } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs index 388e42eed..25ecd7d09 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs @@ -147,7 +147,7 @@ namespace Tango.Integration.ExternalBridge ThreadsHelper.InvokeUINow(() => { - AvailableMachines.Add(newMachine); + AvailableMachines.Insert(1, newMachine); }); } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs index 2a18aff57..c4f559c58 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs @@ -17,6 +17,7 @@ using Tango.Transport.Adapters; using Tango.PMR.Connection; using Tango.PMR.Diagnostics; using Tango.PMR.Debugging; +using System.Security.Authentication; namespace Tango.Integration.ExternalBridge { @@ -26,6 +27,7 @@ namespace Tango.Integration.ExternalBridge private TcpServer _tcpServer; private bool _send_app_logs; private String _app_logs_token; + private Dictionary> _messageHandlers; #region Events @@ -116,6 +118,9 @@ namespace Tango.Integration.ExternalBridge /// public ExternalBridgeService() { + _messageHandlers = new Dictionary>(); + RegisterMessageHandlers(); + _tcpServer = new TcpServer(1984); _tcpServer.ClientConnected += _tcpServer_ClientConnected; @@ -274,31 +279,46 @@ namespace Tango.Integration.ExternalBridge { //Do nothing ! } - else if (container.Type == MessageType.ExternalBridgeLoginRequest) - { - OnExternalBridgeLoginRequest(container); - } - else if (container.Type == MessageType.ExternalBridgeLogoutRequest) - { - OnExternalBridgeLogoutRequest(container); - } - else if (container.Type == MessageType.StartApplicationLogsRequest) - { - _app_logs_token = container.Token; - _send_app_logs = true; - SendResponse(new StartApplicationLogsResponse(), container.Token); - } - else if (container.Type == MessageType.StopApplicationLogsRequest) - { - _send_app_logs = false; - SendResponse(new StopApplicationLogsResponse() { }, container.Token); - SendResponse(new StartApplicationLogsResponse() { }, _app_logs_token, true); - } else { - if (IsInSession && SessionIntent == ExternalBridgeLoginIntent.Override) + if (IsInSession) { - OnAnyRequest(container); + if (_messageHandlers.ContainsKey(container.Type)) + { + try + { + try + { + _messageHandlers[container.Type](container); + } + catch (Exception ex) + { + SendErrorResponse(ex, container.Token); + } + } + catch (Exception ex) + { + if (ex is ResponseErrorException) + { + SendResponse((ex as ResponseErrorException).Container); + } + else + { + SendErrorResponse(ex, container.Token); + } + } + } + else + { + OnAnyRequest(container); + } + } + else + { + if (container.Type == MessageType.ExternalBridgeLoginRequest) + { + OnExternalBridgeLoginRequest(container); + } } } } @@ -380,16 +400,21 @@ namespace Tango.Integration.ExternalBridge #region Message Handlers + private void RegisterMessageHandlers() + { + _messageHandlers.Add(MessageType.ExternalBridgeLogoutRequest, OnExternalBridgeLogoutRequest); + + _messageHandlers.Add(MessageType.StartApplicationLogsRequest, OnStartApplicationLogsRequest); + _messageHandlers.Add(MessageType.StopApplicationLogsRequest, OnStopApplicationLogsRequest); + + _messageHandlers.Add(MessageType.JobRequest, OnJobRequest); + } + protected virtual async void OnAnyRequest(MessageContainer container) { - if (MachineOperator.Status == MachineStatuses.Disconnected) + if (SessionIntent == ExternalBridgeLoginIntent.ColorProfile) { - try - { - await SendErrorResponse(new Exception("Machine operator is disconnected."), container.Token); - } - catch { } - + await SendErrorResponse(new AuthenticationException("The specified intent does not grant the specified action."), container.Token); return; } @@ -411,42 +436,31 @@ namespace Tango.Integration.ExternalBridge } else { - MachineOperator.SendContinuousRequest(container).Subscribe((response) => + try { - if (Enabled && IsInSession) + MachineOperator.SendContinuousRequest(container).Subscribe((response) => { - SendResponse(response); - } + if (Enabled && IsInSession) + { + SendResponse(response); + } - }, (ex) => - { - if (Enabled) + }, (ex) => { - if (ex is ResponseErrorException) + if (Enabled) { - SendResponse((ex as ResponseErrorException).Container); + if (ex is ResponseErrorException) + { + SendResponse((ex as ResponseErrorException).Container); + } } - } - }); - } - } - - protected async virtual void OnExternalBridgeLogoutRequest(MessageContainer container) - { - try - { - await SendResponse(new ExternalBridgeLogoutResponse(), container.Token); - } - catch (Exception ex) - { - LogManager.Log(ex); - } - finally - { - ClearQueues(); + }); + } + catch (Exception ex) + { + await SendErrorResponse(ex, container.Token); + } } - - OnClientDisconnected(); } protected async virtual void OnExternalBridgeLoginRequest(MessageContainer container) @@ -454,9 +468,9 @@ namespace Tango.Integration.ExternalBridge var request = MessageFactory.ParseTangoMessageFromContainer(container); - LogManager.Log(String.Format("External bridge login attempt:{0}{1}", Environment.NewLine, request.Message.ToJsonString())); + LogManager.Log($"External bridge login attempt:\nIntent: {request.Message.Intent}\nMessage:\n{request.Message.ToJsonString()}"); - if (MachineOperator.Status != MachineStatuses.Printing || request.Message.Intent != ExternalBridgeLoginIntent.Override) + if (MachineOperator.Status != MachineStatuses.Printing || request.Message.Intent != ExternalBridgeLoginIntent.FullControl) { ExternalBridgeClientConnectedEventArgs args = new ExternalBridgeClientConnectedEventArgs(); args.Request = request; @@ -482,12 +496,74 @@ namespace Tango.Integration.ExternalBridge LogManager.Log("External bridge client login failed, invalid password."); } - await SendResponse(response, container.Token); + await SendResponse(response, container.Token, null, null, IsInSession ? null : "Invalid password or intent."); + } + else + { + LogManager.Log($"External bridge client login failed because the machine is currently printing and '{ExternalBridgeLoginIntent.FullControl}' intent was requested."); + await SendResponse(new ExternalBridgeLoginResponse(), container.Token, false, ErrorCode.GeneralError, $"Machine connection with '{ExternalBridgeLoginIntent.FullControl}' intent is not permitted while printing."); + } + } + + protected async virtual void OnExternalBridgeLogoutRequest(MessageContainer container) + { + try + { + await SendResponse(new ExternalBridgeLogoutResponse(), container.Token); + } + catch (Exception ex) + { + LogManager.Log(ex); + } + finally + { + ClearQueues(); + } + + OnClientDisconnected(); + } + + protected virtual void OnStartApplicationLogsRequest(MessageContainer container) + { + if (SessionIntent == ExternalBridgeLoginIntent.Diagnostics || SessionIntent == ExternalBridgeLoginIntent.FullControl) + { + _app_logs_token = container.Token; + _send_app_logs = true; + SendResponse(new StartApplicationLogsResponse(), container.Token); + } + else + { + throw new AuthenticationException("The specified intent does not grant the specified action."); + } + } + + protected virtual void OnStopApplicationLogsRequest(MessageContainer container) + { + if (SessionIntent == ExternalBridgeLoginIntent.Diagnostics || SessionIntent == ExternalBridgeLoginIntent.FullControl) + { + _send_app_logs = false; + SendResponse(new StopApplicationLogsResponse() { }, container.Token); + SendResponse(new StartApplicationLogsResponse() { }, _app_logs_token, true); + } + else + { + throw new AuthenticationException("The specified intent does not grant the specified action."); + } + } + + protected virtual void OnJobRequest(MessageContainer container) + { + if (SessionIntent != ExternalBridgeLoginIntent.FullControl) + { + throw new InvalidOperationException($"Job execution is disabled while session intent is '{SessionIntent}'."); + } + if (MachineOperator.Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException($"Could not execute job while machine operator status is '{MachineOperator.Status}'."); } else { - LogManager.Log("External bridge client login failed because the machine is currently printing."); - await SendResponse(new ExternalBridgeLoginResponse(), container.Token, false, ErrorCode.GeneralError, "Machine connection override is not permitted while printing."); + OnAnyRequest(container); } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs index 887242961..2839c2df1 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs @@ -111,7 +111,7 @@ namespace Tango.Integration.ExternalBridge if (!response.Message.Authenticated) { await Adapter.Disconnect(); - throw new AuthenticationException("The machine password is invalid."); + throw new AuthenticationException(response.Container.ErrorMessage); } Status = MachineStatuses.ReadyToDye; diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index c13961191..520b06626 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1196,6 +1196,16 @@ namespace Tango.Integration.Operation throw new InvalidOperationException($"Unsupported color space {stop.BrushColorSpace}."); } } + + if (job.EnableLubrication) + { + var lubricantVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack != null && x.IdsPack.LiquidType != null && x.IdsPack.LiquidType.Code == LiquidTypes.Lubricant.ToInt32()); + + if (lubricantVolume != null) + { + lubricantVolume.Volume = 100; + } + } } return Print(job, processParameters); @@ -1248,6 +1258,7 @@ namespace Tango.Integration.Operation ticket.Guid = originalJob.Guid; ticket.EnableInterSegment = job.EnableInterSegment; ticket.InterSegmentLength = job.InterSegmentLength; + ticket.EnableLubrication = job.EnableLubrication; ticket.Length = job.Length; ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; ticket.Spool = new JobSpool(); diff --git a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs index e80b45ade..83667da72 100644 --- a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs +++ b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs @@ -8,38 +8,52 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.PMR.Common; +using Tango.PMR.Integration; +/// +/// Contains PMR extension methods. +/// +public static class ExtensionMethods +{ /// - /// Contains PMR extension methods. + /// Gets the protobuf attribute value from the message type. /// - public static class ExtensionMethods + /// The value. + /// + public static String ToOriginalName(this MessageType value) { - /// - /// Gets the protobuf attribute value from the message type. - /// - /// The value. - /// - public static String ToOriginalName(this MessageType value) - { - FieldInfo fi = value.GetType().GetField(value.ToString()); + FieldInfo fi = value.GetType().GetField(value.ToString()); - OriginalNameAttribute[] attributes = (OriginalNameAttribute[])fi.GetCustomAttributes(typeof(OriginalNameAttribute), false); + OriginalNameAttribute[] attributes = (OriginalNameAttribute[])fi.GetCustomAttributes(typeof(OriginalNameAttribute), false); - if (attributes != null && - attributes.Length > 0) - return attributes[0].Name; - else - return value.ToString(); - } + if (attributes != null && + attributes.Length > 0) + return attributes[0].Name; + else + return value.ToString(); + } - /// - /// Gets the message parser. - /// - /// The message. - /// - public static MessageParser GetParser(this IMessage message) - { - MessageParser parser = message.GetType().GetProperty("Parser").GetValue(message) as MessageParser; - return parser; - } + /// + /// Gets the message parser. + /// + /// The message. + /// + public static MessageParser GetParser(this IMessage message) + { + MessageParser parser = message.GetType().GetProperty("Parser").GetValue(message) as MessageParser; + return parser; + } + + /// + /// Determines whether the specified intent requires a password. + /// + /// The intent. + /// + public static bool RequiresPassword(this ExternalBridgeLoginIntent intent) + { + return + intent == ExternalBridgeLoginIntent.Diagnostics + || + intent == ExternalBridgeLoginIntent.FullControl; } +} diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeLoginIntent.cs b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeLoginIntent.cs index 63455d8f2..3205ff168 100644 --- a/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeLoginIntent.cs +++ b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeLoginIntent.cs @@ -23,9 +23,9 @@ namespace Tango.PMR.Integration { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ch9FeHRlcm5hbEJyaWRnZUxvZ2luSW50ZW50LnByb3RvEhVUYW5nby5QTVIu", - "SW50ZWdyYXRpb24qRQoZRXh0ZXJuYWxCcmlkZ2VMb2dpbkludGVudBIJCgVC", - "YXNpYxAAEgwKCE92ZXJyaWRlEAESDwoLRGlhZ25vc3RpY3MQAkIhCh9jb20u", - "dHdpbmUudGFuZ28ucG1yLmludGVncmF0aW9uYgZwcm90bzM=")); + "SW50ZWdyYXRpb24qTwoZRXh0ZXJuYWxCcmlkZ2VMb2dpbkludGVudBIQCgxD", + "b2xvclByb2ZpbGUQABIPCgtEaWFnbm9zdGljcxABEg8KC0Z1bGxDb250cm9s", + "EAJCIQofY29tLnR3aW5lLnRhbmdvLnBtci5pbnRlZ3JhdGlvbmIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Integration.ExternalBridgeLoginIntent), }, null)); @@ -35,9 +35,9 @@ namespace Tango.PMR.Integration { } #region Enums public enum ExternalBridgeLoginIntent { - [pbr::OriginalName("Basic")] Basic = 0, - [pbr::OriginalName("Override")] Override = 1, - [pbr::OriginalName("Diagnostics")] Diagnostics = 2, + [pbr::OriginalName("ColorProfile")] ColorProfile = 0, + [pbr::OriginalName("Diagnostics")] Diagnostics = 1, + [pbr::OriginalName("FullControl")] FullControl = 2, } #endregion diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index fe7d8a249..e68e3c919 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -887,7 +887,10 @@ namespace Tango.Transport } else { - LogManager.Log("Could not send message " + message.Message.GetType().Name + ". Adapter is disconnected.", LogCategory.Warning); + if (message.Direction == TransportMessageDirection.Request) + { + message.SetException(LogManager.Log(new InvalidOperationException("Could not send message " + message.Message.GetType().Name + ". Adapter is disconnected."))); + } } if (message.Direction == TransportMessageDirection.Response) -- cgit v1.3.1 From 88ac356fd2d30e016bb884697e7b67f8ede51d2b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 20 Mar 2019 13:13:52 +0200 Subject: Fixed issue with PPC "add job" button hiding the "delete job" button. Removed message box on error in color lab module. --- .../Visual_Studio/Build/Shortcuts/Machine Studio.lnk | Bin 1344 -> 1516 bytes .../ViewModels/MainViewVM.cs | 10 +++++----- .../Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 4 +++- .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 4 ++++ Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs | 2 +- Software/Visual_Studio/Tango.BL/LiquidVolume.cs | 2 +- .../Tango.Integration/Operation/MachineOperator.cs | 8 +++++--- 7 files changed, 19 insertions(+), 11 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index ed1da5b24..92c553e6e 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 97af89253..f01637b5b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -410,12 +410,12 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } catch (Exception ex) { - LogManager.Log(ex, "Error in color conversion."); + LogManager.Log(ex, "An error occurred while trying to convert from source color to Volume."); - InvokeUI(() => - { - _notification.ShowError($"An error occurred while trying to convert from source color to Volume.\n" + ex.Message); - }); + //InvokeUI(() => + //{ + // _notification.ShowError($"An error occurred while trying to convert from source color to Volume.\n" + ex.Message); + //}); } }); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index cc9202b30..aef6dd549 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -607,7 +607,9 @@ namespace Tango.PPC.Jobs.ViewModels private async void ExportJob() { - var selected_job = SelectedJobs.First(); + var selected_job = SelectedJobs.FirstOrDefault(); + if (selected_job == null) return; + ClearSelection(); var result = await NavigationManager. diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index 47a3df569..475437cf3 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -59,6 +59,7 @@ - - + + diff --git a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs index cc13688ff..63b951a2f 100644 --- a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs +++ b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs @@ -264,6 +264,16 @@ namespace Tango.AnimatedGif private static void SetAnimationController(DependencyObject obj, ImageAnimationController value) { obj.SetValue(AnimationControllerPropertyKey, value); + + if (value != null) + { + (value as ImageAnimationController).SpeedRatio = GetSpeedRatio(obj as Image); + + if (GetEnableAnimation(obj as Image)) + { + (value as ImageAnimationController).Play(); + } + } } private static readonly DependencyPropertyKey AnimationControllerPropertyKey = diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index ca546922f..4371796c4 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -42,6 +42,13 @@ public static class FrameworkElementExtensions /// The handler. public static String RegisterForMouseOrTouchDown(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) { + var existing_container = _containers.SingleOrDefault(x => x.Element == element && x.Handler == handler); + + if (existing_container != null) + { + return existing_container.Token; + } + bool mousePressed = false; bool touchDown = false; @@ -145,6 +152,13 @@ public static class FrameworkElementExtensions /// The handler. public static String RegisterForMouseOrTouchUp(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) { + var existing_container = _containers.SingleOrDefault(x => x.Element == element && x.Handler == handler); + + if (existing_container != null) + { + return existing_container.Token; + } + bool mouseReleased = false; bool touchReleased = false; @@ -245,6 +259,13 @@ public static class FrameworkElementExtensions /// The handler. public static String RegisterForPreviewMouseOrTouchDown(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) { + var existing_container = _containers.SingleOrDefault(x => x.Element == element && x.Handler == handler); + + if (existing_container != null) + { + return existing_container.Token; + } + bool mousePressed = false; bool touchDown = false; @@ -348,6 +369,13 @@ public static class FrameworkElementExtensions /// The handler. public static String RegisterForPreviewMouseOrTouchUp(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) { + var existing_container = _containers.SingleOrDefault(x => x.Element == element && x.Handler == handler); + + if (existing_container != null) + { + return existing_container.Token; + } + bool mouseReleased = false; bool touchReleased = false; @@ -464,6 +492,13 @@ public static class FrameworkElementExtensions /// The handler. public static void RegisterForMouseOrTouchMove(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) { + var existing_container = _containers.SingleOrDefault(x => x.Element == element && x.Handler == handler); + + if (existing_container != null) + { + return; + } + bool _isTouch = false; MouseEventHandler mouseHandler = (x, e) => diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index b25afd67d..2672b2d0f 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1356,7 +1356,7 @@ namespace Tango.Integration.Operation ThreadFactory.StartNew(async () => { - Status = MachineStatuses.Printing; + Status = MachineStatuses.GettingReady; RunningJob = originalJob; PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); @@ -1411,6 +1411,22 @@ namespace Tango.Integration.Operation responseLogged = true; LogResponseReceived(response.Message); } + + if (JobHandlingMode == JobHandlerModes.SettingUp) + { + if (response.Message.Status.Progress > request.JobTicket.ProcessParameters.DryerBufferLength) + { + Status = MachineStatuses.Printing; + } + } + else + { + if (response.Message.Status.Progress > 0) + { + Status = MachineStatuses.Printing; + } + } + }, (ex) => { if (!(ex is ContinuousResponseAbortedException)) diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs index 3a09256b1..059c1f859 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs @@ -15,6 +15,8 @@ namespace Tango.Integration.Operation Standby, [Description("Ready To Dye")] ReadyToDye, + [Description("Getting Ready")] + GettingReady, [Description("Dyeing")] Printing, [Description("Service")] diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs index 45e552a43..38a2175d8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs @@ -49,6 +49,15 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty EnableAnimationProperty = DependencyProperty.Register("EnableAnimation", typeof(bool), typeof(TouchGifAnimation), new PropertyMetadata(false)); + public TouchGifAnimation() + { + Loaded += TouchGifAnimation_Loaded; + } + + private void TouchGifAnimation_Loaded(object sender, RoutedEventArgs e) + { + EnableAnimation = EnableAnimation; + } static TouchGifAnimation() { -- cgit v1.3.1 From 26ede873b194b0df70979b6f1b62e0c91ca19341 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 20 Apr 2019 21:48:32 +0300 Subject: Working on PPC performance... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 7 +- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 3 +- .../Visual_Studio/Tango.Core/ExtendedObject.cs | 9 +- .../Tango.SharedUI/Controls/FastTextBlock.cs | 73 +++++++++++++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- .../Controls/TouchVirtualizedContentControl.cs | 99 +++++++++++++++++++++ .../Controls/TouchVirtualizedContentControl.xaml | 15 ++++ .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 7 +- .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 1 + Software/Visual_Studio/Tango.sln | 12 +-- 12 files changed, 217 insertions(+), 12 deletions(-) create mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 724b8c150..1d4f688b1 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index a2be2cb15..dc895c719 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 850bd5964..9aaf9fcbd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -764,8 +764,11 @@ namespace Tango.PPC.Jobs.ViewModels /// The brush stop. public void OnBrushStopFieldValueChanged(BrushStop brushStop) { - brushStop.Corrected = false; - brushStop.OutOfGamutChecked = false; + if (brushStop != null) + { + brushStop.Corrected = false; + brushStop.OutOfGamutChecked = false; + } } /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 95d6bc290..86c53440e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -272,6 +272,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Job '{job.Name}' selected."); + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); + if (!directlyToEdit && MachineProvider.MachineOperator.Status == Integration.Operation.MachineStatuses.ReadyToDye) { await NavigationManager.NavigateWithObject(new JobSummeryNavigationObject() @@ -284,7 +286,6 @@ namespace Tango.PPC.Jobs.ViewModels { await NavigationManager.NavigateTo(nameof(JobView)); } - RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); } /// diff --git a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs index 44663b503..acead4157 100644 --- a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs +++ b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs @@ -109,7 +109,14 @@ namespace Tango.Core /// The action. protected virtual void InvokeUI(Action action) { - Application.Current.Dispatcher.BeginInvoke(action); + if (Application.Current != null) + { + Application.Current.Dispatcher.BeginInvoke(action); + } + else + { + action(); + } } /// diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs new file mode 100644 index 000000000..5b2808ab1 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.SharedUI.Controls +{ + + public class FastTextBlock : Control + { + private FormattedText _formattedText; + + static FastTextBlock() + { + + } + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register( + "Text", + typeof(string), + typeof(FastTextBlock), + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure, + (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue))); + + private void TextPropertyChanged(string text) + { + if (text != null) + { + var typeface = new Typeface( + FontFamily, + FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + + _formattedText = new FormattedText( + text, CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, typeface, FontSize, Foreground); + } + } + + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + protected override void OnRender(DrawingContext drawingContext) + { + if (_formattedText != null) + { + drawingContext.DrawText(_formattedText, new Point()); + } + } + + protected override Size MeasureOverride(Size constraint) + { + return _formattedText != null + ? new Size(_formattedText.Width, _formattedText.Height) + : new Size(); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index a8bd06040..37ba006f0 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -68,6 +68,7 @@ + HiveControl.xaml @@ -235,7 +236,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs new file mode 100644 index 000000000..8e3db84fa --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; +using System.Windows.Shapes; +using Tango.Core.Threading; + +namespace Tango.Touch.Controls +{ + [ContentProperty(nameof(Content))] + public class TouchVirtualizedContentControl : Control + { + private LightTouchScrollViewer _scrollViewer; + private ContentPresenter _innerBorder; + private ActionTimer _updateTimer; + private Point _location; + private bool _loaded; + + public UIElement Content + { + get { return (UIElement)GetValue(ContentProperty); } + set { SetValue(ContentProperty, value); } + } + public static readonly DependencyProperty ContentProperty = + DependencyProperty.Register("Content", typeof(UIElement), typeof(TouchVirtualizedContentControl), new PropertyMetadata(null)); + + static TouchVirtualizedContentControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchVirtualizedContentControl), new FrameworkPropertyMetadata(typeof(TouchVirtualizedContentControl))); + } + + public TouchVirtualizedContentControl() + { + _updateTimer = new ActionTimer(TimeSpan.FromMilliseconds(200)); + Loaded += TouchVirtualizedContentControl_Loaded; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _innerBorder = GetTemplateChild("PART_innerBorder") as ContentPresenter; + } + + private void TouchVirtualizedContentControl_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + _scrollViewer = this.FindAncestor(); + _scrollViewer.Scrolling += _scrollViewer_Scrolling; + + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer); + + ApplyOptimization(); + _loaded = true; + } + + private void _scrollViewer_Scrolling(object sender, DoubleValueChangedEventArgs e) + { + if (_loaded) + { + //_updateTimer.ResetReplace(() => + //{ + // Dispatcher.BeginInvoke(new Action(() => + // { + ApplyOptimization(); + // })); + //}); + } + } + + private void ApplyOptimization() + { + var _border_viewport = _scrollViewer.GetViewportBorder(); + + if (_border_viewport.IsAncestorOf(this)) + { + //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); + //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); + //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); + if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) + { + if (_innerBorder.Visibility == Visibility.Hidden) + { + _innerBorder.Visibility = Visibility.Visible; + } + } + else + { + if (_innerBorder.Visibility == Visibility.Visible) + { + _innerBorder.Visibility = Visibility.Hidden; + } + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml new file mode 100644 index 000000000..7cd72cc40 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 15e455168..3177f206d 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -91,6 +91,7 @@ + @@ -245,6 +246,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -385,7 +390,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index 832a3bf95..b80e058db 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -44,6 +44,7 @@ + diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 880ff9c4a..a3e349ad0 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -5296,12 +5296,12 @@ Global {B822CBD9-1113-4668-85C9-22AA9C24CE60} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal -- cgit v1.3.1 From ba4aec4c691476d68b3da383a70bff42341c7171 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 23 Apr 2019 16:13:41 +0300 Subject: Implemented screen lock for PPC. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.PPC.Jobs/Dialogs/JobCreationView.xaml | 5 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 64 ++++++++++++++++--- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 2 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 46 +++++++++++++- .../Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs | 11 ++++ .../ViewModels/MainViewVM.cs | 27 ++++++++ .../Tango.PPC.MachineSettings/Views/MainView.xaml | 25 +++++++- .../Application/IPPCApplicationManager.cs | 15 +++++ .../PPC/Tango.PPC.Common/PPCSettings.cs | 17 +++++ .../PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml | 30 +++++++++ .../Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs | 36 +++++++++++ .../PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs | 19 ++++++ .../Dialogs/TechnicianModeLoginView.xaml | 7 ++- .../Dialogs/TechnicianModeLoginView.xaml.cs | 8 +++ .../PPCApplication/DefaultPPCApplicationManager.cs | 70 ++++++++++++++++++++- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 10 ++- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 5 ++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs | 12 ++++ Software/Visual_Studio/Tango.BL/Entities/Job.cs | 4 +- .../Tango.Core/Threading/ActionTimer.cs | 14 ++++- .../Tango.Touch/Controls/TouchNumericTextBox.cs | 12 ++++ .../Tango.Touch/Controls/TouchNumericTextBox.xaml | 56 ++++++++++++----- .../Tango.Touch/Controls/TouchTextBox.cs | 11 +++- 27 files changed, 472 insertions(+), 34 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 385ec2708..a7bbbb937 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index c94ea41e5..e23788fde 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 488624b20..f5902c028 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index 6e8a53f2e..c47eeefb7 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml index 0e4f6e38c..cecdf813c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml @@ -65,7 +65,9 @@ - + + + @@ -96,6 +98,7 @@ + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index c7946ee6a..713dfce42 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -31,6 +31,9 @@ using Tango.Logging; using Tango.PPC.Common.Messages; using Tango.BL.Builders; using Tango.PPC.Jobs.AppButtons; +using Tango.Core.Threading; +using System.Diagnostics; +using System.Runtime.ExceptionServices; namespace Tango.PPC.Jobs.ViewModels { @@ -47,6 +50,7 @@ namespace Tango.PPC.Jobs.ViewModels private JobNavigationIntent _job_to_load_intent; private static Dictionary> _jobs_fine_tune_items; private StartPrintingButton _start_printing_btn; + private ActionTimer _volumeConversionTimer; #region Properties @@ -319,6 +323,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public JobViewVM() { + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + RegisterForMessage(HandleJobSelectedMessage); FineTuneItems = new ObservableCollection(); @@ -426,6 +432,11 @@ namespace Tango.PPC.Jobs.ViewModels Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); + foreach (var segment in Job.Segments) + { + SetSegmentLiquidVolumesIfVolume(segment); + } + if (!_check_gamut_thread.IsAlive) { _check_gamut_thread.Start(); @@ -601,7 +612,9 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Adding new solid segment..."); - return Job.AddSolidSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + var s = Job.AddSolidSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + SetSegmentLiquidVolumesIfVolume(s); + return s; } catch (Exception ex) { @@ -619,7 +632,9 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Adding new gradient segment..."); - return Job.AddGradientSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + var s = Job.AddGradientSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + SetSegmentLiquidVolumesIfVolume(s); + return s; } catch (Exception ex) { @@ -683,6 +698,18 @@ namespace Tango.PPC.Jobs.ViewModels } } + /// + /// Sets the segment liquid volumes. + /// + /// The segment. + private void SetSegmentLiquidVolumesIfVolume(Segment segment) + { + if (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32()) + { + segment.BrushStops.ToList().ForEach(x => x.SetLiquidVolumes(Job.Machine.Configuration, Job.Rml, Job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault())); + } + } + #endregion #region Brush Stops Management @@ -695,6 +722,7 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Adding new brush stop to segment {segment.SegmentIndex}."); segment.AddBrushStop(); + SetSegmentLiquidVolumesIfVolume(segment); } /// @@ -764,13 +792,35 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Called when the brush stop field value has been changed (This called from the view!). /// - /// The brush stop. - public void OnBrushStopFieldValueChanged(BrushStop brushStop) + /// The brush stop. + [HandleProcessCorruptedStateExceptions] + public void OnBrushStopFieldValueChanged(BrushStop stop) { - if (brushStop != null) + if (stop != null) { - brushStop.Corrected = false; - brushStop.OutOfGamutChecked = false; + stop.Corrected = false; + stop.OutOfGamutChecked = false; + + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + _volumeConversionTimer.ResetReplace(() => + { + try + { + var output = TangoColorConverter.GetSuggestions(stop); + + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + stop.Corrected = true; + stop.IsOutOfGamut = false; + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + } + }); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 86c53440e..bd6f95d44 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -378,7 +378,7 @@ namespace Tango.PPC.Jobs.ViewModels JobCreationViewVM vm = new JobCreationViewVM( machine.SupportedJobTypes.Count > 0 ? machine.SupportedJobTypes : Enum.GetValues(typeof(JobTypes)).Cast().ToList(), - machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace()).ToList() + machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace() || (ApplicationManager.IsInTechnicianMode && x == ColorSpaces.Volume)).ToList() ); var settings = SettingsManager.Default.GetOrCreate(); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 02e4cb6eb..75c4e9578 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -25,7 +25,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -120,6 +156,9 @@ + + + @@ -258,6 +297,9 @@ + + + @@ -385,7 +427,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs index 6a6e770a7..3cd6e1bce 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.BL; using Tango.BL.Entities; using Tango.Core.DI; using Tango.PPC.Jobs.ViewContracts; @@ -111,5 +112,15 @@ namespace Tango.PPC.Jobs.Views borderDockFloat.Child = dockEdit; borderEditDock.Visibility = Visibility.Collapsed; } + + private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; + + if (liquidVolume != null) + { + _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index c858e982e..b413fee0d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -86,6 +86,27 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _enableRemoteAssistance = value; RaisePropertyChangedAuto(); OnEnableRemoteAssistanceChanged(); } } + private bool _enableLockScreen; + public bool EnableLockScreen + { + get { return _enableLockScreen; } + set { _enableLockScreen = value; RaisePropertyChangedAuto(); } + } + + private int _lockScreenTimeoutMinutes; + public int LockScreenTimeoutMinutes + { + get { return _lockScreenTimeoutMinutes; } + set { _lockScreenTimeoutMinutes = value; RaisePropertyChangedAuto(); } + } + + private String _lockScreenPassword; + public String LockScreenPassword + { + get { return _lockScreenPassword; } + set { _lockScreenPassword = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -125,6 +146,9 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.HotSpotPassword = HotSpotPassword; Settings.EnableExternalBridge = EnableExternalBridge; Settings.ExternalBridgePassword = ExternalBridgePassword; + Settings.EnableLockScreen = EnableLockScreen; + Settings.LockScreenTimeout = TimeSpan.FromMinutes(LockScreenTimeoutMinutes); + Settings.LockScreenPassword = LockScreenPassword; Settings.Save(); await MachineProvider.SaveMachine(); @@ -166,6 +190,9 @@ namespace Tango.PPC.MachineSettings.ViewModels _enableRemoteAssistance = RemoteAssistanceProvider.IsEnabled; RaisePropertyChanged(nameof(EnableRemoteAssistance)); + EnableLockScreen = Settings.EnableLockScreen; + LockScreenTimeoutMinutes = (int)Settings.LockScreenTimeout.TotalMinutes; + LockScreenPassword = Settings.LockScreenPassword; SelectedJobTypes = new SelectedObjectCollection(Enum.GetValues(typeof(JobTypes)).Cast().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection()); SelectedColorSpaces = new SelectedObjectCollection(Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace()).ToObservableCollection(), Machine.SupportedColorSpaces.ToObservableCollection()); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 4f846a46d..dd5f89bb2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -11,7 +11,7 @@ xmlns:global="clr-namespace:Tango.PPC.MachineSettings" xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views" mc:Ignorable="d" - d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="2500" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -172,6 +172,29 @@ + + + + + + Enable Lock Screen + + + Lock Screen Timeout (m) + + + Lock Screen Password + + + + + + + Enable the lock screen to protect the panel from unauthorized access. + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index 2d76b202f..5f58be48b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -94,5 +94,20 @@ namespace Tango.PPC.Common.Application /// Gets the application build date. /// String BuildDate { get; } + + /// + /// Gets or sets a value indicating whether the screen is currently locked. + /// + bool IsScreenLocked { get; set; } + + /// + /// Resets the screen lock timer. + /// + void ResetScreenLockTimer(); + + /// + /// Invokes a dialog for entering a password and releasing the screen lock. + /// + void ReleaseScreenLock(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 698dbf374..050f1615c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -97,6 +97,21 @@ namespace Tango.PPC.Common /// public int GradientGenerationResolution { get; set; } + /// + /// Gets or sets a value indicating whether to enable the application lock screen. + /// + public bool EnableLockScreen { get; set; } + + /// + /// Gets or sets the lock screen timeout. + /// + public TimeSpan LockScreenTimeout { get; set; } + + /// + /// Gets or sets the lock screen password. + /// + public String LockScreenPassword { get; set; } + /// /// Gets the machine service address. /// @@ -119,6 +134,8 @@ namespace Tango.PPC.Common EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; + LockScreenTimeout = TimeSpan.FromMinutes(10); + LockScreenPassword = "1111"; DeploymentSlot = DeploymentSlot.TEST; EnableWatchDog = true; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml new file mode 100644 index 000000000..8a90b03a0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + CANCEL + OK + + + + + Screen Locked + Please enter the password to unlock the screen. + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs new file mode 100644 index 000000000..4a28984e6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// + /// Interaction logic for TechnicianModeLoginView.xaml + /// + public partial class ScreenLockView : UserControl + { + public ScreenLockView() + { + InitializeComponent(); + + Loaded += ScreenLockView_Loaded; + } + + private async void ScreenLockView_Loaded(object sender, RoutedEventArgs e) + { + await Task.Delay(200); + txtPassword.Focus(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs new file mode 100644 index 000000000..e19117621 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class ScreenLockViewVM : DialogViewVM + { + private String _password; + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml index ca53d6027..24a5416ba 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml @@ -7,6 +7,11 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="250" d:DataContext="{d:DesignInstance Type=local:TechnicianModeLoginViewVM, IsDesignTimeCreatable=False}"> + + + + + @@ -18,7 +23,7 @@ Technician Mode Please enter the technician mode password. - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs index 02dfed896..3a809b6f3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs @@ -23,6 +23,14 @@ namespace Tango.PPC.UI.Dialogs public TechnicianModeLoginView() { InitializeComponent(); + + Loaded += TechnicianModeLoginView_Loaded; + } + + private async void TechnicianModeLoginView_Loaded(object sender, RoutedEventArgs e) + { + await Task.Delay(200); + txtPassword.Focus(); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index ba1b44c8a..1550e97e1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -29,6 +29,8 @@ using Tango.BL.Enumerations; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.WatchDog; using Tango.PPC.UI.Dialogs; +using Tango.Core.Threading; +using Tango.PPC.Common.Messages; namespace Tango.PPC.UI.PPCApplication { @@ -48,6 +50,7 @@ namespace Tango.PPC.UI.PPCApplication private INotificationProvider _notificationProvider; private WatchDogServer _watchdogServer; private ObservablesContext _machineContext; + private ActionTimer _screenLockTimer; /// /// Occurs when a system restart is required. @@ -116,6 +119,16 @@ namespace Tango.PPC.UI.PPCApplication } } + private bool _isScreenLocked; + /// + /// Gets or sets a value indicating whether the screen is currently locked. + /// + public bool IsScreenLocked + { + get { return _isScreenLocked; } + set { _isScreenLocked = value; RaisePropertyChangedAuto(); } + } + /// /// Initializes a new instance of the class. /// @@ -306,6 +319,8 @@ namespace Tango.PPC.UI.PPCApplication /// private void FinalizeModuleInitialization() { + var settings = SettingsManager.Default.GetOrCreate(); + LogManager.Log("Finalizing application initialization..."); LogManager.Log("Initializing Machine Provider..."); @@ -336,10 +351,30 @@ namespace Tango.PPC.UI.PPCApplication vm.OnApplicationReady(); } - if (SettingsManager.Default.GetOrCreate().EnableTechnicianModeByDefault) + if (settings.EnableTechnicianModeByDefault) { EnterTechnicianMode(false); } + + if (settings.EnableLockScreen) + { + _screenLockTimer = new ActionTimer(settings.LockScreenTimeout); + _screenLockTimer.ResetReplace(ScreenLockTimerAction); + } + + TangoMessenger.Default.Register((msg) => + { + if (_screenLockTimer != null) + { + _screenLockTimer.Dispose(); + } + + if (settings.EnableLockScreen) + { + _screenLockTimer = new ActionTimer(settings.LockScreenTimeout); + _screenLockTimer.ResetReplace(ScreenLockTimerAction); + } + }); }); } @@ -460,5 +495,38 @@ namespace Tango.PPC.UI.PPCApplication _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianExited()); _notificationProvider.ShowInfo("Technician mode is now disabled."); } + + /// + /// Invokes a dialog for entering a password and releasing the screen lock. + /// + public async void ReleaseScreenLock() + { + if (IsScreenLocked) + { + var vm = await _notificationProvider.ShowDialog(); + + if (vm.DialogResult) + { + if (vm.Password == SettingsManager.Default.GetOrCreate().LockScreenPassword) + { + IsScreenLocked = false; + ResetScreenLockTimer(); + } + } + } + } + + public void ResetScreenLockTimer() + { + if (_screenLockTimer != null) + { + _screenLockTimer.ResetReplace(ScreenLockTimerAction); + } + } + + private void ScreenLockTimerAction() + { + IsScreenLocked = true; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 22ecff0f6..71fa82504 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -122,9 +122,13 @@ + + ScreenLockView.xaml + TechnicianModeLoginView.xaml + UpdateFromFileView.xaml @@ -186,6 +190,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -526,7 +534,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 768fce222..6e820ab64 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -279,7 +279,12 @@ + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs index 777083b67..883d3f893 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs @@ -42,6 +42,13 @@ namespace Tango.PPC.UI.Views _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(10); _timer.Tick += _timer_Tick; + + this.PreviewMouseUp += LayoutView_PreviewMouseUp; + } + + private void LayoutView_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + _vm.ApplicationManager.ResetScreenLockTimer(); } private void _timer_Tick(object sender, EventArgs e) @@ -77,5 +84,10 @@ namespace Tango.PPC.UI.Views _timer.Stop(); } + + private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + _vm.ApplicationManager.ReleaseScreenLock(); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 555e26ccc..c93889dad 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -455,9 +455,9 @@ namespace Tango.BL.Entities public Segment AddGradientSegment(double length) { var segment = AddSolidSegment(length); - segment.BrushStops.Last().Color = System.Windows.Media.Colors.Silver; + segment.BrushStops.Last().Color = System.Windows.Media.Colors.White; segment.AddBrushStop(); - segment.BrushStops.Last().Color = System.Windows.Media.Colors.DimGray; + segment.BrushStops.Last().Color = System.Windows.Media.Colors.White; return segment; } diff --git a/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs b/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs index 48ee12964..f16e7739c 100644 --- a/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs +++ b/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs @@ -10,7 +10,7 @@ namespace Tango.Core.Threading /// /// Represents an action executer with a predefined interval and a reset mechanism. /// - public class ActionTimer + public class ActionTimer : IDisposable { private Timer _timer; private Action _action; @@ -43,5 +43,17 @@ namespace Tango.Core.Threading _timer.Stop(); _action?.Invoke(); } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + if (_timer != null) + { + _timer.Stop(); + _timer = null; + } + } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 5e6a309da..6fbce65bf 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -49,6 +49,18 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(String), typeof(TouchNumericTextBox), new PropertyMetadata(null)); + + + public bool DisplayWatermarkHint + { + get { return (bool)GetValue(DisplayWatermarkHintProperty); } + set { SetValue(DisplayWatermarkHintProperty, value); } + } + public static readonly DependencyProperty DisplayWatermarkHintProperty = + DependencyProperty.Register("DisplayWatermarkHint", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(false)); + + + public String StringFormat { get { return (String)GetValue(StringFormatProperty); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml index bfe65cbd1..29be2dd00 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml @@ -88,23 +88,49 @@ - - - - - - - - + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs index 777e53ed0..beb7e0c18 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs @@ -21,6 +21,7 @@ namespace Tango.Touch.Controls public class TouchTextBox : TouchInput { private TextBox _text_box; + private PasswordBox _password_box; private DateTime _lost_focus_time; public String Text @@ -97,6 +98,7 @@ namespace Tango.Touch.Controls base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; + _password_box = GetTemplateChild("PART_PasswordBox") as PasswordBox; _text_box.GotFocus += _text_box_GotFocus; _text_box.LostFocus += _text_box_LostFocus; @@ -137,7 +139,14 @@ namespace Tango.Touch.Controls public new void Focus() { - _text_box.Focus(); + if (IsPassword) + { + _password_box.Focus(); + } + else + { + _text_box.Focus(); + } } } } -- cgit v1.3.1