diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML')
4 files changed, 115 insertions, 77 deletions
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<LiquidTypeColorValue> 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<RmlModel> models = new List<RmlModel>(); + LoadingRmls = true; - //var tables = ActiveRML.GetActiveProcessGroup().ProcessParametersTables; + var filter = RMLFilter.ToStringOrEmpty().ToLower(); - foreach (var rml in rmls.OrderBy(x => x.Name).ToList()) + 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<RmlModel> models = new List<RmlModel>(); + + //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 @@ <TextBlock Text="Count (den):" ></TextBlock> <TextBlock Text="{Binding ActiveRML.DencityCount}" Foreground="Blue" ></TextBlock> + <TextBlock Text="Default Liquid Factor:" ></TextBlock> + <mahapps:NumericUpDown Minimum="1" Maximum="1000" Value="{Binding ActiveRML.DefaultLiquidFactor}" Foreground="Blue" ></mahapps:NumericUpDown> + + <TextBlock Text="Machine Type:" ></TextBlock> + <ComboBox ItemsSource="{Binding Source={x:Type enumerations:MachineTypes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding ActiveRML.ForMachineType}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Foreground="Blue" ></ComboBox> <!--<TextBlock Text="Fiber Shape:" ></TextBlock> <ComboBox ItemsSource="{Binding FiberShapes}" SelectedItem="{Binding ActiveRML.FiberShape,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox>--> 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 @@ <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> <converters:IsNullToVisibilityConverter x:Key="IsNullToVisibilityConverter" /> + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> </UserControl.Resources> <Grid IsEnabled="{Binding IsFree}"> @@ -130,7 +132,8 @@ <!--<DataGridTextColumn Header="CL GR" Binding="{Binding UseGradients,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" />--> <!--<DataGridTextColumn Header="LIGHT INKS" Binding="{Binding UseLightInks,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" />--> <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> - <DataGridTemplateColumn Header="LIQUID FACTORS" Width="1*"> + <DataGridTextColumn Header="MACHINE TYPE" Binding="{Binding MachineType,Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto" /> + <!--<DataGridTemplateColumn Header="LIQUID FACTORS" Width="1*"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ItemsControl ItemsSource="{Binding LiquidTypesR}" Margin="0 -5 0 0"> @@ -157,9 +160,13 @@ </ItemsControl> </DataTemplate> </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> + </DataGridTemplateColumn>--> </DataGrid.Columns> </DataGrid> + + <Grid Background="#19000000" Visibility="{Binding LoadingRmls,Converter={StaticResource BooleanToVisibilityConverter}}"> + <mahapps:ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="100"></mahapps:ProgressRing> + </Grid> </Grid> </DockPanel> </Grid> |
