diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-06-22 15:31:41 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-06-22 15:31:41 +0300 |
| commit | e0485a64c8be34fb596fd02befaebec0091625c4 (patch) | |
| tree | f712180bb03dcd12cce7b58a433c7f53a5ecc4c6 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels | |
| parent | 69a5fa82c4633e1c9afa3e0164ff215a8d54c1ed (diff) | |
| download | Tango-e0485a64c8be34fb596fd02befaebec0091625c4.tar.gz Tango-e0485a64c8be34fb596fd02befaebec0091625c4.zip | |
Color calibration. Added warning text and Factor to show in GUI.
Related Work Items: #2957
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(); |
