diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-01-09 16:17:15 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-01-09 16:17:15 +0200 |
| commit | b6b16143304b50744e974ddaa9c71c49766be4dc (patch) | |
| tree | d773bd1c50b4241669a07cc6cb2e7f4cf936f86b /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models | |
| parent | 506b18058821a3791b28c0296e54ef3bc5a3391a (diff) | |
| download | Tango-b6b16143304b50744e974ddaa9c71c49766be4dc.tar.gz Tango-b6b16143304b50744e974ddaa9c71c49766be4dc.zip | |
#5821 RML extension - Color calibration window
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models')
3 files changed, 262 insertions, 3 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs new file mode 100644 index 000000000..d6a7212c0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -0,0 +1,205 @@ +using OxyPlot; +using OxyPlot.Wpf; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + + public class CalibrationPlotModel : ExtendedObject + { + #region Properties + + public Plot DataPlotControl { get; set; } + public Plot LinearizationPlotControl { get; set; } + + private string _title; + + public string Title + { + get { return _title; } + set { _title = value; RaisePropertyChangedAuto(); } + } + + private FactorColors _color; + + private IList<DataPoint> _LPoints; + + public IList<DataPoint> LPoints + { + get { return _LPoints; } + set { _LPoints = value; } + } + + private IList<DataPoint> _APoints; + + public IList<DataPoint> APoints + { + get { return _APoints; } + set { _APoints = value; } + } + + private IList<DataPoint> _BPoints; + + public IList<DataPoint> BPoints + { + get { return _BPoints; } + set { _BPoints = value; } + } + + private IList<DataPoint> _points; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> LinearizationPoints + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _minY; + /// <summary> + /// From use to binding to left axis min value + /// </summary> + public double MinY + { + get { return _minY; } + set + { + _minY = value; RaisePropertyChangedAuto(); + } + } + + private double _maxY; + /// <summary> + /// To use to binding to left axis max value + /// </summary> + public double MaxY + { + get { return _maxY; } + set + { + _maxY = value; RaisePropertyChangedAuto(); + } + } + private int _maxX; + /// <summary> + /// Gets or sets the maximum lab plot X values for LinearizationGraph left part + /// </summary> + public int MaxX + { + get { return _maxX; } + set + { + _maxX = value; + RaisePropertyChangedAuto(); + } + } + + private double _linearizationMaxX; + + public double LinearizationMaxX + { + get { return _linearizationMaxX; } + set + { + _linearizationMaxX = value; + RaisePropertyChangedAuto(); + } + } + + private double _linearizationMaxY; + + public double LinearizationMaxY + { + get { return _linearizationMaxY; } + set + { + _linearizationMaxY = value; + RaisePropertyChangedAuto(); + } + } + #endregion + + public CalibrationPlotModel(FactorColors color, string title) + { + LinearizationPoints = new List<DataPoint>(); + LPoints = new List<DataPoint>(); + APoints = new List<DataPoint>(); + BPoints = new List<DataPoint>(); + _color = color; + _title = title; + + } + public void ClearResults() + { + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LinearizationPoints.Clear(); + } + + public void InitDataGraph(List<ColorLinearizationModel.LinearizationDataItem> items) + { + if (DataPlotControl == null) + { + Debug.WriteLine("ERROR!!! CreateGraph. Plot Control is NULL."); + return; + } + + if (items == null || items.Count == 0) + return; + + ClearResults(); + DataPlotControl.InvalidatePlot(true); + LinearizationPlotControl.InvalidatePlot(true); + + foreach (var labItem in items) + { + LPoints.Add(new DataPoint(labItem.InkPercentage, labItem.L)); + APoints.Add(new DataPoint(labItem.InkPercentage, labItem.A)); + BPoints.Add(new DataPoint(labItem.InkPercentage, labItem.B)); + } + int maxValue = (int)(items.Max(x => x.InkPercentage)); + MaxX = Math.Max(100, maxValue); + + MinY = Math.Min(0, items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B)))); + MaxY = Math.Max( 100, items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B)))); + + DataPlotControl.InvalidatePlot(true); + } + + public void InitLinearizationGraph(List<ColorLinearizationModel.LinearizationDataItem> items, List<double> outputPoints) + { + + if (outputPoints == null) + return; + + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); + } + + LinearizationMaxX = Math.Max(100, LinearizationPoints.Max(x => x.X)); + LinearizationMaxY = Math.Max(100, LinearizationPoints.Max(x => x.Y)); + + LinearizationPlotControl.InvalidatePlot(true); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs new file mode 100644 index 000000000..39774f7d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorLinearizationModel + { + public class LinearizationDataItem + { + public double InkPercentage { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + } + + public ColorLinearizationModel() + { + + } + + public void GetDataFromFile(string fileName, out List<LinearizationDataItem> items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex<LinearizationDataItem>("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs index e41a6a220..c2b00fe92 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.Core; namespace Tango.MachineStudio.ThreadExtensions.Models @@ -10,14 +11,14 @@ namespace Tango.MachineStudio.ThreadExtensions.Models public class MachineModel : ExtendedObject { public String Guid { get; set; } - + public string Name { get; set; } protected String _serialnumber; - + public String SerialNumber { - get{ return _serialnumber; } + get { return _serialnumber; } set { _serialnumber = value; @@ -35,6 +36,16 @@ namespace Tango.MachineStudio.ThreadExtensions.Models } } + protected IEnumerable<IdsPack> _idspacks; + public IEnumerable<IdsPack> IdsPacks + { + get { return _idspacks; } + set + { + _idspacks = value; + } + } + public MachineModel() { HasRMLTest = false; |
