From d0faa49dc04de0ceb5e9854e965bb32473bc5b85 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 13 Nov 2018 14:45:22 +0200 Subject: Machine Studio v3.5.68 Prevent graph crashing on OnRender. Differed SynchronizeColorSpaces with timer. Implemented color calibration for Research module. --- .../Build/Shortcuts/Machine Studio.lnk | Bin 1532 -> 1516 bytes .../Properties/AssemblyInfo.cs | 2 +- .../Renderers/GraphScrollingRenderer.cs | 71 +++++++++++---------- .../ColorConversion/TangoColorConverter.cs | 27 +++++++- .../Tango.BL/EntitiesExtensions/BrushStop.cs | 48 ++++++++++---- 5 files changed, 98 insertions(+), 50 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 58ee3bfb0..63a00b856 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 3fecdab0b..183d1ba89 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.5.66.18305")] +[assembly: AssemblyVersion("3.5.68.18305")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX/Renderers/GraphScrollingRenderer.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX/Renderers/GraphScrollingRenderer.cs index e3bf6182e..3d127c448 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX/Renderers/GraphScrollingRenderer.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX/Renderers/GraphScrollingRenderer.cs @@ -27,52 +27,55 @@ namespace RealTimeGraphX.Renderers /// protected override List OnRender(IEnumerable seriesCollection, TDataSeries series, PendingSeries toRender) { - XDataPoint min_x = toRender.XX.First(); - XDataPoint max_x = toRender.XX.Last(); - - YDataPoint min_y = Input.Range.MinimumY; - YDataPoint max_y = Input.Range.MaximumY; + List points = new List(); - if (Input.Range.AutoY) + if (toRender.XX.Count > 0 && toRender.YY.Count > 0) { - min_y = _current_min_y; - max_y = _current_max_y; - } + XDataPoint min_x = toRender.XX.First(); + XDataPoint max_x = toRender.XX.Last(); + + YDataPoint min_y = Input.Range.MinimumY; + YDataPoint max_y = Input.Range.MaximumY; - OnEffectiveRangeXChanged(min_x, max_x); - OnEffectiveRangeYChanged(min_y, max_y); + if (Input.Range.AutoY) + { + min_y = _current_min_y; + max_y = _current_max_y; + } - var dxList = toRender.XX.Select(x => x.ComputeRelativePosition(min_x, max_x)).ToList(); - var dyList = toRender.YY.Select(x => x.ComputeRelativePosition(min_y, max_y)).ToList(); + OnEffectiveRangeXChanged(min_x, max_x); + OnEffectiveRangeYChanged(min_y, max_y); - if (max_x - min_x > Input.Range.MaximumX) - { - var offset = ((max_x - min_x) - Input.Range.MaximumX) + min_x; + var dxList = toRender.XX.Select(x => x.ComputeRelativePosition(min_x, max_x)).ToList(); + var dyList = toRender.YY.Select(x => x.ComputeRelativePosition(min_y, max_y)).ToList(); - for (int i = 0; i < toRender.XX.Count; i++) + if (max_x - min_x > Input.Range.MaximumX) { - if (toRender.XX[i] < offset) - { - toRender.XX.RemoveAt(i); - toRender.YY.RemoveAt(i); - i--; - } - else + var offset = ((max_x - min_x) - Input.Range.MaximumX) + min_x; + + for (int i = 0; i < toRender.XX.Count; i++) { - break; + if (toRender.XX[i] < offset) + { + toRender.XX.RemoveAt(i); + toRender.YY.RemoveAt(i); + i--; + } + else + { + break; + } } } - } - - List points = new List(); - for (int i = 0; i < dxList.Count; i++) - { - float image_x = ConvertXValueToRendererValue(dxList[i]); - float image_y = (float)Math.Min(ConvertYValueToRendererValue(dyList[i]), Output.SurfaceHeight - 2); + for (int i = 0; i < dxList.Count; i++) + { + float image_x = ConvertXValueToRendererValue(dxList[i]); + float image_y = (float)Math.Min(ConvertYValueToRendererValue(dyList[i]), Output.SurfaceHeight - 2); - GraphPoint point = new GraphPoint(image_x, image_y); - points.Add(point); + GraphPoint point = new GraphPoint(image_x, image_y); + points.Add(point); + } } return points; diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index abe77da12..f98efad06 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -166,14 +166,37 @@ namespace Tango.BL.ColorConversion conversionInput.ForwardData = ByteString.CopyFrom(brushStop.Segment.Job.Rml.Ccts.FirstOrDefault().ForwardData); - foreach (var ids_pack in brushStop.Segment.Job.Machine.Configuration.GetSupportedIdsPacks(brushStop.Segment.Job.Rml)) + var machine = brushStop.Segment.Job.Machine; + var job = brushStop.Segment.Job; + + foreach (var ids_pack in machine.Configuration.GetSupportedIdsPacks(brushStop.Segment.Job.Rml)) { + CalibrationData calibrationData = Cat.CreateDemoCalibrationData((PMR.ColorLab.LiquidType)ids_pack.LiquidType.Code); + + //TODO: Enable Machine Calibration Also.. + + //var machine_cat = ids_pack.LiquidType.Cats.SingleOrDefault(x => x.MachineGuid == machine.Guid && x.RmlGuid == job.RmlGuid); + + //if (machine_cat != null) + //{ + // calibrationData = machine_cat.GetCalibrationData(); + //} + //else + //{ + var rml_cat = job.Rml.LiquidTypesRmls.SingleOrDefault(x => x.LiquidType.Code == ids_pack.LiquidType.Code); + + if (rml_cat != null) + { + calibrationData = rml_cat.GetCalibrationData(); + } + //} + conversionInput.InputCoordinates.InputLiquids.Add(new InputLiquid() { LiquidType = (PMR.ColorLab.LiquidType)ids_pack.LiquidType.Code, MaxNanoliterPerCentimeter = ids_pack.LiquidType.LiquidTypesRmls.Single(x => x.Rml == brushStop.Segment.Job.Rml).MaxNlPerCm, Volume = brushStop.GetVolume(ids_pack.PackIndex), - CalibrationData = Cat.CreateDemoCalibrationData((PMR.ColorLab.LiquidType)ids_pack.LiquidType.Code), //ids_pack.LiquidType.Cats.Single(x => x.Rml == brushStop.Segment.Job.Rml && x.Machine == brushStop.Segment.Job.Machine).GetCalibrationData() + CalibrationData = calibrationData, }); } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs index 82f9dc106..b518b55e4 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs @@ -18,6 +18,8 @@ using System.Runtime.InteropServices; using Tango.PMR; using System.Diagnostics; using Tango.BL.ColorConversion; +using System.Windows.Threading; +using System.Timers; namespace Tango.BL.Entities { @@ -27,6 +29,8 @@ namespace Tango.BL.Entities /// public partial class BrushStop { + private Timer _timer; + [NotMapped] private bool _ignorePropChanged; @@ -351,7 +355,7 @@ namespace Tango.BL.Entities /// Raises the property changed event. /// /// Name of the property. - protected override async void RaisePropertyChanged(string propName) + protected override void RaisePropertyChanged(string propName) { base.RaisePropertyChanged(propName); @@ -359,21 +363,37 @@ namespace Tango.BL.Entities { if (_colorPropertyNames.Contains(propName)) { - await SynchronizeColorSpaces(); + if (_timer == null) + { + _timer = new Timer(); + _timer.Interval = 10; + _timer.Elapsed += (x, y) => + { + _timer.Stop(); - _ignorePropChanged = true; + SynchronizeColorSpaces(() => + { - foreach (var prop in _colorPropertyNames) - { - RaisePropertyChanged(prop); - } + _ignorePropChanged = true; - if (Segment != null) - { - Segment.RaiseSegmentBrushChanged(); + foreach (var prop in _colorPropertyNames) + { + RaisePropertyChanged(prop); + } + + if (Segment != null) + { + Segment.RaiseSegmentBrushChanged(); + } + + _ignorePropChanged = false; + + }); + }; } - _ignorePropChanged = false; + _timer.Stop(); + _timer.Start(); } } if (propName == nameof(OffsetPercent)) @@ -413,9 +433,9 @@ namespace Tango.BL.Entities /// /// Synchronizes between the different brush stop color spaces. /// - private Task SynchronizeColorSpaces() + private void SynchronizeColorSpaces(Action onComplete = null) { - return Task.Factory.StartNew(() => + Task.Factory.StartNew(() => { Rgb rgb = new Rgb(Red, Green, Blue); Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); @@ -461,6 +481,8 @@ namespace Tango.BL.Entities _l = lab.L; _a = lab.A; _b = lab.B; + + onComplete?.Invoke(); }); } -- cgit v1.3.1