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. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../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 +- Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs | 8 + Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 15 ++ .../Visual_Studio/Tango.BL/Entities/RmlBase.cs | 38 ++++ Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 194 ++++++++++----------- .../JobRuns/BasicJobRunsLogger.cs | 53 +++--- .../SQLExaminer/Configurations/OverrideData.xml | Bin 97788 -> 98058 bytes .../Tango.Telemetry/Mappers/JobRunMapper.cs | 54 ++++-- .../Tango.Telemetry/Telemetries/TelemetryJobRun.cs | 40 +++++ 16 files changed, 377 insertions(+), 225 deletions(-) (limited to 'Software') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 98f11ffc6..950d88e6b 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 f646d3953..be4dd47bc 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 @@ - + + + + + + diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs index 460d1f193..03bd6b656 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs @@ -445,5 +445,13 @@ namespace Tango.BL.DTO get; set; } + /// + /// machine type + /// + public Nullable MachineType + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs index fdeb8f05e..3f35ed11f 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs @@ -106,6 +106,21 @@ namespace Tango.BL.Entities } } + [NotMapped] + [JsonIgnore] + public MachineTypes? ForMachineType + { + get + { + return MachineType != null ? (MachineTypes?)MachineType : null; + } + set + { + MachineType = (int?)value; + RaisePropertyChanged(nameof(ForMachineType)); + } + } + protected override void OnNameChanged(string name) { base.OnNameChanged(name); diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs index 357be1666..59881f3d5 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs @@ -111,6 +111,8 @@ namespace Tango.BL.Entities public event EventHandler DefaultLiquidFactorChanged; + public event EventHandler> MachineTypeChanged; + public event EventHandler BtsrApplicationTypeChanged; public event EventHandler BtsrYarnTypeChanged; @@ -1569,6 +1571,33 @@ namespace Tango.BL.Entities } } + protected Nullable _machinetype; + + /// + /// Gets or sets the rmlbase machine type. + /// + + [Column("MACHINE_TYPE")] + + public Nullable MachineType + { + get + { + return _machinetype; + } + + set + { + if (_machinetype != value) + { + _machinetype = value; + + OnMachineTypeChanged(value); + + } + } + } + protected BtsrApplicationType _btsrapplicationtype; /// @@ -2499,6 +2528,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(DefaultLiquidFactor)); } + /// + /// Called when the MachineType has changed. + /// + protected virtual void OnMachineTypeChanged(Nullable machinetype) + { + MachineTypeChanged?.Invoke(this, machinetype); + RaisePropertyChanged(nameof(MachineType)); + } + /// /// Called when the BtsrApplicationType has changed. /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index f6f747893..7f73b5575 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -83,6 +83,7 @@ namespace Tango.DAL.Remote.DB public string BTSR_YARN_TYPE_GUID { get; set; } public double BTSR_TENSION_ERROR { get; set; } public double DEFAULT_LIQUID_FACTOR { get; set; } + public Nullable MACHINE_TYPE { get; set; } public virtual BTSR_APPLICATION_TYPES BTSR_APPLICATION_TYPES { get; set; } public virtual BTSR_YARN_TYPES BTSR_YARN_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 8ed5c4fed..93ca57214 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1459,6 +1459,7 @@ + @@ -7109,6 +7110,7 @@ + @@ -10593,6 +10595,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 99c611661..b032b64d6 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,103 +5,103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index e128a5949..4f442152d 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -15,6 +15,7 @@ using Tango.BL.Enumerations; using Tango.Core; using Tango.Core.ExtensionMethods; using Tango.Integration.Operation; +using Tango.Logging; using Tango.PMR.MachineStatus; using Tango.PMR.Printing; @@ -399,44 +400,32 @@ namespace Tango.Integration.JobRuns } } - private void SetJobRunLiquidQuantities(JobRun run, List quantities, bool update = false) + + public void SetJobRunLiquidQuantities(JobRun run, IEnumerable quantities, bool update = false) { - if (run == null || quantities == null) - return; + if (run == null || quantities == null) return; - // Map each LiquidType to the corresponding JobRun property updater - var setters = new Dictionary> - { - { LiquidTypes.Cyan, q => run.CyanQuantity = update ? run.CyanQuantity + q : q }, - { LiquidTypes.Magenta, q => run.MagentaQuantity = update ? run.MagentaQuantity + q : q }, - { LiquidTypes.Yellow, q => run.YellowQuantity = update ? run.YellowQuantity + q : q }, - { LiquidTypes.Black, q => run.BlackQuantity = update ? run.BlackQuantity + q : q }, - { LiquidTypes.Transparent, q => run.TransparentQuantity = update ? run.TransparentQuantity + q : q }, - { LiquidTypes.Lubricant, q => run.LubricantQuantity = update ? run.LubricantQuantity + q : q }, - { LiquidTypes.Cleaner, q => run.CleanerQuantity = update ? run.CleanerQuantity + q : q }, - { LiquidTypes.LightCyan, q => run.LightCyanQuantity = update ? run.LightCyanQuantity + q : q }, - { LiquidTypes.LightMagenta, q => run.LightMagentaQuantity = update ? run.LightMagentaQuantity + q : q }, - { LiquidTypes.LightYellow, q => run.LightYellowQuantity = update ? run.LightYellowQuantity + q : q }, - { LiquidTypes.Blue, q => run.BlueQuantity = update ? run.BlueQuantity + q : q }, - { LiquidTypes.LightBlue, q => run.LightBlueQuantity = update ? run.LightBlueQuantity + q : q }, - { LiquidTypes.Orange, q => run.OrangeQuantity = update ? run.OrangeQuantity + q : q }, - { LiquidTypes.LightOrange, q => run.LightOrangeQuantity = update ? run.LightOrangeQuantity + q : q }, - { LiquidTypes.Rubine, q => run.RubineQuantity = update ? run.RubineQuantity + q : q }, - { LiquidTypes.LightRubine, q => run.LightRubineQuantity = update ? run.LightRubineQuantity + q : q }, - { LiquidTypes.Navy, q => run.NavyQuantity = update ? run.NavyQuantity + q : q }, - { LiquidTypes.Violet, q => run.VioletQuantity = update ? run.VioletQuantity + q : q }, - { LiquidTypes.TWCyan, q => run.TwCyanQuantity = update ? run.VioletQuantity + q : q } - }; - - foreach (var liquidType in setters.Keys) + var props = run.GetType() + .GetProperties(BindingFlags.Instance | BindingFlags.Public) + .Where(p => p.CanRead && p.CanWrite && p.PropertyType == typeof(long)) + .Where(p => p.Name.EndsWith("Quantity", StringComparison.OrdinalIgnoreCase)) + .ToDictionary(p => p.Name.ToLower(), p => p); + + foreach (var q in quantities) { - var quantityObj = quantities.SingleOrDefault(x => x.LiquidType == liquidType); - var quantity = quantityObj?.Quantity ?? 0; - setters[liquidType](quantity); + var key = (q.LiquidType.ToString() + "Quantity").ToLower(); + if (!props.TryGetValue(key, out var prop)) + { + LogManager.Log($"Could not locate liquid quantity field for {q.LiquidType} on JobRun object.", LogCategory.Error); + continue; + } + + var currentVal = (long)(prop.GetValue(run) ?? 0L); + var newVal = update ? currentVal + q.Quantity : q.Quantity; + prop.SetValue(run, newVal); } } - #endregion #region Public Methods diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml index a5b64e7d9..0e232786a 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml differ diff --git a/Software/Visual_Studio/Tango.Telemetry/Mappers/JobRunMapper.cs b/Software/Visual_Studio/Tango.Telemetry/Mappers/JobRunMapper.cs index 8d8023c95..81bff1eb4 100644 --- a/Software/Visual_Studio/Tango.Telemetry/Mappers/JobRunMapper.cs +++ b/Software/Visual_Studio/Tango.Telemetry/Mappers/JobRunMapper.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Data.Entity; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.BL; @@ -63,6 +64,8 @@ namespace Tango.Telemetry.Mappers } } + + public static TelemetryJobRun MapJobRun(JobRun run) { Init(); @@ -106,23 +109,7 @@ namespace Tango.Telemetry.Mappers tRun.Status = run.JobRunStatus.ToString(); - tRun.OutputCyan = run.CyanQuantity; - tRun.OutputMagenta = run.MagentaQuantity; - tRun.OutputYellow = run.YellowQuantity; - tRun.OutputBlack = run.BlackQuantity; - tRun.OutputLightCyan = run.LightCyanQuantity; - tRun.OutputLightMagenta = run.LightMagentaQuantity; - tRun.OutputLightYellow = run.LightYellowQuantity; - tRun.OutputBlue = run.BlueQuantity; - tRun.OutputLightBlue = run.LightBlueQuantity; - tRun.OutputOrange = run.OrangeQuantity; - tRun.OutputLightOrange = run.LightOrangeQuantity; - tRun.OutputRubine = run.RubineQuantity; - tRun.OutputLightRubine = run.LightRubineQuantity; - tRun.OutputNavy = run.NavyQuantity; - tRun.OutputViolet = run.VioletQuantity; - tRun.OutputTransparent = run.TransparentQuantity; - tRun.OutputLubricant = run.LubricantQuantity; + MapToOutputs(run, tRun); tRun.FailureReason = run.FailedMessage; @@ -319,5 +306,38 @@ namespace Tango.Telemetry.Mappers return tRun; } + + public static void MapToOutputs(JobRun run, TelemetryJobRun tRun) + { + if (run == null || tRun == null) return; + + var runProps = run.GetType() + .GetProperties(BindingFlags.Instance | BindingFlags.Public) + .Where(p => p.CanRead && p.PropertyType == typeof(long)) + .Where(p => p.Name.EndsWith("Quantity", StringComparison.OrdinalIgnoreCase)) + .ToDictionary(p => p.Name.ToLower(), p => p); + + var tRunProps = tRun.GetType() + .GetProperties(BindingFlags.Instance | BindingFlags.Public) + .Where(p => p.CanWrite && p.PropertyType == typeof(long)) + .Where(p => p.Name.StartsWith("Output", StringComparison.OrdinalIgnoreCase)) + .ToDictionary(p => p.Name.ToLower(), p => p); + + foreach (var tProp in tRunProps.Values) + { + // "OutputCyan" -> "CyanQuantity" + var baseName = tProp.Name.Substring("Output".Length); + var runKey = (baseName + "Quantity").ToLower(); + + if (!runProps.TryGetValue(runKey, out var runProp)) + { + LogManager.Default.Log($"Could not locate liquid quantity field {runKey} for JobRun Telemetry object.", LogCategory.Warning); + continue; + } + + var value = (long)(runProp.GetValue(run) ?? 0L); + tProp.SetValue(tRun, value); + } + } } } diff --git a/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryJobRun.cs b/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryJobRun.cs index c5f4da8ea..1c52fb2c4 100644 --- a/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryJobRun.cs +++ b/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryJobRun.cs @@ -122,6 +122,46 @@ namespace Tango.Telemetry.Telemetries public long OutputTransparent { get; set; } public long OutputLubricant { get; set; } + public long OutputTwTransparentInk { get; set; } + public long OutputC1Ti { get; set; } + public long OutputTwCyan { get; set; } + public long OutputTwLightCyan { get; set; } + public long OutputTwMagenta { get; set; } + public long OutputTwLightMagenta { get; set; } + public long OutputTwYellow { get; set; } + public long OutputTwLightYellow { get; set; } + public long OutputC1Yellow { get; set; } + public long OutputC1LightYellow { get; set; } + public long OutputTwBlack { get; set; } + public long OutputTwViolet { get; set; } + public long OutputTwLightViolet { get; set; } + public long OutputCtBlue { get; set; } + public long OutputCtLightBlue { get; set; } + public long OutputCtRubine { get; set; } + public long OutputCtLightRubine { get; set; } + public long OutputCtOrange { get; set; } + public long OutputCtLightOrange { get; set; } + public long OutputCtNavy { get; set; } + public long OutputHdBlue { get; set; } + public long OutputHdLightBlue { get; set; } + public long OutputHdRubine { get; set; } + public long OutputHdLightRubine { get; set; } + public long OutputHdOrange { get; set; } + public long OutputHdLightOrange { get; set; } + public long OutputHdNavy { get; set; } + public long OutputHdLightNavy { get; set; } + public long OutputAmBlue { get; set; } + public long OutputAmLightBlue { get; set; } + public long OutputAmRed { get; set; } + public long OutputAmLightRed { get; set; } + public long OutputAmOrange { get; set; } + public long OutputAmLightOrange { get; set; } + public long OutputAmYellow { get; set; } + public long OutputAmLightYellow { get; set; } + public long OutputAmBlack { get; set; } + + + //The error that has occurred when Status = "Failed" public String FailureReason { get; set; } -- cgit v1.3.1