From 1cbef6c4d79a1db8c8d3923edfec2e50277caa51 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 9 Sep 2025 06:51:14 +0300 Subject: RMl Default Liquid Factor + Machine Type + Improved RML Filter Loading. --- .../Tango.MachineStudio.RML/Models/RmlModel.cs | 2 + .../ViewModels/MainViewVM.cs | 178 ++++++++++++--------- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 5 + .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 11 +- 4 files changed, 117 insertions(+), 79 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs index dce3432e2..c2245bcb2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs @@ -45,6 +45,8 @@ namespace Tango.MachineStudio.RML.Models public List LiquidTypesR { get; set; } + public MachineTypes? MachineType { get; set; } + public RmlModel() { DyeingSpeed = "-"; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 2e39f9e12..c0318e17b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -239,7 +239,15 @@ namespace Tango.MachineStudio.RML.ViewModels get { return _RMLFilter; } set { _RMLFilter = value; RaisePropertyChangedAuto(); OnRMLFilterChanged(); } } - + + private bool _loadingRmls; + public bool LoadingRmls + { + get { return _loadingRmls; } + set { _loadingRmls = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -348,105 +356,120 @@ namespace Tango.MachineStudio.RML.ViewModels BatchConversionCommand = new RelayCommand(BatchConversion); } - public override async void OnApplicationReady() + public override void OnApplicationReady() { } private async Task LoadRmls() { - var filter = RMLFilter.ToStringOrEmpty().ToLower(); - - using (ObservablesContext db = ObservablesContext.CreateDefault()) + try { - - var rmls = await db.Rmls.Where(x => x.Name.ToLower().Contains(filter) || x.DisplayName.ToLower().Contains(filter)) - .Include(x => x.Cct.FileName) - .Include(x => x.LiquidTypesRmls) - .Include(x => x.LiquidTypesRmls.Select(y => y.LiquidType)) - .Include(x => x.BtsrApplicationType.Name) - .Include(x => x.BtsrYarnType.Name) - .Include(x => x.ProcessParametersTablesGroups) - .Select(x => new - { - x.Name, - x.Guid, - x.DisplayName, - x.Cct.FileName, - x.ColorConversionVersion, - x.UseColorLibGradients, - x.UseLightInks, - x.HeadType, - x.LastUpdated, - BtsrApplicationType = x.BtsrApplicationType != null ? x.BtsrApplicationType.Name : String.Empty, - BtsrYarnType = x.BtsrYarnType != null ? x.BtsrYarnType.Name : String.Empty, - LiquidTypesRmls = x.LiquidTypesRmls, - LiquidTypes = x.LiquidTypesRmls.Select(y => y.LiquidType), - ProcessParametersTables = x.ProcessParametersTablesGroups - }).ToListAsync(); - - - List models = new List(); - - //var tables = ActiveRML.GetActiveProcessGroup().ProcessParametersTables; - - foreach (var rml in rmls.OrderBy(x => x.Name).ToList()) + LoadingRmls = true; + + var filter = RMLFilter.ToStringOrEmpty().ToLower(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) { - ProcessParametersTable tableZone1 = null; - ProcessParametersTable tableZone2 = null; - if (rml.ProcessParametersTables != null) + + var rmls = await db.Rmls.Where(x => x.Name.ToLower().Contains(filter) || x.DisplayName.ToLower().Contains(filter)) + .Include(x => x.Cct.FileName) + .Include(x => x.LiquidTypesRmls) + .Include(x => x.LiquidTypesRmls.Select(y => y.LiquidType)) + .Include(x => x.BtsrApplicationType.Name) + .Include(x => x.BtsrYarnType.Name) + .Include(x => x.ProcessParametersTablesGroups) + .Select(x => new + { + x.Name, + x.Guid, + x.DisplayName, + x.Cct.FileName, + x.ColorConversionVersion, + x.UseColorLibGradients, + x.UseLightInks, + x.HeadType, + x.LastUpdated, + x.MachineType, + BtsrApplicationType = x.BtsrApplicationType != null ? x.BtsrApplicationType.Name : String.Empty, + BtsrYarnType = x.BtsrYarnType != null ? x.BtsrYarnType.Name : String.Empty, + //LiquidTypesRmls = x.LiquidTypesRmls, + //LiquidTypes = x.LiquidTypesRmls.Select(y => y.LiquidType), + ProcessParametersTables = x.ProcessParametersTablesGroups + }).ToListAsync(); + + + List models = new List(); + + //var tables = ActiveRML.GetActiveProcessGroup().ProcessParametersTables; + + foreach (var rml in rmls.OrderBy(x => x.Name).ToList()) { - var activeTablesGroup = rml.ProcessParametersTables.Where(x=>x.Active).FirstOrDefault(); - if ( activeTablesGroup != null) - { - try + ProcessParametersTable tableZone1 = null; + ProcessParametersTable tableZone2 = null; + if (rml.ProcessParametersTables != null) + { + var activeTablesGroup = rml.ProcessParametersTables.Where(x => x.Active).FirstOrDefault(); + if (activeTablesGroup != null) { - var tables = await db.ProcessParametersTables.Where(x => x.ProcessParametersTablesGroupGuid == activeTablesGroup.Guid).OrderBy(x => x.TableIndex).ToListAsync(); - if (tables.Count > 0) + try { - tableZone1 = tables[0]; + var tables = await db.ProcessParametersTables.Where(x => x.ProcessParametersTablesGroupGuid == activeTablesGroup.Guid).OrderBy(x => x.TableIndex).ToListAsync(); + if (tables.Count > 0) + { + tableZone1 = tables[0]; + } + if (tables.Count > 1) + { + tableZone2 = tables[1]; + } } - if (tables.Count > 1) + catch (Exception ex) { - tableZone2 = tables[1]; + LogManager.Log($"Error loading ProcessParametersTables {ex.Message}"); } - } - catch (Exception ex) - { - LogManager.Log($"Error loading ProcessParametersTables {ex.Message}"); - } - }; - } - - RmlModel model = new RmlModel(); - model.Guid = rml.Guid; - model.Name = rml.Name; - model.LastUpdated = rml.LastUpdated; - model.DisplayName = rml.DisplayName; - model.CCT = rml.FileName + " v" + rml.ColorConversionVersion; - model.UseGradients = rml.UseColorLibGradients; - model.UseLightInks = rml.UseLightInks; - model.HeadType = (HeadTypes)rml.HeadType; - model.Btsr = (String.IsNullOrEmpty(rml.BtsrApplicationType) ? "N/A" : rml.BtsrApplicationType) + ", " + (String.IsNullOrEmpty(rml.BtsrYarnType) ? "N/A" : rml.BtsrYarnType); - - if( tableZone1 != null) + }; + } + + RmlModel model = new RmlModel(); + model.Guid = rml.Guid; + model.Name = rml.Name; + model.LastUpdated = rml.LastUpdated; + model.DisplayName = rml.DisplayName; + model.CCT = rml.FileName + " v" + rml.ColorConversionVersion; + model.UseGradients = rml.UseColorLibGradients; + model.UseLightInks = rml.UseLightInks; + model.HeadType = (HeadTypes)rml.HeadType; + model.Btsr = (String.IsNullOrEmpty(rml.BtsrApplicationType) ? "N/A" : rml.BtsrApplicationType) + ", " + (String.IsNullOrEmpty(rml.BtsrYarnType) ? "N/A" : rml.BtsrYarnType); + model.MachineType = (MachineTypes?)rml.MachineType; + + if (tableZone1 != null) { - model.Zone1InkUptake = String.Format($"{tableZone1.MinInkUptake}-{tableZone1.MaxInkUptake}"); + model.Zone1InkUptake = String.Format($"{tableZone1.MinInkUptake}-{tableZone1.MaxInkUptake}"); model.DyeingSpeed = tableZone1.DyeingSpeed.ToString(); } - if(tableZone2 != null) + if (tableZone2 != null) { model.DyeingSpeed += String.Format($"-{tableZone2.DyeingSpeed}"); model.Zone2InkUptake = tableZone2 == null ? "-" : String.Format($"{tableZone2.MinInkUptake}-{tableZone2.MaxInkUptake}"); + } + + //model.LiquidTypes = rml.LiquidTypes.OrderBy(x => x.Code).Select(x => x.Color).ToList(); + //model.LiquidTypesR = rml.LiquidTypesRmls.OrderBy(x => x.LiquidType.Code).ToList().Select((n) => new RmlModel.LiquidTypeColorValue(){ Color = n.LiquidType.Color, LiquidTypeValue = n.MaxNlPerCm }).ToList(); + + models.Add(model); } - model.LiquidTypes = rml.LiquidTypes.OrderBy(x => x.Code).Select(x => x.Color).ToList(); - model.LiquidTypesR = rml.LiquidTypesRmls.OrderBy(x => x.LiquidType.Code).ToList().Select((n) => new RmlModel.LiquidTypeColorValue(){ Color = n.LiquidType.Color, LiquidTypeValue = n.MaxNlPerCm }).ToList(); - - models.Add(model); + Rmls = models; } - - Rmls = models; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error filtering rmls on RML module."); + } + finally + { + LoadingRmls = false; } } @@ -730,6 +753,7 @@ namespace Tango.MachineStudio.RML.ViewModels rml.DisplayName = name; rml.QualificationDate = DateTime.UtcNow; rml.Manufacturer = "Twine"; + rml.DefaultLiquidFactor = 140; using (ObservablesContext db = ObservablesContext.CreateDefault()) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index 8447a3899..acd83cee2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -125,6 +125,11 @@ + + + + + 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 2c0f77937..eee16a2df 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 @@ -9,6 +9,7 @@ xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:local="clr-namespace:Tango.MachineStudio.RML.Views" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -19,6 +20,7 @@ + @@ -130,7 +132,8 @@ - + + + + + + -- cgit v1.3.1