diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-11-13 03:46:12 +0200 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-11-13 03:46:12 +0200 |
| commit | d38bf750367c6d6cdda3a6a3efbdf3552aa85358 (patch) | |
| tree | 000818a2a1e49d1e3decc630a94cf183bbaf2128 /Software/Visual_Studio/PPC | |
| parent | 8431040bf909ba65d5ce242b5fd2cc91005ba679 (diff) | |
| download | Tango-d38bf750367c6d6cdda3a6a3efbdf3552aa85358.tar.gz Tango-d38bf750367c6d6cdda3a6a3efbdf3552aa85358.zip | |
FSE Stats Module.
Extended job run structure.
CSV export.
Diffstat (limited to 'Software/Visual_Studio/PPC')
3 files changed, 75 insertions, 44 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs index 621c6d5eb..00381377d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs @@ -11,6 +11,7 @@ using Tango.BL.Enumerations; using Tango.Core; using Tango.Core.DI; using Tango.Integration.ExternalBridge; +using Tango.PPC.Common.Connection; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Shared.Statistics; @@ -19,12 +20,15 @@ namespace Tango.PPC.Common.Statistics [TangoCreateWhenRegistered] public class DefaultStatisticsService : ExtendedObject, IStatisticsService, IExternalBridgeRequestHandler { + private IMachineProvider _machineProvider; + public bool Enabled { get; set; } = true; - public DefaultStatisticsService(IPPCExternalBridgeService externalBridge) + public DefaultStatisticsService(IPPCExternalBridgeService externalBridge, IMachineProvider machineProvider) { try { + _machineProvider = machineProvider; externalBridge.RegisterRequestHandler(this); } catch (Exception ex) @@ -43,10 +47,18 @@ namespace Tango.PPC.Common.Statistics using (ObservablesContext db = ObservablesContext.CreateDefault()) { - var jobNames = await db.JobRuns.Select(x => x.JobName).ToListAsync(); - var threadNames = await db.Rmls.Select(x => new { x.Guid, x.DisplayName }).ToListAsync(); + var jobNames = (await db.JobRuns.Select(x => x.JobName).ToListAsync()).Distinct().ToList(); + + var threadNames = await db.Rmls.Select(x => new { x.Guid, x.Name, x.DisplayName }).ToListAsync(); + + if (_machineProvider.Machine.SiteGuid != null) + { + var siteRmlsGuids = (await db.SitesRmls.Where(x => x.SiteGuid == _machineProvider.Machine.SiteGuid).ToListAsync()).Select(x => x.RmlGuid).Where(x => x != null).Distinct().ToList(); + threadNames.RemoveAll(x => !siteRmlsGuids.Contains(x.Guid)); + } + response.FiltersData.Jobs = jobNames; - response.FiltersData.Rmls = threadNames.Select(x => new ThreadFilterData() { Guid = x.Guid, Name = x.DisplayName }).ToList(); + response.FiltersData.Rmls = threadNames.Select(x => new ThreadFilterData() { Guid = x.Guid, Name = x.DisplayName.IsNotNullOrEmpty() ? x.DisplayName : x.Name }).ToList(); } await receiver.SendGenericResponse(response, token); @@ -85,7 +97,14 @@ namespace Tango.PPC.Common.Statistics if (filters.JobName.IsNotNullOrEmpty()) { - db_JobRuns = db_JobRuns.Where(x => x.JobName.ToLower().StartsWith(filters.JobName.ToLower())); + if (!filters.ExactJobName) + { + db_JobRuns = db_JobRuns.Where(x => x.JobName.ToLower().StartsWith(filters.JobName.ToLower())); + } + else + { + db_JobRuns = db_JobRuns.Where(x => x.JobName.ToLower() == filters.JobName.ToLower()); + } } db_JobRuns = db_JobRuns.Where(x => x.JobLength >= filters.MinLength && x.JobLength <= filters.MaxLength); @@ -106,51 +125,58 @@ namespace Tango.PPC.Common.Statistics pj.ID = jobRun.ID; jobRunComposition.Job = pj; - foreach (var segment in jobRun.JobFile.Segments) + if (jobRun.JobFile != null) { - PresentationSegment ps = new PresentationSegment(); - ps.Length = (int)segment.Length; - pj.Segments.Add(ps); - - foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) + foreach (var segment in jobRun.JobFile.Segments) { - PresentationBrushStop pbs = new PresentationBrushStop(); - pbs.ColorSpace = colorSpaces.First(x => x.Guid == stop.ColorSpaceGuid).Space; - pbs.StartMeters = segment.Length * (stop.OffsetPercent / 100d); ; + PresentationSegment ps = new PresentationSegment(); + ps.Length = (int)segment.Length; + pj.Segments.Add(ps); - foreach (var liquidType in stop.LiquidVolumes) + foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).DistinctBy(x => x.OffsetPercent).ToList()) { - PresentationLiquidVolume plt = new PresentationLiquidVolume(); - plt.LiquidType = (LiquidTypes)Enum.Parse(typeof(LiquidTypes), liquidType.LiquidTypeName.Replace(" ","")); - plt.Volume = liquidType.Volume; - pbs.LiquidVolumes.Add(plt); - } + PresentationBrushStop pbs = new PresentationBrushStop(); + pbs.ColorSpace = colorSpaces.First(x => x.Guid == stop.ColorSpaceGuid).Space; + pbs.StartMeters = segment.Length * (stop.OffsetPercent / 100d); ; - switch (pbs.ColorSpace) - { - case ColorSpaces.RGB: - pbs.Red = stop.Red; - pbs.Green = stop.Green; - pbs.Blue = stop.Blue; - break; - case ColorSpaces.LAB: - pbs.L = stop.L; - pbs.A = stop.B; - pbs.B = stop.B; - break; - case ColorSpaces.Volume: - pbs.Cyan = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Cyan).Volume; - pbs.Magenta = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Magenta).Volume; - pbs.Yellow = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Yellow).Volume; - pbs.Black = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Black).Volume; - break; - case ColorSpaces.Catalog: - pbs.Catalog = catalogs.FirstOrDefault(x => x.Guid == stop.ColorCatalogGuid)?.Name; - pbs.CatalogItem = color_catalog_Items.FirstOrDefault(x => x.Guid == stop.ColorCatalogItemGuid)?.Name; - break; - } + foreach (var liquidType in stop.LiquidVolumes) + { + PresentationLiquidVolume plt = new PresentationLiquidVolume(); + plt.LiquidType = (LiquidTypes)Enum.Parse(typeof(LiquidTypes), liquidType.LiquidTypeName.Replace(" ", "")); + plt.Volume = liquidType.Volume; + pbs.LiquidVolumes.Add(plt); + } + + switch (pbs.ColorSpace) + { + case ColorSpaces.RGB: + pbs.Red = stop.Red; + pbs.Green = stop.Green; + pbs.Blue = stop.Blue; + break; + case ColorSpaces.LAB: + pbs.L = stop.L; + pbs.A = stop.B; + pbs.B = stop.B; + break; + case ColorSpaces.Volume: + pbs.Cyan = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Cyan).Volume; + pbs.Magenta = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Magenta).Volume; + pbs.Yellow = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Yellow).Volume; + pbs.Black = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Black).Volume; + break; + case ColorSpaces.Catalog: + pbs.Catalog = catalogs.FirstOrDefault(x => x.Guid == stop.ColorCatalogGuid)?.Name; + pbs.CatalogItem = color_catalog_Items.FirstOrDefault(x => x.Guid == stop.ColorCatalogItemGuid)?.Name; + break; + } - ps.Stops.Add(pbs); + pbs.BestMatchR = stop.BestMatchR; + pbs.BestMatchG = stop.BestMatchG; + pbs.BestMatchB = stop.BestMatchB; + + ps.Stops.Add(pbs); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs index d15b3784b..eda91ab9e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs @@ -12,6 +12,7 @@ namespace Tango.PPC.Shared.Statistics public DateTime EndDateUTC { get; set; } public List<String> RmlGuids { get; set; } public String JobName { get; set; } + public bool ExactJobName { get; set; } public int MinLength { get; set; } public int MaxLength { get; set; } public List<int> EndStatuses { get; set; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/PresentationBrushStop.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/PresentationBrushStop.cs index 91f5faee0..d17cc8d42 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/PresentationBrushStop.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/PresentationBrushStop.cs @@ -24,6 +24,10 @@ namespace Tango.PPC.Shared.Statistics public String Catalog { get; set; } public String CatalogItem { get; set; } + public int BestMatchR { get; set; } + public int BestMatchG { get; set; } + public int BestMatchB { get; set; } + public List<PresentationLiquidVolume> LiquidVolumes { get; set; } public PresentationBrushStop() |
