aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs65
2 files changed, 47 insertions, 22 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs
index f82c04bbc..23179b3f2 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs
@@ -23,7 +23,7 @@ namespace Tango.MachineStudio.RML.Models
}
- public void GetDataFromFile(string fileName, out List<LinearizationDataItem> items)
+ public void GetDataFromFile(string fileName, out List<LinearizationDataItem> items, ref string errors)
{
items = null;
try
@@ -35,7 +35,7 @@ namespace Tango.MachineStudio.RML.Models
}
catch (Exception ex)
{
- Console.WriteLine($" Error in GetDataFromFile {fileName} exception: {ex.Message}" + Environment.NewLine);
+ errors = ex.Message;
}
}
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)