From 97ea085d1fac43aedc5258486ef355eb13abc195 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 13 Dec 2018 17:16:43 +0200 Subject: Fixed issues in segment indices !!! Fixed issue with PPC fine tuning. Added support to Twine & Panton in color conversion. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 20578304 -> 20578304 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Converters/JobToColumnDefinitionsConverter.cs | 2 +- .../ViewModels/MainViewVM.cs | 8 +++-- .../Views/JobView.xaml.cs | 4 +-- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 5 +++ .../Printing/DefaultPrintingManager.cs | 2 +- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../ColorConversion/TangoColorConverter.cs | 14 ++++++++ .../Tango.BL/EntitiesExtensions/BrushStop.cs | 10 ++++++ .../Tango.BL/EntitiesExtensions/Job.cs | 25 ++++++++++--- .../Tango.BL/EntitiesExtensions/Segment.cs | 10 ++++++ .../Tango.Integration/Operation/MachineOperator.cs | 39 +++++++-------------- 15 files changed, 83 insertions(+), 38 deletions(-) diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 8f59fd29d..623792e8e 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index c8d82d51f..0b0bee34f 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 9ce9473be..632cae29a 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 63d4bebf6..c04361480 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.Developer/Converters/JobToColumnDefinitionsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs index 0aadeca68..2ce5886c6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs @@ -21,7 +21,7 @@ namespace Tango.MachineStudio.Developer.Converters double totalLength = job.Segments.Sum(x => x.Length); - foreach (var segment in job.Segments) + foreach (var segment in job.OrderedSegments) { columns.Add(new ColumnDefinition() { Width = new GridLength(segment.Length / totalLength, GridUnitType.Star) }); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index b75a84a6c..55ef56ce4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1708,7 +1708,7 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Setting selected segment..."); - _selectedSegment = ActiveJob.Segments.FirstOrDefault(); + _selectedSegment = ActiveJob.OrderedSegments.FirstOrDefault(); ActiveJob.LengthChanged -= ActiveJob_LengthChanged; ActiveJob.LengthChanged += ActiveJob_LengthChanged; @@ -2153,10 +2153,14 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.LogFormat("Duplicating {0} segments...", SelectedSegments.Count); + int start_index = SelectedSegments.Max(x => x.SegmentIndex); + + ActiveJob.Segments.Where(x => x.SegmentIndex > start_index).ToList().ForEach(x => x.SegmentIndex = x.SegmentIndex + SelectedSegments.Count); + foreach (var segment in SelectedSegments.OrderBy(x => x.SegmentIndex)) { var cloned = segment.Clone(); - cloned.SegmentIndex = ActiveJob.Segments.Max(x => x.SegmentIndex) + 1; + cloned.SegmentIndex = start_index++; ActiveJob.Segments.Add(cloned); SelectedSegment = cloned; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index 8c58690fd..f3af53352 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -65,11 +65,11 @@ namespace Tango.MachineStudio.Developer.Views if (_vm != null && _vm.ActiveJob != null) { List segments = new List(); - foreach (var s in _vm.ActiveJob.Segments.OrderBy(x => x.SegmentIndex)) + foreach (var s in _vm.ActiveJob.OrderedSegments) { segments.Add(s); - if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.Segments.IndexOf(s) != _vm.ActiveJob.Segments.Count - 1) + if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.OrderedSegments.IndexOf(s) != _vm.ActiveJob.OrderedSegments.Count - 1) { segments.Add(new Segment() { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index b009762b4..98f429889 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -888,6 +888,11 @@ namespace Tango.PPC.Jobs.ViewModels /// private void ResetFineTuning() { + if (Job != null && _jobs_fine_tune_items.ContainsKey(Job.Guid)) + { + _jobs_fine_tune_items.Remove(Job.Guid); + } + SyncFineTuneItemsToBrushStops(); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 1a509f78b..347701c6e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -121,7 +121,7 @@ namespace Tango.PPC.UI.Printing { sampleDyeJob.NumberOfUnits = 1; - foreach (var segment in sampleDyeJob.Segments) + foreach (var segment in sampleDyeJob.OrderedSegments) { segment.Length = job.SampleUnitsOrMeters; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index 327880b63..776fa7448 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -199,6 +199,20 @@ namespace Tango.BL.ColorConversion ConversionInput conversionInput = new ConversionInput(); conversionInput.ColorSpace = (PMR.ColorLab.ColorSpace)brushStop.ColorSpace.Code; + + if (conversionInput.ColorSpace == PMR.ColorLab.ColorSpace.Twine || conversionInput.ColorSpace == PMR.ColorLab.ColorSpace.Panton) + { + conversionInput.ColorSpace = PMR.ColorLab.ColorSpace.Volume; + + if (brushStop.ColorCatalog != null) + { + brushStop.SetVolume(Enumerations.LiquidTypes.Cyan, brushStop.ColorCatalog.Cyan); + brushStop.SetVolume(Enumerations.LiquidTypes.Magenta, brushStop.ColorCatalog.Magenta); + brushStop.SetVolume(Enumerations.LiquidTypes.Yellow, brushStop.ColorCatalog.Yellow); + brushStop.SetVolume(Enumerations.LiquidTypes.Black, brushStop.ColorCatalog.Black); + } + } + conversionInput.InputCoordinates = new InputCoordinates(); conversionInput.SegmentLength = brushStop.Segment.Length; //TODO: for gradient ? diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs index 19258026c..5524cbd06 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs @@ -328,6 +328,16 @@ namespace Tango.BL.Entities typeof(BrushStop).GetProperty("V" + packIndex).SetValue(this, volume); } + public void SetVolume(LiquidTypes liquidType, double volume) + { + SetVolume(Segment.Job.Machine.Configuration.IdsPacks.SingleOrDefault(x => x.LiquidType.Code == liquidType.ToInt32()).PackIndex, volume); + } + + public double GetVolume(LiquidTypes liquidType) + { + return GetVolume(Segment.Job.Machine.Configuration.IdsPacks.SingleOrDefault(x => x.LiquidType.Code == liquidType.ToInt32()).PackIndex); + } + public int GetDispensingDivision(int packIndex) { return (int)typeof(BrushStop).GetProperty("V" + packIndex + "Div").GetValue(this); diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index 95779f03e..6ae2f1daf 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -150,13 +150,15 @@ namespace Tango.BL.Entities { if (EnableInterSegment && IsAllSegmentsPerSpool) { + int max = Segments.Max(x => x.SegmentIndex); + ObservableCollection effectiveSegments = new ObservableCollection(); - foreach (var s in Segments.ToList()) + foreach (var s in Segments.ToList().OrderBy(x => x.SegmentIndex)) { effectiveSegments.Add(s); - if (Segments.IndexOf(s) != Segments.Count - 1) + if (s.SegmentIndex != max) { effectiveSegments.Add(CreateInterSegment(InterSegmentLength)); } @@ -166,11 +168,24 @@ namespace Tango.BL.Entities } else { - return Segments; + return Segments.OrderBy(x => x.SegmentIndex).ToObservableCollection(); } } } + /// + /// Gets the ordered segments. + /// + [NotMapped] + [JsonIgnore] + public ObservableCollection OrderedSegments + { + get + { + return Segments.OrderBy(x => x.SegmentIndex).ToObservableCollection(); + } + } + /// /// Gets or sets the job fine tuning status. /// @@ -370,7 +385,7 @@ namespace Tango.BL.Entities int fromAngle = -90; double totalLength = Segments.Sum(x => x.Length); //Excluding inter segment. - foreach (var segment in Segments.ToList().OrderBy(x => x.SegmentIndex)) + foreach (var segment in OrderedSegments) { int toAngle = (int)((segment.Length / totalLength) * 360d); g.FillPie(segment.CreateGdiBrush(bmp.Width - 2, bmp.Height - 2), new Rectangle(0, 0, bmp.Width - 2, bmp.Height - 2), fromAngle, toAngle); @@ -538,7 +553,7 @@ namespace Tango.BL.Entities jobFile.Type = job.Type; jobFile.WindingMethodGuid = job.WindingMethodGuid; - foreach (var segment in job.Segments.OrderBy(x => x.SegmentIndex)) + foreach (var segment in job.OrderedSegments) { JobFileSegment s = new JobFileSegment(); s.Length = segment.Length; diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs index e2c919938..8737e0413 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs @@ -297,6 +297,16 @@ namespace Tango.BL.Entities return stop; } + public Segment GetNextSegment() + { + return Job.OrderedSegments.FirstOrDefault(x => x.SegmentIndex > SegmentIndex); + } + + public Segment GetPreviousSegment() + { + return Job.OrderedSegments.LastOrDefault(x => x.SegmentIndex < SegmentIndex); + } + /// /// Gets the duration estimation for this job. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 63a19dcac..991442510 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -764,23 +764,6 @@ namespace Tango.Integration.Operation CurrentProcessParameters = processParameters; - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } - - job = job.Clone(); - - var segments = job.Segments.ToList(); - - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) - { - job.Segments.Add(s); - } - } - var request = new ResumeCurrentJobRequest(); JobHandler handler = null; @@ -981,7 +964,7 @@ namespace Tango.Integration.Operation handler.RaiseStatusReceived(response.Message.Status); - if (!responseLogged && segment == job.Segments.First()) + if (!responseLogged && segment == job.OrderedSegments.First()) { responseLogged = true; Status = MachineStatuses.Printing; @@ -1009,7 +992,7 @@ namespace Tango.Integration.Operation } }, () => { - if (segment == job.Segments.Last()) + if (segment == job.OrderedSegments.Last()) { Status = MachineStatuses.ReadyToDye; PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, handler.Job)); @@ -1019,7 +1002,7 @@ namespace Tango.Integration.Operation { handler.RaiseSpoolChangeRequired(() => { - ContinueSingleSpoolJob(job.Segments[job.Segments.IndexOf(segment) + 1], job, processParameters, handler); + ContinueSingleSpoolJob(segment.GetNextSegment(), job, processParameters, handler); },() => { PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, handler.Job)); @@ -1198,13 +1181,17 @@ namespace Tango.Integration.Operation job = job.Clone(); - var segments = job.Segments.ToList(); + int max = job.OrderedSegments.Last().SegmentIndex; + + var segments = job.OrderedSegments.ToList(); for (int i = 0; i < job.NumberOfUnits - 1; i++) { foreach (var s in segments) { - job.Segments.Add(s); + var cloned = s.Clone(job); + cloned.SegmentIndex = max++; + job.Segments.Add(cloned); } } @@ -1223,7 +1210,7 @@ namespace Tango.Integration.Operation processParameters.MapPrimitivesTo(process); ticket.ProcessParameters = process; - foreach (var segment in job.Segments) + foreach (var segment in job.OrderedSegments) { ticket.Segments.Add(CreatePMRJobSegment(segment, job, processParameters)); } @@ -1253,7 +1240,7 @@ namespace Tango.Integration.Operation if (!job.IsAllSegmentsPerSpool) { - ContinueSingleSpoolJob(job.Segments.First(), job, processParameters, handler); + ContinueSingleSpoolJob(job.OrderedSegments.First(), job, processParameters, handler); return handler; } @@ -1385,7 +1372,7 @@ namespace Tango.Integration.Operation job = job.Clone(); - var segments = job.Segments.ToList(); + var segments = job.OrderedSegments.ToList(); for (int i = 0; i < job.NumberOfUnits - 1; i++) { @@ -1410,7 +1397,7 @@ namespace Tango.Integration.Operation processParameters.MapPrimitivesTo(process); ticket.ProcessParameters = process; - foreach (var segment in job.Segments) + foreach (var segment in job.OrderedSegments) { JobSegment jobSegment = new JobSegment(); jobSegment.Length = segment.LengthWithFactor; -- cgit v1.3.1