aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-06-17 19:04:33 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-06-17 19:04:33 +0300
commitdd007b87b400427c02b57983ce3c1cce695bc960 (patch)
treee95ea9c6f2b8ef3f8857ffedc04f8ee5369f60b6 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parent9d1a217a8410e36cb224e7d47f49326c0e92c474 (diff)
downloadTango-dd007b87b400427c02b57983ce3c1cce695bc960.tar.gz
Tango-dd007b87b400427c02b57983ce3c1cce695bc960.zip
Color Calibration. Added calling Native method "GetLiquidFactor".
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.cs61
1 files changed, 40 insertions, 21 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 a6a2b3f7b..24867122e 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
@@ -12,13 +12,14 @@ using Tango.SharedUI;
using OxyPlot;
using OxyPlot.Wpf;
using OxyPlot.Annotations;
-
+using Tango.ColorCalibration;
+using Tango.PMR.ColorLab;
namespace Tango.MachineStudio.RML.ViewModels
{
public class ColorCalibrationViewVM : ExtendedObject
{
-
+ private IColorCalibrator _calibrator;
#region Properties
private Rml _rml;
@@ -28,17 +29,17 @@ namespace Tango.MachineStudio.RML.ViewModels
set { _rml = value; RaisePropertyChangedAuto(); }
}
- private LiquidType _liquidType;
+ private BL.Entities.LiquidType _liquidType;
- public LiquidType LiquidType
+ public BL.Entities.LiquidType LiquidType
{
get { return _liquidType; }
set { _liquidType = value; RaisePropertyChangedAuto(); }
}
- private List<LiquidType> _liquidTypes;
+ private List<BL.Entities.LiquidType> _liquidTypes;
- public List<LiquidType> LiquidTypes
+ public List<BL.Entities.LiquidType> LiquidTypes
{
get { return _liquidTypes; }
set { _liquidTypes = value; }
@@ -154,27 +155,45 @@ namespace Tango.MachineStudio.RML.ViewModels
public void Loading()
{
LiquidType = LiquidTypes.Count > 0 ? LiquidTypes[0] : null;
+ _calibrator = new DefaultColorCalibrator();
+
}
- private void CreateGraph(object obj)
+ 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;
+
+ 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;
+ }
+ catch (Exception ex )
+ {
+ LogManager.Log(ex, "Error occurred while trying to call GetLiquidFactor.");
+ }
+ return 0.0;
+ }
+
+ private async void CreateGraph(object obj)
{
if (_liquidType == null)
return;
LAB lab;
- string color = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type];
- if( ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab))
+ string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type];
+ await Task.Factory.StartNew(() =>
{
- var value = lab.GetType().GetProperty(color)?.GetValue(lab, null);
- Factor = (double)value;
- }
-
-
-
- //call color calibration function
- ////////////////////////
- ///
-
+ Factor = GetLiquidFactor();
+ });
Points.Clear();
TargetPoints.Clear();
@@ -186,8 +205,8 @@ namespace Tango.MachineStudio.RML.ViewModels
Points.Add(new DataPoint(x.Ink, x.L));
TargetPoints.Add(new DataPoint(x.Ink,Factor)); });
- _to = color == "L"? 100 : 128;
- _from = color == "L" ? 0 : -127;
+ _to = labType == "L"? 100 : 128;
+ _from = labType == "L" ? 0 : -127;
RaisePropertyChanged("To");
RaisePropertyChanged("From");