aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common
diff options
context:
space:
mode:
authorRoy <Roy.mail.net@gmail.com>2022-11-13 03:46:12 +0200
committerRoy <Roy.mail.net@gmail.com>2022-11-13 03:46:12 +0200
commitd38bf750367c6d6cdda3a6a3efbdf3552aa85358 (patch)
tree000818a2a1e49d1e3decc630a94cf183bbaf2128 /Software/Visual_Studio/PPC/Tango.PPC.Common
parent8431040bf909ba65d5ce242b5fd2cc91005ba679 (diff)
downloadTango-d38bf750367c6d6cdda3a6a3efbdf3552aa85358.tar.gz
Tango-d38bf750367c6d6cdda3a6a3efbdf3552aa85358.zip
FSE Stats Module.
Extended job run structure. CSV export.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs114
1 files changed, 70 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);
+ }
}
}