diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-06-25 00:11:09 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-06-25 00:11:09 +0300 |
| commit | a05ceb824d4f8a43601006ed7ec451a78dfacd8c (patch) | |
| tree | 7dab2523cac02a5802b9ac2faa09e4c969ed70be /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels | |
| parent | 74c4f1009d3eeeab61e98c4adcea0286988fc00e (diff) | |
| parent | af3bb827a435ba4b42652b52e4723bf0b3567c97 (diff) | |
| download | Tango-a05ceb824d4f8a43601006ed7ec451a78dfacd8c.tar.gz Tango-a05ceb824d4f8a43601006ed7ec451a78dfacd8c.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 | 57 |
1 files changed, 40 insertions, 17 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 dd0c66c58..d44ef7a0c 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 @@ -16,6 +16,7 @@ using Tango.ColorCalibration; using Tango.PMR.ColorLab; using Tango.Logging; using Tango.MachineStudio.Common.Notifications; +using System.Text.RegularExpressions; namespace Tango.MachineStudio.RML.ViewModels { @@ -69,9 +70,24 @@ namespace Tango.MachineStudio.RML.ViewModels public double Factor { get { return _factor; } - set { _factor = value; } + set { _factor = value; RaisePropertyChangedAuto(); } } + private string _errorMessage; + + public string ErrorMessage + { + get { return _errorMessage; } + set { _errorMessage = value; RaisePropertyChangedAuto(); } + } + private bool _hasError; + + public bool HasError + { + get { return _hasError; } + set { _hasError = value; RaisePropertyChangedAuto(); } + } + public RelayCommand CreateGraphCommand { get; set; } @@ -152,6 +168,7 @@ namespace Tango.MachineStudio.RML.ViewModels new CalibrationMeasurementModel(), }; Factor = 0; + HasError = false; CreateGraphCommand = new RelayCommand(CreateGraph); this.Points = new List<DataPoint>(); TargetPoints = new List<DataPoint>(); @@ -166,24 +183,31 @@ namespace Tango.MachineStudio.RML.ViewModels private double GetLiquidFactor() { - try{ - CalibrationInput conversionInput = new CalibrationInput(); - Measurements.ToList().ForEach(x => conversionInput.Measurements.Add(new CalibrationMeasurement{ L = x.L, A = x.A, B = x.B, NanoliterPerCentimeter = x.Ink })); - conversionInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; - + try + { + CalibrationInput conversionInput = new CalibrationInput(); + Measurements.ToList().ForEach(x => conversionInput.Measurements.Add(new CalibrationMeasurement { L = x.L, A = x.A, B = x.B, NanoliterPerCentimeter = x.Ink })); + conversionInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; - LAB lab; - if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) - { - conversionInput.TargetL = lab.L; - conversionInput.TargetA = lab.A; - conversionInput.TargetB = lab.B; - } - CalibrationOutput result = _calibrator.GetLiquidFactor(conversionInput); - return result.LiquidFactor; + + LAB lab; + if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) + { + conversionInput.TargetL = lab.L; + conversionInput.TargetA = lab.A; + conversionInput.TargetB = lab.B; + } + CalibrationOutput result = _calibrator.GetLiquidFactor(conversionInput); + + ErrorMessage = Regex.Replace(result.ErrorMessage, "[^A-Za-z0-9_., ]+", ""); + + HasError = false == String.IsNullOrEmpty(ErrorMessage); + return result.LiquidFactor; } catch (Exception ex ) { + HasError = true; + ErrorMessage = "Error occurred while trying to call GetLiquidFactor."; LogManager.Log(ex, "Error occurred while trying to call GetLiquidFactor."); } return 0.0; @@ -196,11 +220,10 @@ namespace Tango.MachineStudio.RML.ViewModels if (_liquidType == null) return; - LAB lab; string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; await Task.Factory.StartNew(() => { - Factor = GetLiquidFactor(); + Factor = GetLiquidFactor( ); }); Points.Clear(); |
