From 8e49a8041391c9aa946060aed2c538b1ce958a68 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 19 Sep 2019 18:29:10 +0300 Subject: Added support for multiple ColorLib versions ! Added version control and display in RML & Research Module. Implemented GenerateHive optimizations. --- .../Tango.MachineStudio.Developer.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 6e55b6d14..10fce1b20 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -141,6 +141,10 @@ RunningJobView.xaml + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -361,7 +365,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From b5c5758e431077d84fb53a3ff62f8e751fca2731 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 23 Sep 2019 18:22:32 +0300 Subject: Implemented Insufficient liquid levels !!! --- .../Tango.MachineStudio.Developer.csproj | 10 ++- .../ViewModels/InsufficientLiquidQuantityViewVM.cs | 20 +++++ .../ViewModels/MainViewVM.cs | 10 +++ .../Views/EmbroideryDisplayView.xaml | 2 +- .../Views/EmbroideryImportView.xaml | 2 +- .../Views/InsufficientLiquidQuantityView.xaml | 81 ++++++++++++++++++++ .../Views/InsufficientLiquidQuantityView.xaml.cs | 54 +++++++++++++ .../Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs | 5 ++ .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 5 ++ .../Connection/DefaultMachineProvider.cs | 11 ++- .../PPC/Tango.PPC.Common/PPCSettings.cs | 8 +- .../Dialogs/InsufficientLiquidQuantityView.xaml | 78 +++++++++++++++++++ .../Dialogs/InsufficientLiquidQuantityView.xaml.cs | 54 +++++++++++++ .../Dialogs/InsufficientLiquidQuantityViewVM.cs | 20 +++++ .../Printing/DefaultPrintingManager.cs | 17 ++++- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 10 ++- .../Visual_Studio/Tango.BL/Entities/LiquidType.cs | 11 +++ .../Operation/IMachineOperator.cs | 6 ++ .../InsufficientLiquidQuantityException.cs | 31 ++++++++ .../Tango.Integration/Operation/MachineOperator.cs | 89 +++++++++++++++++++--- .../Tango.Integration/Tango.Integration.csproj | 3 +- .../Tango.MachineEM.UI/Views/MainView.xaml | 8 +- 22 files changed, 505 insertions(+), 30 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/InsufficientLiquidQuantityViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityViewVM.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/InsufficientLiquidQuantityException.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 10fce1b20..f57f83d7e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -121,6 +121,7 @@ + EmbroideryDisplayView.xaml @@ -128,6 +129,9 @@ EmbroideryImportView.xaml + + InsufficientLiquidQuantityView.xaml + MainView.xaml @@ -153,6 +157,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -365,7 +373,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/InsufficientLiquidQuantityViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/InsufficientLiquidQuantityViewVM.cs new file mode 100644 index 000000000..e18fc842f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/InsufficientLiquidQuantityViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Operation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Developer.ViewModels +{ + public class InsufficientLiquidQuantityViewVM : DialogViewVM + { + public InsufficientLiquidQuantityException Exception { get; set; } + + public InsufficientLiquidQuantityViewVM(InsufficientLiquidQuantityException ex) + { + Exception = ex; + } + } +} 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 3f551c866..c2fad9d87 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 @@ -1446,6 +1446,16 @@ namespace Tango.MachineStudio.Developer.ViewModels //Finally Canceled.. }; } + catch (InsufficientLiquidQuantityException ex) + { + _notification.ShowModalDialog(new InsufficientLiquidQuantityViewVM(ex), (x) => + { + + MachineOperator.EnableJobLiquidQuantityValidation = false; + StartJob(); + + }, () => { }); + } catch (Exception ex) { LogManager.Log(ex); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml index 22414b4b2..2e1eaf6a1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml @@ -9,7 +9,7 @@ xmlns:converters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - Width="1280" Height="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:EmbroideryDisplayViewVM, IsDesignTimeCreatable=False}"> + Width="1280" Height="720" Background="{StaticResource WhiteBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:EmbroideryDisplayViewVM, IsDesignTimeCreatable=False}"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml index 8d25719e8..d9ff176d9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml @@ -10,7 +10,7 @@ xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - Height="720" Width="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:EmbroideryImportViewVM, IsDesignTimeCreatable=False}"> + Height="720" Width="1280" Background="{StaticResource WhiteBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:EmbroideryImportViewVM, IsDesignTimeCreatable=False}"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml new file mode 100644 index 000000000..f0e9dc29c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml @@ -0,0 +1,81 @@ + + + + + Insufficient Liquid Level + + There seems to be an insufficient ink levels in one or more of the following dispensers. + + The job cannot be completed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs new file mode 100644 index 000000000..171cb754e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs @@ -0,0 +1,54 @@ +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; +using Tango.Integration.Operation; +using static Tango.Integration.Operation.InsufficientLiquidQuantityException; + +namespace Tango.MachineStudio.Developer.Views +{ + /// + /// Interaction logic for InsufficientLiquidQuantityView.xaml + /// + public partial class InsufficientLiquidQuantityView : UserControl + { + public InsufficientLiquidQuantityView() + { + InitializeComponent(); + } + + private void IdsPackLoaded(object sender, RoutedEventArgs e) + { + Border border = sender as Border; + Grid parent = border.Parent as Grid; + IDSPackLevel packLevel = border.DataContext as IDSPackLevel; + + border.Height = ((double)packLevel.Current / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; + } + + private void Limit_Loaded(object sender, RoutedEventArgs e) + { + Rectangle rect = sender as Rectangle; + Grid parent = rect.Parent as Grid; + IDSPackLevel packLevel = rect.DataContext as IDSPackLevel; + + var top = ((double)packLevel.Required / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; + rect.Margin = new Thickness(0, 0, 0, top); + + if (packLevel.IsValid) + { + rect.Visibility = Visibility.Hidden; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 14065ccba..49d11a8fd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -8,6 +8,7 @@ using Tango.BL.Builders; using Tango.BL.Entities; using Tango.ColorConversion; using Tango.Core.Commands; +using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Messages; using Tango.PPC.Common.Navigation; @@ -91,6 +92,10 @@ namespace Tango.PPC.Jobs.ViewModels await PrintingManager.Print(Job, _context); await NavigationManager.NavigateTo(false, nameof(JobProgressView)); } + catch (InsufficientLiquidQuantityException) + { + //Ignore.. + } catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 85eb87824..a99e45eb3 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -36,6 +36,7 @@ using Tango.Explorer; using Tango.PPC.Storage; using System.IO; using Tango.ColorConversion; +using Tango.Integration.Operation; namespace Tango.PPC.Jobs.ViewModels { @@ -644,6 +645,10 @@ namespace Tango.PPC.Jobs.ViewModels await PrintingManager.Print(Job, _db); await NavigationManager.NavigateTo(nameof(JobProgressView)); } + catch (InsufficientLiquidQuantityException) + { + //Ignore.. + } catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index cd432538c..a16e2f649 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -89,6 +89,11 @@ namespace Tango.PPC.Common.Connection MachineOperator.GradientGenerationConfiguration.IsEnabled = settings.EnableGradientGeneration; MachineOperator.GradientGenerationConfiguration.ResolutionCM = settings.GradientGenerationResolution; + + MachineOperator.EmergencyNotificationProvider.Address = settings.EmergencyComPort; + MachineOperator.EmergencyNotificationProvider.IsEnabled = settings.EnableEmergencyNotifications; + + MachineOperator.EnableJobLiquidQuantityValidation = settings.EnableJobLiquidQuantityValidation; } private async void ConnectionThreadMethod() @@ -159,9 +164,6 @@ namespace Tango.PPC.Common.Connection await Task.Delay(1000); await MachineOperator.UploadHardwareConfiguration(Machine.Configuration.HardwareVersion, Machine.Configuration); MachineOperator.UseKeepAlive = true; - - MachineOperator.EmergencyNotificationProvider.Address = settings.EmergencyComPort; - MachineOperator.EmergencyNotificationProvider.IsEnabled = settings.EnableEmergencyNotifications; } } else @@ -184,9 +186,6 @@ namespace Tango.PPC.Common.Connection await Task.Delay(1000); await MachineOperator.UploadHardwareConfiguration(Machine.Configuration.HardwareVersion, Machine.Configuration); - - MachineOperator.EmergencyNotificationProvider.Address = settings.EmergencyComPort; - MachineOperator.EmergencyNotificationProvider.IsEnabled = settings.EnableEmergencyNotifications; } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index b495ec54d..b1bc3faad 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -132,6 +132,11 @@ namespace Tango.PPC.Common /// public String EmergencyComPort { get; set; } + /// + /// Gets or sets a value indicating whether to enable the job liquid quantity validation. + /// + public bool EnableJobLiquidQuantityValidation { get; set; } + /// /// Gets the machine service address. /// @@ -160,7 +165,8 @@ namespace Tango.PPC.Common DeploymentSlot = DeploymentSlot.TEST; EnableWatchDog = true; EnableEmergencyNotifications = true; - EmergencyComPort = "COM1"; + EmergencyComPort = "COM2"; + EnableJobLiquidQuantityValidation = true; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml new file mode 100644 index 000000000..f3c471954 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml @@ -0,0 +1,78 @@ + + + + + CLOSE + + + + Insufficient Ink Level + + There seems to be an insufficient ink levels in one or more of the following dispensers. + The job cannot be completed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml.cs new file mode 100644 index 000000000..9ec1eec0e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityView.xaml.cs @@ -0,0 +1,54 @@ +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; +using Tango.Integration.Operation; +using static Tango.Integration.Operation.InsufficientLiquidQuantityException; + +namespace Tango.PPC.UI.Dialogs +{ + /// + /// Interaction logic for InsufficientLiquidQuantityView.xaml + /// + public partial class InsufficientLiquidQuantityView : UserControl + { + public InsufficientLiquidQuantityView() + { + InitializeComponent(); + } + + private void IdsPackLoaded(object sender, RoutedEventArgs e) + { + Border border = sender as Border; + Grid parent = border.Parent as Grid; + IDSPackLevel packLevel = border.DataContext as IDSPackLevel; + + border.Height = ((double)packLevel.Current / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; + } + + private void Limit_Loaded(object sender, RoutedEventArgs e) + { + Rectangle rect = sender as Rectangle; + Grid parent = rect.Parent as Grid; + IDSPackLevel packLevel = rect.DataContext as IDSPackLevel; + + var top = ((double)packLevel.Required / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; + rect.Margin = new Thickness(0, 0, 0, top); + + if (packLevel.IsValid) + { + rect.Visibility = Visibility.Hidden; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityViewVM.cs new file mode 100644 index 000000000..8b15d2e00 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/InsufficientLiquidQuantityViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Operation; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class InsufficientLiquidQuantityViewVM : DialogViewVM + { + public InsufficientLiquidQuantityException Exception { get; set; } + + public InsufficientLiquidQuantityViewVM(InsufficientLiquidQuantityException ex) + { + Exception = ex; + } + } +} 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 41a231932..56ec2fa7e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -13,8 +13,10 @@ using Tango.PPC.Common.Connection; using Tango.PPC.Common.Messages; using Tango.PPC.Common.Models; using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; using Tango.PPC.Jobs.Messages; +using Tango.PPC.UI.Dialogs; namespace Tango.PPC.UI.Printing { @@ -26,14 +28,16 @@ namespace Tango.PPC.UI.Printing public class DefaultPrintingManager : ExtendedObject, IPrintingManager { private IMachineProvider _machineProvider; + private INotificationProvider _notificationProvider; /// /// Initializes a new instance of the class. /// /// The machine provider. - public DefaultPrintingManager(IMachineProvider machineProvider) + public DefaultPrintingManager(IMachineProvider machineProvider, INotificationProvider notificationProvider) { _machineProvider = machineProvider; + _notificationProvider = notificationProvider; } /// @@ -52,7 +56,16 @@ namespace Tango.PPC.UI.Printing #if STUBPRINT handler = await _machineProvider.MachineOperator.PrintStub(job); #else - handler = await _machineProvider.MachineOperator.Print(job); + try + { + handler = await _machineProvider.MachineOperator.Print(job); + } + catch (InsufficientLiquidQuantityException ex) + { + LogManager.Log(ex); + await _notificationProvider.ShowDialog(new InsufficientLiquidQuantityViewVM(ex)); + throw ex; + } #endif handler.Completed += async (x, e) => 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 b32ee0339..40afab3de 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 @@ -125,6 +125,10 @@ CartridgeValidationView.xaml + + InsufficientLiquidQuantityView.xaml + + ScreenLockView.xaml @@ -202,6 +206,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -569,7 +577,7 @@ if $(ConfigurationName) == Release del *.xml - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs b/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs index 2dcb98a24..60fdc6707 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs @@ -1,8 +1,11 @@ +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; namespace Tango.BL.Entities { @@ -13,6 +16,14 @@ namespace Tango.BL.Entities return (PMR.ColorLab.LiquidType)Code; } + + [NotMapped] + [JsonIgnore] + public Color LiquidTypeColor + { + get { return Core.Helpers.ColorHelper.IntegerToColor(Color); } + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index c1d204bae..733f7a981 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -52,6 +52,12 @@ namespace Tango.Integration.Operation /// MachineStatuses Status { get; } + /// + /// Gets or sets a value indicating whether to enable liquid quantity validation before starting the job. + /// The validation is done using the reported . + /// + bool EnableJobLiquidQuantityValidation { get; set; } + /// /// Gets the machine embedded device status. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/InsufficientLiquidQuantityException.cs b/Software/Visual_Studio/Tango.Integration/Operation/InsufficientLiquidQuantityException.cs new file mode 100644 index 000000000..a1c18370b --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/InsufficientLiquidQuantityException.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 +{ + public class InsufficientLiquidQuantityException : Exception + { + public class IDSPackLevel + { + public IdsPack IdsPack { get; set; } + public int Current { get; set; } + public int Required { get; set; } + + public bool IsValid + { + get { return Current >= Required; } + } + } + + public InsufficientLiquidQuantityException(String message) : base(message) + { + IdsPackLevels = new List(); + } + + public List IdsPackLevels { get; internal set; } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 943afa21a..867ac7ec1 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -38,6 +38,7 @@ using Tango.Core.ExtensionMethods; using Tango.ColorConversion; using Tango.Integration.Emergency; using Tango.PMR.MachineStatus; +using Newtonsoft.Json; namespace Tango.Integration.Operation { @@ -51,6 +52,7 @@ namespace Tango.Integration.Operation public const String FIRMWARE_UPGRADE_FOLDER_NAME = "UpgradePackage"; public const String FIRMWARE_UPGRADE_CONFIG_FILE_NAME = "package.cfg"; public const String JOB_DESCRIPTION_FILE_NAME = "job_segments.jdf"; + public const int MAX_DISPENSER_NANOLITER = 130000000; private bool _diagnosticsSent; private bool _eventsSent; @@ -97,6 +99,7 @@ namespace Tango.Integration.Operation FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE; GradientGenerationConfiguration = new DefaultGradientGenerationConfiguration(); EmergencyNotificationProvider = new UsbEmergencyNotificationProvider("COM1"); + EnableJobLiquidQuantityValidation = true; } /// @@ -247,6 +250,12 @@ namespace Tango.Integration.Operation set { _machineStatus = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets a value indicating whether to enable liquid quantity validation before starting the job. + /// The validation is done using the reported . + /// + public bool EnableJobLiquidQuantityValidation { get; set; } + /// /// Gets or sets the firmware upgrade mode. /// @@ -1323,7 +1332,7 @@ namespace Tango.Integration.Operation }); } - private void ValidateJobLiquidQuantity(JobTicket ticket, ProcessParametersTable processParameters, Configuration configuration) + private void ValidateJobLiquidQuantity(Job job, ProcessParametersTable processParameters, Configuration configuration) { Dictionary liquidQuantities = new Dictionary(); @@ -1332,23 +1341,76 @@ namespace Tango.Integration.Operation liquidQuantities.Add(pack.PackIndex, 0); } - for (int segmentIndex = 0; segmentIndex < ticket.Segments.Count; segmentIndex++) + for (int i = 0; i < Math.Max(job.NumberOfUnits, 1); i++) + { + for (int segmentIndex = 0; segmentIndex < job.Segments.Count; segmentIndex++) + { + var segment = job.Segments[segmentIndex]; + var segment_length_cm = segment.Length * 100d; + + var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1); + var stop_length_centimeters = segment_length_cm / stop_count; + + for (int stopIndex = 0; stopIndex < stop_count; stopIndex++) + { + var stop = segment.BrushStops[stopIndex]; + + foreach (var liquidVolumes in stop.LiquidVolumes) + { + liquidQuantities[liquidVolumes.IdsPack.PackIndex] += liquidVolumes.NanoliterPerCentimeter * stop_length_centimeters; + } + } + } + } + + if (MachineStatus != null) { - var segment = ticket.Segments[segmentIndex]; - var segment_length_cm = segment.Length * 100d; + var exception = new InsufficientLiquidQuantityException($"Insufficient liquids level."); - var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1); - var stop_length_centimeters = segment_length_cm / stop_count; + bool shouldThrow = false; - for (int stopIndex = 0; stopIndex < stop_count; stopIndex++) + foreach (var liquidQuantity in liquidQuantities) { - var stop = segment.BrushStops[stopIndex]; + int index = liquidQuantity.Key; + var packLevel = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == index); + var idsPack = configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == index); + + if (packLevel != null) + { + var idsLevel = new InsufficientLiquidQuantityException.IDSPackLevel() + { + IdsPack = idsPack, + Current = packLevel.DispenserLevel, + Required = (int)liquidQuantities[index] + }; - foreach (var dispenser in stop.Dispensers) + if (liquidQuantities[index] > packLevel.DispenserLevel) + { + shouldThrow = true; + } + + exception.IdsPackLevels.Add(idsLevel); + } + else { - liquidQuantities[dispenser.Index] += dispenser.NanoliterPerCentimeter * stop_length_centimeters; + LogManager.Log($"Could not validate required liquid quantity for job. Missing IDS Pack level at index {index}.", LogCategory.Warning); } } + + + if (shouldThrow) + { + throw LogManager.Log(exception, JsonConvert.SerializeObject(exception.IdsPackLevels.Select(x => new + { + Liquid = x.IdsPack.LiquidType.Name, + x.Required, + x.Current + }).ToList())); + } + } + else + { + LogManager.Log("Could not validate required liquid quantity for job. No machine status received", LogCategory.Warning); } } @@ -1525,6 +1587,11 @@ namespace Tango.Integration.Operation job.NumberOfUnits = 1; } + if (EnableJobLiquidQuantityValidation) + { + ValidateJobLiquidQuantity(job, processParameters, job.Machine.Configuration); + } + var originalJob = job; var clonedJob = job.Clone(); clonedJob.Guid = job.Guid; @@ -1697,8 +1764,6 @@ namespace Tango.Integration.Operation ticket.Segments.AddRange(segs); } - ValidateJobLiquidQuantity(ticket, processParameters, job.Machine.Configuration); - request.JobTicket = ticket.Clone(); request.JobTicket.UploadStrategy = JobUploadStrategy; diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 6bd13ae6d..6b8d4ee8d 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -104,6 +104,7 @@ + @@ -194,7 +195,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index 51cc1d3ec..02c1b4eba 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -205,10 +205,10 @@ - - - - + + + + -- cgit v1.3.1 From ebd971a77a5fdabdf4040f07ac0e63e687abb8aa Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 2 Oct 2019 16:59:05 +0300 Subject: Another fix for SetLiquidVolumes. Changed JobFile PMR. Implemented new JobFile with Liquid Volume awareness. Implemented Import/Export jobs on research module. --- .../PMR/Messages/Exports/JobFileBrushStop.proto | 11 +- .../PMR/Messages/Exports/JobFileLiquidVolume.proto | 10 + .../Tango.MachineStudio.Developer.csproj | 19 +- .../ViewModels/MainViewVM.cs | 120 ++++++++++ .../Views/MachineJobSelectionView.xaml | 27 ++- .../Tango.MachineStudio.Developer/app.config | 16 +- .../Tango.MachineStudio.Developer/packages.config | 2 + .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 2 +- .../Tango.MachineStudio.UI/App.config | 2 +- .../Visual_Studio/Tango.BL/Entities/BrushStop.cs | 11 +- Software/Visual_Studio/Tango.BL/Entities/Job.cs | 45 +++- .../Tango.PMR/Exports/JobFileBrushStop.cs | 264 +++------------------ .../Tango.PMR/Exports/JobFileLiquidVolume.cs | 188 +++++++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 3 +- 14 files changed, 450 insertions(+), 270 deletions(-) create mode 100644 Software/PMR/Messages/Exports/JobFileLiquidVolume.proto create mode 100644 Software/Visual_Studio/Tango.PMR/Exports/JobFileLiquidVolume.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj') diff --git a/Software/PMR/Messages/Exports/JobFileBrushStop.proto b/Software/PMR/Messages/Exports/JobFileBrushStop.proto index 98b7e56ff..fae9f77c0 100644 --- a/Software/PMR/Messages/Exports/JobFileBrushStop.proto +++ b/Software/PMR/Messages/Exports/JobFileBrushStop.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "JobFileLiquidVolume.proto"; + package Tango.PMR.Exports; option java_package = "com.twine.tango.pmr.exports"; @@ -21,14 +23,7 @@ message JobFileBrushStop double A = 11; double B = 12; - double V0 = 13; - double V1 = 14; - double V2 = 15; - double V3 = 16; - double V4 = 17; - double V5 = 18; - double V6 = 19; - double V7 = 20; + repeated JobFileLiquidVolume LiquidVolumes = 24; bool Corrected = 21; string ColorCatalogGuid = 22; diff --git a/Software/PMR/Messages/Exports/JobFileLiquidVolume.proto b/Software/PMR/Messages/Exports/JobFileLiquidVolume.proto new file mode 100644 index 000000000..1c68f9064 --- /dev/null +++ b/Software/PMR/Messages/Exports/JobFileLiquidVolume.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Exports; +option java_package = "com.twine.tango.pmr.exports"; + +message JobFileLiquidVolume +{ + string LiquidTypeName = 1; + double Volume = 2; +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f57f83d7e..012ed8d0d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -52,6 +52,15 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll + @@ -196,8 +205,12 @@ ResXFileCodeGenerator Resources.Designer.cs - - + + Designer + + + Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -373,7 +386,7 @@ - + \ No newline at end of file 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 2d04866d8..27d43bd20 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 @@ -48,6 +48,8 @@ using Tango.MachineStudio.Common.Navigation; using System.Diagnostics; using Tango.Core.ExtensionMethods; using Tango.ColorConversion; +using Tango.PMR.Exports; +using Microsoft.WindowsAPICodePack.Dialogs; namespace Tango.MachineStudio.Developer.ViewModels { @@ -725,6 +727,16 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand ResetProcessParametersCommand { get; set; } + /// + /// Gets or sets the import job file command. + /// + public RelayCommand ImportJobFileCommand { get; set; } + + /// + /// Gets or sets the export job file command. + /// + public RelayCommand ExportJobFileCommand { get; set; } + #endregion #region Constructors @@ -786,6 +798,8 @@ namespace Tango.MachineStudio.Developer.ViewModels DisplayJobEmbroideryFileCommand = new RelayCommand(DisplayJobEmbroideryFile, () => CanWork); ReloadMachinesCommand = new RelayCommand(() => LoadMachine(), () => CanWork && SelectedMachine != null); ResetProcessParametersCommand = new RelayCommand(ResetProcessParameters, () => CanWork && MachineOperator != null); + ImportJobFileCommand = new RelayCommand(ImportJobFile, () => SelectedMachine != null && CanWork); + ExportJobFileCommand = new RelayCommand(ExportJobFile, () => SelectedMachine != null && SelectedMachineJob != null && CanWork); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; @@ -2488,6 +2502,112 @@ namespace Tango.MachineStudio.Developer.ViewModels #endregion + #region Job Import/Export + + private async void ExportJobFile() + { + if (SelectedJobs != null && SelectedJobs.Count > 1) + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select a folder to place all job files."; + dlg.IsFolderPicker = true; + + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + foreach (var job in SelectedJobs) + { + using (_notification.PushTaskItem($"Exporting job '{job.Name}'...")) + { + try + { + LogManager.Log($"Exporting job file {job.Name}"); + + var jobFile = await job.ToJobFile(); + File.WriteAllBytes(Path.Combine(dlg.FileName, job.Name + ".job"), jobFile.ToBytes()); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting job file."); + _notification.ShowError($"An error occurred while trying to export job '{job.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + } + else + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Export Job File"; + dlg.Filter = "Twine Job Files|*.job"; + dlg.DefaultExt = ".job"; + dlg.FileName = SelectedMachineJob.Name; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Exporting job '{SelectedMachineJob.Name}'...")) + { + try + { + LogManager.Log($"Exporting job file {SelectedMachineJob.Name}"); + + var jobFile = await SelectedMachineJob.ToJobFile(); + File.WriteAllBytes(dlg.FileName, jobFile.ToBytes()); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting job file."); + _notification.ShowError($"An error occurred while trying to export job '{SelectedMachineJob.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + } + + private async void ImportJobFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Import Job File"; + dlg.Filter = "Twine Job Files|*.job"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Importing job files...")) + { + try + { + IsFree = false; + + LogManager.Log($"Importing job files..."); + + foreach (var file in dlg.FileNames) + { + var bytes = File.ReadAllBytes(file); + var jobFile = JobFile.Parser.ParseFrom(bytes); + var job = await Job.FromJobFile(jobFile, SelectedMachine.Guid, AuthenticationProvider.CurrentUser.Guid); + + _machineDbContext.Jobs.Add(job); + } + + await _machineDbContext.SaveChangesAsync(); + + IsFree = true; + + _notification.ShowInfo($"Jobs imported successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing job file."); + _notification.ShowError($"An error occurred while trying to import the selected job file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + + #endregion + #region Override Methods protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 70d5b6180..f8a10e7c4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -260,12 +260,27 @@ - + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config index ff251eb7d..1fafd5ffd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config @@ -20,7 +20,7 @@ - + @@ -28,27 +28,27 @@ - + - + - + - + - + - + @@ -72,7 +72,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config index 999461d6a..85174f848 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config @@ -8,6 +8,8 @@ + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml index 719167679..fdfc00ba6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml @@ -40,7 +40,7 @@ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index b8ad73b04..59f92d6b9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -78,7 +78,7 @@ - + diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index ad44ee56d..d23e9b1f2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -393,24 +393,21 @@ namespace Tango.BL.Entities /// The process parameters table. public void SetLiquidVolumes(Configuration configuration, Rml rml, ProcessParametersTable processParametersTable) { - _liquidVolumes = null; + LiquidVolumes = new ObservableCollection(); - ObservableCollection liquidVolumes = new ObservableCollection(); - foreach (var idsPack in configuration.GetSupportedIdsPacks(rml)) { var liquidVolume = new LiquidVolume(configuration, idsPack, rml, processParametersTable, this); liquidVolume.VolumeChanged += LiquidVolume_VolumeChanged; - liquidVolumes.Add(liquidVolume); + LiquidVolumes.Add(liquidVolume); } - foreach (var volume in liquidVolumes.ToList()) + foreach (var volume in LiquidVolumes.ToList()) { volume.Invalidate(); } - LiquidVolumes = liquidVolumes; - + RaisePropertyChanged(nameof(LiquidVolumes)); RaisePropertyChanged(nameof(LiquidVolumesOrdered)); RaisePropertyChanged(nameof(LiquidVolumesOrderedPigmented)); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 2d536c268..de1107077 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -568,6 +568,7 @@ namespace Tango.BL.Entities using (ObservablesContext db = ObservablesContext.CreateDefault()) { var job = new JobBuilder(db).Set(Guid).WithUser().WithRML().WithSegments().WithBrushStops().Build(); + var machine = new MachineBuilder(db).Set(job.MachineGuid).WithConfiguration().Build(); var jobFile = new JobFile(); @@ -609,6 +610,24 @@ namespace Tango.BL.Entities JobFileBrushStop st = new JobFileBrushStop(); stop.MapPrimitivesWithStringsNoNullsTo(st); st.ColorCatalogItemGuid = stop.ColorCatalogsItemGuid.ToStringOrEmpty(); + + foreach (var idsPack in machine.Configuration.NoneEmptyIdsPacks) + { + try + { + var volume = stop.GetVolume(idsPack.PackIndex); + st.LiquidVolumes.Add(new JobFileLiquidVolume() + { + LiquidTypeName = idsPack.LiquidType.Name, + Volume = volume, + }); + } + catch (Exception ex) + { + throw new InvalidOperationException($"Error extracting liquid volume from ids pack {idsPack.PackIndex}", ex); + } + } + s.BrushStops.Add(st); } } @@ -624,10 +643,21 @@ namespace Tango.BL.Entities { using (ObservablesContext db = ObservablesContext.CreateDefault()) { + Machine machine; + var job = new Job(); job.MachineGuid = machineGuid; job.UserGuid = userGuid; + try + { + machine = new MachineBuilder(db).Set(machineGuid).WithConfiguration().Build(); + } + catch + { + throw new ArgumentException("Error loading the machine details."); + } + if (!String.IsNullOrEmpty(jobFile.ColorSpaceGuid)) { var job_color_space = db.ColorSpaces.SingleOrDefault(x => x.Guid == jobFile.ColorSpaceGuid); @@ -708,6 +738,19 @@ namespace Tango.BL.Entities st.SegmentGuid = s.Guid; stop.MapPrimitivesWithStringsNoNullsTo(st); + foreach (var volume in stop.LiquidVolumes) + { + var idsPack = machine.Configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Name == volume.LiquidTypeName); + + if (idsPack == null) + { + throw new InvalidOperationException($"Liquid type '{volume.LiquidTypeName}' is not configured on the target machine."); + } + + st.SetVolume(idsPack.PackIndex, volume.Volume); + } + + if (!String.IsNullOrWhiteSpace(stop.ColorCatalogGuid)) { var stop_color_catalog = db.ColorCatalogs.SingleOrDefault(x => x.Guid == stop.ColorCatalogGuid); @@ -724,7 +767,7 @@ namespace Tango.BL.Entities st.ColorCatalogsItemGuid = stop.ColorCatalogItemGuid; } - + s.BrushStops.Add(st); } } diff --git a/Software/Visual_Studio/Tango.PMR/Exports/JobFileBrushStop.cs b/Software/Visual_Studio/Tango.PMR/Exports/JobFileBrushStop.cs index 26dec4be0..36da58b4e 100644 --- a/Software/Visual_Studio/Tango.PMR/Exports/JobFileBrushStop.cs +++ b/Software/Visual_Studio/Tango.PMR/Exports/JobFileBrushStop.cs @@ -22,21 +22,21 @@ namespace Tango.PMR.Exports { static JobFileBrushStopReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChZKb2JGaWxlQnJ1c2hTdG9wLnByb3RvEhFUYW5nby5QTVIuRXhwb3J0cyL1", - "AgoQSm9iRmlsZUJydXNoU3RvcBIWCg5Db2xvclNwYWNlR3VpZBgBIAEoCRIV", - "Cg1PZmZzZXRQZXJjZW50GAIgASgBEgwKBEN5YW4YAyABKAESDwoHTWFnZW50", - "YRgEIAEoARIOCgZZZWxsb3cYBSABKAESDQoFQmxhY2sYBiABKAESCwoDUmVk", - "GAcgASgFEg0KBUdyZWVuGAggASgFEgwKBEJsdWUYCSABKAUSCQoBTBgKIAEo", - "ARIJCgFBGAsgASgBEgkKAUIYDCABKAESCgoCVjAYDSABKAESCgoCVjEYDiAB", - "KAESCgoCVjIYDyABKAESCgoCVjMYECABKAESCgoCVjQYESABKAESCgoCVjUY", - "EiABKAESCgoCVjYYEyABKAESCgoCVjcYFCABKAESEQoJQ29ycmVjdGVkGBUg", - "ASgIEhgKEENvbG9yQ2F0YWxvZ0d1aWQYFiABKAkSHAoUQ29sb3JDYXRhbG9n", - "SXRlbUd1aWQYFyABKAlCHQobY29tLnR3aW5lLnRhbmdvLnBtci5leHBvcnRz", - "YgZwcm90bzM=")); + "ChZKb2JGaWxlQnJ1c2hTdG9wLnByb3RvEhFUYW5nby5QTVIuRXhwb3J0cxoZ", + "Sm9iRmlsZUxpcXVpZFZvbHVtZS5wcm90byLUAgoQSm9iRmlsZUJydXNoU3Rv", + "cBIWCg5Db2xvclNwYWNlR3VpZBgBIAEoCRIVCg1PZmZzZXRQZXJjZW50GAIg", + "ASgBEgwKBEN5YW4YAyABKAESDwoHTWFnZW50YRgEIAEoARIOCgZZZWxsb3cY", + "BSABKAESDQoFQmxhY2sYBiABKAESCwoDUmVkGAcgASgFEg0KBUdyZWVuGAgg", + "ASgFEgwKBEJsdWUYCSABKAUSCQoBTBgKIAEoARIJCgFBGAsgASgBEgkKAUIY", + "DCABKAESPQoNTGlxdWlkVm9sdW1lcxgYIAMoCzImLlRhbmdvLlBNUi5FeHBv", + "cnRzLkpvYkZpbGVMaXF1aWRWb2x1bWUSEQoJQ29ycmVjdGVkGBUgASgIEhgK", + "EENvbG9yQ2F0YWxvZ0d1aWQYFiABKAkSHAoUQ29sb3JDYXRhbG9nSXRlbUd1", + "aWQYFyABKAlCHQobY29tLnR3aW5lLnRhbmdvLnBtci5leHBvcnRzYgZwcm90", + "bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, + new pbr::FileDescriptor[] { global::Tango.PMR.Exports.JobFileLiquidVolumeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Exports.JobFileBrushStop), global::Tango.PMR.Exports.JobFileBrushStop.Parser, new[]{ "ColorSpaceGuid", "OffsetPercent", "Cyan", "Magenta", "Yellow", "Black", "Red", "Green", "Blue", "L", "A", "B", "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7", "Corrected", "ColorCatalogGuid", "ColorCatalogItemGuid" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Exports.JobFileBrushStop), global::Tango.PMR.Exports.JobFileBrushStop.Parser, new[]{ "ColorSpaceGuid", "OffsetPercent", "Cyan", "Magenta", "Yellow", "Black", "Red", "Green", "Blue", "L", "A", "B", "LiquidVolumes", "Corrected", "ColorCatalogGuid", "ColorCatalogItemGuid" }, null, null, null) })); } #endregion @@ -79,14 +79,7 @@ namespace Tango.PMR.Exports { l_ = other.l_; a_ = other.a_; b_ = other.b_; - v0_ = other.v0_; - v1_ = other.v1_; - v2_ = other.v2_; - v3_ = other.v3_; - v4_ = other.v4_; - v5_ = other.v5_; - v6_ = other.v6_; - v7_ = other.v7_; + liquidVolumes_ = other.liquidVolumes_.Clone(); corrected_ = other.corrected_; colorCatalogGuid_ = other.colorCatalogGuid_; colorCatalogItemGuid_ = other.colorCatalogItemGuid_; @@ -229,92 +222,14 @@ namespace Tango.PMR.Exports { } } - /// Field number for the "V0" field. - public const int V0FieldNumber = 13; - private double v0_; + /// Field number for the "LiquidVolumes" field. + public const int LiquidVolumesFieldNumber = 24; + private static readonly pb::FieldCodec _repeated_liquidVolumes_codec + = pb::FieldCodec.ForMessage(194, global::Tango.PMR.Exports.JobFileLiquidVolume.Parser); + private readonly pbc::RepeatedField liquidVolumes_ = new pbc::RepeatedField(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V0 { - get { return v0_; } - set { - v0_ = value; - } - } - - /// Field number for the "V1" field. - public const int V1FieldNumber = 14; - private double v1_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V1 { - get { return v1_; } - set { - v1_ = value; - } - } - - /// Field number for the "V2" field. - public const int V2FieldNumber = 15; - private double v2_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V2 { - get { return v2_; } - set { - v2_ = value; - } - } - - /// Field number for the "V3" field. - public const int V3FieldNumber = 16; - private double v3_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V3 { - get { return v3_; } - set { - v3_ = value; - } - } - - /// Field number for the "V4" field. - public const int V4FieldNumber = 17; - private double v4_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V4 { - get { return v4_; } - set { - v4_ = value; - } - } - - /// Field number for the "V5" field. - public const int V5FieldNumber = 18; - private double v5_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V5 { - get { return v5_; } - set { - v5_ = value; - } - } - - /// Field number for the "V6" field. - public const int V6FieldNumber = 19; - private double v6_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V6 { - get { return v6_; } - set { - v6_ = value; - } - } - - /// Field number for the "V7" field. - public const int V7FieldNumber = 20; - private double v7_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double V7 { - get { return v7_; } - set { - v7_ = value; - } + public pbc::RepeatedField LiquidVolumes { + get { return liquidVolumes_; } } /// Field number for the "Corrected" field. @@ -375,14 +290,7 @@ namespace Tango.PMR.Exports { if (L != other.L) return false; if (A != other.A) return false; if (B != other.B) return false; - if (V0 != other.V0) return false; - if (V1 != other.V1) return false; - if (V2 != other.V2) return false; - if (V3 != other.V3) return false; - if (V4 != other.V4) return false; - if (V5 != other.V5) return false; - if (V6 != other.V6) return false; - if (V7 != other.V7) return false; + if(!liquidVolumes_.Equals(other.liquidVolumes_)) return false; if (Corrected != other.Corrected) return false; if (ColorCatalogGuid != other.ColorCatalogGuid) return false; if (ColorCatalogItemGuid != other.ColorCatalogItemGuid) return false; @@ -404,14 +312,7 @@ namespace Tango.PMR.Exports { if (L != 0D) hash ^= L.GetHashCode(); if (A != 0D) hash ^= A.GetHashCode(); if (B != 0D) hash ^= B.GetHashCode(); - if (V0 != 0D) hash ^= V0.GetHashCode(); - if (V1 != 0D) hash ^= V1.GetHashCode(); - if (V2 != 0D) hash ^= V2.GetHashCode(); - if (V3 != 0D) hash ^= V3.GetHashCode(); - if (V4 != 0D) hash ^= V4.GetHashCode(); - if (V5 != 0D) hash ^= V5.GetHashCode(); - if (V6 != 0D) hash ^= V6.GetHashCode(); - if (V7 != 0D) hash ^= V7.GetHashCode(); + hash ^= liquidVolumes_.GetHashCode(); if (Corrected != false) hash ^= Corrected.GetHashCode(); if (ColorCatalogGuid.Length != 0) hash ^= ColorCatalogGuid.GetHashCode(); if (ColorCatalogItemGuid.Length != 0) hash ^= ColorCatalogItemGuid.GetHashCode(); @@ -473,38 +374,6 @@ namespace Tango.PMR.Exports { output.WriteRawTag(97); output.WriteDouble(B); } - if (V0 != 0D) { - output.WriteRawTag(105); - output.WriteDouble(V0); - } - if (V1 != 0D) { - output.WriteRawTag(113); - output.WriteDouble(V1); - } - if (V2 != 0D) { - output.WriteRawTag(121); - output.WriteDouble(V2); - } - if (V3 != 0D) { - output.WriteRawTag(129, 1); - output.WriteDouble(V3); - } - if (V4 != 0D) { - output.WriteRawTag(137, 1); - output.WriteDouble(V4); - } - if (V5 != 0D) { - output.WriteRawTag(145, 1); - output.WriteDouble(V5); - } - if (V6 != 0D) { - output.WriteRawTag(153, 1); - output.WriteDouble(V6); - } - if (V7 != 0D) { - output.WriteRawTag(161, 1); - output.WriteDouble(V7); - } if (Corrected != false) { output.WriteRawTag(168, 1); output.WriteBool(Corrected); @@ -517,6 +386,7 @@ namespace Tango.PMR.Exports { output.WriteRawTag(186, 1); output.WriteString(ColorCatalogItemGuid); } + liquidVolumes_.WriteTo(output, _repeated_liquidVolumes_codec); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -558,30 +428,7 @@ namespace Tango.PMR.Exports { if (B != 0D) { size += 1 + 8; } - if (V0 != 0D) { - size += 1 + 8; - } - if (V1 != 0D) { - size += 1 + 8; - } - if (V2 != 0D) { - size += 1 + 8; - } - if (V3 != 0D) { - size += 2 + 8; - } - if (V4 != 0D) { - size += 2 + 8; - } - if (V5 != 0D) { - size += 2 + 8; - } - if (V6 != 0D) { - size += 2 + 8; - } - if (V7 != 0D) { - size += 2 + 8; - } + size += liquidVolumes_.CalculateSize(_repeated_liquidVolumes_codec); if (Corrected != false) { size += 2 + 1; } @@ -635,30 +482,7 @@ namespace Tango.PMR.Exports { if (other.B != 0D) { B = other.B; } - if (other.V0 != 0D) { - V0 = other.V0; - } - if (other.V1 != 0D) { - V1 = other.V1; - } - if (other.V2 != 0D) { - V2 = other.V2; - } - if (other.V3 != 0D) { - V3 = other.V3; - } - if (other.V4 != 0D) { - V4 = other.V4; - } - if (other.V5 != 0D) { - V5 = other.V5; - } - if (other.V6 != 0D) { - V6 = other.V6; - } - if (other.V7 != 0D) { - V7 = other.V7; - } + liquidVolumes_.Add(other.liquidVolumes_); if (other.Corrected != false) { Corrected = other.Corrected; } @@ -726,38 +550,6 @@ namespace Tango.PMR.Exports { B = input.ReadDouble(); break; } - case 105: { - V0 = input.ReadDouble(); - break; - } - case 113: { - V1 = input.ReadDouble(); - break; - } - case 121: { - V2 = input.ReadDouble(); - break; - } - case 129: { - V3 = input.ReadDouble(); - break; - } - case 137: { - V4 = input.ReadDouble(); - break; - } - case 145: { - V5 = input.ReadDouble(); - break; - } - case 153: { - V6 = input.ReadDouble(); - break; - } - case 161: { - V7 = input.ReadDouble(); - break; - } case 168: { Corrected = input.ReadBool(); break; @@ -770,6 +562,10 @@ namespace Tango.PMR.Exports { ColorCatalogItemGuid = input.ReadString(); break; } + case 194: { + liquidVolumes_.AddEntriesFrom(input, _repeated_liquidVolumes_codec); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Exports/JobFileLiquidVolume.cs b/Software/Visual_Studio/Tango.PMR/Exports/JobFileLiquidVolume.cs new file mode 100644 index 000000000..ddd3f42ed --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Exports/JobFileLiquidVolume.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: JobFileLiquidVolume.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Exports { + + /// Holder for reflection information generated from JobFileLiquidVolume.proto + public static partial class JobFileLiquidVolumeReflection { + + #region Descriptor + /// File descriptor for JobFileLiquidVolume.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static JobFileLiquidVolumeReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChlKb2JGaWxlTGlxdWlkVm9sdW1lLnByb3RvEhFUYW5nby5QTVIuRXhwb3J0", + "cyI9ChNKb2JGaWxlTGlxdWlkVm9sdW1lEhYKDkxpcXVpZFR5cGVOYW1lGAEg", + "ASgJEg4KBlZvbHVtZRgCIAEoAUIdChtjb20udHdpbmUudGFuZ28ucG1yLmV4", + "cG9ydHNiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Exports.JobFileLiquidVolume), global::Tango.PMR.Exports.JobFileLiquidVolume.Parser, new[]{ "LiquidTypeName", "Volume" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class JobFileLiquidVolume : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new JobFileLiquidVolume()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Exports.JobFileLiquidVolumeReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JobFileLiquidVolume() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JobFileLiquidVolume(JobFileLiquidVolume other) : this() { + liquidTypeName_ = other.liquidTypeName_; + volume_ = other.volume_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JobFileLiquidVolume Clone() { + return new JobFileLiquidVolume(this); + } + + /// Field number for the "LiquidTypeName" field. + public const int LiquidTypeNameFieldNumber = 1; + private string liquidTypeName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string LiquidTypeName { + get { return liquidTypeName_; } + set { + liquidTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Volume" field. + public const int VolumeFieldNumber = 2; + private double volume_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Volume { + get { return volume_; } + set { + volume_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as JobFileLiquidVolume); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(JobFileLiquidVolume other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (LiquidTypeName != other.LiquidTypeName) return false; + if (Volume != other.Volume) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (LiquidTypeName.Length != 0) hash ^= LiquidTypeName.GetHashCode(); + if (Volume != 0D) hash ^= Volume.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (LiquidTypeName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(LiquidTypeName); + } + if (Volume != 0D) { + output.WriteRawTag(17); + output.WriteDouble(Volume); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (LiquidTypeName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LiquidTypeName); + } + if (Volume != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(JobFileLiquidVolume other) { + if (other == null) { + return; + } + if (other.LiquidTypeName.Length != 0) { + LiquidTypeName = other.LiquidTypeName; + } + if (other.Volume != 0D) { + Volume = other.Volume; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + LiquidTypeName = input.ReadString(); + break; + } + case 17: { + Volume = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index b83f98fd6..2ede3ac5e 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -172,6 +172,7 @@ + @@ -305,7 +306,7 @@ - + \ No newline at end of file -- cgit v1.3.1