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. --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 52f0fb403..1c1eeca5e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -38,7 +38,15 @@ namespace Tango.PPC.UI.ViewModels public bool IsMenuOpened { get { return _isMenuOpened; } - set { _isMenuOpened = value; RaisePropertyChangedAuto(); } + set + { + _isMenuOpened = value; RaisePropertyChangedAuto(); + + if (!_isMenuOpened) + { + IsPowerOpened = false; + } + } } private bool _isNotificationsOpened; @@ -48,7 +56,20 @@ namespace Tango.PPC.UI.ViewModels public bool IsNotificationsOpened { get { return _isNotificationsOpened; } - set { _isNotificationsOpened = value; RaisePropertyChangedAuto(); } + set + { + _isNotificationsOpened = value; RaisePropertyChangedAuto(); + } + } + + private bool _isPowerOpened; + /// + /// Gets or sets a value indicating whether the power area is opened. + /// + public bool IsPowerOpened + { + get { return _isPowerOpened; } + set { _isPowerOpened = value; RaisePropertyChangedAuto(); } } #endregion @@ -90,6 +111,10 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand UpdateCommand { get; set; } + /// + /// Gets or sets the power command. + /// + public RelayCommand PowerCommand { get; set; } #endregion #region Constructors @@ -106,12 +131,14 @@ namespace Tango.PPC.UI.ViewModels StopPrintingCommand = new RelayCommand(StopPrinting); SignOutCommand = new RelayCommand(SignOut); - UpdateCommand = new RelayCommand(() => + UpdateCommand = new RelayCommand(() => { NavigationManager.NavigateTo(NavigationView.MachineUpdateView); TangoIOC.Default.GetInstance().CheckForUpdates(); IsMenuOpened = false; }); + + PowerCommand = new RelayCommand(() => IsPowerOpened = true); } #endregion -- 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/Tango.PPC.UI/ViewModels') 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 bfc481bb93045f759a147f074a2ab1be57076c92 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 12 Mar 2019 17:28:51 +0200 Subject: Working on PPC update.. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/Graphics/From Marketing/3.png | Bin 0 -> 18722 bytes Software/Graphics/From Marketing/Embroider.png | Bin 0 -> 90271 bytes Software/Graphics/From Marketing/Front.png | Bin 0 -> 318202 bytes Software/Graphics/From Marketing/Icon Cloud.png | Bin 0 -> 329523 bytes Software/Graphics/From Marketing/Left view.png | Bin 0 -> 385090 bytes Software/Graphics/From Marketing/Left.png | Bin 0 -> 7873247 bytes Software/Graphics/From Marketing/Right view.png | Bin 0 -> 291867 bytes Software/Graphics/From Marketing/Right.png | Bin 0 -> 7527881 bytes .../Graphics/From Marketing/System contour 2D.png | Bin 0 -> 53085 bytes Software/Graphics/From Marketing/TS Red Spool.png | Bin 0 -> 109753 bytes Software/Graphics/From Marketing/TS blue spool.png | Bin 0 -> 109797 bytes Software/Graphics/From Marketing/logo.png | Bin 0 -> 168881 bytes Software/Graphics/Mobile/m_update.png | Bin 0 -> 88509 bytes Software/Graphics/Mobile/machine-update.png | Bin 0 -> 54914 bytes .../Tango.PPC.MachineSettings/Views/MainView.xaml | 174 +++++++++------ .../MachineUpdate/MachineUpdateManager.cs | 7 + .../PPC/Tango.PPC.UI/Images/machine-update.png | Bin 54914 -> 88509 bytes .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 8 + .../PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml | 234 ++++++++++++--------- 21 files changed, 248 insertions(+), 175 deletions(-) create mode 100644 Software/Graphics/From Marketing/3.png create mode 100644 Software/Graphics/From Marketing/Embroider.png create mode 100644 Software/Graphics/From Marketing/Front.png create mode 100644 Software/Graphics/From Marketing/Icon Cloud.png create mode 100644 Software/Graphics/From Marketing/Left view.png create mode 100644 Software/Graphics/From Marketing/Left.png create mode 100644 Software/Graphics/From Marketing/Right view.png create mode 100644 Software/Graphics/From Marketing/Right.png create mode 100644 Software/Graphics/From Marketing/System contour 2D.png create mode 100644 Software/Graphics/From Marketing/TS Red Spool.png create mode 100644 Software/Graphics/From Marketing/TS blue spool.png create mode 100644 Software/Graphics/From Marketing/logo.png create mode 100644 Software/Graphics/Mobile/m_update.png create mode 100644 Software/Graphics/Mobile/machine-update.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index e88a5f3bd..1f297db88 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 0d682e1a5..fb6cec7dc 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Graphics/From Marketing/3.png b/Software/Graphics/From Marketing/3.png new file mode 100644 index 000000000..c31bc5f66 Binary files /dev/null and b/Software/Graphics/From Marketing/3.png differ diff --git a/Software/Graphics/From Marketing/Embroider.png b/Software/Graphics/From Marketing/Embroider.png new file mode 100644 index 000000000..f71bc2a70 Binary files /dev/null and b/Software/Graphics/From Marketing/Embroider.png differ diff --git a/Software/Graphics/From Marketing/Front.png b/Software/Graphics/From Marketing/Front.png new file mode 100644 index 000000000..4bf9fd6c9 Binary files /dev/null and b/Software/Graphics/From Marketing/Front.png differ diff --git a/Software/Graphics/From Marketing/Icon Cloud.png b/Software/Graphics/From Marketing/Icon Cloud.png new file mode 100644 index 000000000..720609099 Binary files /dev/null and b/Software/Graphics/From Marketing/Icon Cloud.png differ diff --git a/Software/Graphics/From Marketing/Left view.png b/Software/Graphics/From Marketing/Left view.png new file mode 100644 index 000000000..65b269743 Binary files /dev/null and b/Software/Graphics/From Marketing/Left view.png differ diff --git a/Software/Graphics/From Marketing/Left.png b/Software/Graphics/From Marketing/Left.png new file mode 100644 index 000000000..3d6d63d30 Binary files /dev/null and b/Software/Graphics/From Marketing/Left.png differ diff --git a/Software/Graphics/From Marketing/Right view.png b/Software/Graphics/From Marketing/Right view.png new file mode 100644 index 000000000..aedacdcfd Binary files /dev/null and b/Software/Graphics/From Marketing/Right view.png differ diff --git a/Software/Graphics/From Marketing/Right.png b/Software/Graphics/From Marketing/Right.png new file mode 100644 index 000000000..158d4b625 Binary files /dev/null and b/Software/Graphics/From Marketing/Right.png differ diff --git a/Software/Graphics/From Marketing/System contour 2D.png b/Software/Graphics/From Marketing/System contour 2D.png new file mode 100644 index 000000000..fdee5a30d Binary files /dev/null and b/Software/Graphics/From Marketing/System contour 2D.png differ diff --git a/Software/Graphics/From Marketing/TS Red Spool.png b/Software/Graphics/From Marketing/TS Red Spool.png new file mode 100644 index 000000000..5a60c6b16 Binary files /dev/null and b/Software/Graphics/From Marketing/TS Red Spool.png differ diff --git a/Software/Graphics/From Marketing/TS blue spool.png b/Software/Graphics/From Marketing/TS blue spool.png new file mode 100644 index 000000000..140a7b516 Binary files /dev/null and b/Software/Graphics/From Marketing/TS blue spool.png differ diff --git a/Software/Graphics/From Marketing/logo.png b/Software/Graphics/From Marketing/logo.png new file mode 100644 index 000000000..649a73180 Binary files /dev/null and b/Software/Graphics/From Marketing/logo.png differ diff --git a/Software/Graphics/Mobile/m_update.png b/Software/Graphics/Mobile/m_update.png new file mode 100644 index 000000000..d8db51337 Binary files /dev/null and b/Software/Graphics/Mobile/m_update.png differ diff --git a/Software/Graphics/Mobile/machine-update.png b/Software/Graphics/Mobile/machine-update.png new file mode 100644 index 000000000..3e49520dd Binary files /dev/null and b/Software/Graphics/Mobile/machine-update.png differ 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 8ba06eb43..4f846a46d 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="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -48,95 +48,129 @@ Enable Hot Spot - + Hot Spot Password + + + + + Enabling a hot-spot will create a wireless network dedicated to this machine. + + - - Enable External Bridge Service - + + + Enable External Bridge Service + + + External Bridge Password + + - External Bridge Password - - + + + + Enabling the external bridge service allows external Twine applications to interact with this machine over the local network. + + + - - Supported Job Types - - - - - - - - - - - - - - - - - - Supported Color Spaces/Catalogs - - - - - - - - - - - - - - - - - - Default Thread Type - - - - Default Segment Length - + Default Segment Length + + + - + + + + Job settings allows you to set the default configuration for new jobs. + + + - - Enable Remote Assistance - - + + + Enable Remote Assistance + + + + + + + Enable remote assistance for Twine's technicians. + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 952944cf9..3fffc2045 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -340,6 +340,8 @@ namespace Tango.PPC.Common.MachineUpdate { LogManager.Log("Starting database update..."); + UpdateProgress("Updating Database", "Initializing..."); + LogManager.Log("Looking for update scripts configuration on application path..."); String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "config.xml"); @@ -355,6 +357,8 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Updating database '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); + UpdateProgress("Updating Database", "Initializing update sequence..."); + ExaminerSequenceConfiguration config_sequence = ExaminerSequenceConfiguration.FromFile(config_file); foreach (var item in config_sequence.Items.Where(x => x.Type == ExaminerSequenceItemType.Data).OrderBy(x => x.Index)) @@ -382,6 +386,8 @@ namespace Tango.PPC.Common.MachineUpdate try { + UpdateProgress("Updating Database", item.Name + "..."); + var result = process.Execute().Result; if (result.ExitCode != ExaminerProcessExitCode.Success) @@ -397,6 +403,7 @@ namespace Tango.PPC.Common.MachineUpdate } } + UpdateProgress("Updating Database", "Database synchronization completed successfully."); LogManager.Log("Update completed successfully."); }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/machine-update.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/machine-update.png index 3e49520dd..d8db51337 100644 Binary files a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/machine-update.png and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/machine-update.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index b5b5f56bc..07da99818 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -33,6 +33,7 @@ namespace Tango.PPC.UI.ViewModels private MachineUpdateResult _update_result; private DbCompareResult _db_compare_result; + private bool _isChecking; #region Properties @@ -132,8 +133,11 @@ namespace Tango.PPC.UI.ViewModels { await NavigateTo(MachineUpdateView.UpdateCheckView); + if (_isChecking) return; + try { + _isChecking = true; IsDbUpdate = false; var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber); @@ -164,6 +168,10 @@ namespace Tango.PPC.UI.ViewModels LogManager.Log(ex, "Error while trying to check for updates."); await NavigateTo(MachineUpdateView.UpdateFailedView); } + finally + { + _isChecking = false; + } } private async void Update() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml index 0fb9d9e09..ba7e9e019 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml @@ -11,115 +11,127 @@ xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" xmlns:local="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:MachineUpdateViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineUpdateViewVM}"> + d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:MachineUpdateViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineUpdateViewVM}"> - - + + - - - + + + Back To Application + + + + Checking for updates, please wait... - - + + + - - - - - - - - + + + + + + + + + + Updating your machine can improve the following: - - - - - - Support for new media - - - - - Refined color conversion and calibration algorithms + + + + + + Support for new media + + + + + Refined color conversion and calibration algorithms + + + + + Software fixes and improvements + + + + + Firmware upgrade + - - - Software fixes and improvements - - - - - Firmware upgrade - - - - + Tap 'UPDATE' to start updating now. - - - UPDATE - - Back To Application - + + + - - - Your machine is up to date! - - CLOSE - + + + CLOSE + + + + Your machine is up to date! + + - - - An error occurred while trying to check for updates. Please check your internet connection and try again. - - TRY AGAIN - - Back To Application - + + + TRY AGAIN + Back To Application + + + + An error occurred while trying to check for updates. Please check your internet connection and try again. + + - Updating your machine + Updating your machine Do not turn off the machine - + @@ -129,37 +141,46 @@ - - - - Updating database... - + + Updating your machine + Do not turn off the machine + + + + + + - - - Update completed successfully ! - - RESTART - + + + RESTART + + + + Your machine is up to date! + + - - - Update Failed - - - TRY AGAIN - - Back To Application - + + + TRY AGAIN + Back To Application + + + + Update Failed + + + - + Updating your software @@ -168,12 +189,15 @@ - - - An error occurred while trying to update the machine. - - Back To Application - + + + CLOSE + + + + An error occurred while trying to update the machine. + + -- cgit v1.3.1 From c5cde62cecfdd413e9902b26b30b0d4dfd05a24d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 14 Mar 2019 13:25:32 +0200 Subject: Machine Studio v4.0.10 PPC v1.0.9 --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../DB/SQLExaminer Projects/DEV TO TEST.sdeproj | 999 +++++++++++++++++++++ Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Machine Studio Installer.aip | 94 +- .../Advanced Installer Projects/PPC Installer.aip | 102 +-- .../ViewModels/MainViewVM.cs | 41 +- .../Views/JobView.xaml | 6 +- .../ViewModels/MachineTechViewVM.cs | 4 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 4 +- .../AvailableWiFiConnectionsControl.xaml | 4 +- .../HotSpot/DefaultHotSpotProvider.cs | 2 +- .../MachineUpdate/MachineUpdateManager.cs | 11 +- .../Tango.PPC.Common/Printing/IPrintingManager.cs | 6 +- .../Printing/DefaultPrintingManager.cs | 14 +- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../ViewModels/ExternalBridgeViewVM.cs | 13 +- .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 8 + .../PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/MainView.xaml | 2 +- .../ColorConversion/TangoColorConverter.cs | 92 +- .../ExtensionMethods/ExceptionExtensions.cs | 6 +- .../ExtensionMethods/FrameworkElementExtensions.cs | 199 +++- .../Tango.DragAndDrop/DragAndDropService.cs | 5 +- .../ExternalBridge/ExternalBridgeService.cs | 6 + .../DefaultGradientGenerationConfiguration.cs | 134 +++ .../Operation/IGradientGenerationConfiguration.cs | 34 + .../Operation/IMachineOperator.cs | 16 +- .../Tango.Integration/Operation/MachineOperator.cs | 579 ++++++------ .../Operation/PreparingJobProgressEventArgs.cs | 31 + .../Tango.Integration/Tango.Integration.csproj | 5 +- .../SQLExaminer/Configurations/UpdateMachine.xml | Bin 39266 -> 41074 bytes .../Tango.Touch/Controls/LightTouchDataGrid.cs | 16 +- 34 files changed, 1905 insertions(+), 532 deletions(-) create mode 100644 Software/DB/SQLExaminer Projects/DEV TO TEST.sdeproj create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 1f297db88..99c40040f 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 fb6cec7dc..537db63a9 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/SQLExaminer Projects/DEV TO TEST.sdeproj b/Software/DB/SQLExaminer Projects/DEV TO TEST.sdeproj new file mode 100644 index 000000000..cfffb2a75 --- /dev/null +++ b/Software/DB/SQLExaminer Projects/DEV TO TEST.sdeproj @@ -0,0 +1,999 @@ + + + + MsSqlAzure + LiveDb + twine.database.windows.net + Tango_DEV + False + False + Roy + Aa123456 + true + + + MsSqlAzure + LiveDb + twine.database.windows.net + Tango_TEST + False + False + Roy + Aa123456 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + False + False + 0 + 0 + + + + + + \ No newline at end of file diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 23d1ce16b..7c3c65c6c 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 6dbbf2c2c..e24b691d1 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index 65e40810e..5f01dbb66 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -67,17 +67,9 @@ - - - - - - - - @@ -107,7 +99,6 @@ - @@ -123,9 +114,7 @@ - - @@ -134,7 +123,6 @@ - @@ -142,11 +130,8 @@ - - - @@ -158,18 +143,13 @@ - - - - - @@ -196,7 +176,6 @@ - @@ -213,23 +192,15 @@ - - - - - - - - @@ -237,25 +208,19 @@ - - - - - - @@ -309,12 +274,8 @@ - - - - @@ -322,13 +283,13 @@ + - - + @@ -372,21 +333,12 @@ - - - - - - - - - @@ -433,7 +385,6 @@ - @@ -442,7 +393,6 @@ - @@ -467,9 +417,7 @@ - - @@ -478,7 +426,6 @@ - @@ -488,11 +435,8 @@ - - - @@ -504,18 +448,13 @@ - - - - - @@ -550,7 +489,6 @@ - @@ -567,24 +505,16 @@ - - - - - - - - @@ -592,12 +522,10 @@ - - @@ -606,17 +534,13 @@ - - - - - + @@ -750,19 +674,11 @@ - - - - - - - - @@ -773,9 +689,6 @@ - - - @@ -869,6 +782,7 @@ + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 747e6eae3..edeedd43d 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -73,17 +73,9 @@ - - - - - - - - @@ -110,12 +102,11 @@ - - + @@ -130,46 +121,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -205,19 +170,15 @@ - - - - + - - + @@ -229,7 +190,7 @@ - + @@ -252,21 +213,12 @@ - - - - - - - - - @@ -310,14 +262,12 @@ - - @@ -337,23 +287,12 @@ - - - - - - - - - - - @@ -367,28 +306,13 @@ - - - - - - - - - - - - - - - @@ -482,20 +406,9 @@ - - - - - - - - - - - @@ -507,7 +420,7 @@ - + @@ -575,6 +488,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 35aca807c..04d2fae4b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -46,6 +46,7 @@ using System.Data.Entity; using System.Runtime.ExceptionServices; using Tango.BL.Builders; using Tango.MachineStudio.Common.Navigation; +using System.Diagnostics; namespace Tango.MachineStudio.Developer.ViewModels { @@ -78,6 +79,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private bool _dialog_shown; private bool _disable_gamut_check; private bool _rml_has_no_cct; + private TaskItem _preparingTaskItem; #region Properties @@ -739,8 +741,8 @@ namespace Tango.MachineStudio.Developer.ViewModels RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null && CanWork); SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null && CanWork); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null && CanWork); - StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.PreventJob))); - StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.PreventJob))); + StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null); + StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning && CanWork); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); LoadJobCommand = new RelayCommand(() => LoadSelectedJob(), () => SelectedMachineJob != null && CanWork); @@ -956,6 +958,17 @@ namespace Tango.MachineStudio.Developer.ViewModels MachineOperator.ResumingJob -= MachineOperator_ResumingJob; MachineOperator.ResumingJob += MachineOperator_ResumingJob; + + MachineOperator.PreparingJobProgress -= MachineOperator_PreparingJobProgress; + MachineOperator.PreparingJobProgress += MachineOperator_PreparingJobProgress; + } + } + + private void MachineOperator_PreparingJobProgress(object sender, PreparingJobProgressEventArgs e) + { + if (_preparingTaskItem != null) + { + _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; } } @@ -991,6 +1004,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineEventsStateProvider_EventsChanged(object sender, IEnumerable changedEvents) { InvokeUI(StartJobCommand.RaiseCanExecuteChanged); + InvokeUI(StartJobAndRecordCommand.RaiseCanExecuteChanged); } /// @@ -1277,7 +1291,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Starts the job. /// - private void StartJob(Func resumeFunc = null) + private async void StartJob(Func resumeFunc = null) { LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) @@ -1301,22 +1315,27 @@ namespace Tango.MachineStudio.Developer.ViewModels IsJobFailed = false; IsJobCanceled = false; IsJobCompleted = false; - IsJobRunning = true; - ShowJobStatus = true; RunningJob = ActiveJob; _runningJobEstimatedDuration = EstimatedDuration; RunningJobSegments = RunningJob.EffectiveSegments.ToList(); - _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); - try { + IsFree = false; LogManager.Log("Sending job to machine operator..."); if (resumeFunc == null) { - JobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + using (var item = _notification.PushTaskItem("Preparing job for printing...")) + { + _preparingTaskItem = item; + JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + } + + _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); + IsJobRunning = true; + ShowJobStatus = true; } else { @@ -1403,6 +1422,10 @@ namespace Tango.MachineStudio.Developer.ViewModels SetJobFailed(); StopRecordingIfInProgress(); } + finally + { + IsFree = true; + } } /// @@ -2077,7 +2100,7 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.ColorSpace = _machineDbContext.ColorSpaces.FirstOrDefault(); newJob.Machine = SelectedMachine; - + SelectedMachine.Jobs.Add(newJob); var segment = newJob.AddSolidSegment(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 1057f7c84..9504d5769 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -432,7 +432,7 @@ - + @@ -866,8 +866,8 @@ - - Enable Color Conversion + + Enable Gradient Generation diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 666a56704..e78047563 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -1749,13 +1749,13 @@ namespace Tango.MachineStudio.Technician.ViewModels /// private void InitJobRunnerItem(JobRunnerItem item) { - item.StartJob += () => + item.StartJob += async () => { try { CheckMachineOperator(); - var handler = MachineOperator.Print(item.Job, item.ProcessParameters); + var handler = await MachineOperator.Print(item.Job, item.ProcessParameters); item.JobHandler = handler; 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 ace1d38af..47a3df569 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 @@ -279,8 +279,8 @@ - - + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml index 80581551e..dac37ba10 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml @@ -64,8 +64,8 @@ Connect automatically - Connect - Disconnect + Connect + Disconnect diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs index 4f035d814..835a7fc4a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -77,7 +77,7 @@ namespace Tango.PPC.Common.HotSpot { try { - CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango-" + _machineProvider.Machine.SerialNumber}' key='{password}'"); + CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid={"Tango-" + _machineProvider.Machine.SerialNumber} key={password}"); await command.Run(); command = new CmdCommand("netsh", "wlan start hosted network"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 3fffc2045..b64b624fe 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -75,13 +75,10 @@ namespace Tango.PPC.Common.MachineUpdate private Task Login(String serialNumber) { - return Task.Factory.StartNew(() => + return _client.Login(new LoginRequest() { - return _client.Login(new LoginRequest() - { - Mode = LoginMode.Machine, - SerialNumber = serialNumber, - }).Result; + Mode = LoginMode.Machine, + SerialNumber = serialNumber, }); } @@ -310,7 +307,7 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); - Login(serialNumber).Wait(); + Login(serialNumber).GetAwaiter().GetResult(); LogManager.Log($"Checking if updates available..."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs index 37a71c965..dc097a805 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs @@ -22,7 +22,7 @@ namespace Tango.PPC.Common.Printing /// The job. /// The context. /// - JobHandler Print(Job job, ObservablesContext context); + Task Print(Job job, ObservablesContext context); /// /// Creates a sample dye job from the specified job and prints it. @@ -31,7 +31,7 @@ namespace Tango.PPC.Common.Printing /// The job. /// The context. /// - JobHandler PrintSample(Job job, ObservablesContext context); + Task PrintSample(Job job, ObservablesContext context); /// /// Creates a fine tuning job from the specified job and fine tune items. @@ -41,6 +41,6 @@ namespace Tango.PPC.Common.Printing /// The context. /// The fine tune items. /// - JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems); + Task PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index d6770ed45..f05c05a44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -42,13 +42,13 @@ namespace Tango.PPC.UI.Printing /// The job. /// The context. /// - public JobHandler Print(Job job, ObservablesContext context) + public async Task Print(Job job, ObservablesContext context) { #if STUBPRINT - var handler = _machineProvider.MachineOperator.PrintStub(job); + var handler = await _machineProvider.MachineOperator.PrintStub(job); #else - var handler = _machineProvider.MachineOperator.Print(job); + var handler = await _machineProvider.MachineOperator.Print(job); #endif handler.Completed += async (x, e) => @@ -104,7 +104,7 @@ namespace Tango.PPC.UI.Printing /// The job. /// The context. /// - public JobHandler PrintSample(Job job, ObservablesContext context) + public async Task PrintSample(Job job, ObservablesContext context) { LogManager.Log("Cloning job..."); Job sampleDyeJob = job.Clone(); @@ -131,7 +131,7 @@ namespace Tango.PPC.UI.Printing LogManager.Log("Executing sample dye job..."); - var handler = _machineProvider.MachineOperator.Print(sampleDyeJob); + var handler = await _machineProvider.MachineOperator.Print(sampleDyeJob); handler.Completed += async (x, e) => { try @@ -157,7 +157,7 @@ namespace Tango.PPC.UI.Printing /// The context. /// The fine tune items. /// - public JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) + public async Task PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) { LogManager.Log("Cloning job..."); Job fineTuneJob = job.Clone(); @@ -172,7 +172,7 @@ namespace Tango.PPC.UI.Printing var segment = fineTuneJob.AddSolidSegment(suggestion.Color); } - var handler = _machineProvider.MachineOperator.Print(fineTuneJob); + var handler = await _machineProvider.MachineOperator.Print(fineTuneJob); handler.Completed += async (x, e) => { try 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 fa54f491e..a0db99ffb 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.6.0")] +[assembly: AssemblyVersion("1.0.9.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 83f629159..80a95d1bf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs @@ -116,12 +116,15 @@ namespace Tango.PPC.UI.ViewModels /// The instance containing the event data. private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e) { - LogManager.Log("External bridge client disconnected. Navigating to home module..."); - - InvokeUI(() => + if (IsVisible) { - NavigationManager.NavigateTo(NavigationView.HomeModule); - }); + LogManager.Log("External bridge client disconnected. Navigating to home module..."); + + InvokeUI(() => + { + NavigationManager.NavigateTo(NavigationView.HomeModule); + }); + } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 07da99818..f265c5dbf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -140,6 +140,14 @@ namespace Tango.PPC.UI.ViewModels _isChecking = true; IsDbUpdate = false; + await Task.Delay(2000); + if (!await ConnectivityProvider.CheckInternetConnection()) + { + _isChecking = false; + await NavigateTo(MachineUpdateView.UpdateCheckErrorView); + return; + } + var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber); if (response.IsUpdateAvailable) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml index ba7e9e019..fba8a599d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml @@ -174,7 +174,7 @@ Update Failed - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index e4c107049..c63ef1e13 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -59,7 +59,7 @@ - + diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index d44859413..3c8a58459 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Logging; using Tango.PMR; using Tango.PMR.ColorLab; @@ -70,9 +71,9 @@ namespace Tango.BL.ColorConversion conversionInput.ColorSpace = PMR.ColorLab.ColorSpace.Rgb; conversionInput.InputCoordinates = new InputCoordinates(); - conversionInput.InputCoordinates.Red = Math.Max((int)color.R, 1); - conversionInput.InputCoordinates.Green = Math.Max((int)color.G, 1); - conversionInput.InputCoordinates.Blue = Math.Max((int)color.B, 1); + conversionInput.InputCoordinates.Red = Math.Max((int)color.R, 0); + conversionInput.InputCoordinates.Green = Math.Max((int)color.G, 0); + conversionInput.InputCoordinates.Blue = Math.Max((int)color.B, 0); conversionInput.ThreadL = 92.1815;//brushStop.Segment.Job.Rml.WhitePoint.L; conversionInput.ThreadA = 2.2555;//brushStop.Segment.Job.Rml.WhitePoint.A; @@ -290,5 +291,90 @@ namespace Tango.BL.ColorConversion return conversionInput; } + + public static void ApplyBrushStopCorrection(BrushStop stop, ProcessParametersTable processTable, ConversionOutput conversionOutput) + { + var output = conversionOutput; + + stop.SetLiquidVolumes(stop.Segment.Job.Machine.Configuration, stop.Segment.Job.Rml, processTable); + + foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) + { + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); + } + + liquidVolume.Volume = outputLiquid.Volume; + } + } + + public static List CreateSegmentLinearGradient(Segment segment, ProcessParametersTable processTable, int resolutionCM) + { + List stops = new List(); + + int stopIndex = 1; + + for (double cm = 0; cm < segment.Length; cm += (resolutionCM / 100d)) + { + double offset = (double)cm / segment.Length; + + var color = GetRelativeColor(segment.BrushStops.ToList(), offset); + var output = GetSuggestions(segment.Job, color); + + BrushStop s = new BrushStop(); + s.Segment = segment; + s.ColorSpace = new Entities.ColorSpace(); + s.ColorSpace.Code = ColorSpaces.RGB.ToInt32(); + s.Corrected = true; + s.OffsetPercent = offset * 100d; + s.OffsetMeters = segment.Length * offset; + s.Red = color.R; + s.Green = color.G; + s.Blue = color.B; + s.StopIndex = stopIndex++; + + ApplyBrushStopCorrection(s, processTable, output); + + stops.Add(s); + } + + return stops; + } + + private static Color GetRelativeColor(List brushStopsCollection, double offset) + { + brushStopsCollection = brushStopsCollection.Select(x => x.ShallowClone()).ToList(); + brushStopsCollection.ForEach(x => x.OffsetPercent = x.OffsetPercent / 100d); + + var point = brushStopsCollection.SingleOrDefault(f => f.OffsetPercent == offset); + if (point != null) return point.Color; + + BrushStop before = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Min(m => m.OffsetPercent)).First(); + BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).First(); + + foreach (var gs in brushStopsCollection) + { + if (gs.OffsetPercent < offset && gs.OffsetPercent > before.OffsetPercent) + { + before = gs; + } + if (gs.OffsetPercent > offset && gs.OffsetPercent < after.OffsetPercent) + { + after = gs; + } + } + + var color = new Color(); + + color.ScA = (float)((offset - before.OffsetPercent) * (after.Color.ScA - before.Color.ScA) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScA); + color.ScR = (float)((offset - before.OffsetPercent) * (after.Color.ScR - before.Color.ScR) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScR); + color.ScG = (float)((offset - before.OffsetPercent) * (after.Color.ScG - before.Color.ScG) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScG); + color.ScB = (float)((offset - before.OffsetPercent) * (after.Color.ScB - before.Color.ScB) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScB); + + return color; + } } } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs index 86434cdc4..af4fc39b5 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs @@ -43,10 +43,14 @@ public static class ExceptionExtensions { try { - message += Environment.NewLine + String.Join(Environment.NewLine, (exception as AggregateException).InnerExceptions.Select(x => x.Message)); + message = String.Join(Environment.NewLine, (exception as AggregateException).InnerExceptions.Select(x => x.FlattenMessage())); } catch { } } + else if (exception.InnerException != null) + { + message += Environment.NewLine + exception.InnerException.FlattenMessage(); + } return message; } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index 2e1791b63..08f3bb101 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Animation; @@ -18,6 +19,14 @@ public static class FrameworkElementExtensions { #region Mouse Or Touch Events + //Used to hold the registered event handlers for later use by UnRegisterMouseOrTouch. + private static List _containers = new List(); + private class ElementEventsContainer + { + public EventHandler Handler { get; set; } + public Action Clear { get; set; } + } + /// /// Registers for mouse or touch down. /// @@ -29,7 +38,7 @@ public static class FrameworkElementExtensions bool mousePressed = false; bool touchDown = false; - element.MouseDown += (x, e) => + MouseButtonEventHandler mouseDownHandler = (x, e) => { if (!touchDown) { @@ -53,7 +62,9 @@ public static class FrameworkElementExtensions } }; - element.TouchDown += (x, e) => + element.MouseDown += mouseDownHandler; + + EventHandler touchDownHandler = (x, e) => { if (!mousePressed) { @@ -77,16 +88,31 @@ public static class FrameworkElementExtensions } }; - element.MouseUp += (_, __) => + element.TouchDown += touchDownHandler; + + MouseButtonEventHandler mouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; }; - element.TouchDown += (_, __) => - { + element.MouseUp += mouseUpHandler; + + //element.TouchDown += (_, __) => + //{ + + //}; + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.MouseUp -= mouseUpHandler; + element.TouchDown -= touchDownHandler; + element.MouseDown -= mouseDownHandler; }; + + _containers.Add(container); } /// @@ -99,6 +125,101 @@ public static class FrameworkElementExtensions RegisterForMouseOrTouchDown(element, null, handler); } + /// + /// Registers for mouse or touch up. + /// + /// The element. + /// The relative to. + /// The handler. + public static void RegisterForMouseOrTouchUp(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) + { + bool mouseReleased = false; + bool touchReleased = false; + + MouseButtonEventHandler mouseUpHandler = (x, e) => + { + if (!touchReleased) + { + mouseReleased = true; + + var args = new MouseOrTouchEventArgs() + { + Location = new Point(e.GetPosition(relativeTo != null ? relativeTo : element).X, e.GetPosition(relativeTo != null ? relativeTo : element).Y), + Source = e.Source, + OriginalSource = e.OriginalSource, + Handled = e.Handled, + GetPositionAction = e.GetPosition + }; + + handler(element, args); + e.Handled = args.Handled; + } + else + { + touchReleased = false; + } + }; + + element.MouseUp += mouseUpHandler; + + EventHandler touchUpHandler = (x, e) => + { + + if (!mouseReleased) + { + touchReleased = true; + + var args = new MouseOrTouchEventArgs() + { + Location = new Point(e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.X, e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.Y), + Source = e.Source, + OriginalSource = e.OriginalSource, + Handled = e.Handled, + GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + }; + + handler(element, args); + e.Handled = args.Handled; + } + else + { + touchReleased = false; + } + + }; + + element.TouchUp += touchUpHandler; + + EventHandler touchDownHandler = (_, __) => + { + touchReleased = false; + mouseReleased = false; + }; + + element.TouchDown += touchDownHandler; + + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.TouchDown -= touchDownHandler; + element.TouchUp -= touchUpHandler; + element.MouseUp -= mouseUpHandler; + }; + + _containers.Add(container); + } + + /// + /// Registers for mouse or touch up. + /// + /// The element. + /// The handler. + public static void RegisterForMouseOrTouchUp(this FrameworkElement element, EventHandler handler) + { + RegisterForMouseOrTouchUp(element, null, handler); + } + /// /// Registers for preview mouse or touch down. /// @@ -110,7 +231,7 @@ public static class FrameworkElementExtensions bool mousePressed = false; bool touchDown = false; - element.PreviewMouseDown += (x, e) => + MouseButtonEventHandler previewMouseDownHandler = (x, e) => { if (!touchDown) { @@ -134,7 +255,9 @@ public static class FrameworkElementExtensions } }; - element.PreviewTouchDown += (x, e) => + element.PreviewMouseDown += previewMouseDownHandler; + + EventHandler previewTouchDownHandler = (x, e) => { if (!mousePressed) { @@ -158,16 +281,31 @@ public static class FrameworkElementExtensions } }; - element.PreviewMouseUp += (_, __) => + element.PreviewTouchDown += previewTouchDownHandler; + + MouseButtonEventHandler previewMouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; }; - element.PreviewTouchDown += (_, __) => - { + element.PreviewMouseUp += previewMouseUpHandler; + + //element.PreviewTouchDown += (_, __) => + //{ + + //}; + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.PreviewTouchDown -= previewTouchDownHandler; + element.PreviewMouseDown -= previewMouseDownHandler; + element.PreviewMouseUp -= previewMouseUpHandler; }; + + _containers.Add(container); } /// @@ -191,7 +329,7 @@ public static class FrameworkElementExtensions bool mouseReleased = false; bool touchReleased = false; - element.PreviewMouseUp += (x, e) => + MouseButtonEventHandler previewMouseUpHandler = (x, e) => { if (!touchReleased) { @@ -215,8 +353,11 @@ public static class FrameworkElementExtensions } }; - element.PreviewTouchUp += (x, e) => + element.PreviewMouseUp += previewMouseUpHandler; + + EventHandler previewTouchHandler = (x, e) => { + if (!mouseReleased) { touchReleased = true; @@ -237,13 +378,29 @@ public static class FrameworkElementExtensions { touchReleased = false; } + }; - element.PreviewTouchDown += (_, __) => + element.PreviewTouchUp += previewTouchHandler; + + EventHandler previewTouchDownHandler = (_, __) => { touchReleased = false; mouseReleased = false; }; + + element.PreviewTouchDown += previewTouchDownHandler; + + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.PreviewTouchDown -= previewTouchDownHandler; + element.PreviewTouchUp -= previewTouchHandler; + element.PreviewMouseUp -= previewMouseUpHandler; + }; + + _containers.Add(container); } /// @@ -256,6 +413,22 @@ public static class FrameworkElementExtensions RegisterForPreviewMouseOrTouchUp(element, null, handler); } + /// + /// Detaches the specified handler from event which it was originally registered. + /// + /// The element. + /// The handler. + public static void UnRegisterMouseOrTouch(this FrameworkElement element, EventHandler handler) + { + var containers = _containers.Where(x => x.Handler == handler); + + foreach (var container in containers.ToList()) + { + container.Clear(); + _containers.Remove(container); + } + } + /// /// Registers for mouse or touch move. /// diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 586071363..8833feff8 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -730,6 +730,7 @@ namespace Tango.DragAndDrop if ((e.Source != sender && dragThumb == null) || (dragThumb != null && dragThumb != e.OriginalSource)) { + _currentDragedElement = null; return; } @@ -759,10 +760,10 @@ namespace Tango.DragAndDrop { FrameworkElement element = _currentDragedElement; - int minDragOffset = GetMinDragOffset(element); - if (element != null) { + int minDragOffset = GetMinDragOffset(element); + var surface = GetDraggingSurface(element); if (surface != null) diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs index c4f559c58..4cdd372f5 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs @@ -283,6 +283,12 @@ namespace Tango.Integration.ExternalBridge { if (IsInSession) { + if (container.Type == MessageType.ExternalBridgeLoginRequest) + { + SendErrorResponse(new AuthenticationException("Machine is already in session."), container.Token); + return; + } + if (_messageHandlers.ContainsKey(container.Type)) { try diff --git a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs new file mode 100644 index 000000000..2f531a95f --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.BL.ColorConversion; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; + +namespace Tango.Integration.Operation +{ + /// + /// Represents the default gradient steps generation configuration. + /// + public class DefaultGradientGenerationConfiguration : ExtendedObject, IGradientGenerationConfiguration + { + private bool _isEnabled; + /// + /// Gets or sets a value indicating whether to generate the gradient steps. + /// + public bool IsEnabled + { + get { return _isEnabled; } + set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + private int _resolutionCM; + /// + /// Gets or sets the gradient steps resolution in centimeters. + /// + public int ResolutionCM + { + get { return _resolutionCM; } + set { _resolutionCM = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public DefaultGradientGenerationConfiguration() + { + ResolutionCM = 10; + } + + /// + /// Creates a collection of brush stops representing the required gradient steps. + /// + /// The segment. + /// The process parameters. + /// Progress callback. + /// + public List Generate(Segment segment, ProcessParametersTable processParameters, Action progress = null) + { + List stops = new List(); + + int stopIndex = 1; + + for (double cm = 0; cm < segment.Length; cm += (ResolutionCM / 100d)) + { + double offset = (double)cm / segment.Length; + + var color = GetRelativeColor(segment.BrushStops.ToList(), offset); + var output = TangoColorConverter.GetSuggestions(segment.Job, color); + + BrushStop s = new BrushStop(); + s.Segment = segment; + s.ColorSpace = new ColorSpace(); + s.ColorSpace.Code = ColorSpaces.RGB.ToInt32(); + s.Corrected = true; + s.OffsetPercent = offset * 100d; + s.OffsetMeters = segment.Length * offset; + s.Red = color.R; + s.Green = color.G; + s.Blue = color.B; + s.StopIndex = stopIndex++; + + TangoColorConverter.ApplyBrushStopCorrection(s, processParameters, output); + + stops.Add(s); + + progress?.Invoke(new PreparingJobProgressEventArgs() + { + Job = segment.Job, + Total = segment.Length, + Progress = cm, + }); + } + + progress?.Invoke(new PreparingJobProgressEventArgs() + { + Job = segment.Job, + Total = segment.Length, + Progress = segment.Length, + }); + + return stops; + } + + private Color GetRelativeColor(List brushStopsCollection, double offset) + { + brushStopsCollection = brushStopsCollection.Select(x => x.ShallowClone()).ToList(); + brushStopsCollection.ForEach(x => x.OffsetPercent = x.OffsetPercent / 100d); + + var point = brushStopsCollection.SingleOrDefault(f => f.OffsetPercent == offset); + if (point != null) return point.Color; + + BrushStop before = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Min(m => m.OffsetPercent)).First(); + BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).First(); + + foreach (var gs in brushStopsCollection) + { + if (gs.OffsetPercent < offset && gs.OffsetPercent > before.OffsetPercent) + { + before = gs; + } + if (gs.OffsetPercent > offset && gs.OffsetPercent < after.OffsetPercent) + { + after = gs; + } + } + + var color = new Color(); + + color.ScA = (float)((offset - before.OffsetPercent) * (after.Color.ScA - before.Color.ScA) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScA); + color.ScR = (float)((offset - before.OffsetPercent) * (after.Color.ScR - before.Color.ScR) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScR); + color.ScG = (float)((offset - before.OffsetPercent) * (after.Color.ScG - before.Color.ScG) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScG); + color.ScB = (float)((offset - before.OffsetPercent) * (after.Color.ScB - before.Color.ScB) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScB); + + return color; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs new file mode 100644 index 000000000..238d80d61 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + /// + /// Represents a gradient steps generation configuration. + /// + public interface IGradientGenerationConfiguration + { + /// + /// Gets or sets a value indicating whether to generate the gradient steps. + /// + bool IsEnabled { get; set; } + + /// + /// Gets or sets the gradient steps resolution in centimeters. + /// + int ResolutionCM { get; set; } + + /// + /// Creates a collection of brush stops representing the required gradient steps. + /// + /// The segment. + /// The process parameters. + /// Progress callback. + /// + List Generate(Segment segment, ProcessParametersTable processParameters, Action progress = null); + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 992323c6d..a5534a063 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -60,6 +60,11 @@ namespace Tango.Integration.Operation /// RunningJobStatus RunningJobStatus { get; } + /// + /// Gets or sets the gradients generation configuration. + /// + IGradientGenerationConfiguration GradientGenerationConfiguration { get; set; } + /// /// Gets a value indicating whether this instance is printing. /// @@ -75,6 +80,11 @@ namespace Tango.Integration.Operation /// event EventHandler StatusChanged; + /// + /// Reports about the job printing preparation progress. + /// + event EventHandler PreparingJobProgress; + /// /// Occurs when a printing process has started. /// @@ -192,7 +202,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - JobHandler Print(Job job); + Task Print(Job job); /// /// Executes a print stub for emulating a full job. @@ -201,7 +211,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - JobHandler PrintStub(Job job); + Task PrintStub(Job job); /// /// Prints the specified job using the specified job parameters. @@ -209,7 +219,7 @@ namespace Tango.Integration.Operation /// The job. /// Process parameters table /// - JobHandler Print(Job job, ProcessParametersTable processParameters); + Task Print(Job job, ProcessParametersTable processParameters); /// /// Uploads the specified process parameters to the embedded device. diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 520b06626..ba9d21451 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -88,6 +88,7 @@ namespace Tango.Integration.Operation EnableJobResume = true; LogEmbeddedDebuggingToFile = true; FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE; + GradientGenerationConfiguration = new DefaultGradientGenerationConfiguration(); } /// @@ -143,6 +144,11 @@ namespace Tango.Integration.Operation /// public event EventHandler ResponseReceived; + /// + /// Reports about the job printing preparation progress. + /// + public event EventHandler PreparingJobProgress; + /// /// Occurs when a printing process has started. /// @@ -378,6 +384,16 @@ namespace Tango.Integration.Operation set { _deviceInformation = value; RaisePropertyChangedAuto(); } } + private IGradientGenerationConfiguration _gradientGenerationConfiguration; + /// + /// Gets or sets the gradients generation configuration. + /// + public IGradientGenerationConfiguration GradientGenerationConfiguration + { + get { return _gradientGenerationConfiguration; } + set { _gradientGenerationConfiguration = value; RaisePropertyChangedAuto(); } + } + #endregion #region Virtual Methods @@ -933,7 +949,17 @@ namespace Tango.Integration.Operation jobSegment.Length = segment.LengthWithFactor; jobSegment.Name = segment.Name; - foreach (var stop in segment.BrushStops) + var stops = segment.BrushStops.ToList(); + + if (GradientGenerationConfiguration != null && GradientGenerationConfiguration.IsEnabled) + { + GradientGenerationConfiguration.Generate(segment, processParameters, (e) => + { + PreparingJobProgress?.Invoke(this, e); + }); + } + + foreach (var stop in stops) { JobBrushStop jobStop = new JobBrushStop(); jobStop.Index = stop.StopIndex; @@ -1073,7 +1099,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - public JobHandler Print(Job job) + public Task Print(Job job) { //Check not brush stop has color space 'Volume'. if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) @@ -1217,181 +1243,185 @@ namespace Tango.Integration.Operation /// The job. /// Process parameters table /// - public JobHandler Print(Job job, ProcessParametersTable processParameters) + public Task Print(Job job, ProcessParametersTable processParameters) { - if (Status != MachineStatuses.ReadyToDye) + return Task.Factory.StartNew(() => { - throw new InvalidOperationException("Could not print while status = " + Status); - } + if (Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException("Could not print while status = " + Status); + } - RunningJob = null; - RunningJobStatus = null; + RunningJob = null; + RunningJobStatus = null; - var originalJob = job; + var originalJob = job; - CurrentProcessParameters = processParameters; + CurrentProcessParameters = processParameters; - JobRequest request = new JobRequest(); + JobRequest request = new JobRequest(); - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } + if (job.NumberOfUnits < 1) + { + job.NumberOfUnits = 1; + } - job = job.Clone(); + job = job.Clone(); - int max = job.OrderedSegments.Last().SegmentIndex; + int max = job.OrderedSegments.Last().SegmentIndex; - var segments = job.OrderedSegments.ToList(); + var segments = job.OrderedSegments.ToList(); - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) + for (int i = 0; i < job.NumberOfUnits - 1; i++) { - var cloned = s.Clone(job); - cloned.SegmentIndex = max++; - job.Segments.Add(cloned); + foreach (var s in segments) + { + var cloned = s.Clone(job); + cloned.SegmentIndex = max++; + job.Segments.Add(cloned); + } } - } - JobTicket ticket = new JobTicket(); - 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(); + JobTicket ticket = new JobTicket(); + 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(); - job.SpoolType.MapPrimitivesTo(ticket.Spool); + job.SpoolType.MapPrimitivesTo(ticket.Spool); - var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); + var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); - if (spool == null) - { - throw new InvalidOperationException("Job spool type is not registered with this machine."); - } - else - { - spool.MapPrimitivesTo(ticket.Spool); - } + if (spool == null) + { + throw new InvalidOperationException("Job spool type is not registered with this machine."); + } + else + { + spool.MapPrimitivesTo(ticket.Spool); + } - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - ProcessParameters process = new ProcessParameters(); - processParameters.MapPrimitivesTo(process); - ticket.ProcessParameters = process; + ProcessParameters process = new ProcessParameters(); + processParameters.MapPrimitivesTo(process); + ticket.ProcessParameters = process; - foreach (var segment in job.OrderedSegments) - { - ticket.Segments.Add(CreatePMRJobSegment(segment, job, processParameters)); - } + foreach (var segment in job.OrderedSegments) + { + ticket.Segments.Add(CreatePMRJobSegment(segment, job, processParameters)); + } - request.JobTicket = ticket.Clone(); + request.JobTicket = ticket.Clone(); - JobHandler handler = null; + JobHandler handler = null; - handler = new JobHandler(async () => - { - try - { - var result = await SendRequest(new AbortJobRequest()); - PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCanceled(); - } - catch (Exception ex) + handler = new JobHandler(async () => { - LogManager.Log(ex, "Failed to cancel job."); - } - }, originalJob, ticket, processParameters, JobHandlingMode); + try + { + var result = await SendRequest(new AbortJobRequest()); + PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCanceled(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed to cancel job."); + } + }, originalJob, ticket, processParameters, JobHandlingMode); - handler.StatusChanged += (x, s) => - { - RunningJobStatus = s; - }; + handler.StatusChanged += (x, s) => + { + RunningJobStatus = s; + }; - if (!job.IsAllSegmentsPerSpool) - { - ContinueSingleSpoolJob(job.OrderedSegments.First(), job, processParameters, handler); - return handler; - } + if (!job.IsAllSegmentsPerSpool) + { + ContinueSingleSpoolJob(job.OrderedSegments.First(), job, processParameters, handler); + return handler; + } - request.JobTicket.UploadStrategy = JobUploadStrategy; + request.JobTicket.UploadStrategy = JobUploadStrategy; - ThreadFactory.StartNew(async () => - { - if (JobUploadStrategy == JobUploadStrategy.JobDescriptionFile) + ThreadFactory.StartNew(async () => { - request.JobTicket.Segments.Clear(); - - JobDescriptionFile jobDescriptionFile = new JobDescriptionFile(ticket.Segments); - MemoryStream ms = jobDescriptionFile.ToStream(); + if (JobUploadStrategy == JobUploadStrategy.JobDescriptionFile) + { + request.JobTicket.Segments.Clear(); - var storage = CreateStorageManager(); + JobDescriptionFile jobDescriptionFile = new JobDescriptionFile(ticket.Segments); + MemoryStream ms = jobDescriptionFile.ToStream(); - var storageInfo = await storage.GetStorageDrive(); - var root_folder = await storage.GetRootFolder(); + var storage = CreateStorageManager(); - var existing_item = root_folder.Items.SingleOrDefault(x => x.Name == JOB_DESCRIPTION_FILE_NAME); - if (existing_item != null) - { - await storage.DeleteItem(existing_item); - } + var storageInfo = await storage.GetStorageDrive(); + var root_folder = await storage.GetRootFolder(); - String job_file_path = Path.Combine(storageInfo.Root, JOB_DESCRIPTION_FILE_NAME); + var existing_item = root_folder.Items.SingleOrDefault(x => x.Name == JOB_DESCRIPTION_FILE_NAME); + if (existing_item != null) + { + await storage.DeleteItem(existing_item); + } - await storage.UploadFileSync(job_file_path, ms); + String job_file_path = Path.Combine(storageInfo.Root, JOB_DESCRIPTION_FILE_NAME); - ms.Dispose(); + await storage.UploadFileSync(job_file_path, ms); - request.JobTicket.JobDescriptionFile = job_file_path; - } + ms.Dispose(); - LogRequestSent(request); - bool responseLogged = false; + request.JobTicket.JobDescriptionFile = job_file_path; + } - Status = MachineStatuses.Printing; - RunningJob = originalJob; - PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + LogRequestSent(request); + bool responseLogged = false; - SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => - { - handler.RaiseStatusReceived(response.Message.Status); + Status = MachineStatuses.Printing; + RunningJob = originalJob; + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - if (!responseLogged) + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { - responseLogged = true; - LogResponseReceived(response.Message); - } - }, (ex) => - { - if (!(ex is ContinuousResponseAbortedException)) + handler.RaiseStatusReceived(response.Message.Status); + + if (!responseLogged) + { + responseLogged = true; + LogResponseReceived(response.Message); + } + }, (ex) => { - Status = MachineStatuses.ReadyToDye; + if (!(ex is ContinuousResponseAbortedException)) + { + Status = MachineStatuses.ReadyToDye; - if (!handler.IsCanceled) + if (!handler.IsCanceled) + { + PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseFailed(ex); + LogRequestFailed(request, ex); + } + } + else { - PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseFailed(ex); - LogRequestFailed(request, ex); + Status = MachineStatuses.ReadyToDye; } - } - else + }, () => { Status = MachineStatuses.ReadyToDye; - } - }, () => - { - Status = MachineStatuses.ReadyToDye; - PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCompleted(); + PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCompleted(); + }); }); - }); - return handler; + return handler; + + }); } /// @@ -1415,204 +1445,209 @@ namespace Tango.Integration.Operation /// or /// Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'. /// - public JobHandler PrintStub(Job job) + public Task PrintStub(Job job) { - //Check not brush stop has color space 'Volume'. - if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) + return Task.Factory.StartNew(() => { - throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); - } - //Get least common process parameters table index. - int processParametersTableIndex = 0; + //Check not brush stop has color space 'Volume'. + if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) + { + throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); + } - if (job.Rml == null) - { - throw new NullReferenceException("Job RML is null"); - } + //Get least common process parameters table index. + int processParametersTableIndex = 0; - var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); + if (job.Rml == null) + { + throw new NullReferenceException("Job RML is null"); + } - if (processGroup == null) - { - throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); - } + var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); - var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); + if (processGroup == null) + { + throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); + } - if (processParameters == null) - { - throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); - } + var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); - //Perform color correction - foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) - { - if (stop.LiquidVolumes == null) + if (processParameters == null) { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); } - foreach (var liquidVolume in stop.LiquidVolumes) + //Perform color correction + foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) { - liquidVolume.Volume = 10; + if (stop.LiquidVolumes == null) + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + } + + foreach (var liquidVolume in stop.LiquidVolumes) + { + liquidVolume.Volume = 10; + } } - } - if (Status != MachineStatuses.ReadyToDye) - { - throw new InvalidOperationException("Could not print while status = " + Status); - } + if (Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException("Could not print while status = " + Status); + } - RunningJob = null; - RunningJobStatus = null; + RunningJob = null; + RunningJobStatus = null; - var originalJob = job; + var originalJob = job; - CurrentProcessParameters = processParameters; + CurrentProcessParameters = processParameters; - StubJobRequest request = new StubJobRequest(); + StubJobRequest request = new StubJobRequest(); - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } + if (job.NumberOfUnits < 1) + { + job.NumberOfUnits = 1; + } - job = job.Clone(); + job = job.Clone(); - var segments = job.OrderedSegments.ToList(); + var segments = job.OrderedSegments.ToList(); - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) + for (int i = 0; i < job.NumberOfUnits - 1; i++) { - job.Segments.Add(s); + foreach (var s in segments) + { + job.Segments.Add(s); + } } - } - - JobTicket ticket = new JobTicket(); - ticket.Guid = originalJob.Guid; - ticket.EnableInterSegment = job.EnableInterSegment; - ticket.InterSegmentLength = job.InterSegmentLength; - ticket.Length = job.Length; - ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; - ticket.Spool = new JobSpool(); - job.SpoolType.MapPrimitivesTo(ticket.Spool); - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; + JobTicket ticket = new JobTicket(); + ticket.Guid = originalJob.Guid; + ticket.EnableInterSegment = job.EnableInterSegment; + ticket.InterSegmentLength = job.InterSegmentLength; + ticket.Length = job.Length; + ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; + ticket.Spool = new JobSpool(); - ProcessParameters process = new ProcessParameters(); - processParameters.MapPrimitivesTo(process); - ticket.ProcessParameters = process; + job.SpoolType.MapPrimitivesTo(ticket.Spool); + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - foreach (var segment in job.OrderedSegments) - { - JobSegment jobSegment = new JobSegment(); - jobSegment.Length = segment.LengthWithFactor; - jobSegment.Name = segment.Name; + ProcessParameters process = new ProcessParameters(); + processParameters.MapPrimitivesTo(process); + ticket.ProcessParameters = process; - foreach (var stop in segment.BrushStops) + foreach (var segment in job.OrderedSegments) { - JobBrushStop jobStop = new JobBrushStop(); - jobStop.Index = stop.StopIndex; - jobStop.OffsetPercent = stop.OffsetPercent; - jobStop.OffsetMeters = stop.OffsetMeters; + JobSegment jobSegment = new JobSegment(); + jobSegment.Length = segment.LengthWithFactor; + jobSegment.Name = segment.Name; - if (stop.LiquidVolumes == null) + foreach (var stop in segment.BrushStops) { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - } + JobBrushStop jobStop = new JobBrushStop(); + jobStop.Index = stop.StopIndex; + jobStop.OffsetPercent = stop.OffsetPercent; + jobStop.OffsetMeters = stop.OffsetMeters; - foreach (var liquidVolume in stop.LiquidVolumes) - { - JobDispenser dispenser = new JobDispenser(); - dispenser.Index = liquidVolume.IdsPack.PackIndex; - dispenser.Volume = liquidVolume.Volume; - dispenser.DispenserLiquidType = (DispenserLiquidType)liquidVolume.IdsPack.LiquidType.Code; - dispenser.DispenserStepDivision = (DispenserStepDivision)liquidVolume.DispenserStepDivision; + if (stop.LiquidVolumes == null) + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + } - dispenser.NanoliterPerPulse = liquidVolume.IdsPack.Dispenser.NlPerPulse; + foreach (var liquidVolume in stop.LiquidVolumes) + { + JobDispenser dispenser = new JobDispenser(); + dispenser.Index = liquidVolume.IdsPack.PackIndex; + dispenser.Volume = liquidVolume.Volume; + dispenser.DispenserLiquidType = (DispenserLiquidType)liquidVolume.IdsPack.LiquidType.Code; + dispenser.DispenserStepDivision = (DispenserStepDivision)liquidVolume.DispenserStepDivision; + + dispenser.NanoliterPerPulse = liquidVolume.IdsPack.Dispenser.NlPerPulse; - dispenser.LiquidMaxNanoliterPerCentimeter = liquidVolume.LiquidMaxNanoliterPerCentimeter; - dispenser.NanoliterPerCentimeter = liquidVolume.NanoliterPerCentimeter; - dispenser.NanolitterPerSecond = liquidVolume.NanoliterPerSecond; - dispenser.PulsePerSecond = liquidVolume.PulsePerSecond; + dispenser.LiquidMaxNanoliterPerCentimeter = liquidVolume.LiquidMaxNanoliterPerCentimeter; + dispenser.NanoliterPerCentimeter = liquidVolume.NanoliterPerCentimeter; + dispenser.NanolitterPerSecond = liquidVolume.NanoliterPerSecond; + dispenser.PulsePerSecond = liquidVolume.PulsePerSecond; - jobStop.Dispensers.Add(dispenser); + jobStop.Dispensers.Add(dispenser); + } + + jobSegment.BrushStops.Add(jobStop); } - jobSegment.BrushStops.Add(jobStop); + ticket.Segments.Add(jobSegment); } - ticket.Segments.Add(jobSegment); - } + request.JobTicket = ticket; - request.JobTicket = ticket; - - JobHandler handler = null; + JobHandler handler = null; - handler = new JobHandler(async () => - { - try + handler = new JobHandler(async () => { - var result = await SendRequest(new StubAbortJobRequest()); - PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCanceled(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Failed to cancel job."); - } - }, originalJob, ticket, processParameters, JobHandlingMode); - - handler.StatusChanged += (x, s) => - { - RunningJobStatus = s; - }; + try + { + var result = await SendRequest(new StubAbortJobRequest()); + PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCanceled(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed to cancel job."); + } + }, originalJob, ticket, processParameters, JobHandlingMode); - LogRequestSent(request); - bool responseLogged = false; + handler.StatusChanged += (x, s) => + { + RunningJobStatus = s; + }; - SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => - { - handler.RaiseStatusReceived(response.Message.Status); + LogRequestSent(request); + bool responseLogged = false; - if (!responseLogged) + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { - responseLogged = true; - Status = MachineStatuses.Printing; - RunningJob = originalJob; - PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - LogResponseReceived(response.Message); - } - }, (ex) => - { - if (!(ex is ContinuousResponseAbortedException)) + handler.RaiseStatusReceived(response.Message.Status); + + if (!responseLogged) + { + responseLogged = true; + Status = MachineStatuses.Printing; + RunningJob = originalJob; + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + LogResponseReceived(response.Message); + } + }, (ex) => { - Status = MachineStatuses.ReadyToDye; + if (!(ex is ContinuousResponseAbortedException)) + { + Status = MachineStatuses.ReadyToDye; - if (!handler.IsCanceled) + if (!handler.IsCanceled) + { + PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseFailed(ex); + LogRequestFailed(request, ex); + } + } + else { - PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseFailed(ex); - LogRequestFailed(request, ex); + Status = MachineStatuses.ReadyToDye; } - } - else + }, () => { Status = MachineStatuses.ReadyToDye; - } - }, () => - { - Status = MachineStatuses.ReadyToDye; - PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCompleted(); - }); + PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCompleted(); + }); + + return handler; - return handler; + }); } /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs new file mode 100644 index 000000000..7c53fd7fb --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + /// + /// Represents the event arguments. + /// + /// + public class PreparingJobProgressEventArgs : EventArgs + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + + /// + /// Gets or sets the progress. + /// + public double Progress { get; set; } + + /// + /// Gets or sets the total progress. + /// + public double Total { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 8d6d43c02..7bea3eccb 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -92,7 +92,10 @@ + + + @@ -176,7 +179,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml index f352bebb6..8d5e99f72 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml differ diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs index f098af31d..552543320 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs @@ -555,16 +555,14 @@ namespace Tango.Touch.Controls current_top += (ordered[i].Margin.Top + ordered[i].ActualHeight + ordered[i].Margin.Bottom); - if (contentPresenter.Tag == null) - { - LightTouchDataGridRow row = contentPresenter.FindChild(); + LightTouchDataGridRow row = contentPresenter.FindChild(); - if (row != null) - { - contentPresenter.Tag = 1; - row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); - row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); - } + if (row != null) + { + row.UnRegisterMouseOrTouch(OnRowMouseTouchUp); + row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); + row.UnRegisterMouseOrTouch(OnRowMouseTouchDown); + row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); } } -- cgit v1.3.1 From 24d0a8782f8324f80222251a4ff4977d1258e3a8 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 19 Mar 2019 15:50:02 +0200 Subject: PPC Working on Tech Module. TCC using arocus + barcode scanning using ZBar! --- .../Android_Studio/ColorCapture/app/build.gradle | 1 + .../main/cpp/ColorCaptureLib/ColorCaptureLib.cpp | 1 + .../ColorCapture/app/src/main/cpp/native-lib.cpp | 2 +- .../views/capture/CaptureFragment.java | 33 +++++- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../PPC/Modules/Tango.PPC.Logging/App.xaml | 11 -- .../Tango.PPC.Logging/Images/logging_module.png | Bin 1345 -> 0 bytes .../PPC/Modules/Tango.PPC.Logging/LoggingModule.cs | 47 -------- .../Tango.PPC.Logging/Properties/AssemblyInfo.cs | 20 ---- .../Properties/Resources.Designer.cs | 62 ---------- .../Tango.PPC.Logging/Properties/Resources.resx | 117 ------------------- .../Properties/Settings.Designer.cs | 30 ----- .../Tango.PPC.Logging/Properties/Settings.settings | 7 -- .../Tango.PPC.Logging/Tango.PPC.Logging.csproj | 126 --------------------- .../Modules/Tango.PPC.Logging/ViewModelLocator.cs | 32 ------ .../Tango.PPC.Logging/ViewModels/MainViewVM.cs | 17 --- .../Modules/Tango.PPC.Logging/Views/MainView.xaml | 45 -------- .../Tango.PPC.Logging/Views/MainView.xaml.cs | 28 ----- .../PPC/Modules/Tango.PPC.Logging/app.config | 85 -------------- .../PPC/Modules/Tango.PPC.Logging/packages.config | 4 - .../PPC/Modules/Tango.PPC.Technician/App.xaml | 11 ++ .../Images/technician_module.png | Bin 0 -> 2518 bytes .../Properties/AssemblyInfo.cs | 20 ++++ .../Properties/Resources.Designer.cs | 63 +++++++++++ .../Tango.PPC.Technician/Properties/Resources.resx | 117 +++++++++++++++++++ .../Properties/Settings.Designer.cs | 26 +++++ .../Properties/Settings.settings | 7 ++ .../Tango.PPC.Technician.csproj | 126 +++++++++++++++++++++ .../Tango.PPC.Technician/TechnicianModule.cs | 47 ++++++++ .../Tango.PPC.Technician/ViewModelLocator.cs | 32 ++++++ .../Tango.PPC.Technician/ViewModels/MainViewVM.cs | 17 +++ .../Tango.PPC.Technician/Views/MainView.xaml | 45 ++++++++ .../Tango.PPC.Technician/Views/MainView.xaml.cs | 28 +++++ .../PPC/Modules/Tango.PPC.Technician/app.config | 85 ++++++++++++++ .../Modules/Tango.PPC.Technician/packages.config | 4 + .../Application/IPPCApplicationManager.cs | 5 + .../Dialogs/TechnicianModeLoginView.xaml | 26 +++++ .../Dialogs/TechnicianModeLoginView.xaml.cs | 28 +++++ .../Dialogs/TechnicianModeLoginViewVM.cs | 19 ++++ .../PPC/Tango.PPC.UI/Images/technician-mode.png | Bin 0 -> 3818 bytes .../PPCApplication/DefaultPPCApplicationManager.cs | 27 ++++- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 19 +++- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 19 ++++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs | 40 +++++++ .../Tango.Touch/Controls/TouchPanel.xaml | 15 +-- Software/Visual_Studio/Tango.sln | 98 ++++++++-------- 48 files changed, 896 insertions(+), 698 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/App.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Images/logging_module.png delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/LoggingModule.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.Designer.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.resx delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.Designer.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.settings delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Tango.PPC.Logging.csproj delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModelLocator.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModels/MainViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/app.config delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/packages.config create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/App.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/technician_module.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.resx create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.settings create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/TechnicianModule.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/technician-mode.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle index 57a59ea11..9a9df5b1a 100644 --- a/Software/Android_Studio/ColorCapture/app/build.gradle +++ b/Software/Android_Studio/ColorCapture/app/build.gradle @@ -66,5 +66,6 @@ dependencies { annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' annotationProcessor 'com.google.dagger:dagger-android-processor:2.11' annotationProcessor 'com.google.dagger:dagger-compiler:2.11' + compile 'com.yanzhenjie.zbar:zbar:1.0.0' implementation project(':onboarding') } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp b/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp index 0b91e7b08..3a97b4911 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp +++ b/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp @@ -732,6 +732,7 @@ vector ColorCaptureLib::GetArcusVertices(Mat image) aruco::DetectorParameters* params = new aruco::DetectorParameters(); params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; + params->perspectiveRemovePixelPerCell = 50; Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_50); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp b/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp index 3afccbec0..343203368 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp +++ b/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp @@ -77,7 +77,7 @@ Java_com_twine_colorcapture_opencv_ImageProcessor_ProcessImage( Mat rot_mat = getRotationMatrix2D(src_center, -90, 1.0); warpAffine(rgb, rgb, rot_mat, rgb.size());*/ - vector vertices = capture.GetQRVertices4(rgb); + vector vertices = capture.GetArcusVertices(rgb); for (size_t i = 0; i < vertices.size(); i++) { circle(rgb, vertices[i], 2, CV_RGB(0, 0, 255), -1); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java index 4da196dda..491a05564 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java @@ -10,6 +10,7 @@ import android.hardware.Camera.Size; import android.os.Build; import android.os.Handler; import android.os.Looper; +import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -23,10 +24,16 @@ import android.widget.ImageView; import com.twine.colorcapture.App; import com.twine.colorcapture.R; import com.twine.colorcapture.core.Task; +import com.twine.colorcapture.core.Task.TaskBuilder; import com.twine.colorcapture.databinding.FragmentCaptureBinding; import com.twine.colorcapture.mvvm.FragmentBase; import com.twine.colorcapture.opencv.ImageProcessor; +import com.yanzhenjie.zbar.Image; +import com.yanzhenjie.zbar.ImageScanner; +import com.yanzhenjie.zbar.Symbol; +import com.yanzhenjie.zbar.SymbolSet; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; @@ -275,13 +282,37 @@ public class CaptureFragment extends FragmentBase { bProcessing = true; processor.ProcessImage(previewWidth, previewHeight, frameData, pixels, wrappedPixels); bitmap.setPixels(pixels, 0, previewHeight, 0, 0, previewHeight, previewWidth); wrappedBitmap.setPixels(wrappedPixels, 0, 300, 0, 0, 300, 330); + + + Log.d("BARCODE", "scanning barcode..."); + ImageScanner scanner = new ImageScanner(); + Image img = new Image(bitmap.getWidth(),bitmap.getHeight(),"RGB4"); + img.setData(pixels); + int result = scanner.scanImage(img.convert("Y800")); + + if (result != 0) + { + Log.d("BARCODE", "Got positive result..."); + + String text = null; + + SymbolSet symSet = scanner.getResults(); + for (Symbol sym : symSet) + text = sym.getData(); + + + String f = text; + + Log.d("BARCODE", "Barcode text is: " + text); + } + }) .setContinueWith(() -> { diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index c8adf1df5..36b58c4d0 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 0fde9e3de..ab7c33171 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/App.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/App.xaml deleted file mode 100644 index 66ea48976..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/App.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Images/logging_module.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Images/logging_module.png deleted file mode 100644 index 3f8318f70..000000000 Binary files a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Images/logging_module.png and /dev/null differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/LoggingModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/LoggingModule.cs deleted file mode 100644 index 78c597e81..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/LoggingModule.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media.Imaging; -using Tango.BL.Enumerations; -using Tango.PPC.Common; -using Tango.PPC.Logging.Views; -using Tango.SharedUI.Helpers; - -namespace Tango.PPC.Logging -{ - [PPCModule(5)] - public class LoggingModule : PPCModuleBase - { - public override string Name => "Logging"; - public override string Description => "PPC logging module."; - public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/logging_module.png"); - public override Type MainViewType => typeof(MainView); - public override Permissions Permission => Permissions.RunPPC; - - public LoggingModule() - { - IsVisibleInMenu = false; - } - - public override void OnTechnicianEntered() - { - base.OnTechnicianEntered(); - - IsVisibleInMenu = true; - } - - public override void OnTechnicianExited() - { - base.OnTechnicianExited(); - - IsVisibleInMenu = false; - } - - public override void Dispose() - { - - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs deleted file mode 100644 index a834fd095..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Tango PPC Logging Module")] -[assembly: AssemblyVersion("1.0.0.0")] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.Designer.cs deleted file mode 100644 index 6cbf8164a..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.PPC.Logging.Properties { - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if ((resourceMan == null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.PPC.Logging.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.resx b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.Designer.cs deleted file mode 100644 index ab102e0eb..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.PPC.Logging.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.settings b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Tango.PPC.Logging.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Tango.PPC.Logging.csproj deleted file mode 100644 index 51e41dba8..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Tango.PPC.Logging.csproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - AnyCPU - {D2EE865B-B006-487A-9487-60A663636AC3} - library - Tango.PPC.Logging - Tango.PPC.Logging - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - true - full - false - ..\..\..\Build\PPC\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\..\Build\PPC\Release\ - TRACE - prompt - 4 - - - - ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - - - - - - - - - - - 4.0 - - - - - - - - GlobalVersionInfo.cs - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - MainView.xaml - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - {F441FEEE-322A-4943-B566-110E12FD3B72} - Tango.BL - - - {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} - Tango.Core - - - {8491D07B-C1F6-4B62-A412-41B9FD2D6538} - Tango.SharedUI - - - {fd86424c-6e84-491b-8df9-3d0f5c236a2a} - Tango.Touch - - - {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} - Tango.PPC.Common - - - - - - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModelLocator.cs deleted file mode 100644 index d86a0d2ab..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModelLocator.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.DI; -using Tango.PPC.Logging.ViewModels; - -namespace Tango.PPC.Logging -{ - public static class ViewModelLocator - { - /// - /// Initializes a new instance of the ViewModelLocator class. - /// - static ViewModelLocator() - { - TangoIOC.Default.Register(); - } - - /// - /// Gets the main view VM. - /// - public static MainViewVM MainViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModels/MainViewVM.cs deleted file mode 100644 index 736bff5a2..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/ViewModels/MainViewVM.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Common; - -namespace Tango.PPC.Logging.ViewModels -{ - public class MainViewVM : PPCViewModel - { - public override void OnApplicationStarted() - { - - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml deleted file mode 100644 index fb4dd5d04..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - Logs - - - - - - - - Application - Embedded - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml.cs deleted file mode 100644 index eb448c67c..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Views/MainView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.Logging.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : UserControl - { - public MainView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/app.config deleted file mode 100644 index f47375ba5..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/app.config +++ /dev/null @@ -1,85 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/packages.config deleted file mode 100644 index b3daf0d6c..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/App.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/App.xaml new file mode 100644 index 000000000..a696ceef9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/App.xaml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/technician_module.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/technician_module.png new file mode 100644 index 000000000..2c5cc1fbc Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/technician_module.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..97a615572 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango PPC Technician Module")] +[assembly: AssemblyVersion("1.0.0.0")] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.Designer.cs new file mode 100644 index 000000000..26e366738 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Technician.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.PPC.Technician.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.resx b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.Designer.cs new file mode 100644 index 000000000..dfc1a086b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Technician.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.settings b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj new file mode 100644 index 000000000..2a4c1d39c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -0,0 +1,126 @@ + + + + + Debug + AnyCPU + {D2EE865B-B006-487A-9487-60A663636AC3} + library + Tango.PPC.Technician + Tango.PPC.Technician + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\PPC\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\..\Build\PPC\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + GlobalVersionInfo.cs + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainView.xaml + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {F441FEEE-322A-4943-B566-110E12FD3B72} + Tango.BL + + + {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} + Tango.Core + + + {8491D07B-C1F6-4B62-A412-41B9FD2D6538} + Tango.SharedUI + + + {fd86424c-6e84-491b-8df9-3d0f5c236a2a} + Tango.Touch + + + {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} + Tango.PPC.Common + + + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/TechnicianModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/TechnicianModule.cs new file mode 100644 index 000000000..07ef8cabf --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/TechnicianModule.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.PPC.Common; +using Tango.PPC.Technician.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Technician +{ + [PPCModule(5)] + public class TechnicianModule : PPCModuleBase + { + public override string Name => "Technician"; + public override string Description => "PPC technician module."; + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/technician_module.png"); + public override Type MainViewType => typeof(MainView); + public override Permissions Permission => Permissions.RunPPC; + + public TechnicianModule() + { + IsVisibleInMenu = false; + } + + public override void OnTechnicianEntered() + { + base.OnTechnicianEntered(); + + IsVisibleInMenu = true; + } + + public override void OnTechnicianExited() + { + base.OnTechnicianExited(); + + IsVisibleInMenu = false; + } + + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs new file mode 100644 index 000000000..3a4c8d829 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.PPC.Technician.ViewModels; + +namespace Tango.PPC.Technician +{ + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + TangoIOC.Default.Register(); + } + + /// + /// Gets the main view VM. + /// + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..893d495fc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class MainViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml new file mode 100644 index 000000000..5e9401742 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + Logs + + + + + + + + Application + Embedded + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml.cs new file mode 100644 index 000000000..41eb08c0f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml.cs @@ -0,0 +1,28 @@ +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.Technician.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config new file mode 100644 index 000000000..f47375ba5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config @@ -0,0 +1,85 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file 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 7769c74f6..ff3f65221 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -55,6 +55,11 @@ namespace Tango.PPC.Common.Application ///
bool IsShuttingDown { get; } + /// + /// Gets a value indicating whether the application is in technician mode. + /// + bool IsInTechnicianMode { get; } + /// /// Shutdown the application. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml new file mode 100644 index 000000000..ca53d6027 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml @@ -0,0 +1,26 @@ + + + + + CANCEL + OK + + + + + 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 new file mode 100644 index 000000000..02dfed896 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs @@ -0,0 +1,28 @@ +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 TechnicianModeLoginView : UserControl + { + public TechnicianModeLoginView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginViewVM.cs new file mode 100644 index 000000000..2a46bcd96 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginViewVM.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 TechnicianModeLoginViewVM : DialogViewVM + { + private String _password; + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/technician-mode.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/technician-mode.png new file mode 100644 index 000000000..7d98c6734 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/technician-mode.png differ 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 788d2b178..261dbe6d4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -28,6 +28,7 @@ using Tango.PPC.Common.EventLogging; using Tango.BL.Enumerations; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.WatchDog; +using Tango.PPC.UI.Dialogs; namespace Tango.PPC.UI.PPCApplication { @@ -88,6 +89,11 @@ namespace Tango.PPC.UI.PPCApplication ///
public bool IsShuttingDown { get; private set; } + /// + /// Gets a value indicating whether the application is in technician mode. + /// + public bool IsInTechnicianMode { get; private set; } + /// /// Gets the application version. /// @@ -412,10 +418,24 @@ namespace Tango.PPC.UI.PPCApplication /// /// Enteres the application technician mode. /// - public void EnterTechnicianMode() + public async void EnterTechnicianMode() { - _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); - _notificationProvider.ShowInfo("Technician mode is now enabled."); + var vm = await _notificationProvider.ShowDialog(); + + if (vm.DialogResult) + { + if (vm.Password == "Aa123456") + { + IsInTechnicianMode = true; + _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); + await _notificationProvider.ShowInfo("Technician mode is now enabled."); + } + else + { + await _notificationProvider.ShowError("Invalid technician mode password."); + EnterTechnicianMode(); + } + } } /// @@ -423,6 +443,7 @@ namespace Tango.PPC.UI.PPCApplication /// public void ExitTechnicianMode() { + IsInTechnicianMode = false; _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianExited()); _notificationProvider.ShowInfo("Technician mode is now disabled."); } 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 1201c4ab0..8c4cc4992 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,6 +122,10 @@ + + TechnicianModeLoginView.xaml + + UpdateFromFileView.xaml @@ -182,6 +186,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -278,6 +286,7 @@ + @@ -366,10 +375,6 @@ {096f16c8-6d06-4b5f-9496-b9d2df2d94a3} Tango.PPC.Jobs - - {d2ee865b-b006-487a-9487-60a663636ac3} - Tango.PPC.Logging - {91b70e9b-66a7-4873-ae10-400e71cf404f} Tango.PPC.MachineSettings @@ -378,6 +383,10 @@ {04febb02-f782-4b96-b47d-f6902afa43be} Tango.PPC.Storage + + {d2ee865b-b006-487a-9487-60a663636ac3} + Tango.PPC.Technician + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common @@ -509,7 +518,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 1c1eeca5e..3cb790e65 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -244,6 +244,25 @@ namespace Tango.PPC.UI.ViewModels #endregion + #region Public Methods + + /// + /// Toggles the application technician mode. + /// + public void ToggleTechnicianMode() + { + if (!ApplicationManager.IsInTechnicianMode) + { + ApplicationManager.EnterTechnicianMode(); + } + else + { + ApplicationManager.ExitTechnicianMode(); + } + } + + #endregion + #region Event Handlers /// 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 5d4428989..2a2f3e8b5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -213,7 +213,7 @@ - + + + + + + + + + + + Time: + + + + File: + + + + Method: + + + + Line: + + + + Message: + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs new file mode 100644 index 000000000..9c12f7f13 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs @@ -0,0 +1,28 @@ +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.Technician.Views +{ + /// + /// Interaction logic for LoggingView.xaml + /// + public partial class LoggingView : UserControl + { + public LoggingView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index 5e9401742..66e16588b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -7,39 +7,14 @@ xmlns:vm="clr-namespace:Tango.PPC.Technician.ViewModels" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:global="clr-namespace:Tango.PPC.Technician" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.PPC.Technician.Views" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - - - - - - - - - Logs - - - - - - - - Application - Embedded - - - - - - - - - - - + + + + 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 ff3f65221..2d76b202f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -78,7 +78,7 @@ namespace Tango.PPC.Common.Application /// /// Enteres the application technician mode. /// - void EnterTechnicianMode(); + void EnterTechnicianMode(bool displayNotification = true); /// /// Exits the application technician mode. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 409dd1cfc..32181a753 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -76,6 +76,11 @@ namespace Tango.PPC.Common /// public bool EnableWatchDog { get; set; } + /// + /// Gets or sets a value indicating whether to enable the technician mode when the application starts. + /// + public bool EnableTechnicianModeByDefault { get; set; } + /// /// Gets the machine service address. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 05cd998e6..62f248a8c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -14,6 +14,7 @@ + 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 261dbe6d4..ba1b44c8a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -335,6 +335,11 @@ namespace Tango.PPC.UI.PPCApplication LogManager.Log($"Invoking {vm.GetType().Name}.OnApplicationReady..."); vm.OnApplicationReady(); } + + if (SettingsManager.Default.GetOrCreate().EnableTechnicianModeByDefault) + { + EnterTechnicianMode(false); + } }); } @@ -418,24 +423,32 @@ namespace Tango.PPC.UI.PPCApplication /// /// Enteres the application technician mode. /// - public async void EnterTechnicianMode() + public async void EnterTechnicianMode(bool displayNotification = true) { - var vm = await _notificationProvider.ShowDialog(); - - if (vm.DialogResult) + if (displayNotification) { - if (vm.Password == "Aa123456") - { - IsInTechnicianMode = true; - _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); - await _notificationProvider.ShowInfo("Technician mode is now enabled."); - } - else + var vm = await _notificationProvider.ShowDialog(); + + if (vm.DialogResult) { - await _notificationProvider.ShowError("Invalid technician mode password."); - EnterTechnicianMode(); + if (vm.Password == "Aa123456") + { + IsInTechnicianMode = true; + _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); + await _notificationProvider.ShowInfo("Technician mode is now enabled."); + } + else + { + await _notificationProvider.ShowError("Invalid technician mode password."); + EnterTechnicianMode(); + } } } + else + { + IsInTechnicianMode = true; + _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); + } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 3cb790e65..9e8a9fe34 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -115,6 +115,12 @@ namespace Tango.PPC.UI.ViewModels /// Gets or sets the power command. /// public RelayCommand PowerCommand { get; set; } + + /// + /// Gets or sets the restart application command. + /// + public RelayCommand RestartApplicationCommand { get; set; } + #endregion #region Constructors @@ -139,6 +145,7 @@ namespace Tango.PPC.UI.ViewModels }); PowerCommand = new RelayCommand(() => IsPowerOpened = true); + RestartApplicationCommand = new RelayCommand(RestartApplication); } #endregion @@ -221,6 +228,17 @@ namespace Tango.PPC.UI.ViewModels } } + /// + /// Restarts the application. + /// + private async void RestartApplication() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the application?")) + { + ApplicationManager.Restart(); + } + } + #endregion #region Override Methods 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 2a2f3e8b5..4079777f7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -158,7 +158,7 @@ - Restart + Restart 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 2156e45ca..777083b67 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 @@ -52,24 +52,28 @@ namespace Tango.PPC.UI.Views private void OnMouseOrTouchDown(object sender, MouseOrTouchEventArgs e) { - techPressElement.CaptureMouse(); - - if (e.TouchDevice != null) - { - techPressElement.CaptureTouch(e.TouchDevice); - } + //if (e.TouchDevice != null) + //{ + // techPressElement.CaptureTouch(e.TouchDevice); + //} + //else + //{ + // techPressElement.CaptureMouse(); + //} _timer.Start(); } private void OnMouseOrTouchUp(object sender, MouseOrTouchEventArgs e) { - this.ReleaseMouseCapture(); - - if (e.TouchDevice != null) - { - techPressElement.ReleaseTouchCapture(e.TouchDevice); - } + //if (e.TouchDevice != null) + //{ + // techPressElement.ReleaseTouchCapture(e.TouchDevice); + //} + //else + //{ + // techPressElement.ReleaseMouseCapture(); + //} _timer.Stop(); } diff --git a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs index a159106e6..cc13688ff 100644 --- a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs +++ b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs @@ -573,10 +573,8 @@ namespace Tango.AnimatedGif animation.RepeatBehavior = GetActualRepeatBehavior(imageControl, decoder, gifMetadata); - //Removed animation cache for PPC AsyncAdornerControl! - - //AnimationCache.AddAnimation(source, GetRepeatBehavior(imageControl), animation); - //AnimationCache.IncrementReferenceCount(source, GetRepeatBehavior(imageControl)); + AnimationCache.AddAnimation(source, GetRepeatBehavior(imageControl), animation); + AnimationCache.IncrementReferenceCount(source, GetRepeatBehavior(imageControl)); return animation; } return null; diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index 08f3bb101..909366ffd 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -77,6 +77,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -176,6 +177,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -270,6 +272,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -369,6 +372,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml index 7d04c902a..456e82750 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml @@ -7,37 +7,35 @@ - - - - - - - - - - + + + + + + + + + + + + +