diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-09-07 09:36:58 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-09-07 09:36:58 +0300 |
| commit | 32594b7cff47dca3205bb35876085501a48b30ab (patch) | |
| tree | 8a431fd571ad2ac5a6c05118f16c299be7a80b41 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels | |
| parent | 424cc484e1b37b40d112b3412416d485e7e63b89 (diff) | |
| parent | 281bd2c6b8faf50f11d1aac3f5d61677f007ad3d (diff) | |
| download | Tango-32594b7cff47dca3205bb35876085501a48b30ab.tar.gz Tango-32594b7cff47dca3205bb35876085501a48b30ab.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs index 31d89005e..8daa1b085 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs @@ -253,6 +253,15 @@ namespace Tango.MachineStudio.RML.ViewModels } + public void ClearResults() + { + Points.Clear(); + TargetPoints.Clear(); + ErrorMessage = ""; + HasError = false; + Factor = 0.0; + } + private double GetLiquidFactor() { try @@ -295,11 +304,17 @@ namespace Tango.MachineStudio.RML.ViewModels dlg.Filter = "Excel Files|*.xlsx"; if (dlg.ShowDialog().Value) { + ClearResults(); + List<ColorLinearizationModel.LinearizationDataItem> items;//List<LinearizationDataItem> items ColorLinearizationModel model = new ColorLinearizationModel(); - model.GetDataFromFile(dlg.FileName, out items); - if (items == null || items.Count == 0) + string error = ""; + model.GetDataFromFile(dlg.FileName, out items, ref error); + if (false == String.IsNullOrEmpty(error) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); return; + } Measurements.Clear(); items.ForEach(x => Measurements.Add(new CalibrationMeasurementModel(x))); } @@ -316,7 +331,7 @@ namespace Tango.MachineStudio.RML.ViewModels { if (_liquidType == null) return; - + ClearResults(); string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; await Task.Factory.StartNew(() => { @@ -324,8 +339,6 @@ namespace Tango.MachineStudio.RML.ViewModels }); DataPoint targetPoint = GetTargetPoint(); - Points.Clear(); - TargetPoints.Clear(); To = 0; From = 0; @@ -387,23 +400,30 @@ namespace Tango.MachineStudio.RML.ViewModels if (fileName == null) return; + LinearizationPoints.Clear(); + LinearizationPlotControl.InvalidatePlot(true); + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LabMinVal = LabMaxVal = 0; + LABLinearizationPlotControl.InvalidatePlot(true); + List<ColorLinearizationModel.LinearizationDataItem> items; - model.GetDataFromFile(fileName, out items); - if (items == null || items.Count == 0) + string errors = ""; + model.GetDataFromFile(fileName, out items, ref errors); + if(false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); return; + } - List<double> outputPoints = new List<double>(); + List<double> outputPoints = new List<double>(); + await Task.Factory.StartNew(() => { outputPoints = GetLinearizationMeasurements(items); }); - LinearizationPoints.Clear(); - LPoints.Clear(); - APoints.Clear(); - BPoints.Clear(); - LabMinVal = LabMaxVal = 0; - LabMinVal = items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B))); LabMaxVal = items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B))); foreach (var labItem in items) @@ -450,6 +470,17 @@ namespace Tango.MachineStudio.RML.ViewModels items.ForEach(x => linearizationInput.Measurements.Add(new LinearizationMeasurement { L = x.L, A = x.A, B = x.B, InkPercentage = x.InkPercentage })); linearizationInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; + LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); + + if(!String.IsNullOrEmpty(result.ErrorMessage)) + { + LogManager.Log(result.ErrorMessage, "GetLinearizationMeasurements returns error." + result.ErrorMessage); + InvokeUI(() => + { + _notification.ShowError("Linearization failed. " + result.ErrorMessage); + }); + } + LAB lab; if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) { @@ -457,12 +488,6 @@ namespace Tango.MachineStudio.RML.ViewModels linearizationInput.TargetA = lab.A; linearizationInput.TargetB = lab.B; } - LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); - - if(!String.IsNullOrEmpty(result.ErrorMessage)) - { - //LogManager.Log(result.ErrorMessage, "Error occurred while trying to call GetLinearizationMeasurements."); - } return result.InkPercentage.ToList(); } catch (Exception ex) |
