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-09-06 14:38:46 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-09-06 14:38:46 +0300
commit92b1cd2bd7f4f42d7613ba424ef568a3a476bd89 (patch)
treea9364f5316d6470067136cca74596878e2e7e53f /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parent751ec679b65431ab3ce13f1c5c58cb0891b2fdbe (diff)
downloadTango-92b1cd2bd7f4f42d7613ba424ef568a3a476bd89.tar.gz
Tango-92b1cd2bd7f4f42d7613ba424ef568a3a476bd89.zip
Color Calibration. Added Error notification to Linearization process. Clear graphs on start new process. Memory testing C++ code in debug.
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.cs65
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)