From 4cd4807ca5a7490c8d7edac496a19d618bf9197e Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 19 Nov 2022 14:43:46 +0200 Subject: Statistics Fine Tuning Adaptation. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.FSE.Statistics/Models/StopModel.cs | 41 ++++ .../Tango.FSE.Statistics/ViewModels/MainViewVM.cs | 89 +++++++- .../Tango.FSE.Statistics/Views/MainView.xaml | 119 +++++++--- .../Controls/SelectionComboBox.xaml | 2 +- .../Dialogs/VectorFineTuningDialogVM.cs | 248 ++++++++++++++------- .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 16 +- .../Modules/Tango.PPC.JobsV2/Models/JobModel.cs | 4 + .../Tango.PPC.JobsV2/Models/TrialsLogModel.cs | 3 + .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 2 + .../Tango.PPC.JobsV2/ViewModels/MainViewVM.cs | 10 +- .../Statistics/DefaultStatisticsService.cs | 8 +- .../PPC/Tango.PPC.Shared/Statistics/Filters.cs | 2 + .../Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs | 8 + Software/Visual_Studio/Tango.BL/Entities/Job.cs | 11 +- .../Visual_Studio/Tango.BL/Entities/JobRunBase.cs | 38 ++++ .../FineTuning/VectorFineTuningRunModel.cs | 25 +++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 3 +- .../Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 192 ++++++++-------- .../JobRuns/BasicJobRunsLogger.cs | 36 ++- Software/Visual_Studio/Tango.sln | 13 +- 26 files changed, 640 insertions(+), 234 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/FineTuning/VectorFineTuningRunModel.cs diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 9ac33e441..9b7b7ea3c 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 84fd2c5b6..deecbaaaf 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 be2aaf23e..5cfd85867 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 545096d43..c500561d4 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs index 487a75970..79331b222 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using Tango.BL.DTO; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.FineTuning; using Tango.Core.Commands; using Tango.PPC.Shared.Statistics; @@ -26,6 +27,16 @@ namespace Tango.FSE.Statistics.Models public RelayCommand CopyCommand { get; set; } public JobRunExtendedInfo ExtendedInfo { get; set; } public bool IsAdvancedMode { get; set; } + public VectorFineTuningRunModel FineTuningModel { get; set; } + + public bool IsFineTuning + { + get { return FineTuningModel != null; } + } + + public bool IsFineTuningApproved { get; set; } + + public bool IsFineTuningSelected { get; set; } public String Input { @@ -148,5 +159,35 @@ namespace Tango.FSE.Statistics.Models { get { return JobRun.NumberOfUnits > 1 ? $"{JobRun.JobLogicalLength} x{JobRun.NumberOfUnits}" : JobRun.JobLogicalLength.ToString(); } } + + public String FineTuningMeasured + { + get + { + if (FineTuningModel == null) return ""; + + return $"{FineTuningModel.FineTuningMeasuredL}, {FineTuningModel.FineTuningMeasuredA}, {FineTuningModel.FineTuningMeasuredB}"; + } + } + + public String FineTuningSuggested + { + get + { + if (FineTuningModel == null) return ""; + + return $"{FineTuningModel.FineTuningSuggestionL.ToString("0.00")}, {FineTuningModel.FineTuningSuggestionA.ToString("0.00")}, {FineTuningModel.FineTuningSuggestionB.ToString("0.00")}"; + } + } + + public String FineTuningTarget + { + get + { + if (FineTuningModel == null) return ""; + + return $"{FineTuningModel.FineTuningTargetL.ToString("0.00")}, {FineTuningModel.FineTuningTargetA.ToString("0.00")}, {FineTuningModel.FineTuningTargetB.ToString("0.00")}"; + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs index 2b46ad72f..7d71193f9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.Entity; @@ -13,6 +14,7 @@ using Tango.BL; using Tango.BL.DTO; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.FineTuning; using Tango.Core; using Tango.Core.Commands; using Tango.Core.ExtensionMethods; @@ -35,6 +37,8 @@ namespace Tango.FSE.Statistics.ViewModels private const int NULL_JOB_INDEX = -1000; private int _currentJobIndex; private StatisticsModel _model; + private String _currentFineTuningSessionID; + private List _fineTuningStops; #region Properties @@ -92,6 +96,13 @@ namespace Tango.FSE.Statistics.ViewModels set { _jobRunSelectedStatuses = value; RaisePropertyChangedAuto(); } } + private SelectedObjectCollection _jobRunSelectedDesignations; + public SelectedObjectCollection JobRunSelectedDesignations + { + get { return _jobRunSelectedDesignations; } + set { _jobRunSelectedDesignations = value; RaisePropertyChangedAuto(); } + } + private SelectedObjectCollection _selectedThreads; public SelectedObjectCollection SelectedThreads { @@ -176,6 +187,8 @@ namespace Tango.FSE.Statistics.ViewModels public RelayCommand OpenStreamingSettingsCommand { get; set; } + public RelayCommand ClearCommand { get; set; } + #endregion #region Suggestions Providers @@ -205,9 +218,25 @@ namespace Tango.FSE.Statistics.ViewModels JobRunStatus.Failed, }); + + JobRunSelectedDesignations = new SelectedObjectCollection(new ObservableCollection() + { + JobDesignations.Default, + JobDesignations.FineTuning, + + }, new ObservableCollection() + { + JobDesignations.Default, + JobDesignations.FineTuning, + }); + + JobRunSelectedStatuses.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(JobRunSelectedStatuses)); JobRunSelectedStatuses.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(JobRunSelectedStatuses)); + JobRunSelectedDesignations.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(JobRunSelectedDesignations)); + JobRunSelectedDesignations.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(JobRunSelectedDesignations)); + JobsAutoCompleteProvider = new AutoCompleteSource(AutoCompleteJobs); StartSelectedDate = DateTime.Now.AddMonths(-1); @@ -230,6 +259,7 @@ namespace Tango.FSE.Statistics.ViewModels CopyCommand = new RelayCommand(CopyStopToClipboard); ExportToCsvCommand = new RelayCommand(ExportToCSV, () => IsResultsAvailable); OpenStreamingSettingsCommand = new RelayCommand(OpenStreamingSettings); + ClearCommand = new RelayCommand(Clear); } #endregion @@ -281,7 +311,7 @@ namespace Tango.FSE.Statistics.ViewModels } #endregion - + #region Statistics Methods private async Task LoadFiltersData() @@ -311,6 +341,7 @@ namespace Tango.FSE.Statistics.ViewModels filters.StartDateUTC = StartSelectedDate; filters.EndDateUTC = EndSelectedDate; filters.EndStatuses = JobRunSelectedStatuses.SynchedSource.Cast().ToList(); + filters.JobDesignation = JobRunSelectedDesignations.SynchedSource.Cast().ToList(); filters.IncludeHeadCleaning = IncludeHeadCleaning; filters.JobName = JobName; filters.ExactJobName = JobNameExact; @@ -323,6 +354,8 @@ namespace Tango.FSE.Statistics.ViewModels List stops = new List(); _currentJobIndex = 0; + _currentFineTuningSessionID = null; + _fineTuningStops = new List(); foreach (var job in _model.StatisticsResult.JobRuns.OrderByDescending(x => x.JobRun.StartDate)) { @@ -351,7 +384,7 @@ namespace Tango.FSE.Statistics.ViewModels } catch (Exception ex) { - NotificationProvider.PushErrorReportingSnackbar(ex, "Statistics Module Error", "Error statistics from the remote machine."); + NotificationProvider.PushErrorReportingSnackbar(ex, "Statistics Module Error", "Error getting statistics from the remote machine."); } } @@ -361,7 +394,22 @@ namespace Tango.FSE.Statistics.ViewModels var rmlName = FiltersData.Rmls.FirstOrDefault(x => x.Guid == job.JobRun.RmlGuid)?.Name; - _currentJobIndex++; + VectorFineTuningRunModel fineTuningModel = null; + + if (job.JobRun.JobDesignation == (int)JobDesignations.FineTuning && job.JobRun.FineTuningString != null) + { + fineTuningModel = JsonConvert.DeserializeObject(job.JobRun.FineTuningString); + if (fineTuningModel.FineTuningSessionID != _currentFineTuningSessionID) + { + _fineTuningStops = new List(); + _currentFineTuningSessionID = fineTuningModel.FineTuningSessionID; + _currentJobIndex++; + } + } + else + { + _currentJobIndex++; + } foreach (var jobSegment in job.Job.Segments) { @@ -373,6 +421,20 @@ namespace Tango.FSE.Statistics.ViewModels stop.SegmentIndex = job.Job.Segments.IndexOf(jobSegment) + 1; stop.ThreadName = rmlName; stop.IsAdvancedMode = !BuildProvider.IsTwineRSM && CurrentUser.HasRole(Roles.FSEAdvancedTechnician); + stop.FineTuningModel = fineTuningModel; + + if (fineTuningModel != null) + { + stop.IsFineTuningApproved = fineTuningModel.Approved; + stop.IsFineTuningSelected = fineTuningModel.Approved; + + _fineTuningStops.Add(stop); + + if (_fineTuningStops.Exists(x => x.IsFineTuningApproved)) + { + _fineTuningStops.ForEach(x => x.IsFineTuningApproved = true); + } + } stop.ColorSpace = jobStop.ColorSpace; @@ -479,6 +541,12 @@ namespace Tango.FSE.Statistics.ViewModels return FiltersData.Jobs.Where(x => x != null).Where(x => x.ToLower().Contains(key.ToLower())).ToList(); } + private void Clear() + { + Stops?.Clear(); + Stats = new StatsModel(); + } + #endregion #region Stop Commands Handler @@ -578,7 +646,7 @@ namespace Tango.FSE.Statistics.ViewModels } #endregion - + #region CSV Export private async void ExportToCSV() @@ -734,6 +802,17 @@ namespace Tango.FSE.Statistics.ViewModels Stops.Clear(); } + if (stops.First().IsFineTuning && stops.First().FineTuningModel != null) + { + var sessionStop = Stops.Where(x => x.IsFineTuning).FirstOrDefault(x => x.FineTuningModel.FineTuningSessionID == stops[0].FineTuningModel.FineTuningSessionID); + + if (sessionStop != null) + { + stops.First().JobIndex = sessionStop.JobIndex; + stops.First().IsFineTuningApproved = sessionStop.IsFineTuningApproved; + } + } + foreach (var stop in stops) { Stops.Insert(0, stop); diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml index 29d12d773..31dee1093 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml @@ -21,9 +21,11 @@ + + @@ -31,17 +33,36 @@ - - + + + + + Best Match + + , + , + + + + + + + + + - Best Match - - , - , - + Measured: + + Suggested: - - + + + Measured: + , + , + + + @@ -51,9 +72,11 @@ + + @@ -75,29 +98,39 @@ - + - - + + @@ -123,10 +156,14 @@ - + + + + + - + - - + + @@ -218,6 +269,8 @@ + + @@ -266,6 +319,11 @@ + + + + + @@ -279,8 +337,8 @@ - - + + @@ -311,6 +369,13 @@ + + + Kind + + + + Job diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/SelectionComboBox.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/SelectionComboBox.xaml index 551693f2f..08a94663d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/SelectionComboBox.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/SelectionComboBox.xaml @@ -58,7 +58,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs index 596eb9316..752ae08b2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs @@ -1,6 +1,8 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Data.Entity; using System.IO; using System.Linq; using System.Text; @@ -12,6 +14,7 @@ using Tango.BL; using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.FineTuning; using Tango.Core; using Tango.Core.Commands; using Tango.Core.DI; @@ -38,6 +41,7 @@ namespace Tango.PPC.Jobs.Dialogs public class VectorFineTuningDialogVM : DialogViewVM { private JobHandler _handler; + private String _sessionID; #region Properties @@ -68,7 +72,7 @@ namespace Tango.PPC.Jobs.Dialogs /// [TangoInject] public IPrintingManager PrintingManager { get; set; } - + [TangoInject] public INavigationManager NavigationManager { get; set; } @@ -236,7 +240,7 @@ namespace Tango.PPC.Jobs.Dialogs } } } - + protected Double _cyan; /// @@ -371,11 +375,11 @@ namespace Tango.PPC.Jobs.Dialogs get { return _selectedLog; } set { - - _selectedLog = value; - RaisePropertyChangedAuto(); - OKCommand.RaiseCanExecuteChanged(); - + + _selectedLog = value; + RaisePropertyChangedAuto(); + OKCommand.RaiseCanExecuteChanged(); + } } @@ -394,14 +398,16 @@ namespace Tango.PPC.Jobs.Dialogs public bool IsJobRunning { get { return _isJobRunning; } - set { _isJobRunning = value; + set + { + _isJobRunning = value; RaisePropertyChangedAuto(); - Application.Current.Dispatcher.Invoke(() => - { - OKCommand.RaiseCanExecuteChanged(); - RaisePropertyChanged(nameof(IsDisableInputLAB)); - }); - } + Application.Current.Dispatcher.Invoke(() => + { + OKCommand.RaiseCanExecuteChanged(); + RaisePropertyChanged(nameof(IsDisableInputLAB)); + }); + } } private bool _isJobFailed; @@ -455,7 +461,7 @@ namespace Tango.PPC.Jobs.Dialogs TestCommand = new RelayCommand(StartJob, CanStartJob); StopCommand = new RelayCommand(StopTest); DeleteTrialCommand = new RelayCommand(DeleteTrialLog); - PressedCommand = new RelayCommand((x)=>{ });; + PressedCommand = new RelayCommand((x) => { }); ; IsExpanderOpened = true; @@ -464,16 +470,19 @@ namespace Tango.PPC.Jobs.Dialogs public void Init(BrushStopModel brushstop, double l, double a, double b, System.Windows.Media.Color targetColor) { + _sessionID = brushstop.Guid + $"{l}{a}{b}"; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + MachineProvider.MachineOperator.JobRunsLogger.JobRunAvailable += JobRunsLogger_JobRunAvailable; BrushStopModel = brushstop.Clone(); BrushStopModel.Guid = brushstop.Guid; TargetL = l; TargetB = b; TargetA = a; - + TargetColor = targetColor; BrushStopModel.ConvertColorToVolume(); @@ -497,18 +506,18 @@ namespace Tango.PPC.Jobs.Dialogs TrialsLogitems = new SynchronizedObservableCollection(); TrialsLogitems.Add(ActiveLogModel); //TEST - //for(int i = 1; i < 10; i++) - //{ - // var model = new TrialsLogModel(i , Cyan, Magenta, Yellow, Black); - // TrialsLogitems.Insert(0, model); - //} - + //for(int i = 1; i < 10; i++) + //{ + // var model = new TrialsLogModel(i , Cyan, Magenta, Yellow, Black); + // TrialsLogitems.Insert(0, model); + //} + } else { - TrialsLogitems = new SynchronizedObservableCollection(TestColor.TrialslogList.OrderByDescending(x=>x.TrialNumber)); - - int maxTrialsNumber = TrialsLogitems.Max( x=>x.TrialNumber); + TrialsLogitems = new SynchronizedObservableCollection(TestColor.TrialslogList.OrderByDescending(x => x.TrialNumber)); + + int maxTrialsNumber = TrialsLogitems.Max(x => x.TrialNumber); ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == maxTrialsNumber); if (ActiveLogModel == null) { @@ -520,7 +529,7 @@ namespace Tango.PPC.Jobs.Dialogs } if (ActiveLogModel.IsTested == false) { - if(ActiveLogModel.L != null) + if (ActiveLogModel.L != null) { MeasuredL = ActiveLogModel.L; } @@ -537,13 +546,13 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.IsActiveTrial = true; ActiveLogModel.IsSelectionEnable = true; - + var minValue = TrialsLogitems.Min(x => x.DeltaE); - if(minValue != null && minValue < 2) + if (minValue != null && minValue < 2) { - TrialsLogitems.Where(x=>x.DeltaE == minValue).ToList().ForEach(i => i.IsBest = true); + TrialsLogitems.Where(x => x.DeltaE == minValue).ToList().ForEach(i => i.IsBest = true); } - + OKCommand.RaiseCanExecuteChanged(); TestCommand.RaiseCanExecuteChanged(); @@ -580,8 +589,8 @@ namespace Tango.PPC.Jobs.Dialogs // Filter = ExplorerFileDefinition.PDFFile.Extension, // Title = "Save Color Correction Report", // }); - - // if (result != null) + + // if (result != null) { DateTime reportDateTime = DateTime.UtcNow.ToLocalTime(); ColorCorrectionRepotVM vm = new ColorCorrectionRepotVM() @@ -606,13 +615,13 @@ namespace Tango.PPC.Jobs.Dialogs PdfWpfWriter writer = new PdfWpfWriter(); writer.AddElement(new ColorCorrectionReport() { DataContext = vm }); string path = StorageProvider.Drive.Name + "\\Color Correction Report_" + reportDateTime.ToString(@"MM_dd_y_HH_mm") + ExplorerFileDefinition.PDFFile.Extension; - if(File.Exists(path)) + if (File.Exists(path)) { path = StorageProvider.Drive.Name + "\\Color Correction Report_" + reportDateTime.ToString(@"MM_dd_y_HH_mm") + "_1" + ExplorerFileDefinition.PDFFile.Extension; } writer.Save(path); await NotificationProvider.ShowSuccess("Color Correction Report saved successfully."); - LogManager.Log( $"Color Correction Report saved successfully to file {path}."); + LogManager.Log($"Color Correction Report saved successfully to file {path}."); } catch (Exception ex) { @@ -630,7 +639,7 @@ namespace Tango.PPC.Jobs.Dialogs { return; } - ActiveLogModel = TrialsLogitems.FirstOrDefault(x=> x.TrialNumber == 0); + ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == 0); ActiveLogModel.L = ActiveLogModel.A = ActiveLogModel.B = null; ActiveLogModel.NewSuggestionL = ActiveLogModel.NewSuggestionA = ActiveLogModel.NewSuggestionB = 0; ActiveLogModel.DeltaE = null; @@ -650,22 +659,22 @@ namespace Tango.PPC.Jobs.Dialogs private void DeleteTrialLog(object obj) { - if (SelectedLog != null ) + if (SelectedLog != null) { - if (SelectedLog.TrialNumber != 0 ) + if (SelectedLog.TrialNumber != 0) { bool isLastItem = (TrialsLogitems.Count - 1) == SelectedLog.TrialNumber; TrialsLogitems.Remove(SelectedLog); - + int trialNumber = 0; - foreach ( var trial in TrialsLogitems.OrderBy(x=>x.TrialNumber)) + foreach (var trial in TrialsLogitems.OrderBy(x => x.TrialNumber)) { trial.TrialNumber = trialNumber; trialNumber++; } - var max = TrialsLogitems.Max(x=>x.TrialNumber); + var max = TrialsLogitems.Max(x => x.TrialNumber); ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == max); - if(isLastItem) + if (isLastItem) { ActiveLogModel.IsTested = false; _measuredL = ActiveLogModel.L; @@ -682,7 +691,7 @@ namespace Tango.PPC.Jobs.Dialogs TestColor.TrialslogList.AddRange(TrialsLogitems); TrialsLogEngine.Default.UpdateTest(TestColor); } - + RaisePropertyChanged(nameof(IsDisableInputLAB)); SelectedLog = null; var minDelataE = TrialsLogitems.Min(x => x.DeltaE); @@ -690,7 +699,7 @@ namespace Tango.PPC.Jobs.Dialogs TrialsLogitems.ToList().ForEach(x => x.IsBest = (x.DeltaE == minDelataE)); RaisePropertyChanged(nameof(TrialNumber)); } - else if( TrialsLogitems.Count == 1) + else if (TrialsLogitems.Count == 1) { ActiveLogModel.L = ActiveLogModel.A = ActiveLogModel.B = null; ActiveLogModel.NewSuggestionL = ActiveLogModel.NewSuggestionA = ActiveLogModel.NewSuggestionB = 0; @@ -715,44 +724,66 @@ namespace Tango.PPC.Jobs.Dialogs protected override async void Accept() { - if(IsBusy) + if (IsBusy) return; IsBusy = true; OnClose(); - - if(SelectedLog.TrialNumber == 0 ) + + if (SelectedLog.TrialNumber == 0) { IsBusy = false; base.Accept(); return; } - var prevtrial = TrialsLogitems.FirstOrDefault( x=> x.TrialNumber == (SelectedLog.TrialNumber -1)); - if(prevtrial != null && prevtrial.DeltaE >=2) + var prevtrial = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == (SelectedLog.TrialNumber - 1)); + if (prevtrial != null && prevtrial.DeltaE >= 2) { - if( false == await NotificationProvider.ShowQuestion("Please note that the color you have chosen is not the closest one.")) + if (false == await NotificationProvider.ShowQuestion("Please note that the color you have chosen is not the closest one.")) { IsBusy = false; return; } } - + BrushStopModel.PreventPropertyUpdate = true; BrushStopModel.Cyan = SelectedLog.C; BrushStopModel.Magenta = SelectedLog.M; BrushStopModel.Yellow = SelectedLog.Y; BrushStopModel.PreventPropertyUpdate = false; BrushStopModel.Black = SelectedLog.K; - + BrushStopModel.PreventPropertyUpdate = true; BrushStopModel.L = SelectedLog.SuggestionL; BrushStopModel.A = SelectedLog.SuggestionA; BrushStopModel.B = SelectedLog.SuggestionB; BrushStopModel.PreventPropertyUpdate = false; - + + + if (TestColor != null) { TrialsLogEngine.Default.Delete(TestColor); } + + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var selectedRun = await db.JobRuns.FirstOrDefaultAsync(x => x.Guid == SelectedLog.JobRunGuid); + if (selectedRun != null) + { + VectorFineTuningRunModel model = JsonConvert.DeserializeObject(selectedRun.FineTuningString); + model.Approved = true; + selectedRun.FineTuningString = JsonConvert.SerializeObject(model); + await db.SaveChangesAsync(); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error updating the selected job run fine tuning db entry."); + } + IsBusy = false; base.Accept(); } @@ -761,7 +792,7 @@ namespace Tango.PPC.Jobs.Dialogs { OnClose(); - if (TestColor != null ) + if (TestColor != null) { if (TrialsLogitems.Count > 0) { @@ -776,7 +807,7 @@ namespace Tango.PPC.Jobs.Dialogs //else // TrialsLogEngine.Default.Delete(TestColor); } - else if(TrialsLogitems.Count > 0) + else if (TrialsLogitems.Count > 0) { TestColor = new TestColor(); TestColor.BrushStopGuid = BrushStopModel.Guid; @@ -794,6 +825,7 @@ namespace Tango.PPC.Jobs.Dialogs MachineProvider.MachineOperator.PrintingStarted -= MachineOperator_PrintingStarted; MachineProvider.MachineOperator.PrintingEnded -= MachineOperator_PrintingEnded; MachineProvider.MachineOperator.PrintingCompleted -= MachineOperator_PrintingCompleted; + MachineProvider.MachineOperator.JobRunsLogger.JobRunAvailable -= JobRunsLogger_JobRunAvailable; } private bool IsValidLAB() @@ -805,7 +837,7 @@ namespace Tango.PPC.Jobs.Dialogs return true; } - private void OnLABChanged() + private void OnLABChanged() { if (ActiveLogModel == null) return; @@ -822,7 +854,7 @@ namespace Tango.PPC.Jobs.Dialogs //{ // await NotificationProvider.ShowInfo("Color is out of gamut!"); //} - + var deltaE = DeltaE_CMC(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); ActiveLogModel.DeltaE = deltaE; ValidationTests(); @@ -838,22 +870,24 @@ namespace Tango.PPC.Jobs.Dialogs { if (ActiveLogModel.DeltaE <= 0.5) { - if(true == await NotificationProvider.ShowQuestion("Previous trial seems to be very close; no more trials are recommended")) + if (true == await NotificationProvider.ShowQuestion("Previous trial seems to be very close; no more trials are recommended")) return; } BrushStopModel.PreventPropertyUpdate = true; - - CalculateSuggestionLAB( ActiveLogModel); - + + CalculateSuggestionLAB(ActiveLogModel); + BrushStopModel.PreventPropertyUpdate = true; BrushStopModel.L = ActiveLogModel.NewSuggestionL; BrushStopModel.A = ActiveLogModel.NewSuggestionA; BrushStopModel.B = ActiveLogModel.NewSuggestionB; BrushStopModel.PreventPropertyUpdate = false; - + + + //calculate CMYK BrushStopModel.FineTuningConverter(); - if(BrushStopModel.IsOutOfGamut) + if (BrushStopModel.IsOutOfGamut) { ActiveLogModel.NewSuggestionL = BrushStopModel.L; ActiveLogModel.NewSuggestionA = BrushStopModel.A; @@ -866,20 +900,21 @@ namespace Tango.PPC.Jobs.Dialogs using (ObservablesContext db = ObservablesContext.CreateDefault()) { Job job = new Job(); + job.Guid = BrushStopModel.SegmentModel.Job.Guid; + job.ID = BrushStopModel.SegmentModel.Job.ID; job.EnableLubrication = true; job.Designation = JobDesignations.FineTuning; job.Machine = await new MachineBuilder(db).Set(MachineProvider.Machine.Guid).WithConfiguration().WithSpools().WithCats().WithVersion().BuildAsync(); var trialNumber = ActiveLogModel.TrialNumber + 1; - job.Name = $"Manual color test #{trialNumber}"; + job.Name = BrushStopModel.SegmentModel.Job.Name; job.Rml = await new RmlBuilder(db).Set(BrushStopModel.SegmentModel.Job.Rml.Guid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithGbdAndLub().WithLiquidFactors().WithSpools().BuildAsync(); job.SpoolType = db.SpoolTypes.FirstOrDefault(x => x.Guid == settings.SpoolTypeGuid); job.WindingMethod = db.WindingMethods.FirstOrDefault(); - - + job.VectorFineTuningRunModel = CreateFineTuningRunModel(); Segment segment = new Segment(); - segment.Name = "Standard Segment"; + segment.Name = "VFT Segment"; segment.Length = settings.FineTuningTrialLengthMeters; segment.Job = job; segment.JobGuid = job.Guid; @@ -891,6 +926,14 @@ namespace Tango.PPC.Jobs.Dialogs stop.ColorSpace = db.ColorSpaces.FirstOrDefault(x => x.Code == (int)ColorSpaces.Volume); stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + stop.BestMatchR = BrushStopModel.BestMatchRed; + stop.BestMatchG = BrushStopModel.BestMatchGreen; + stop.BestMatchB = BrushStopModel.BestMatchBlue; + + stop.L = BrushStopModel.L; + stop.A = BrushStopModel.A; + stop.B = BrushStopModel.B; + stop.SetVolume(LiquidTypes.Cyan, BrushStopModel.Cyan); stop.SetVolume(LiquidTypes.Magenta, BrushStopModel.Magenta); stop.SetVolume(LiquidTypes.Yellow, BrushStopModel.Yellow); @@ -932,7 +975,7 @@ namespace Tango.PPC.Jobs.Dialogs IsJobFailed = false; IsJobRunning = true; }); - + //e.JobHandler.CanCancelChanged += JobHandler_CanCancelChanged; } } @@ -982,7 +1025,7 @@ namespace Tango.PPC.Jobs.Dialogs private void MachineOperator_PrintingEnded(object sender, PrintingEventArgs e) { - + } private void MachineOperator_PrintingCompleted(object sender, PrintingEventArgs e) @@ -1049,9 +1092,9 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.SuggestionA = suggestionA; ActiveLogModel.SuggestionB = suggestionB; TrialsLogitems.Insert(0, ActiveLogModel); - var minDelataE = TrialsLogitems.Min(x=>x.DeltaE); - if(minDelataE != null && minDelataE < 2) - TrialsLogitems.ToList().ForEach( x=> x.IsBest = (x.DeltaE == minDelataE)); + var minDelataE = TrialsLogitems.Min(x => x.DeltaE); + if (minDelataE != null && minDelataE < 2) + TrialsLogitems.ToList().ForEach(x => x.IsBest = (x.DeltaE == minDelataE)); RaisePropertyChanged(nameof(TrialsLogitems)); _measuredL = null; @@ -1143,7 +1186,7 @@ namespace Tango.PPC.Jobs.Dialogs return Math.Sqrt(Math.Pow(L1 - L2, 2) + Math.Pow(a1 - a2, 2) + Math.Pow(b1 - b2, 2)); } - private async void ValidationTests() + private async void ValidationTests() { //if (ActiveLogModel.DeltaE <= 0.5) //{ @@ -1151,25 +1194,25 @@ namespace Tango.PPC.Jobs.Dialogs // return ; //} if (TrialsLogitems.Count == 1 || ActiveLogModel.DeltaE == null) - return ; + return; int currentTrialNumber = ActiveLogModel.TrialNumber; - if(TrialsLogitems.Count >= 3) + if (TrialsLogitems.Count >= 3) { - var item = TrialsLogitems.FirstOrDefault( x=>x.TrialNumber == currentTrialNumber - 2); + var item = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == currentTrialNumber - 2); var item1 = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == currentTrialNumber - 1); var item2 = ActiveLogModel; - if(item1 != null && item2 != null && item != null) + if (item1 != null && item2 != null && item != null) {//dEi+2- dEi+1>0.5 and dEi+1-dEi>0.5 - if (( item2.DeltaE - item1.DeltaE) > 0.5 && (item1.DeltaE - item.DeltaE) > 0.5) + if ((item2.DeltaE - item1.DeltaE) > 0.5 && (item1.DeltaE - item.DeltaE) > 0.5) { await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); - return ; + return; } //Math.Abs //| dEi+1- dEi | and |dEi+2 -dEi+1|<=0.1. - if(Math.Abs((double)item1.DeltaE - (double)item.DeltaE)<= 0.1 && Math.Abs((double)item2.DeltaE - (double)item1.DeltaE) <= 0.1) + if (Math.Abs((double)item1.DeltaE - (double)item.DeltaE) <= 0.1 && Math.Abs((double)item2.DeltaE - (double)item1.DeltaE) <= 0.1) { await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); return; @@ -1180,7 +1223,7 @@ namespace Tango.PPC.Jobs.Dialogs { var item = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == currentTrialNumber - 1); var item1 = ActiveLogModel; - if(item == null || item1 == null) + if (item == null || item1 == null) return; var deltaE_reg = DeltaE_regular(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); @@ -1190,7 +1233,7 @@ namespace Tango.PPC.Jobs.Dialogs await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); return; } - if(Math.Abs((double)item1.C - (double)item.C) < 0.1 + if (Math.Abs((double)item1.C - (double)item.C) < 0.1 && Math.Abs((double)item1.M - (double)item.M) < 0.1 && Math.Abs((double)item1.Y - (double)item.Y) < 0.1 && Math.Abs((double)item1.K - (double)item.K) < 0.1) @@ -1202,13 +1245,13 @@ namespace Tango.PPC.Jobs.Dialogs return; } - private bool CalculateSuggestionLAB( TrialsLogModel trial) + private bool CalculateSuggestionLAB(TrialsLogModel trial) { - if(MeasuredL != null && MeasuredA != null && MeasuredB != null) + if (MeasuredL != null && MeasuredA != null && MeasuredB != null) { - trial.NewSuggestionL = LimitToRange((trial.SuggestionL + (TargetL - (double)MeasuredL)),0, 100) ; + trial.NewSuggestionL = LimitToRange((trial.SuggestionL + (TargetL - (double)MeasuredL)), 0, 100); trial.NewSuggestionA = LimitToRange((trial.SuggestionA + (TargetA - (double)MeasuredA)), -128, 127); - trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)MeasuredB )), -128, 127); + trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)MeasuredB)), -128, 127); LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); return true; @@ -1231,5 +1274,38 @@ namespace Tango.PPC.Jobs.Dialogs #endregion + #region JobRun Extensions + + private VectorFineTuningRunModel CreateFineTuningRunModel() + { + VectorFineTuningRunModel model = new VectorFineTuningRunModel(); + + model.FineTuningSessionID = _sessionID; + model.FineTuningTrialNumber = ActiveLogModel.TrialNumber + 1; + model.JobName = BrushStopModel.SegmentModel.Job.Name; + + model.FineTuningTargetL = TargetL; + model.FineTuningTargetA = TargetA; + model.FineTuningTargetB = TargetB; + + model.FineTuningSuggestionL = BrushStopModel.L; + model.FineTuningSuggestionA = BrushStopModel.A; + model.FineTuningSuggestionB = BrushStopModel.B; + + model.FineTuningMeasuredL = MeasuredL; + model.FineTuningMeasuredA = MeasuredA; + model.FineTuningMeasuredB = MeasuredB; + + return model; + } + + private void JobRunsLogger_JobRunAvailable(object sender, Integration.JobRuns.JobRunAvailableEventArgs e) + { + ActiveLogModel.JobRunGuid = e.JobRun.Guid; + } + + + #endregion + } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index f4a239c98..2a347df3d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -17,6 +17,7 @@ using Tango.Core.ExtensionMethods; using Newtonsoft.Json; using Tango.Settings; using Tango.PPC.Common; +using Tango.PMR.ColorLab; namespace Tango.PPC.Jobs.Models { @@ -375,6 +376,10 @@ namespace Tango.PPC.Jobs.Models } } + public int BestMatchRed { get; set; } + public int BestMatchGreen { get; set; } + public int BestMatchBlue { get; set; } + protected Double _offsetpercent; /// @@ -1405,10 +1410,13 @@ namespace Tango.PPC.Jobs.Models ColorSpaces colorSpace = ColorSpaces.LAB; BrushStop stop = CreateBrushStop(colorSpace); + + ConversionOutput output = null; + try { IsBusy = true; - var output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); + output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); _cyan = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume); _yellow = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume); @@ -1424,7 +1432,11 @@ namespace Tango.PPC.Jobs.Models _l = output.SingleCoordinates.L; _a = output.SingleCoordinates.A; _b = output.SingleCoordinates.B; - } + } + + BestMatchRed = output.SingleCoordinates.Red; + BestMatchGreen = output.SingleCoordinates.Green; + BestMatchBlue = output.SingleCoordinates.Blue; } catch (Exception ex) { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs index 2176b230a..d2ad7e96b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs @@ -20,6 +20,10 @@ namespace Tango.PPC.Jobs.Models #region Properties + public String Guid { get; set; } + + public int ID { get; set; } + protected String _name; public String Name diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs index a4913dbef..bae1df037 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs @@ -12,6 +12,9 @@ namespace Tango.PPC.Jobs.Models { #region Properties + [BsonIgnore] + public String JobRunGuid { get; set; } + private int _trialNumber; public int TrialNumber diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 3e94a42c5..60db14e21 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -515,6 +515,8 @@ namespace Tango.PPC.Jobs.ViewModels var jobModel = new JobModel(ColorSpaces) { Name = Job.Name, + Guid = Job.Guid, + ID = Job.ID, CreationDate = Job.CreationDate, LengthPercentageFactor = Job.LengthPercentageFactor, NumberOfUnits = Job.NumberOfUnits, diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs index 769a9a5c9..1ceb47ebd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs @@ -143,11 +143,11 @@ namespace Tango.PPC.Jobs.ViewModels } else if (e.Job.Designation == BL.Enumerations.JobDesignations.FineTuning) { - NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' fine tuning completed successfully", e.Job.Name), "Tap to approve or repeat.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => - { - NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = e.Job, Intent = JobNavigationIntent.FineTuning }); - NavigationManager.ClearHistoryExcept(); - })); + //NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' fine tuning completed successfully", e.Job.Name), "Tap to approve or repeat.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + //{ + // NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = e.Job, Intent = JobNavigationIntent.FineTuning }); + // NavigationManager.ClearHistoryExcept(); + //})); } else { 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 f699f4a7e..a275d95bb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs @@ -117,6 +117,12 @@ namespace Tango.PPC.Common.Statistics db_JobRuns = db_JobRuns.Where(x => jobRunStatusArr.Contains(x.Status)); } + int[] jobDesignationArr = filters.JobDesignation.Distinct().ToArray(); + if (jobDesignationArr.Length > 0) + { + db_JobRuns = db_JobRuns.Where(x => jobDesignationArr.Contains(x.JobDesignation)); + } + if (!filters.IncludeHeadCleaning) { db_JobRuns = db_JobRuns.Where(x => !x.IsHeadCleaning); @@ -205,7 +211,7 @@ namespace Tango.PPC.Common.Statistics break; case ColorSpaces.LAB: pbs.L = stop.L; - pbs.A = stop.B; + pbs.A = stop.A; pbs.B = stop.B; break; case ColorSpaces.Volume: 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 eda91ab9e..196618f46 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/Filters.cs @@ -16,12 +16,14 @@ namespace Tango.PPC.Shared.Statistics public int MinLength { get; set; } public int MaxLength { get; set; } public List EndStatuses { get; set; } + public List JobDesignation { get; set; } public bool IncludeHeadCleaning { get; set; } public Filters() { RmlGuids = new List(); EndStatuses = new List(); + JobDesignation = new List(); } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs index 999f0dcf8..02e445c09 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs @@ -317,6 +317,14 @@ namespace Tango.BL.DTO get; set; } + /// + /// fine tuning string + /// + public String FineTuningString + { + get; set; + } + /// /// is synchronized /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 614c6f8c6..c6a6ea226 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -13,6 +13,7 @@ using System.Windows.Media.Imaging; using Tango.BL.ActionLogs; using Tango.BL.Builders; using Tango.BL.Enumerations; +using Tango.BL.FineTuning; using Tango.BL.Interfaces; using Tango.BL.ValueObjects; using Tango.Core; @@ -33,7 +34,7 @@ namespace Tango.BL.Entities /// public Job() : base() { - + VectorFineTuningRunModel = new VectorFineTuningRunModel(); } /// @@ -319,6 +320,14 @@ namespace Tango.BL.Entities #endregion + #region Unmapped Fine Tuning + + [NotMapped] + [JsonIgnore] + public VectorFineTuningRunModel VectorFineTuningRunModel { get; set; } + + #endregion + #region Event Handlers /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs b/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs index abfe9d321..4c0092e55 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs @@ -91,6 +91,8 @@ namespace Tango.BL.Entities public event EventHandler CeVersionChanged; + public event EventHandler FineTuningStringChanged; + public event EventHandler IsSynchronizedChanged; protected String _machineguid; @@ -1084,6 +1086,33 @@ namespace Tango.BL.Entities } } + protected String _finetuningstring; + + /// + /// Gets or sets the jobrunbase fine tuning string. + /// + + [Column("FINE_TUNING_STRING")] + + public String FineTuningString + { + get + { + return _finetuningstring; + } + + set + { + if (_finetuningstring != value) + { + _finetuningstring = value; + + OnFineTuningStringChanged(value); + + } + } + } + protected Boolean _issynchronized; /// @@ -1399,6 +1428,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(CeVersion)); } + /// + /// Called when the FineTuningString has changed. + /// + protected virtual void OnFineTuningStringChanged(String finetuningstring) + { + FineTuningStringChanged?.Invoke(this, finetuningstring); + RaisePropertyChanged(nameof(FineTuningString)); + } + /// /// Called when the IsSynchronized has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/FineTuning/VectorFineTuningRunModel.cs b/Software/Visual_Studio/Tango.BL/FineTuning/VectorFineTuningRunModel.cs new file mode 100644 index 000000000..e5666c095 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/FineTuning/VectorFineTuningRunModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.FineTuning +{ + public class VectorFineTuningRunModel + { + public String JobName { get; set; } + public String FineTuningSessionID { get; set; } + public int FineTuningTrialNumber { get; set; } + public double FineTuningTargetL { get; set; } + public double FineTuningTargetA { get; set; } + public double FineTuningTargetB { get; set; } + public double FineTuningSuggestionL { get; set; } + public double FineTuningSuggestionA { get; set; } + public double FineTuningSuggestionB { get; set; } + public double? FineTuningMeasuredL { get; set; } + public double? FineTuningMeasuredA { get; set; } + public double? FineTuningMeasuredB { get; set; } + public bool Approved { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index aaf7d362b..55e6b7efc 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -599,6 +599,7 @@ + @@ -830,7 +831,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs index 5ed87ecd8..1f863e723 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs @@ -54,6 +54,7 @@ namespace Tango.DAL.Remote.DB public string FIRMWARE_VERSION { get; set; } public string CE_VERSION { get; set; } public string PROCESS_PARAMETERS_TABLE_GUID { get; set; } + public string FINE_TUNING_STRING { get; set; } public bool IS_SYNCHRONIZED { 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 f27945995..5d288984b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -789,6 +789,7 @@ + @@ -6401,6 +6402,7 @@ + @@ -9811,6 +9813,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 6d7f9ff14..72ac56ec8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,102 +5,102 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index 40f1d0789..e80b1f652 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -132,6 +133,8 @@ namespace Tango.Integration.JobRuns { using (var db = ObservablesContext.CreateDefault()) { + var colorSpaces = db.ColorSpaces.ToList(); + JobRun run = new JobRun(); run.UserGuid = _job.UserGuid; @@ -154,7 +157,22 @@ namespace Tango.Integration.JobRuns run.LiquidQuantities = e.LiquidQuantities; run.IsGradient = _job.Segments.Any(x => x.BrushStops.Count > 1); run.GradientResolutionCm = MachineOperator.GradientGenerationConfiguration.ResolutionCM; - run.JobString = e.Job.ToJobFileWhenLoaded().ToString(); + + var jobFile = e.Job.ToJobFileWhenLoaded(); + + try + { + if (_job.Designation == JobDesignations.FineTuning) + { + jobFile.Segments.First().BrushStops.First().ColorSpaceGuid = colorSpaces.First(x => x.Code == (int)ColorSpaces.LAB).Guid; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error setting brush stop color space to LAB on fine tuning job run (JobFileString)."); + } + + run.JobString = jobFile.ToString(); run.ApplicationVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(); run.FirmwareVersion = MachineOperator.DeviceInformation?.Version; @@ -208,6 +226,18 @@ namespace Tango.Integration.JobRuns run.FailedMessage = exception.FlattenMessage(); } + if (_job.Designation == JobDesignations.FineTuning) + { + try + { + run.FineTuningString = JsonConvert.SerializeObject(_job.VectorFineTuningRunModel); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error serializing fine tuning model for job run."); + } + } + db.JobRuns.Add(run); e.Job.LastRun = DateTime.UtcNow; @@ -403,7 +433,7 @@ namespace Tango.Integration.JobRuns _startMachineStatus = MachineOperator.MachineStatus?.Clone(); _jobTicket = e.JobHandler.JobTicket; - if (_job.Designation == JobDesignations.FineTuning) return; + //if (_job.Designation == JobDesignations.FineTuning) return; if (e.IsResumed) { diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 75e0e75fc..61a334aad 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -17426,6 +17426,7 @@ Global {90B53209-C60C-4655-B28D-A1B3E1044BA3} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} {F079FB0A-A8ED-4216-B6A5-345756751A04} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} {43ECCD8D-EE54-44EF-A51A-D77E3DF7263F} = {4443B71C-216E-4D4C-8D19-868F50803813} + {CD2513CC-7596-498C-957D-DE6473561A1C} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} {09EE4BC6-F1C6-46DD-B4FE-918377A4EF02} = {CD2513CC-7596-498C-957D-DE6473561A1C} {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} {654BEDA3-16FB-44FF-ADE7-B52E50B02E63} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} @@ -17557,12 +17558,12 @@ Global {7A30B35F-94DC-4A9C-B9D2-CB5CAA735788} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal -- cgit v1.3.1