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-30 20:12:50 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-06-30 20:12:50 +0300
commitd5d9da51c01d7db8374d4bbf1f2416ae6f434347 (patch)
tree88c74060b3941bd18f08720afbfb1b516510a261 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parentbe65c5a249a7d687bf7a71b4a2936c51e9e28c5e (diff)
downloadTango-d5d9da51c01d7db8374d4bbf1f2416ae6f434347.tar.gz
Tango-d5d9da51c01d7db8374d4bbf1f2416ae6f434347.zip
Color calibration. Changes in GUI.
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.cs133
1 files changed, 55 insertions, 78 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 d44ef7a0c..f118ce77a 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
@@ -42,6 +42,14 @@ namespace Tango.MachineStudio.RML.ViewModels
set { _liquidType = value; RaisePropertyChangedAuto(); }
}
+ private BL.Entities.LiquidType _selectedLinearizationliquidType;
+
+ public BL.Entities.LiquidType SelectedLinearizationLiquidType
+ {
+ get { return _selectedLinearizationliquidType; }
+ set { _selectedLinearizationliquidType = value; RaisePropertyChangedAuto(); }
+ }
+
private List<BL.Entities.LiquidType> _liquidTypes;
public List<BL.Entities.LiquidType> LiquidTypes
@@ -89,13 +97,19 @@ namespace Tango.MachineStudio.RML.ViewModels
}
public RelayCommand CreateGraphCommand { get; set; }
+ public RelayCommand CreateLinearizationGraphCommand { get; set; }
-
- public string CalibrationType
+
+ public string CalibrationLiquidTypeName
{
get { return LiquidType == null ?"" : LiquidType.Name; }
}
+ public string LinearizationLiquidTypeName
+ {
+ get { return SelectedLinearizationLiquidType == null ? "" : SelectedLinearizationLiquidType.Name; }
+ }
+
public Plot PlotControl { get; set; }
private IList<DataPoint> _points;
/// <summary>
@@ -156,6 +170,22 @@ namespace Tango.MachineStudio.RML.ViewModels
}
}
+
+ public Plot LinearizationPlotControl { get; set; }
+ private IList<DataPoint> _linearizationPoints;
+ /// <summary>
+ /// Binding to ItemsSource of line chart.
+ /// </summary>
+ public IList<DataPoint> LinearizationPoints
+ {
+ get { return _linearizationPoints; }
+ set
+ {
+ _linearizationPoints = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
#endregion
public ColorCalibrationViewVM(INotificationProvider notification)
@@ -170,6 +200,7 @@ namespace Tango.MachineStudio.RML.ViewModels
Factor = 0;
HasError = false;
CreateGraphCommand = new RelayCommand(CreateGraph);
+ CreateLinearizationGraphCommand = new RelayCommand(CreateLinearizationGraph);
this.Points = new List<DataPoint>();
TargetPoints = new List<DataPoint>();
}
@@ -245,92 +276,38 @@ namespace Tango.MachineStudio.RML.ViewModels
RaisePropertyChanged("CalibrationType");
PlotControl.InvalidatePlot(true);
- //await Task.Factory.StartNew(() =>
- //{
- // DataPoint ? intersectionpoints = FindIntersection(Points.ToArray(), TargetPoints.ToArray());
- // if(intersectionpoints == null)
- // {
- // InvokeUI(() =>
- // {
- // _notification.ShowWarning(LogManager.Log($"No intersect target value with input values", LogCategory.Warning));
- // });
- // }
- //});
-
}
#endregion
+ #region CreateLinearizationGraph
- #region Intersect
-
- public DataPoint? FindIntersection(DataPoint[] line1, DataPoint[] line2)
- {
- for (int i = 0; i < line1.Length; i++)
- {
- int nextI = i;
- nextI++;
- if (nextI == line1.Length) break;
-
- for (int j = 0; j < line2.Length; j++)
- {
- int nextJ = j;
- nextJ++;
- if (nextJ == line2.Length) break;
- DataPoint? d = CheckIntersecting(line1[i], line1[nextI], line2[j], line2[nextJ]);
- return d;
-
- }
- }
- return null;
- }
-
- public DataPoint? CheckIntersecting(DataPoint A, DataPoint B, DataPoint C, DataPoint D)
+ private void CreateLinearizationGraph(object obj)
{
- // Line AB represented as a1x + b1y = c1
- double a1 = B.Y - A.Y;
- double b1 = A.X - B.X;
- double c1 = a1 * (A.X) + b1 * (A.Y);
+ if (_selectedLinearizationliquidType == null)
+ return;
- // Line CD represented as a2x + b2y = c2
- double a2 = D.Y - C.Y;
- double b2 = C.X - D.X;
- double c2 = a2 * (C.X) + b2 * (C.Y);
+ string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_selectedLinearizationliquidType.Type];
- double determinant = a1 * b2 - a2 * b1;
+ ColorLinearizationModel model = new ColorLinearizationModel();
+ string fileName = @"C:\Test\Test Input Lineration.xlsx";
+ model.GetDataFromFile(fileName);
+ //await Task.Factory.StartNew(() =>
+ //{
+ // Factor = GetLiquidFactor();
+ //});
- if (determinant == 0)
- {
- // The lines are parallel. This is simplified
- }
- else
- {
- double x = (b2 * c1 - b1 * c2) / determinant;
- double y = (a1 * c2 - a2 * c1) / determinant;
+ LinearizationPoints.Clear();
+
+ Measurements.ToList().ForEach(x => {
+ LinearizationPoints.Add(new DataPoint(x.Ink, x.L));
+ });
- // check if the point lies on given line segment
- /* To check if "x" is between "a" and "b";
- int m = (a+b)/2;
- if(Math.abs(x-m) <= (Math.abs(a-m)))
- {
- }
- */
- double mx1 = (A.X + B.X) / 2;
- double mx2 = (C.X + D.X) / 2;
- double my1 = (A.Y + B.Y) / 2;
- double my2 = (C.Y + D.Y) / 2;
- if (Math.Abs(x - mx1) <= Math.Abs(A.X - mx1)
- && Math.Abs(x - mx2) <= Math.Abs(C.X - mx2)
- && Math.Abs(y - my1) <= Math.Abs(A.Y - my1)
- && Math.Abs(y - my2) <= Math.Abs(C.Y - my2))
- {
- return new DataPoint(x, y);
- }
-
- }
- return null;
+ RaisePropertyChanged("To");
+ RaisePropertyChanged("From");
+ XStep = (int)(Points.Count / 6);
+ LinearizationPlotControl.InvalidatePlot(true);
}
-
#endregion
-
+
}
}