From b6b16143304b50744e974ddaa9c71c49766be4dc Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 9 Jan 2022 16:17:15 +0200 Subject: #5821 RML extension - Color calibration window --- .../Models/CalibrationPlotModel.cs | 205 +++++++++ .../Models/ColorLinearizationModel.cs | 43 ++ .../Models/MachineModel.cs | 17 +- .../Tango.MachineStudio.ThreadExtensions.csproj | 24 ++ .../ViewModels/CalibrationDataVM.cs | 138 ++++++ .../ViewModels/ColorCalibrationTabVM.cs | 323 ++++++++++++++ .../ViewModels/ColorCalibrationViewVM.cs | 467 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 73 ++-- .../Views/ColorCalibrationView.xaml | 349 +++++++++++++++ .../Views/ColorCalibrationView.xaml.cs | 77 ++++ .../Views/MachineTestResultsView.xaml | 3 + 11 files changed, 1691 insertions(+), 28 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') 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 _LPoints; + + public IList LPoints + { + get { return _LPoints; } + set { _LPoints = value; } + } + + private IList _APoints; + + public IList APoints + { + get { return _APoints; } + set { _APoints = value; } + } + + private IList _BPoints; + + public IList BPoints + { + get { return _BPoints; } + set { _BPoints = value; } + } + + private IList _points; + /// + /// Binding to ItemsSource of line chart. + /// + public IList LinearizationPoints + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _minY; + /// + /// From use to binding to left axis min value + /// + public double MinY + { + get { return _minY; } + set + { + _minY = value; RaisePropertyChangedAuto(); + } + } + + private double _maxY; + /// + /// To use to binding to left axis max value + /// + public double MaxY + { + get { return _maxY; } + set + { + _maxY = value; RaisePropertyChangedAuto(); + } + } + private int _maxX; + /// + /// Gets or sets the maximum lab plot X values for LinearizationGraph left part + /// + 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(); + LPoints = new List(); + APoints = new List(); + BPoints = new List(); + _color = color; + _title = title; + + } + public void ClearResults() + { + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LinearizationPoints.Clear(); + } + + public void InitDataGraph(List 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 items, List 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 items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex("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 _idspacks; + public IEnumerable IdsPacks + { + get { return _idspacks; } + set + { + _idspacks = value; + } + } + public MachineModel() { HasRMLTest = false; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 9ea43ad0b..4af5d899b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -97,6 +97,8 @@ + + @@ -105,6 +107,9 @@ + + + @@ -112,6 +117,9 @@ AddItemDialog.xaml + + ColorCalibrationView.xaml + ColorParametersView.xaml @@ -145,6 +153,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -208,6 +220,10 @@ + + {37E4CEAB-B54B-451F-B535-04CF7DA9C459} + ColorMine + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -216,6 +232,10 @@ {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL + + {b60c695c-61e8-4091-b506-4c45349c04aa} + Tango.ColorCalibration + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -228,6 +248,10 @@ {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs new file mode 100644 index 000000000..b8fab210c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core; +using Tango.PMR.ColorLab; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class CalibrationDataPointVM : ExtendedObject + { + private double _x; + + public double X + { + get { return _x; } + set { _x = value; RaisePropertyChangedAuto(); } + } + + private double _y; + + public double Y + { + get { return _y; } + set { _y = value; RaisePropertyChangedAuto(); } + } + + private int _index; + + public int Index + { + get { return _index; } + set { _index = value; RaisePropertyChangedAuto(); } + } + + + public CalibrationDataPointVM() + { + + } + + public CalibrationDataPointVM(double x, double y) + { + X = x; + Y = y; + } + + public CalibrationDataPointVM(CalibrationPoint calibrationPoint) : this(calibrationPoint.X, calibrationPoint.Y) + { + + } + + public CalibrationPoint ToPMR() + { + return new CalibrationPoint() + { + X = X, + Y = Y, + }; + } + } + + public class CalibrationDataVM : ExtendedObject + { + private BL.Entities.LiquidType _liquidType; + + public BL.Entities.LiquidType LiquidType + { + get { return _liquidType; } + set { _liquidType = value; RaisePropertyChangedAuto(); } + } + + private IdsPack _idsPack; + + public IdsPack IdsPack + { + get { return _idsPack; } + set { _idsPack = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _calibrationPoints; + + public ObservableCollection CalibrationPoints + { + get { return _calibrationPoints; } + set { _calibrationPoints = value; RaisePropertyChangedAuto(); OnCalibrationPointsChanged(); } + } + + private void OnCalibrationPointsChanged() + { + if (CalibrationPoints != null) + { + CalibrationPoints.CollectionChanged -= CalibrationPoints_CollectionChanged; + CalibrationPoints.CollectionChanged += CalibrationPoints_CollectionChanged; + + SetIndices(); + } + } + + private void CalibrationPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + SetIndices(); + } + + private void SetIndices() + { + if (CalibrationPoints != null) + { + int index = 1; + foreach (var p in CalibrationPoints) + { + p.Index = index++; + } + } + } + + private CalibrationDataVM() + { + CalibrationPoints = new ObservableCollection(); + } + + public CalibrationDataVM(IdsPack pack) : this() + { + IdsPack = pack; + LiquidType = pack.LiquidType; + } + + public CalibrationDataVM(BL.Entities.LiquidType liquidType) : this() + { + LiquidType = liquidType; + CalibrationPoints = new ObservableCollection(); + //CalibrationPoints.Add(new CalibrationDataPointVM() { Index = 1, X = 2, Y = 22 }); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs new file mode 100644 index 000000000..103052b52 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -0,0 +1,323 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.MachineStudio.Common.Notifications; +using Tango.PMR.ColorLab; +using Tango.ColorCalibration; +using Tango.BL.ActionLogs; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorCalibrationTabVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + private ILinearizationMeasurements _linearizationMeasurementscalibrator; + + #region Properties + + private string _name; + /// + /// Gets or sets the name of the thread. Using in print + /// + public string Name + { + get { return _name; } + set + { + _name = value; + RaisePropertyChangedAuto(); + } + } + + private int _tabIndex; + + public int TabIndex + { + get { return _tabIndex; } + set { _tabIndex = value; } + } + + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private CalibrationPlotModel _cyanPlot; + + public CalibrationPlotModel CyanPlot + { + get { return _cyanPlot; } + set + { + _cyanPlot = value; + RaisePropertyChangedAuto(); + } + } + + private CalibrationPlotModel _magentaPlot; + + public CalibrationPlotModel MagentaPlot + { + get { return _magentaPlot; } + set { _magentaPlot = value; } + } + + private CalibrationPlotModel _yellowPlot; + + public CalibrationPlotModel YellowPlot + { + get { return _yellowPlot; } + set { _yellowPlot = value; } + } + + private CalibrationPlotModel _blackPlot; + + public CalibrationPlotModel BlackPlot + { + get { return _blackPlot; } + set { _blackPlot = value; } + } + + private CalibrationDataVM _cyanCalibrationData; + + public CalibrationDataVM CyanCalibrationData + { + get { return _cyanCalibrationData; } + set { _cyanCalibrationData = value; } + } + + private CalibrationDataVM _magentaCalibrationData; + + public CalibrationDataVM MagentaCalibrationData + { + get { return _magentaCalibrationData; } + set { _magentaCalibrationData = value; } + } + + private CalibrationDataVM _yellowCalibrationData; + + public CalibrationDataVM YellowCalibrationData + { + get { return _yellowCalibrationData; } + set { _yellowCalibrationData = value; } + } + + private CalibrationDataVM _blackCalibrationData; + + public CalibrationDataVM BlackCalibrationData + { + get { return _blackCalibrationData; } + set { _blackCalibrationData = value; RaisePropertyChangedAuto(); } + } + + + #endregion + + #region Commands + + public RelayCommand ImportCyanDataCommand { get; set; } + public RelayCommand ImportMagentaDataCommand { get; set; } + public RelayCommand ImportYellowDataCommand { get; set; } + public RelayCommand ImportBlackDataCommand { get; set; } + + #endregion + + public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + _linearizationMeasurementscalibrator = new DefaultColorCalibrator(); + + CyanPlot = new CalibrationPlotModel(FactorColors.CYAN, "Cyan"); + YellowPlot = new CalibrationPlotModel(FactorColors.YELLOW, "Yellow"); + MagentaPlot = new CalibrationPlotModel(FactorColors.MAGENTA, "Magenta"); + BlackPlot = new CalibrationPlotModel(FactorColors.BLACK, "Black"); + + CyanCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Cyan }); + MagentaCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Magenta }); + YellowCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Yellow }); + BlackCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Black }); + + ImportCyanDataCommand = new RelayCommand(ImportCyanData); + ImportMagentaDataCommand = new RelayCommand(ImportMagentaData); + ImportYellowDataCommand = new RelayCommand(ImportYellowData); + ImportBlackDataCommand = new RelayCommand(ImportBlackData); + } + + #region Methods + private async void ImportCyanData(object obj) + { + + List items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + CyanPlot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Cyan); + }); + + CyanPlot.InitLinearizationGraph(items, outputPoints); + CyanCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + CyanCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + } + + } + + private async void ImportMagentaData(object obj) + { + + List items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + MagentaPlot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Magenta); + }); + + MagentaPlot.InitLinearizationGraph(items, outputPoints); + MagentaCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + MagentaCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2}); + } + } + } + + private async void ImportYellowData(object obj) + { + + List items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + YellowPlot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Yellow); + }); + YellowPlot.InitLinearizationGraph(items, outputPoints); + YellowCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + YellowCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + } + } + + + private async void ImportBlackData(object obj) + { + + List items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + BlackPlot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Black); + }); + BlackPlot.InitLinearizationGraph(items, outputPoints); + BlackCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + BlackCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + } + + } + + /// + /// Open file dialog and get name of file + /// + /// + private bool ImportDataFromFile(out List items) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "Excel |*.xlsx"; + items = null; + if (dlg.ShowDialogCenter() && dlg.FileName.IsNotNullOrEmpty()) + { + ColorLinearizationModel model = new ColorLinearizationModel(); + string errors = ""; + model.GetDataFromFile(dlg.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 false; + } + return true; + } + + return false; + } + + #endregion + + #region CreateLinearizationGraph + + private List GetLinearizationMeasurements(List items, PMR.ColorLab.LiquidType liquidType) + { + try + { + LinearizationInput linearizationInput = new LinearizationInput(); + items.ForEach(x => linearizationInput.Measurements.Add(new LinearizationMeasurement { L = x.L, A = x.A, B = x.B, InkPercentage = x.InkPercentage })); + linearizationInput.LiquidType = liquidType; + + LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); + + if (!String.IsNullOrEmpty(result.ErrorMessage)) + { + LogManager.Log(result.ErrorMessage, "GetLinearizationMeasurements returns error." + result.ErrorMessage); + InvokeUI(() => + { + _notification.ShowError("Linearizion process failed. " + result.ErrorMessage); + }); + } + + return result.InkPercentage.ToList(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred while trying to call GetLinearizationMeasurements."); + } + return null; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs new file mode 100644 index 000000000..99bb896d7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -0,0 +1,467 @@ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; +using Tango.AutoComplete.Editors; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.Logging; +using Tango.BL.Enumerations; +using Tango.PMR.ColorLab; +using Tango.BL.Calibration; + + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorCalibrationViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + + public event EventHandler SaveColorCalibration; + + + #region Properties + + private ObservableCollection _calibrationTabs; + + public ObservableCollection CalibrationTabs + { + get { return _calibrationTabs; } + set { _calibrationTabs = value; } + } + + private ColorCalibrationTabVM _selectedTab; + + public ColorCalibrationTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in _calibrationTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtemtionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + private Rml _activeRML; + public Rml ActiveRML + { + get { return _activeRML; } + set + { + _activeRML = value; + RaisePropertyChangedAuto(); + } + } + + private MachineModel _machine; + public MachineModel Machine + { + get { return _machine; } + set { _machine = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + + + private bool _isViewLoaded; + /// + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + + #endregion + + #region commands + public RelayCommand CreateColorDataImportExcelTemplateCommand { get; set; } + public RelayCommand ApplyToRMLCommand { get; set; } + public RelayCommand ApplyToMachineCalibrationCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand AddTabCommand { get; set; } + + public RelayCommand RemoveTabCommand { get; set; } + + public RelayCommand RenameTabCommand { get; set; } + + #endregion + + public ColorCalibrationViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + CalibrationTabs = new ObservableCollection(); + + ApplyToRMLCommand = new RelayCommand(ApplyToRML); + ApplyToMachineCalibrationCommand = new RelayCommand(ApplyToMachineCalibration); + SaveCommand = new RelayCommand(Save, () => IsFree); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); + } + + + + #region Methods + + private void OnRMLExtensionGUIDChanged() + { + } + + private void SelectedMachineChanged() + { + LoadColorCalibrations(); + } + + private void CreateColorDataImportExcelTemplate() + { + SaveFileDialog dlg = new SaveFileDialog(); + try + { + dlg.Title = $"Create excel template file"; + dlg.Filter = "Excel Files|*.xlsx"; + dlg.DefaultExt = ".xlsx"; + dlg.FileName = "Color Data File Template"; + if (dlg.ShowDialog().Value) + { + CalibrationHelper.CreateColorDataInputExcelTemplate(dlg.FileName); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating excel calibration template file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to generate the calibration file."); + } + } + /// + /// Applies calibration points to RML. + /// + private void ApplyToRML(object obj) + { + if(SelectedTab != null && ActiveRML != null) + { + var liquidTypesRmls = ActiveRML.LiquidTypesRmls; + var calibrationDataVM = SelectedTab.CyanCalibrationData; + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Cyan, SelectedTab.CyanCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Magenta, SelectedTab.MagentaCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Yellow, SelectedTab.YellowCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Black, SelectedTab.BlackCalibrationData); + Save(); + } + } + + private void ApplayCalibrationDataToliquidTypesRml(SynchronizedObservableCollection liquidTypesRmls, LiquidTypes type, CalibrationDataVM calibrationDataVM) + { + if (calibrationDataVM.CalibrationPoints.Count == 0) + return; + + var liquidTypeRml = liquidTypesRmls.SingleOrDefault(x => x.LiquidType.Type == type); + CalibrationData calData = new CalibrationData(); + calData.LiquidType = (PMR.ColorLab.LiquidType)liquidTypeRml.LiquidType.Code; + calData.CalibrationPoints.Clear(); + calData.CalibrationPoints.AddRange(calibrationDataVM.CalibrationPoints.Select(x => new CalibrationPoint() { X = x.X, Y = x.Y })); + liquidTypeRml.PutCalibrationData(calData); + } + /// + /// Applies calibration points to machine calibration. + /// + private void ApplyToMachineCalibration(object obj) + { + if (SelectedTab != null) + { + var idsPack = Machine.IdsPacks. + Where(x => ActiveRML.LiquidTypesRmls.ToList().Exists(y => x.LiquidType != null && y.LiquidType.Guid == x.LiquidType.Guid)) + .OrderBy(x => x.PackIndex).ToList(); + + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Cyan, SelectedTab.CyanCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Magenta, SelectedTab.MagentaCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Yellow, SelectedTab.YellowCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Black, SelectedTab.BlackCalibrationData); + Save(); + } + } + + private void ApplayCalibrationDataToToMachineRml(List idsPacks, LiquidTypes type, CalibrationDataVM calibrationDataVM) + { + if (calibrationDataVM.CalibrationPoints.Count == 0) + return; + + var idsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == type); + + if (idsPack != null) + { + var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.MachineGuid == Machine.Guid && x.RmlGuid == ActiveRML.Guid); ; + + if (cat == null) + { + cat = new Cat(); + cat.Name = "untitled"; + _active_context.Cats.Add(cat); + } + + cat.RmlGuid = ActiveRML.Guid; + cat.MachineGuid = Machine.Guid; + cat.LiquidType = idsPack.LiquidType; + + CalibrationData calData = new CalibrationData(); + calData.LiquidType = (PMR.ColorLab.LiquidType)idsPack.LiquidType.Code; + calData.CalibrationPoints.AddRange(calibrationDataVM.CalibrationPoints.Select(x => new CalibrationPoint() { X = x.X, Y = x.Y })); + + cat.PutCalibrationData(calData); + } + } + + #endregion + + #region Loading + + public async void LoadColorCalibrations() + { + if (Machine == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + if (ActiveRML == null) + { + IsFree = false; + return; + } + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + await Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Loading Color Calibrations Tests ...")) + { + } + }); + if (CalibrationTabs.Count == 0) + { + SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); + CalibrationTabs.Add(SelectedTab); + //_active_context.RmlExtensionCalibrationTests.Add(SelectedTab.TestResult); + // await _active_context.SaveChangesAsync(); + } + //LoadColorCalibarions(); + IsFree = true; + } + + public void UpdatePlots() + { + if (IsViewLoaded) + { + //CyanPlot.CreateGraph(CyanProcessData.ToList(), true); + //MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); + //YellowPlot.CreateGraph(YellowProcessData.ToList(), false); + //BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + } + } + + private ColorCalibrationTabVM CreateNewColorCalibrationTabVM(string name, int index) + { + ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager) { Name = name , TabIndex = index}; + + return newtab; + } + + #endregion + + #region Tabs modification + + /// + /// Removes the specified tab. + /// + /// The tab. + private void RemoveTab(ColorCalibrationTabVM tab) + { + if (CalibrationTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + // _active_context.RmlExtensionTestResults.Remove(tab.TestResult); + + CalibrationTabs.Remove(tab); + SelectedTab = CalibrationTabs.LastOrDefault(); + _active_context.SaveChanges(); + } + } + + /// + /// Adds a new tab. + /// + private bool AddNewTab(String name = null) + { + if (CalibrationTabs.Count > 7) + { + //_notification.ShowError("Cannot exceed the maximum number of 8 tabs. You can remove a tab, or create a new project."); + return false; + } + + if (name == null) + { + name = _notification.ShowTextInput("Enter tab name", "Tab Name", "Test"); + } + + if (!String.IsNullOrWhiteSpace(name)) + { + var tab = CreateNewColorCalibrationTabVM(name, (CalibrationTabs.Count + 1)); + CalibrationTabs.Add(tab); + //_active_context.RmlExtensionTestResults.Add(tab.TestResult); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// + /// Renames the tab. + /// + /// The tab. + private void RenameTab() + { + if (SelectedTab != null) + { + var name = _notification.ShowTextInput("Enter tab name", "Tab Name", SelectedTab.Name); + + if (!String.IsNullOrWhiteSpace(name)) + { + SelectedTab.Name = name; + } + } + } + + #endregion + + #region Save + + public async void Save() + { + if (Machine == null) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Calibrations. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + + //SelectedColorProcessParameter.LastUpdated = DateTime.UtcNow; + + //foreach (var item in RemovedColorProcessDataBeforeSave) + //{ + // var existingColorProcessData = await _active_context.ColorProcessData.FirstOrDefaultAsync(y => y.Guid == item); + // if (existingColorProcessData != null) + // { + // _active_context.ColorProcessData.Remove(existingColorProcessData); + // } + //} + //foreach (var colordata in SelectedColorProcessParameter.ColorProcessData) + //{ + // colordata.LastUpdated = DateTime.UtcNow; + //} + //foreach (var factordata in SelectedColorProcessParameter.ColorProcessFactors) + //{ + // factordata.LastUpdated = DateTime.UtcNow; + //} + //foreach (var inkdata in SelectedColorProcessParameter.ColorProcessInkUptake) + //{ + // inkdata.LastUpdated = DateTime.UtcNow; + //} + + await _active_context.SaveChangesAsync(); + + // LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color calibrations."); + _notification.ShowError($"An error occurred while trying to save color calibrations.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorCalibration; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 4802e0af1..e8aafca9d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -257,6 +257,13 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _testResultsViewVM = value; RaisePropertyChangedAuto(); } } + private ColorCalibrationViewVM _colorCalibrationViewVM; + public ColorCalibrationViewVM ColorCalibrationViewVM + { + get { return _colorCalibrationViewVM; } + set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } + } + protected MachineModel _selectedMachine; /// /// Gets or sets the selected machine. @@ -294,20 +301,20 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } - private MachineTestResultsTabs PreviosSelectedTab { get; set; } + //private MachineTestResultsTabs PreviosSelectedTab { get; set; } - private MachineTestResultsTabs _selectedTab; + //private MachineTestResultsTabs _selectedTab; - public MachineTestResultsTabs SelectedTab - { - get { return _selectedTab; } - set { - PreviosSelectedTab = _selectedTab; - _selectedTab = value; - OnSelectedMachineTestResultsTabChanged(); - RaisePropertyChangedAuto(); - } - } + //public MachineTestResultsTabs SelectedTab + //{ + // get { return _selectedTab; } + // set { + // PreviosSelectedTab = _selectedTab; + // _selectedTab = value; + // OnSelectedMachineTestResultsTabChanged(); + // RaisePropertyChangedAuto(); + // } + //} #endregion @@ -922,7 +929,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { Guid = x.Guid, Name = x.Name, - SerialNumber = x.SerialNumber + SerialNumber = x.SerialNumber, + IdsPacks = x.Configuration.IdsPacks.Where(z => !z.IsEmpty) }).ToObservableCollection(); } @@ -994,9 +1002,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels .WithUser() .BuildAsync(); - ActiveRML = new RmlBuilder(_active_context) - .Set(SelectedRMLExtension.RMLGuid) - .Build(); + ActiveRML = new RmlBuilder(_active_context).Set(SelectedRMLExtension.RMLGuid).WithLiquidFactors().Build(); if (!String.IsNullOrEmpty(ActiveRML.Manufacturer) && false == Manufacturers.Any(x => x == ActiveRML.Manufacturer)) { @@ -1040,12 +1046,23 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; + ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, _actionLogManager); + ColorCalibrationViewVM.RMLExtemtionGUID = guid; + ColorCalibrationViewVM.ActiveRML = ActiveRML; + ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; + ColorCalibrationViewVM.Machine = SelectedMachine; + + + + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; ColorParametersVewVM.SaveColorParameters += UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; TestResultsViewVM.SaveTestResults += UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration += UpdateStatus; } View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); @@ -1108,6 +1125,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; ActiveRMLExtension.LastUpdated = DateTime.UtcNow; @@ -1134,6 +1152,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { TestResultsViewVM.SelectedMachineGUID = SelectedMachine.Guid; } + if(ColorCalibrationViewVM != null) + { + ColorCalibrationViewVM.Machine = SelectedMachine; + } } #endregion @@ -1183,10 +1205,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #region selections - private void OnSelectedMachineTestResultsTabChanged() - { - if(SelectedTab == MachineTestResultsTabs.ColorParameters) - { + //private void OnSelectedMachineTestResultsTabChanged() + // { + //if(SelectedTab == MachineTestResultsTabs.ColorParameters) + // { //if(PreviosSelectedTab == MachineTestResultsTabs.TestResults && TestResultsViewVM != null) //{ // TestResultsViewVM.Save(); @@ -1194,15 +1216,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels //save //if (_notification.ShowQuestion("Are you sure you want to exit this page without saving changes?")) - } - else if(SelectedTab == MachineTestResultsTabs.TestResults) - { + // } + // else if(SelectedTab == MachineTestResultsTabs.TestResults) + // { //if (PreviosSelectedTab == MachineTestResultsTabs.ColorParameters && ColorParametersVewVM != null) //{ // ColorParametersVewVM.Save(); //} - } - } + //} + // } #endregion @@ -1304,6 +1326,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels colorParametrsExcelList.Add(colorParametrsExcelModel); TestResultsViewVM.LoadTestResultsExcel(testResultsExcelModelList, machine.Guid, machine.SerialNumber); + //ColorCalibrationViewVM.WritetoExcel } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml new file mode 100644 index 000000000..278d58d02 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LIQUID TYPE CYAN + + + + + + + + + + + + + + + + + + + + + + LIQUID TYPE MAGENTA + + + + + + + + + + + + + + + + + + + + + + LIQUID TYPE YELLOW + + + + + + + + + + + + + + + + + + + + + + LIQUID TYPE BLACK + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs new file mode 100644 index 000000000..06bd67231 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs @@ -0,0 +1,77 @@ +using OxyPlot.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for ColorCalibrationView.xaml + /// + public partial class ColorCalibrationView : UserControl + { + public ColorCalibrationView() + { + InitializeComponent(); + //this.Loaded += ColorCalibrationView_Loaded; + } + + //private void ColorCalibrationView_Loaded(object sender, RoutedEventArgs e) + //{ + // if (contentGrid != null && contentGrid.DataContext is ColorCalibrationViewVM) + // { + // ColorCalibrationViewVM vm = (ColorCalibrationViewVM)contentGrid.DataContext; + // DataTemplate myDataTemplate = cyanChartsContent.ContentTemplate; + + + // vm.CyanPlot.DataPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); + // vm.CyanPlot.LinearizationPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); + // vm.MagentaPlot.DataPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); + // vm.MagentaPlot.LinearizationPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); + // vm.YellowPlot.DataPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); + // vm.YellowPlot.LinearizationPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); + // vm.BlackPlot.DataPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); + // vm.BlackPlot.LinearizationPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); + + // vm.IsViewLoaded = true; + // } + //} + + private void ContentGrid_Loaded(object sender, RoutedEventArgs e) + { + var grid = (UIElement)sender; + if (grid != null && ((UniformGrid)grid).DataContext is ColorCalibrationViewVM) + { + ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((UniformGrid)grid).DataContext; + ColorCalibrationTabVM selectedTab = vm.SelectedTab; + // var Plot = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); + if (selectedTab != null) + { + selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + + vm.IsViewLoaded = true; + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml index bfb8a58d0..b46cb4cf9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml @@ -58,6 +58,9 @@ + + + -- cgit v1.3.1 From 85597e05c8e3d5bd8662e89885b6fec27cbf0fc7 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Thu, 13 Jan 2022 14:40:35 +0200 Subject: #5821 Save all changes in DB and loading data. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Models/CalibrationPlotModel.cs | 24 +- .../Models/ColorLinearizationModel.cs | 1 - .../ViewModels/ColorCalibrationTabVM.cs | 314 ++++++++++++--------- .../ViewModels/ColorCalibrationViewVM.cs | 173 ++++++++---- .../ViewModels/MainViewVM.cs | 5 +- .../Views/ColorCalibrationView.xaml | 2 +- .../Views/ColorCalibrationView.xaml.cs | 68 ++--- .../RMLExtensionColorCalibrationBuilder.cs | 64 +++++ ...ensionColorCalibrationTestsLiquidDataBuilder.cs | 42 +++ .../DTO/RmlExtensionColorCalibrationDTOBase.cs | 4 +- .../Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs | 4 +- .../Entities/RmlExtensionColorCalibrationBase.cs | 42 +-- ...RmlExtensionColorCalibrationsTestsLiquidData.cs | 5 + .../Entities/RmlExtensionColorShadeBase.cs | 42 +-- Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 2 + .../DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs | 2 +- .../DB/RML_EXTENSION_COLOR_SHADES.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 32 +-- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 198 ++++++------- 21 files changed, 625 insertions(+), 401 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index c3b215d87..ef02f27a0 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 165b7e2d5..7bbba7f83 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 index d6a7212c0..0f844097d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -157,18 +157,14 @@ namespace Tango.MachineStudio.ThreadExtensions.Models public void InitDataGraph(List 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); + if (DataPlotControl != null) + DataPlotControl.InvalidatePlot(true); + if (LinearizationPlotControl != null) + LinearizationPlotControl.InvalidatePlot(true); foreach (var labItem in items) { @@ -181,16 +177,17 @@ namespace Tango.MachineStudio.ThreadExtensions.Models 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); + + if (DataPlotControl != null) + DataPlotControl.InvalidatePlot(true); } public void InitLinearizationGraph(List items, List outputPoints) { - if (outputPoints == null) return; + LinearizationPoints.Clear(); foreach (var nw in items.Zip(outputPoints, Tuple.Create)) { LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); @@ -199,7 +196,10 @@ namespace Tango.MachineStudio.ThreadExtensions.Models LinearizationMaxX = Math.Max(100, LinearizationPoints.Max(x => x.X)); LinearizationMaxY = Math.Max(100, LinearizationPoints.Max(x => x.Y)); - LinearizationPlotControl.InvalidatePlot(true); + if (LinearizationPlotControl != null) + { + 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 index 39774f7d8..148f0f416 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs @@ -37,7 +37,6 @@ namespace Tango.MachineStudio.ThreadExtensions.Models { errors = ex.Message; } - } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 103052b52..eed8d41d4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -12,6 +12,8 @@ using Tango.MachineStudio.Common.Notifications; using Tango.PMR.ColorLab; using Tango.ColorCalibration; using Tango.BL.ActionLogs; +using Tango.BL.Entities; +using Tango.Core; namespace Tango.MachineStudio.ThreadExtensions.ViewModels { @@ -20,7 +22,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private INotificationProvider _notification; private IActionLogManager _actionLogManager; private ILinearizationMeasurements _linearizationMeasurementscalibrator; - + private List _liquids; + #region Properties private string _name; @@ -33,6 +36,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _name = value; + if(RmlExtensionColorCalibrationsTest != null) + RmlExtensionColorCalibrationsTest.Name = _name; RaisePropertyChangedAuto(); } } @@ -42,7 +47,9 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels public int TabIndex { get { return _tabIndex; } - set { _tabIndex = value; } + set { _tabIndex = value; + RaisePropertyChangedAuto(); + } } @@ -55,75 +62,43 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _isSelected; } set { _isSelected = value; RaisePropertyChangedAuto(); } } + + public CalibrationPlotModel CyanPlot { get; set; } + + public CalibrationPlotModel MagentaPlot { get; set; } + + public CalibrationPlotModel YellowPlot { get; set; } + + public CalibrationPlotModel BlackPlot { get; set; } + + public CalibrationDataVM CyanCalibrationData { get; set; } + + public CalibrationDataVM MagentaCalibrationData { get; set; } + + public CalibrationDataVM YellowCalibrationData { get; set; } + + public CalibrationDataVM BlackCalibrationData { get; set; } + + private RmlExtensionColorCalibrationsTest _rmlExtensionColorCalibrationsTest; - private CalibrationPlotModel _cyanPlot; - - public CalibrationPlotModel CyanPlot + public RmlExtensionColorCalibrationsTest RmlExtensionColorCalibrationsTest { - get { return _cyanPlot; } - set - { - _cyanPlot = value; - RaisePropertyChangedAuto(); + get { return _rmlExtensionColorCalibrationsTest; } + set { _rmlExtensionColorCalibrationsTest = value; + OnRmlExtensionColorCalibrationsTestChanged(); } } - private CalibrationPlotModel _magentaPlot; - - public CalibrationPlotModel MagentaPlot - { - get { return _magentaPlot; } - set { _magentaPlot = value; } - } - - private CalibrationPlotModel _yellowPlot; - - public CalibrationPlotModel YellowPlot - { - get { return _yellowPlot; } - set { _yellowPlot = value; } - } - - private CalibrationPlotModel _blackPlot; - - public CalibrationPlotModel BlackPlot - { - get { return _blackPlot; } - set { _blackPlot = value; } - } - - private CalibrationDataVM _cyanCalibrationData; - - public CalibrationDataVM CyanCalibrationData - { - get { return _cyanCalibrationData; } - set { _cyanCalibrationData = value; } - } - - private CalibrationDataVM _magentaCalibrationData; - - public CalibrationDataVM MagentaCalibrationData - { - get { return _magentaCalibrationData; } - set { _magentaCalibrationData = value; } - } - - private CalibrationDataVM _yellowCalibrationData; - - public CalibrationDataVM YellowCalibrationData - { - get { return _yellowCalibrationData; } - set { _yellowCalibrationData = value; } - } - - private CalibrationDataVM _blackCalibrationData; - - public CalibrationDataVM BlackCalibrationData - { - get { return _blackCalibrationData; } - set { _blackCalibrationData = value; RaisePropertyChangedAuto(); } - } - + /// + /// Gets or sets last points before save. Used in Save to remove points before save new. + /// + /// + /// The removed points. + /// + public Dictionary> RemovedPoints { get; set; } + + public bool IsTabLoaded { get; set; } + #endregion @@ -136,11 +111,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager, List liquids) { _notification = notification; _actionLogManager = actionLogManager; _linearizationMeasurementscalibrator = new DefaultColorCalibrator(); + _liquids = liquids; + RemovedPoints = new Dictionary>(); + IsTabLoaded = false; CyanPlot = new CalibrationPlotModel(FactorColors.CYAN, "Cyan"); YellowPlot = new CalibrationPlotModel(FactorColors.YELLOW, "Yellow"); @@ -156,105 +134,92 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ImportMagentaDataCommand = new RelayCommand(ImportMagentaData); ImportYellowDataCommand = new RelayCommand(ImportYellowData); ImportBlackDataCommand = new RelayCommand(ImportBlackData); + } #region Methods - private async void ImportCyanData(object obj) + private void ImportCyanData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CyanPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Cyan, CyanPlot, items, CyanCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); + var cyanliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if(cyanliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Cyan); - }); - - CyanPlot.InitLinearizationGraph(items, outputPoints); - CyanCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - CyanCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if(!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) + { + RemovedPoints[LiquidTypes.Cyan] = new List(cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } } - private async void ImportMagentaData(object obj) + private void ImportMagentaData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - MagentaPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Magenta, MagentaPlot, items, MagentaCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); + var magentaliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (magentaliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Magenta); - }); - - MagentaPlot.InitLinearizationGraph(items, outputPoints); - MagentaCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - MagentaCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2}); - } + if (!RemovedPoints.ContainsKey(LiquidTypes.Magenta)) + { + RemovedPoints[LiquidTypes.Magenta] = new List(magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + } } } - private async void ImportYellowData(object obj) + private void ImportYellowData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - YellowPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Yellow, YellowPlot, items, YellowCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); + var yellowliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (yellowliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Yellow); - }); - YellowPlot.InitLinearizationGraph(items, outputPoints); - YellowCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - YellowCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if (!RemovedPoints.ContainsKey(LiquidTypes.Yellow)) + { + RemovedPoints[LiquidTypes.Yellow] = new List(yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } } - - - private async void ImportBlackData(object obj) + + private void ImportBlackData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - BlackPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Black, BlackPlot, items, BlackCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); + var blackliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (blackliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Black); - }); - BlackPlot.InitLinearizationGraph(items, outputPoints); - BlackCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - BlackCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if (!RemovedPoints.ContainsKey(LiquidTypes.Black)) + { + RemovedPoints[LiquidTypes.Black] = new List(blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } @@ -286,6 +251,93 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return false; } + public void InitData() + { + if(RmlExtensionColorCalibrationsTest != null) + { + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + foreach( var liquidData in data) + { + var liquidType = liquidData.LiquidType; + var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); ; + if (points.Count > 0) + { + List items = new List(); + points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); + items.OrderBy(y => y.InkPercentage).ToList(); + CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); + } + } + } + } + + private CalibrationPlotModel GetPlot(BL.Entities.LiquidType liquidType) + { + switch(liquidType.Type) + { + case LiquidTypes.Cyan: + return CyanPlot; + case LiquidTypes.Magenta: + return MagentaPlot; + case LiquidTypes.Yellow: + return YellowPlot; + case LiquidTypes.Black: + return BlackPlot; + default: + return null; + } + } + private CalibrationDataVM GetCalibrationDataVM(BL.Entities.LiquidType liquidType) + { + switch (liquidType.Type) + { + case LiquidTypes.Cyan: + return CyanCalibrationData; + case LiquidTypes.Magenta: + return MagentaCalibrationData; + case LiquidTypes.Yellow: + return YellowCalibrationData; + case LiquidTypes.Black: + return BlackCalibrationData; + default: + return null; + } + } + private PMR.ColorLab.LiquidType ConvertLiquidTypeToPMR(BL.Entities.LiquidType liquidType) + { + if (liquidType.Type == LiquidTypes.Cyan) + return PMR.ColorLab.LiquidType.Cyan; + if (liquidType.Type == LiquidTypes.Yellow) + return PMR.ColorLab.LiquidType.Yellow; + if (liquidType.Type == LiquidTypes.Magenta) + return PMR.ColorLab.LiquidType.Magenta; + return PMR.ColorLab.LiquidType.Black; + } + + private async void CreatePlots(PMR.ColorLab.LiquidType liquidtype, CalibrationPlotModel plot, List items, CalibrationDataVM calibrationTable) + { + plot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, liquidtype); + }); + + plot.InitLinearizationGraph(items, outputPoints); + calibrationTable.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + } + + private void OnRmlExtensionColorCalibrationsTestChanged() + { + + } #endregion #region CreateLinearizationGraph diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs index 99bb896d7..fc15c8caf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -31,6 +31,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private IActionLogManager _actionLogManager; private ObservablesContext _active_context; + private List _liquids; public event EventHandler SaveColorCalibration; @@ -69,7 +70,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private string _RMLExtentionGUID; - public string RMLExtemtionGUID + public string RMLExtentionGUID { get { return _RMLExtentionGUID; } set @@ -130,6 +131,22 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } } + private RmlExtensionColorCalibration _rmlExtensionColorCalibration; + + public RmlExtensionColorCalibration RmlExtensionColorCalibration + { + get { return _rmlExtensionColorCalibration; } + set { _rmlExtensionColorCalibration = value; } + } + + //private ObservableCollection _rmlExtensionColorCalibrationsTests; + + //public ObservableCollection RmlExtensionColorCalibrationsTests + //{ + // get { return _rmlExtensionColorCalibrationsTests; } + // set { _rmlExtensionColorCalibrationsTests = value; } + //} + #endregion @@ -164,9 +181,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); } - - #region Methods private void OnRMLExtensionGUIDChanged() @@ -175,6 +190,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private void SelectedMachineChanged() { + SelectedTab = null; LoadColorCalibrations(); } @@ -293,46 +309,90 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels IsFree = false; return; } - IsFree = false; - if (_active_context != null) + try { - _active_context.Dispose(); - } + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } - _active_context = ObservablesContext.CreateDefault(); + _active_context = ObservablesContext.CreateDefault(); + if (_liquids == null) + { + _liquids = _active_context.LiquidTypes.ToList(); + } + CalibrationTabs.Clear(); + LogManager.Log("Loading color calibration tests ..."); - await Task.Factory.StartNew(() => - { using (_notification.PushTaskItem("Loading Color Calibrations Tests ...")) { + var testResults = await new RMLExtensionColorCalibrationBuilder(_active_context).SetAll().ForRMLExtension(RMLExtentionGUID).ForMachine(Machine.Guid).WithTests().BuildAsync(); + RmlExtensionColorCalibration = testResults.OrderBy(x => x.ID).ToList().FirstOrDefault(); + if (RmlExtensionColorCalibration == null) + { + RmlExtensionColorCalibration = new RmlExtensionColorCalibration() { RmlsExtensionsGuid = RMLExtentionGUID, MachineGuid = Machine.Guid }; + _active_context.RmlExtensionColorCalibrations.Add(RmlExtensionColorCalibration); + _active_context.SaveChanges(); + } + + foreach (var test in RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests) + { + CalibrationTabs.Add(new ColorCalibrationTabVM(_notification, _actionLogManager, _liquids) { RmlExtensionColorCalibrationsTest = test, Name = test.Name }); + if (CalibrationTabs.Count == 1) + SelectedTab = CalibrationTabs[0]; + } + if (CalibrationTabs.Count == 0) + { + SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); + CalibrationTabs.Add(SelectedTab); + _active_context.SaveChanges(); + } + if (IsViewLoaded) + { + CalibrationTabs.ToList().ForEach(x => x.InitData()); + } } - }); - if (CalibrationTabs.Count == 0) + } + catch (Exception ex) { - SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); - CalibrationTabs.Add(SelectedTab); - //_active_context.RmlExtensionCalibrationTests.Add(SelectedTab.TestResult); - // await _active_context.SaveChangesAsync(); + LogManager.Log(ex, $"Error loading Color Calibration tests.\n{ex.FlattenMessage()}"); } - //LoadColorCalibarions(); - IsFree = true; - } - - public void UpdatePlots() - { - if (IsViewLoaded) + finally { - //CyanPlot.CreateGraph(CyanProcessData.ToList(), true); - //MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); - //YellowPlot.CreateGraph(YellowProcessData.ToList(), false); - //BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + IsFree = true; } } - + private ColorCalibrationTabVM CreateNewColorCalibrationTabVM(string name, int index) { - ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager) { Name = name , TabIndex = index}; - + ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager, _liquids) { Name = name, TabIndex = index }; + + newtab.RmlExtensionColorCalibrationsTest = new RmlExtensionColorCalibrationsTest() + { + RmlExtensionColorCalibrationGuid = RMLExtentionGUID, + Name = name + }; + var liquidDataCollection = new SynchronizedObservableCollection(); + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); + var l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid}); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + newtab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData = liquidDataCollection; + if(RmlExtensionColorCalibration != null) + { + RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests.Add(newtab.RmlExtensionColorCalibrationsTest); + // _active_context.RmlExtensionColorCalibrations.Add(RmlExtensionColorCalibration); + } + return newtab; } @@ -350,7 +410,16 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return; if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) { - // _active_context.RmlExtensionTestResults.Remove(tab.TestResult); + foreach( var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + { + + _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints); + } + _active_context.RmlExtensionColorCalibrationsTestsLiquidData.RemoveRange(tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData); + tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData = null; + + RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests.Remove(tab.RmlExtensionColorCalibrationsTest); + _active_context.RmlExtensionColorCalibrationsTests.Remove(tab.RmlExtensionColorCalibrationsTest); CalibrationTabs.Remove(tab); SelectedTab = CalibrationTabs.LastOrDefault(); @@ -377,8 +446,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels if (!String.IsNullOrWhiteSpace(name)) { var tab = CreateNewColorCalibrationTabVM(name, (CalibrationTabs.Count + 1)); + _active_context.SaveChanges(); CalibrationTabs.Add(tab); - //_active_context.RmlExtensionTestResults.Add(tab.TestResult); SelectedTab = tab; return true; } @@ -420,30 +489,24 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels try { IsFree = false; + DateTime lastUpdated = DateTime.UtcNow; + RmlExtensionColorCalibration.LastUpdated = lastUpdated; - //SelectedColorProcessParameter.LastUpdated = DateTime.UtcNow; - - //foreach (var item in RemovedColorProcessDataBeforeSave) - //{ - // var existingColorProcessData = await _active_context.ColorProcessData.FirstOrDefaultAsync(y => y.Guid == item); - // if (existingColorProcessData != null) - // { - // _active_context.ColorProcessData.Remove(existingColorProcessData); - // } - //} - //foreach (var colordata in SelectedColorProcessParameter.ColorProcessData) - //{ - // colordata.LastUpdated = DateTime.UtcNow; - //} - //foreach (var factordata in SelectedColorProcessParameter.ColorProcessFactors) - //{ - // factordata.LastUpdated = DateTime.UtcNow; - //} - //foreach (var inkdata in SelectedColorProcessParameter.ColorProcessInkUptake) - //{ - // inkdata.LastUpdated = DateTime.UtcNow; - //} - + foreach (var tab in CalibrationTabs) + { + tab.RmlExtensionColorCalibrationsTest.LastUpdated = lastUpdated; + var removedPoints = tab.RemovedPoints; + foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + { + var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); + if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) + { + _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); + } + liquidData.LastUpdated = lastUpdated; + } + tab.RemovedPoints.Clear(); + } await _active_context.SaveChangesAsync(); // LoadColorParameters(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index e8aafca9d..1cc6e1dcc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -1047,14 +1047,11 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, _actionLogManager); - ColorCalibrationViewVM.RMLExtemtionGUID = guid; + ColorCalibrationViewVM.RMLExtentionGUID = guid; ColorCalibrationViewVM.ActiveRML = ActiveRML; ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; ColorCalibrationViewVM.Machine = SelectedMachine; - - - if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml index 278d58d02..407ad2e9f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml @@ -175,7 +175,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs index 06bd67231..84219c093 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs @@ -26,30 +26,8 @@ namespace Tango.MachineStudio.ThreadExtensions.Views public ColorCalibrationView() { InitializeComponent(); - //this.Loaded += ColorCalibrationView_Loaded; } - - //private void ColorCalibrationView_Loaded(object sender, RoutedEventArgs e) - //{ - // if (contentGrid != null && contentGrid.DataContext is ColorCalibrationViewVM) - // { - // ColorCalibrationViewVM vm = (ColorCalibrationViewVM)contentGrid.DataContext; - // DataTemplate myDataTemplate = cyanChartsContent.ContentTemplate; - - - // vm.CyanPlot.DataPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.CyanPlot.LinearizationPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.MagentaPlot.DataPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.MagentaPlot.LinearizationPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.YellowPlot.DataPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.YellowPlot.LinearizationPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.BlackPlot.DataPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.BlackPlot.LinearizationPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - - // vm.IsViewLoaded = true; - // } - //} - + private void ContentGrid_Loaded(object sender, RoutedEventArgs e) { var grid = (UIElement)sender; @@ -57,21 +35,43 @@ namespace Tango.MachineStudio.ThreadExtensions.Views { ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((UniformGrid)grid).DataContext; ColorCalibrationTabVM selectedTab = vm.SelectedTab; - // var Plot = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); - if (selectedTab != null) + if (selectedTab != null && !selectedTab.IsTabLoaded) { - selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - + InitPlots(selectedTab); vm.IsViewLoaded = true; } } } + + private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var listBox = (UIElement)sender; + if (listBox != null && ((ListBox)listBox).DataContext is ColorCalibrationViewVM) + { + ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((ListBox)listBox).DataContext; + ColorCalibrationTabVM selectedTab = vm.SelectedTab; + InitPlots(selectedTab); + } + } + + private void InitPlots(ColorCalibrationTabVM selectedTab) + { + if (selectedTab != null && !selectedTab.IsTabLoaded) + { + if (null == (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot")) + return; + selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + + selectedTab.InitData(); + selectedTab.IsTabLoaded = true; + } + } } } diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs new file mode 100644 index 000000000..17a3946b3 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorCalibrationBuilder : EntityCollectionBuilderBase + { + public RMLExtensionColorCalibrationBuilder(ObservablesContext context) : base(context) + { + } + + public virtual RMLExtensionColorCalibrationBuilder ForRMLExtension(String rmlExtensionGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionGUID != null) + { + return query.Where(x => x.RmlsExtensionsGuid == rmlExtensionGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationBuilder ForMachine(String machineGUID) + { + return AddQueryStep(1, (query) => + { + if (machineGUID != null) + { + return query.Where(x => x.MachineGuid == machineGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationBuilder WithTests() + { + return AddStep(2, () => + { + foreach (var result in Entities.ToList()) + { + var testsList = Context.RmlExtensionColorCalibrationsTests.Where(x => x.RmlExtensionColorCalibrationGuid == result.Guid).OrderBy(x => x.ID).ToList(); + foreach (var test in testsList) + { + var b = Context.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.RmlExtensionColorCalibrationsTestGuid == test.Guid).Include(z=>z.LiquidType).Include(y => y.RmlExtensionColorCalibrationsTestsLiquidDataPoints).ToList(); + //RMLExtensionColorCalibrationTestsLiquidDataBuilder builder = new RMLExtensionColorCalibrationTestsLiquidDataBuilder(Context); + //builder.Set(test.Guid); + //var b = builder.ForRmlExtensionColorCalibrationsTest(test.Guid).WithPoints().Build(); + // test.RmlExtensionColorCalibrationsTestsLiquidData.Add(b); + } + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs new file mode 100644 index 000000000..cae435105 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorCalibrationTestsLiquidDataBuilder : EntityBuilderBase + { + public RMLExtensionColorCalibrationTestsLiquidDataBuilder(ObservablesContext context) : base(context) + { + } + protected override IQueryable OnSetQuery(IQueryable query) + { + return query.Include(x => x.LiquidType); + } + public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder ForRmlExtensionColorCalibrationsTest(String rmlExtensionColorCalibrationsTestGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionColorCalibrationsTestGUID != null) + { + return query.Where(x => x.RmlExtensionColorCalibrationsTestGuid == rmlExtensionColorCalibrationsTestGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder WithPoints() + { + return AddStep(1, () => + { + Context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Where(x => x.RmlExtensionColorCalibrationsTestsLiquidDataGuid == Entity.Guid).ToList(); + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs index fab576f25..f2ad42854 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs @@ -22,9 +22,9 @@ namespace Tango.BL.DTO { /// - /// rml extensions guid + /// rmls extensions guid /// - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs index f7fb8344a..50edfca30 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs @@ -22,9 +22,9 @@ namespace Tango.BL.DTO { /// - /// rml extensions guid + /// rmls extensions guid /// - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs index beb87f784..b858163d2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs @@ -29,31 +29,31 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; - public event EventHandler RmlsExtensionChanged; + public event EventHandler RmlsExtensionsChanged; public event EventHandler> RmlExtensionColorCalibrationsTestsChanged; - protected String _rmlextensionsguid; + protected String _rmlsextensionsguid; /// - /// Gets or sets the rmlextensioncolorcalibrationbase rml extensions guid. + /// Gets or sets the rmlextensioncolorcalibrationbase rmls extensions guid. /// - [Column("RML_EXTENSIONS_GUID")] - [ForeignKey("RmlExtensions")] + [Column("RMLS_EXTENSIONS_GUID")] + [ForeignKey("RmlsExtensions")] - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get { - return _rmlextensionsguid; + return _rmlsextensionsguid; } set { - if (_rmlextensionsguid != value) + if (_rmlsextensionsguid != value) { - _rmlextensionsguid = value; + _rmlsextensionsguid = value; } } @@ -117,7 +117,7 @@ namespace Tango.BL.Entities } } - protected RmlsExtension _rmlsextension; + protected RmlsExtension _rmlsextensions; /// /// Gets or sets the rmlextensioncolorcalibrationbase rmls extensions. @@ -125,25 +125,25 @@ namespace Tango.BL.Entities [XmlIgnore] [JsonIgnore] - public virtual RmlsExtension RmlsExtension + public virtual RmlsExtension RmlsExtensions { get { - return _rmlsextension; + return _rmlsextensions; } set { - if (_rmlsextension != value) + if (_rmlsextensions != value) { - _rmlsextension = value; + _rmlsextensions = value; - if (RmlsExtension != null) + if (RmlsExtensions != null) { - RmlExtensionsGuid = RmlsExtension.Guid; + RmlsExtensionsGuid = RmlsExtensions.Guid; } - OnRmlsExtensionChanged(value); + OnRmlsExtensionsChanged(value); } } @@ -184,12 +184,12 @@ namespace Tango.BL.Entities } /// - /// Called when the RmlsExtension has changed. + /// Called when the RmlsExtensions has changed. /// - protected virtual void OnRmlsExtensionChanged(RmlsExtension rmlsextension) + protected virtual void OnRmlsExtensionsChanged(RmlsExtension rmlsextensions) { - RmlsExtensionChanged?.Invoke(this, rmlsextension); - RaisePropertyChanged(nameof(RmlsExtension)); + RmlsExtensionsChanged?.Invoke(this, rmlsextensions); + RaisePropertyChanged(nameof(RmlsExtensions)); } /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs index 9cb724a2b..782a27963 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs @@ -8,9 +8,14 @@ // //------------------------------------------------------------------------------ +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations.Schema; +using Tango.BL.Enumerations; + namespace Tango.BL.Entities { public class RmlExtensionColorCalibrationsTestsLiquidData: RmlExtensionColorCalibrationsTestsLiquidDataBase { + } } \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs index 44e7fe521..b0386f13b 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs @@ -29,31 +29,31 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; - public event EventHandler RmlsExtensionChanged; + public event EventHandler RmlsExtensionsChanged; public event EventHandler> RmlExtensionColorShadesTestsChanged; - protected String _rmlextensionsguid; + protected String _rmlsextensionsguid; /// - /// Gets or sets the rmlextensioncolorshadebase rml extensions guid. + /// Gets or sets the rmlextensioncolorshadebase rmls extensions guid. /// - [Column("RML_EXTENSIONS_GUID")] - [ForeignKey("RmlExtensions")] + [Column("RMLS_EXTENSIONS_GUID")] + [ForeignKey("RmlsExtensions")] - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get { - return _rmlextensionsguid; + return _rmlsextensionsguid; } set { - if (_rmlextensionsguid != value) + if (_rmlsextensionsguid != value) { - _rmlextensionsguid = value; + _rmlsextensionsguid = value; } } @@ -117,7 +117,7 @@ namespace Tango.BL.Entities } } - protected RmlsExtension _rmlsextension; + protected RmlsExtension _rmlsextensions; /// /// Gets or sets the rmlextensioncolorshadebase rmls extensions. @@ -125,25 +125,25 @@ namespace Tango.BL.Entities [XmlIgnore] [JsonIgnore] - public virtual RmlsExtension RmlsExtension + public virtual RmlsExtension RmlsExtensions { get { - return _rmlsextension; + return _rmlsextensions; } set { - if (_rmlsextension != value) + if (_rmlsextensions != value) { - _rmlsextension = value; + _rmlsextensions = value; - if (RmlsExtension != null) + if (RmlsExtensions != null) { - RmlExtensionsGuid = RmlsExtension.Guid; + RmlsExtensionsGuid = RmlsExtensions.Guid; } - OnRmlsExtensionChanged(value); + OnRmlsExtensionsChanged(value); } } @@ -184,12 +184,12 @@ namespace Tango.BL.Entities } /// - /// Called when the RmlsExtension has changed. + /// Called when the RmlsExtensions has changed. /// - protected virtual void OnRmlsExtensionChanged(RmlsExtension rmlsextension) + protected virtual void OnRmlsExtensionsChanged(RmlsExtension rmlsextensions) { - RmlsExtensionChanged?.Invoke(this, rmlsextension); - RaisePropertyChanged(nameof(RmlsExtension)); + RmlsExtensionsChanged?.Invoke(this, rmlsextensions); + RaisePropertyChanged(nameof(RmlsExtensions)); } /// diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 4b6429b87..52dd7f68c 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -116,6 +116,8 @@ + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs index f7aa3a9c4..7f25d41a2 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs @@ -23,7 +23,7 @@ namespace Tango.DAL.Remote.DB public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } - public string RML_EXTENSIONS_GUID { get; set; } + public string RMLS_EXTENSIONS_GUID { get; set; } public string MACHINE_GUID { get; set; } public virtual MACHINE MACHINE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs index c662feb8f..55614d7a4 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs @@ -23,7 +23,7 @@ namespace Tango.DAL.Remote.DB public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } - public string RML_EXTENSIONS_GUID { get; set; } + public string RMLS_EXTENSIONS_GUID { get; set; } public string MACHINE_GUID { get; set; } public virtual MACHINE MACHINE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 17761bf6a..0619a2b9b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1100,7 +1100,7 @@ - + @@ -1143,7 +1143,7 @@ - + @@ -2649,7 +2649,7 @@ - + @@ -2659,7 +2659,7 @@ - + @@ -2743,7 +2743,7 @@ - + @@ -3748,7 +3748,7 @@ - + @@ -4494,7 +4494,7 @@ - + @@ -4727,7 +4727,7 @@ - + @@ -6238,10 +6238,10 @@ - + - + @@ -6290,7 +6290,7 @@ - + @@ -7883,7 +7883,7 @@ - + @@ -7893,7 +7893,7 @@ - + @@ -7949,7 +7949,7 @@ - + @@ -9558,7 +9558,7 @@ - + @@ -9605,7 +9605,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 61920906b..214d6c856 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -4,105 +4,105 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From 4fbbe898fe71837004d0fb0248f3628140cde3f4 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 16 Jan 2022 10:47:44 +0200 Subject: Changes in database - add calculated point --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/ColorCalibrationTabVM.cs | 48 +++-- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../RMLExtensionColorCalibrationBuilder.cs | 4 - ...ensionColorCalibrationTestsLiquidDataBuilder.cs | 42 ----- ...ColorCalibrationsTestsLiquidDataPointDTOBase.cs | 8 + ...ionColorCalibrationsTestsLiquidDataPointBase.cs | 38 ++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 3 +- ..._COLOR_CALIBRATIONS_TESTS_LIQUID_DATA_POINTS.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 196 ++++++++++----------- 14 files changed, 184 insertions(+), 161 deletions(-) delete mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index abf3e1478..a439b4063 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index be99a8e22..8c51f09ac 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index ef02f27a0..0035ae1d8 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 7bbba7f83..5ec2e2d21 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index eed8d41d4..2727b44e5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -154,7 +154,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Cyan] = new List(cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y=> y.X == x.InkPercentage).Select(z=>z.Y ).FirstOrDefault()})); } } @@ -176,7 +176,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Magenta] = new List(magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } @@ -197,7 +197,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Yellow] = new List(yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } @@ -219,7 +219,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Black] = new List(blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } @@ -258,15 +258,23 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; foreach( var liquidData in data) { - var liquidType = liquidData.LiquidType; - var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); ; - if (points.Count > 0) - { - List items = new List(); - points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - items.OrderBy(y => y.InkPercentage).ToList(); - CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); - } + var liquidGUID = liquidData.LiquidTypeGuid; + var liquidType = _liquids.Where(l => l.Guid == liquidGUID).FirstOrDefault(); + + var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); + LoadDataPlots(points, GetPlot(liquidType), GetCalibrationDataVM(liquidType)); + //if (points.Count > 0) + //{ + // List items = new List(); + // points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); + // items.OrderBy(y => y.InkPercentage).ToList(); + // var index = 1; + // List calibrationPoints = new List(); + // points.ForEach(x => calibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); + + + // CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); + //} } } } @@ -333,7 +341,19 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); } } - + + private void LoadDataPlots( List points, CalibrationPlotModel plot, CalibrationDataVM calibrationTable) + { + List items = new List(); + points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); + plot.InitDataGraph(items); + + calibrationTable.CalibrationPoints.Clear(); + var index = 1; + points.ForEach(x => calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); + + } + private void OnRmlExtensionColorCalibrationsTestChanged() { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs index 17a3946b3..041f3c824 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs @@ -52,10 +52,6 @@ namespace Tango.BL.Builders foreach (var test in testsList) { var b = Context.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.RmlExtensionColorCalibrationsTestGuid == test.Guid).Include(z=>z.LiquidType).Include(y => y.RmlExtensionColorCalibrationsTestsLiquidDataPoints).ToList(); - //RMLExtensionColorCalibrationTestsLiquidDataBuilder builder = new RMLExtensionColorCalibrationTestsLiquidDataBuilder(Context); - //builder.Set(test.Guid); - //var b = builder.ForRmlExtensionColorCalibrationsTest(test.Guid).WithPoints().Build(); - // test.RmlExtensionColorCalibrationsTestsLiquidData.Add(b); } } }); diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs deleted file mode 100644 index cae435105..000000000 --- a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using System.Data.Entity; - -namespace Tango.BL.Builders -{ - public class RMLExtensionColorCalibrationTestsLiquidDataBuilder : EntityBuilderBase - { - public RMLExtensionColorCalibrationTestsLiquidDataBuilder(ObservablesContext context) : base(context) - { - } - protected override IQueryable OnSetQuery(IQueryable query) - { - return query.Include(x => x.LiquidType); - } - public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder ForRmlExtensionColorCalibrationsTest(String rmlExtensionColorCalibrationsTestGUID) - { - return AddQueryStep(0, (query) => - { - if (rmlExtensionColorCalibrationsTestGUID != null) - { - return query.Where(x => x.RmlExtensionColorCalibrationsTestGuid == rmlExtensionColorCalibrationsTestGUID); - } - else - { - return query; - } - }); - } - public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder WithPoints() - { - return AddStep(1, () => - { - Context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Where(x => x.RmlExtensionColorCalibrationsTestsLiquidDataGuid == Entity.Guid).ToList(); - }); - } - } -} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationsTestsLiquidDataPointDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationsTestsLiquidDataPointDTOBase.cs index 0b1b45da5..4ad7fa865 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationsTestsLiquidDataPointDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationsTestsLiquidDataPointDTOBase.cs @@ -61,5 +61,13 @@ namespace Tango.BL.DTO get; set; } + /// + /// calculated point + /// + public Double CalculatedPoint + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidDataPointBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidDataPointBase.cs index 26378441c..e1e25e821 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidDataPointBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidDataPointBase.cs @@ -35,6 +35,8 @@ namespace Tango.BL.Entities public event EventHandler BChanged; + public event EventHandler CalculatedPointChanged; + public event EventHandler RmlExtensionColorCalibrationsTestsLiquidDataChanged; protected String _rmlextensioncolorcalibrationstestsliquiddataguid; @@ -171,6 +173,33 @@ namespace Tango.BL.Entities } } + protected Double _calculatedpoint; + + /// + /// Gets or sets the rmlextensioncolorcalibrationstestsliquiddatapointbase calculated point. + /// + + [Column("CALCULATED_POINT")] + + public Double CalculatedPoint + { + get + { + return _calculatedpoint; + } + + set + { + if (_calculatedpoint != value) + { + _calculatedpoint = value; + + OnCalculatedPointChanged(value); + + } + } + } + protected RmlExtensionColorCalibrationsTestsLiquidData _rmlextensioncolorcalibrationstestsliquiddata; /// @@ -239,6 +268,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(B)); } + /// + /// Called when the CalculatedPoint has changed. + /// + protected virtual void OnCalculatedPointChanged(Double calculatedpoint) + { + CalculatedPointChanged?.Invoke(this, calculatedpoint); + RaisePropertyChanged(nameof(CalculatedPoint)); + } + /// /// Called when the RmlExtensionColorCalibrationsTestsLiquidData has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 52dd7f68c..e76aff050 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -117,7 +117,6 @@ - @@ -802,7 +801,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA_POINTS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA_POINTS.cs index 025580c1e..96d70f954 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA_POINTS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA_POINTS.cs @@ -22,6 +22,7 @@ namespace Tango.DAL.Remote.DB public double L { get; set; } public double A { get; set; } public double B { get; set; } + public double CALCULATED_POINT { get; set; } public virtual RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA RML_EXTENSION_COLOR_CALIBRATIONS_TESTS_LIQUID_DATA { get; set; } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 0619a2b9b..ae70f1ed6 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1135,6 +1135,7 @@ + @@ -6281,6 +6282,7 @@ + @@ -9590,6 +9592,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 214d6c856..a72a68e1f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,104 +5,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From 981d893bcdd17e95f94859cb20cf413da6818df4 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 16 Jan 2022 17:42:01 +0200 Subject: loading data from database --- .../Models/CalibrationPlotModel.cs | 4 +- .../ViewModels/ColorCalibrationTabVM.cs | 109 ++++++++++++++------- 2 files changed, 77 insertions(+), 36 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') 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 index 0f844097d..49ca76d14 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -193,8 +193,8 @@ namespace Tango.MachineStudio.ThreadExtensions.Models 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)); + LinearizationMaxX = Math.Max(100, LinearizationPoints.Count > 0? LinearizationPoints.Max(x => x.X) : 0); + LinearizationMaxY = Math.Max(100, LinearizationPoints.Count > 0 ? LinearizationPoints.Max(x => x.Y) : 0); if (LinearizationPlotControl != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 2727b44e5..0a27281ca 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -138,34 +138,60 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #region Methods - private void ImportCyanData(object obj) + private async void ImportCyanData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Cyan, CyanPlot, items, CyanCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Cyan); + }); + UpdatePlots(CyanPlot, items, calibrationPoints); + + CyanCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + CyanCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); var cyanliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); - if(cyanliquidData != null) + if (cyanliquidData != null) { - if(!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) + if (!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) { RemovedPoints[LiquidTypes.Cyan] = new List(cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y=> y.X == x.InkPercentage).Select(z=>z.Y ).FirstOrDefault()})); + items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportMagentaData(object obj) + private async void ImportMagentaData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Magenta, MagentaPlot, items, MagentaCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Magenta); + }); + UpdatePlots(MagentaPlot, items, calibrationPoints); + + MagentaCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + MagentaCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); var magentaliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -176,17 +202,30 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Magenta] = new List(magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = MagentaCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportYellowData(object obj) + private async void ImportYellowData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Yellow, YellowPlot, items, YellowCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Yellow); + }); + UpdatePlots(YellowPlot, items, calibrationPoints); + + YellowCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + YellowCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); var yellowliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -197,18 +236,30 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Yellow] = new List(yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = YellowCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportBlackData(object obj) + private async void ImportBlackData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Black, BlackPlot, items, BlackCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Black); + }); + UpdatePlots(BlackPlot, items, calibrationPoints); + + BlackCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + BlackCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); var blackliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -219,7 +270,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Black] = new List(blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = BlackCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } @@ -322,36 +373,26 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return PMR.ColorLab.LiquidType.Black; } - private async void CreatePlots(PMR.ColorLab.LiquidType liquidtype, CalibrationPlotModel plot, List items, CalibrationDataVM calibrationTable) + private void UpdatePlots( CalibrationPlotModel plot, List items, List calibrationPoints) { plot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => - { - outputPoints = GetLinearizationMeasurements(items, liquidtype); - }); - - plot.InitLinearizationGraph(items, outputPoints); - calibrationTable.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); - } + plot.InitLinearizationGraph(items, calibrationPoints); } private void LoadDataPlots( List points, CalibrationPlotModel plot, CalibrationDataVM calibrationTable) { List items = new List(); points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - plot.InitDataGraph(items); + + List calibrationPoints = new List(); calibrationTable.CalibrationPoints.Clear(); var index = 1; - points.ForEach(x => calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); - + points.ForEach(x => { + calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint }); + calibrationPoints.Add(x.CalculatedPoint); + }); + UpdatePlots(plot, items, calibrationPoints); } private void OnRmlExtensionColorCalibrationsTestChanged() -- cgit v1.3.1 From afdaadac0ddb76b5e905ef5eeda581ade4324f9b Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 19 Jan 2022 16:00:37 +0200 Subject: #5831 RML extension- Color shade window --- .../Models/ColorShadesModel.cs | 42 +++ .../Tango.MachineStudio.ThreadExtensions.csproj | 10 + .../ViewModels/ColorCalibrationTabVM.cs | 12 - .../ViewModels/ColorShadeTabVM.cs | 121 ++++++ .../ViewModels/ColorShadeViewVM.cs | 406 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 22 +- .../Views/ColorShadeView.xaml | 162 ++++++++ .../Views/ColorShadeView.xaml.cs | 28 ++ .../Resources/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Builders/RMLExtensionColorShadeBuilder.cs | 61 ++++ .../Tango.BL/Calibration/CalibrationHelper.cs | 11 + .../Tango.BL/Calibration/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Entities/RmlExtensionColorShadesTestsData.cs | 22 ++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 +- 14 files changed, 887 insertions(+), 14 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs create mode 100644 Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs new file mode 100644 index 000000000..cc4351891 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorShadesModel + { + public class ColorShadesDataItem + { + public double ColorNumber { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + public double C { get; set; } + public double M { get; set; } + public double Y { get; set; } + public double L2 { get; set; } + public double A2 { get; set; } + public double B2 { get; set; } + } + + public void GetDataFromFile(string fileName, out List items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 4af5d899b..065dec29e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -99,6 +99,7 @@ + @@ -111,6 +112,7 @@ + @@ -123,6 +125,10 @@ ColorParametersView.xaml + + ColorShadeView.xaml + + ComboboxEditable.xaml @@ -161,6 +167,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 0a27281ca..a2a119e29 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -314,18 +314,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); LoadDataPlots(points, GetPlot(liquidType), GetCalibrationDataVM(liquidType)); - //if (points.Count > 0) - //{ - // List items = new List(); - // points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - // items.OrderBy(y => y.InkPercentage).ToList(); - // var index = 1; - // List calibrationPoints = new List(); - // points.ForEach(x => calibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); - - - // CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); - //} } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs new file mode 100644 index 000000000..df0ba521c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.MachineStudio.Common.Notifications; +using Tango.BL.ActionLogs; +using Tango.BL.Entities; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeTabVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + #region Properties + + private string _name; + /// + /// Gets or sets the name of the thread. Using in print + /// + public string Name + { + get { return _name; } + set + { + _name = value; + if (RmlExtensionColorShadesTest != null) + RmlExtensionColorShadesTest.Name = _name; + RaisePropertyChangedAuto(); + } + } + + private int _tabIndex; + + public int TabIndex + { + get { return _tabIndex; } + set + { + _tabIndex = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private RmlExtensionColorShadesTest _rmlExtensionColorShadesTest; + + public RmlExtensionColorShadesTest RmlExtensionColorShadesTest + { + get { return _rmlExtensionColorShadesTest; } + set + { + _rmlExtensionColorShadesTest = value; + RaisePropertyChangedAuto(); + } + } + + /// + /// Gets or sets last points before save. Used in Save to remove points before save new. + /// + /// + /// The removed points. + /// + public List RemovedDataList { get; set; } + + #endregion + + RelayCommand ImportColorsCommand { get; set; } + + public ColorShadeTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ImportColorsCommand = new RelayCommand(ImportColors); + } + + private void ImportColors(object obj) + { + List items; + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "Excel |*.xlsx"; + items = null; + if (dlg.ShowDialogCenter() && dlg.FileName.IsNotNullOrEmpty()) + { + ColorShadesModel model = new ColorShadesModel(); + string errors = ""; + model.GetDataFromFile(dlg.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."); + + } + else + { + //Settings data to object + } + + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs new file mode 100644 index 000000000..b1dac5ce9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; +using Tango.AutoComplete.Editors; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.Logging; +using Tango.MachineStudio.ThreadExtensions.ViewModels; +using System.Collections.ObjectModel; +using Tango.BL.Calibration; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + public event EventHandler SaveColorShadesEvent; + + #region Properties + + + private RmlExtensionColorShade _colorShade; + + public RmlExtensionColorShade RmlExtensionColorShade + { + get { return _colorShade; } + set { _colorShade = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection _colorShadeTabs; + + public ObservableCollection ColorShadeTabs + { + get { return _colorShadeTabs; } + set { _colorShadeTabs = value; } + } + + private ColorShadeTabVM _selectedTab; + + public ColorShadeTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in _colorShadeTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtentionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + } + } + + protected string _selectedMachineGuid; + /// + /// Gets or sets the selected machine. + /// + public String SelectedMachineGUID + { + get { return _selectedMachineGuid; } + set + { + if (value != null && _selectedMachineGuid != value) + { + _selectedMachineGuid = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + + private bool _isViewLoaded; + /// + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + #endregion + + #region commands + public RelayCommand CreateColorDataImportExcelTemplateCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand AddTabCommand { get; set; } + + public RelayCommand RemoveTabCommand { get; set; } + + public RelayCommand RenameTabCommand { get; set; } + + #endregion + + public ColorShadeViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ColorShadeTabs = new ObservableCollection(); + + SaveCommand = new RelayCommand(Save, () => IsFree); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); + } + + #region Loading + public async void LoadColorShades() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + if (RMLGUID == null) + { + IsFree = false; + return; + } + try + { + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + ColorShadeTabs.Clear(); + LogManager.Log("Loading color shade view ..."); + using (_notification.PushTaskItem("Loading Color Shade View ...")) + { + var testResults = await new RMLExtensionColorShadeBuilder(_active_context).SetAll().ForRMLExtension(RMLExtentionGUID).ForMachine(SelectedMachineGUID).WithTests().BuildAsync(); + RmlExtensionColorShade = testResults.OrderBy(x => x.ID).ToList().FirstOrDefault(); + if (RmlExtensionColorShade == null) + { + RmlExtensionColorShade = new RmlExtensionColorShade() { RmlsExtensionsGuid = RMLExtentionGUID, MachineGuid = SelectedMachineGUID }; + _active_context.RmlExtensionColorShades.Add(RmlExtensionColorShade); + _active_context.SaveChanges(); + } + + foreach (var test in RmlExtensionColorShade.RmlExtensionColorShadesTests) + { + ColorShadeTabs.Add(new ColorShadeTabVM(_notification, _actionLogManager) { RmlExtensionColorShadesTest = test, Name = test.Name }); + if (ColorShadeTabs.Count == 1) + SelectedTab = ColorShadeTabs[0]; + } + if (ColorShadeTabs.Count == 0) + { + SelectedTab = CreateNewColorShadeTabVM("Untitled", 1); + ColorShadeTabs.Add(SelectedTab); + _active_context.SaveChanges(); + } + if (IsViewLoaded) + { + // ColorShadeTabs.ToList().ForEach(x => x.InitData()); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading Color Calibration tests.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private ColorShadeTabVM CreateNewColorShadeTabVM(string name, int index) + { + ColorShadeTabVM newtab = new ColorShadeTabVM(_notification, _actionLogManager) { Name = name, TabIndex = index }; + + newtab.RmlExtensionColorShadesTest = new RmlExtensionColorShadesTest() + { + RmlExtensionColorShadesGuid = RMLExtentionGUID, + Name = name + }; + if (RmlExtensionColorShade != null) + { + RmlExtensionColorShade.RmlExtensionColorShadesTests.Add(newtab.RmlExtensionColorShadesTest); + } + + return newtab; + } + #endregion + + #region Methods + + private void OnRMLExtensionGUIDChanged() + { + } + + private void SelectedMachineChanged() + { + SelectedTab = null; + LoadColorShades(); + } + + private void CreateColorDataImportExcelTemplate() + { + SaveFileDialog dlg = new SaveFileDialog(); + try + { + dlg.Title = $"Create excel template file"; + dlg.Filter = "Excel Files|*.xlsx"; + dlg.DefaultExt = ".xlsx"; + dlg.FileName = "Color Shades File Template"; + if (dlg.ShowDialog().Value) + { + CalibrationHelper.CreateColorShadesInputExcelTemplate(dlg.FileName); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating excel color shades template file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to generate the color shades file."); + } + } + + #endregion + + #region Tabs modification + + /// + /// Removes the specified tab. + /// + /// The tab. + private void RemoveTab(ColorShadeTabVM tab) + { + if (ColorShadeTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + _active_context.RmlExtensionColorShadesTestsData.RemoveRange(tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.ToList()); + + //_active_context.RmlExtensionColorCalibrationsTestsLiquidData.RemoveRange(tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData); + tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData = null; + + RmlExtensionColorShade.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + _active_context.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + + ColorShadeTabs.Remove(tab); + SelectedTab = ColorShadeTabs.LastOrDefault(); + _active_context.SaveChanges(); + } + } + + /// + /// Adds a new tab. + /// + private bool AddNewTab(String name = null) + { + if (ColorShadeTabs.Count > 7) + { + //_notification.ShowError("Cannot exceed the maximum number of 8 tabs. You can remove a tab, or create a new project."); + return false; + } + + if (name == null) + { + name = _notification.ShowTextInput("Enter tab name", "Tab Name", "Test"); + } + + if (!String.IsNullOrWhiteSpace(name)) + { + var tab = CreateNewColorShadeTabVM(name, (ColorShadeTabs.Count + 1)); + _active_context.SaveChanges(); + ColorShadeTabs.Add(tab); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// + /// Renames the tab. + /// + /// The tab. + private void RenameTab() + { + if (SelectedTab != null) + { + var name = _notification.ShowTextInput("Enter tab name", "Tab Name", SelectedTab.Name); + + if (!String.IsNullOrWhiteSpace(name)) + { + SelectedTab.Name = name; + } + } + } + + #endregion + + #region Save + + public async void Save() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Shades. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + DateTime lastUpdated = DateTime.UtcNow; + RmlExtensionColorShade.LastUpdated = lastUpdated; + + foreach (var tab in ColorShadeTabs) + { + tab.RmlExtensionColorShadesTest.LastUpdated = lastUpdated; + //var removedPoints = tab.RemovedPoints; + //foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + //{ + // var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); + // if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) + // { + // _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); + // } + // liquidData.LastUpdated = lastUpdated; + //} + //tab.RemovedPoints.Clear(); + } + await _active_context.SaveChangesAsync(); + + // LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color shades."); + _notification.ShowError($"An error occurred while trying to save color shades.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorShadesEvent; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 1cc6e1dcc..47965deb4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -264,6 +264,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } } + private ColorShadeViewVM _solorShadeViewVM; + public ColorShadeViewVM ColorShadeViewVM + { + get { return _solorShadeViewVM; } + set { _solorShadeViewVM = value; RaisePropertyChangedAuto(); } + } + + protected MachineModel _selectedMachine; /// /// Gets or sets the selected machine. @@ -1051,7 +1059,12 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorCalibrationViewVM.ActiveRML = ActiveRML; ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; ColorCalibrationViewVM.Machine = SelectedMachine; - + + ColorShadeViewVM = new ColorShadeViewVM(_notification, _actionLogManager); + ColorShadeViewVM.RMLExtentionGUID = guid; + ColorShadeViewVM.RMLGUID = ActiveRML.Guid; + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; ; + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; @@ -1060,6 +1073,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.SaveTestResults += UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration += UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent += UpdateStatus; } View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); @@ -1123,6 +1138,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorParametersVewVM.SaveColorParameters -= UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; ActiveRMLExtension.LastUpdated = DateTime.UtcNow; @@ -1153,6 +1169,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorCalibrationViewVM.Machine = SelectedMachine; } + if(ColorShadeViewVM != null) + { + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine.Guid; + } } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml new file mode 100644 index 000000000..70df4d6bf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs new file mode 100644 index 000000000..2a8079cfe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for ColorShadeView.xaml + /// + public partial class ColorShadeView : UserControl + { + public ColorShadeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs new file mode 100644 index 000000000..0f1894b4a --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorShadeBuilder : EntityCollectionBuilderBase + { + public RMLExtensionColorShadeBuilder(ObservablesContext context) : base(context) + { + } + + public virtual RMLExtensionColorShadeBuilder ForRMLExtension(String rmlExtensionGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionGUID != null) + { + return query.Where(x => x.RmlsExtensionsGuid == rmlExtensionGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder ForMachine(String machineGUID) + { + return AddQueryStep(1, (query) => + { + if (machineGUID != null) + { + return query.Where(x => x.MachineGuid == machineGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder WithTests() + { + return AddStep(2, () => + { + foreach (var result in Entities.ToList()) + { + var testsList = Context.RmlExtensionColorShadesTests.Where(x => x.RmlExtensionColorShadesGuid == result.Guid).Include(y => y.RmlExtensionColorShadesTestsData).OrderBy(z => z.ID).ToList(); + + //foreach (var test in testsList) + //{ + // var b = Context.RmlExtensionColorShadesTestsData.Where(x => x.RmlExtensionColorShadesTestsGuid == test.Guid).ToList(); + //} + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs index b75a9751d..ced98dbff 100644 --- a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs +++ b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs @@ -72,5 +72,16 @@ namespace Tango.BL.Calibration stream.CopyTo(fs); } } + + public static void CreateColorShadesInputExcelTemplate(String fileName) + { + var stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.BL.Calibration.ColorShadesTemplate.xlsx"); + + using (FileStream fs = new FileStream(fileName, FileMode.Create)) + { + stream.Seek(0, SeekOrigin.Begin); + stream.CopyTo(fs); + } + } } } diff --git a/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs index 3d9c77b11..ac2c44f15 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs @@ -7,10 +7,32 @@ // the code is regenerated. Do not modify! // //------------------------------------------------------------------------------ +using ColorMine.ColorSpaces; +using Newtonsoft.Json; +using System.Windows.Media; +using System.ComponentModel.DataAnnotations.Schema; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Tango.BL.Entities { public class RmlExtensionColorShadesTestsData : RmlExtensionColorShadesTestsDataBase { + public RmlExtensionColorShadesTestsData() : base() + { + } + + + [NotMapped] + [JsonIgnore] + public SolidColorBrush ColorBrush + { + get { + Lab lab = new Lab(L, A, B); + Rgb rgb = (Rgb)lab.ToRgb(); + return new SolidColorBrush(Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B)); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index e76aff050..bcc6e303e 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -117,6 +117,7 @@ + @@ -736,6 +737,7 @@ Designer + Designer @@ -801,7 +803,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From 7baca4061db66b1c5fde1c200f0d9323ba1be23f Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 26 Jan 2022 19:29:26 +0200 Subject: Color shade window. GUI. Related Work Items: #5831 --- .../Models/ColorShadesModel.cs | 6 +- .../ViewModels/ColorCalibrationViewVM.cs | 2 +- .../ViewModels/ColorShadeTabVM.cs | 14 ++- .../ViewModels/ColorShadeViewVM.cs | 24 ++-- .../Views/ColorShadeView.xaml | 136 +++++++++++++-------- .../Views/MachineTestResultsView.xaml | 3 + .../Views/TestResultsView.xaml | 42 ++++--- .../Entities/RmlExtensionColorShadesTestsData.cs | 22 ++++ 8 files changed, 163 insertions(+), 86 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs index cc4351891..98d4afe07 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs @@ -11,16 +11,20 @@ namespace Tango.MachineStudio.ThreadExtensions.Models { public class ColorShadesDataItem { - public double ColorNumber { get; set; } + public int ColorNumber { get; set; } public double L { get; set; } public double A { get; set; } public double B { get; set; } public double C { get; set; } public double M { get; set; } public double Y { get; set; } + public double K { get; set; } + public double TI { get; set; } public double L2 { get; set; } public double A2 { get; set; } public double B2 { get; set; } + public double DelteE { get; set; } + } public void GetDataFromFile(string fileName, out List items, ref string errors) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs index fc15c8caf..3f4d8a415 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -370,7 +370,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels newtab.RmlExtensionColorCalibrationsTest = new RmlExtensionColorCalibrationsTest() { - RmlExtensionColorCalibrationGuid = RMLExtentionGUID, + RmlExtensionColorCalibrationGuid = RmlExtensionColorCalibration.Guid, Name = name }; var liquidDataCollection = new SynchronizedObservableCollection(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs index df0ba521c..eaaf7dc96 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs @@ -83,13 +83,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - RelayCommand ImportColorsCommand { get; set; } + public RelayCommand ImportColorsCommand { get; set; } public ColorShadeTabVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; ImportColorsCommand = new RelayCommand(ImportColors); + RemovedDataList = new List(); } private void ImportColors(object obj) @@ -108,11 +109,18 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels 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."); - + } else { - //Settings data to object + if (RemovedDataList.Count == 0 && RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Count > 0) + { + RemovedDataList = new List(RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.ToList()); + } + RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Clear(); + items.ForEach(x => RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Add(new RmlExtensionColorShadesTestsData() { + ColorNum = x.ColorNumber, L = x.L, A = x.A, B = x.B, C = x.C, M = x.M, Y = x.Y, K = x.K, Ti = x.TI, LRes = x.L2, ARes = x.A2, BRes = x.B2, DeltaE = x.DelteE })); + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs index b1dac5ce9..f305d5139 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -231,14 +231,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels newtab.RmlExtensionColorShadesTest = new RmlExtensionColorShadesTest() { - RmlExtensionColorShadesGuid = RMLExtentionGUID, + RmlExtensionColorShadesGuid = RmlExtensionColorShade.Guid, Name = name }; if (RmlExtensionColorShade != null) { RmlExtensionColorShade.RmlExtensionColorShadesTests.Add(newtab.RmlExtensionColorShadesTest); } - + return newtab; } #endregion @@ -372,21 +372,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels foreach (var tab in ColorShadeTabs) { tab.RmlExtensionColorShadesTest.LastUpdated = lastUpdated; - //var removedPoints = tab.RemovedPoints; - //foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) - //{ - // var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); - // if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) - // { - // _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); - // } - // liquidData.LastUpdated = lastUpdated; - //} - //tab.RemovedPoints.Clear(); + var removedPoints = tab.RemovedDataList; + if (removedPoints.Count > 0) + { + _active_context.RmlExtensionColorShadesTestsData.RemoveRange(removedPoints); + } + tab.RemovedDataList.Clear(); } await _active_context.SaveChangesAsync(); - - // LoadColorParameters(); + } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml index 70df4d6bf..f8aaa5e24 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -17,6 +17,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml index b46cb4cf9..820c68715 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml @@ -61,6 +61,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml index 50a2537e1..b8a4b7f28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml @@ -265,20 +265,16 @@ - - - - Conclusion: - - - - - Comments: - - - - - + + + + + + + + + + @@ -631,7 +627,23 @@ - + + + + + + + + + + + Conclusion: + + + Comments: + + + diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs index ac2c44f15..19dce1a0e 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs @@ -23,7 +23,29 @@ namespace Tango.BL.Entities { } + protected override void OnLChanged(double L) + { + base.OnLChanged(L); + UpdateColorBrush(); + } + + protected override void OnAChanged(double L) + { + base.OnAChanged(L); + UpdateColorBrush(); + } + + protected override void OnBChanged(double L) + { + base.OnBChanged(L); + UpdateColorBrush(); + } + private void UpdateColorBrush() + { + RaisePropertyChanged(nameof(ColorBrush)); + } + [NotMapped] [JsonIgnore] public SolidColorBrush ColorBrush -- cgit v1.3.1 From bfc9623f1b20c0a17e54bfbcdc59c43104afec78 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 30 Jan 2022 14:50:12 +0200 Subject: Added Data grid displaying all available recorded files for download. Related Work Items: #5820 --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.MachineStudio.ThreadExtensions.csproj | 9 + .../ViewModels/TestResultViewVM.cs | 119 ++++++++++++- .../ViewModels/TestResultsViewVM.cs | 11 +- .../Views/TestResultsView.xaml | 121 +++++++++---- .../packages.config | 2 + .../RMLExtensionTestResultsCollectionBuilder.cs | 10 ++ .../Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs | 14 ++ .../DTO/RmlExtensionTestResultsFileDTOBase.cs | 49 +++++ .../Entities/RmlExtensionTestResultBase.cs | 38 ++++ .../Entities/RmlExtensionTestResultsFile.cs | 16 ++ .../Entities/RmlExtensionTestResultsFileBase.cs | 182 +++++++++++++++++++ .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 + .../ObservablesEntitiesAdapterExtension.cs | 38 ++++ .../ObservablesStaticCollectionsExtension.cs | 38 ++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 6 +- .../DB/RML_EXTENSION_TEST_RESULTS.cs | 3 + .../DB/RML_EXTENSION_TEST_RESULTS_FILES.cs | 26 +++ .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 74 ++++++++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 197 +++++++++++---------- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 5 +- 23 files changed, 822 insertions(+), 145 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 0035ae1d8..a4a0facae 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 5ec2e2d21..e542c9bc0 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 065dec29e..ae05ca02c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -53,6 +53,15 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll + ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs index 41be789ed..68a886f99 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs @@ -1,8 +1,11 @@ using Microsoft.Win32; +using Microsoft.WindowsAPICodePack.Dialogs; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Data.Entity; +using System.Diagnostics; using System.Text; using System.Threading.Tasks; using Tango.BL; @@ -10,6 +13,7 @@ using Tango.BL.ActionLogs; using Tango.BL.DTO; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.ValueObjects; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.ThreadExtensions.Models; @@ -21,9 +25,9 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { private INotificationProvider _notification; private IActionLogManager _actionLogManager; - + #region Properties - + private string _threadName; /// /// Gets or sets the name of the thread. Using in print @@ -51,7 +55,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _isSelected; } set { _isSelected = value; RaisePropertyChangedAuto(); } } - + private RmlExtensionTestResult _testResult; public RmlExtensionTestResult TestResult @@ -59,19 +63,124 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _testResult; } set { _testResult = value; RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(TestResultsFiles)); } } - - #endregion + public List TestResultsFiles + { + get + { + return TestResult.RmlExtensionTestResultsFiles.ToList(); + } + } + public RelayCommand DeleteCommand { get; set; } + public RelayCommand DownLoadFileCommand { get; set; } + public RelayCommand UploadCommand { get; set; } + public RelayCommand DownLoadAllCommand { get; set; } + #endregion + public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; + + UploadCommand = new RelayCommand(UploadFiles); + DownLoadFileCommand = new RelayCommand(DownLoadFile); + DeleteCommand = new RelayCommand(DeleteFile); + DownLoadAllCommand = new RelayCommand(DownLoadAllFiles); } + + #region TestResultsFiles + private async void UploadFiles(object obj) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + try + { + var files = dlg.FileNames.ToList(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var testResult = await db.RmlExtensionTestResults.Where(x => x.Guid == TestResult.Guid).Include(t1 => t1.RmlExtensionTestResultsFiles).FirstOrDefaultAsync(); + foreach (var strpath in files) + { + var testResultfile = new RmlExtensionTestResultsFile(); + testResultfile.FileName = Path.GetFileName(strpath); + //temporary!!! + testResultfile.FilePath = strpath; + + // TestResult.RmlExtensionTestResultsFiles.Add(testResultfile); + testResult.RmlExtensionTestResultsFiles.Add(testResultfile); + } + if (testResult != null) + { + await db.SaveChangesAsync(); + } + TestResult.RmlExtensionTestResultsFiles = testResult.RmlExtensionTestResultsFiles;///????? + RaisePropertyChanged(nameof(TestResultsFiles)); + } + _notification.ShowInfo("File successfully loaded."); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to import the file.\n{ex.FlattenMessage()}"); + } + } + + } + + private void DownLoadFile(RmlExtensionTestResultsFile file) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save the csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = file.FileName; + if (dlg.ShowDialog().Value) + { + /// + } + } + + private void DownLoadAllFiles() + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select folder."; + dlg.IsFolderPicker = true; + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + var filesPath = TestResult.RmlExtensionTestResultsFiles.Select( x=>x.FilePath).ToList(); + ///// + } + } + + private async void DeleteFile(RmlExtensionTestResultsFile file) + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected file?")) + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var deletefile = db.RmlExtensionTestResultsFiles.FirstOrDefault(x => x.Guid == file.Guid); + if(deletefile != null) + { + db.RmlExtensionTestResultsFiles.Remove(deletefile); + await db.SaveChangesAsync(); + } + } + TestResult.RmlExtensionTestResultsFiles.Remove(file); + RaisePropertyChanged(nameof(TestResultsFiles)); + } + } + #endregion + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs index c1fb4497f..f639eb6e7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs @@ -1,6 +1,8 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -271,7 +273,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels using (_notification.PushTaskItem("Loading Test Results Parameters ...")) { - var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().BuildAsync(); + var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().WithTestResultsFiles().BuildAsync(); SelectedTestResults = testResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); foreach (var result in SelectedTestResults) { @@ -403,6 +405,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion + #region Excel + public async void LoadTestResultsExcel(List testResultsExcelModelList, string machineGUID, string machineSerialNumber) { try @@ -556,5 +560,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels IsFree = true; } } + + #endregion + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml index b8a4b7f28..f6262b52d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml @@ -158,33 +158,12 @@ - + - - + --> + + @@ -266,17 +245,16 @@ + - - - - - + + + @@ -289,8 +267,8 @@ - - Process Parameters @@ -386,7 +364,7 @@ - + Tension through the thread path @@ -627,7 +605,7 @@ - + @@ -637,16 +615,83 @@ - Conclusion: + Conclusion: - Comments: - + Comments: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config index da5ed8abc..f9bce0fbf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config @@ -6,6 +6,8 @@ + + diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs index 574439852..2b962d56b 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs @@ -26,6 +26,16 @@ namespace Tango.BL.Builders } }); } + public virtual RMLExtensionTestResultsCollectionBuilder WithTestResultsFiles() + { + return AddStep(3, () => + { + foreach (var result in Entities.ToList()) + { + Context.RmlExtensionTestResultsFiles.Where(x => x.RmlExtensionTestResultsGuid == result.Guid).OrderBy(x => x.FileName).ToList(); + } + }); + } public virtual RMLExtensionTestResultsCollectionBuilder ForRMLExtension(String rmlExtensionGUID) { return AddQueryStep(0, (query) => diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs new file mode 100644 index 000000000..0e06e750e --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.DTO +{ + public class RmlExtensionTestResultsFileDTO : RmlExtensionTestResultsFileDTOBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs new file mode 100644 index 000000000..f06cdb159 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs @@ -0,0 +1,49 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.BL.DTO +{ + public abstract class RmlExtensionTestResultsFileDTOBase : ObservableEntityDTO + { + + /// + /// rml extension test results guid + /// + public String RmlExtensionTestResultsGuid + { + get; set; + } + + /// + /// file name + /// + public String FileName + { + get; set; + } + + /// + /// file path + /// + public String FilePath + { + get; set; + } + + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs index 561b311d7..7f6804039 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs @@ -93,6 +93,8 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; + public event EventHandler> RmlExtensionTestResultsFilesChanged; + public event EventHandler> RubbingResultsChanged; protected String _rmlsextensionsguid; @@ -1046,6 +1048,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _rmlextensiontestresultsfiles; + + /// + /// Gets or sets the rmlextensiontestresultbase rml extension test results files. + /// + + public virtual SynchronizedObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + if (_rmlextensiontestresultsfiles != value) + { + _rmlextensiontestresultsfiles = value; + + OnRmlExtensionTestResultsFilesChanged(value); + + } + } + } + protected SynchronizedObservableCollection _rubbingresults; /// @@ -1368,6 +1395,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Machine)); } + /// + /// Called when the RmlExtensionTestResultsFiles has changed. + /// + protected virtual void OnRmlExtensionTestResultsFilesChanged(SynchronizedObservableCollection rmlextensiontestresultsfiles) + { + RmlExtensionTestResultsFilesChanged?.Invoke(this, rmlextensiontestresultsfiles); + RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + /// /// Called when the RubbingResults has changed. /// @@ -1385,6 +1421,8 @@ namespace Tango.BL.Entities TensileResults = new SynchronizedObservableCollection(); + RmlExtensionTestResultsFiles = new SynchronizedObservableCollection(); + RubbingResults = new SynchronizedObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs new file mode 100644 index 000000000..5ae38f7f5 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +namespace Tango.BL.Entities +{ + public class RmlExtensionTestResultsFile : RmlExtensionTestResultsFileBase + { + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs new file mode 100644 index 000000000..37cc8fd4a --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs @@ -0,0 +1,182 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; +using Tango.Core; +using System.ComponentModel; +using Tango.Core.CustomAttributes; + +namespace Tango.BL.Entities +{ + [Table("RML_EXTENSION_TEST_RESULTS_FILES")] + public abstract class RmlExtensionTestResultsFileBase : ObservableEntity + { + + public event EventHandler FileNameChanged; + + public event EventHandler FilePathChanged; + + public event EventHandler RmlExtensionTestResultsChanged; + + protected String _rmlextensiontestresultsguid; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase rml extension test results guid. + /// + + [Column("RML_EXTENSION_TEST_RESULTS_GUID")] + [ForeignKey("RmlExtensionTestResults")] + + public String RmlExtensionTestResultsGuid + { + get + { + return _rmlextensiontestresultsguid; + } + + set + { + if (_rmlextensiontestresultsguid != value) + { + _rmlextensiontestresultsguid = value; + + } + } + } + + protected String _filename; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase file name. + /// + + [Column("FILE_NAME")] + + public String FileName + { + get + { + return _filename; + } + + set + { + if (_filename != value) + { + _filename = value; + + OnFileNameChanged(value); + + } + } + } + + protected String _filepath; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase file path. + /// + + [Column("FILE_PATH")] + + public String FilePath + { + get + { + return _filepath; + } + + set + { + if (_filepath != value) + { + _filepath = value; + + OnFilePathChanged(value); + + } + } + } + + protected RmlExtensionTestResult _rmlextensiontestresults; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase rml extension test results. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual RmlExtensionTestResult RmlExtensionTestResults + { + get + { + return _rmlextensiontestresults; + } + + set + { + if (_rmlextensiontestresults != value) + { + _rmlextensiontestresults = value; + + if (RmlExtensionTestResults != null) + { + RmlExtensionTestResultsGuid = RmlExtensionTestResults.Guid; + } + + OnRmlExtensionTestResultsChanged(value); + + } + } + } + + /// + /// Called when the FileName has changed. + /// + protected virtual void OnFileNameChanged(String filename) + { + FileNameChanged?.Invoke(this, filename); + RaisePropertyChanged(nameof(FileName)); + } + + /// + /// Called when the FilePath has changed. + /// + protected virtual void OnFilePathChanged(String filepath) + { + FilePathChanged?.Invoke(this, filepath); + RaisePropertyChanged(nameof(FilePath)); + } + + /// + /// Called when the RmlExtensionTestResults has changed. + /// + protected virtual void OnRmlExtensionTestResultsChanged(RmlExtensionTestResult rmlextensiontestresults) + { + RmlExtensionTestResultsChanged?.Invoke(this, rmlextensiontestresults); + RaisePropertyChanged(nameof(RmlExtensionTestResults)); + } + + /// + /// Initializes a new instance of the class. + /// + public RmlExtensionTestResultsFileBase() : base() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs index 382bb0dca..16e44759b 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs @@ -758,6 +758,14 @@ namespace Tango.BL get; set; } + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public DbSet RmlExtensionTestResultsFiles + { + get; set; + } + /// /// Gets or sets the Rmls. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs index a95bbd787..b18a39cb6 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs @@ -3329,6 +3329,42 @@ namespace Tango.BL } + private ObservableCollection _rmlextensiontestresultsfiles; + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public ObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + _rmlextensiontestresultsfiles = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + + } + + private ICollectionView _rmlextensiontestresultsfilesViewSource; + /// + /// Gets or sets the RmlExtensionTestResultsFiles View Source. + /// + public ICollectionView RmlExtensionTestResultsFilesViewSource + { + get + { + return _rmlextensiontestresultsfilesViewSource; + } + + set + { + _rmlextensiontestresultsfilesViewSource = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFilesViewSource)); + } + + } + private ObservableCollection _rmls; /// /// Gets or sets the Rmls. @@ -4383,6 +4419,8 @@ namespace Tango.BL RmlExtensionColorShadesTestsDataViewSource = CreateCollectionView(RmlExtensionColorShadesTestsData); + RmlExtensionTestResultsFilesViewSource = CreateCollectionView(RmlExtensionTestResultsFiles); + RmlsViewSource = CreateCollectionView(Rmls); RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs index f4ccd1d88..d5f9c0bb9 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs @@ -3329,6 +3329,42 @@ namespace Tango.BL } + private ObservableCollection _rmlextensiontestresultsfiles; + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public ObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + _rmlextensiontestresultsfiles = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + + } + + private ICollectionView _rmlextensiontestresultsfilesViewSource; + /// + /// Gets or sets the RmlExtensionTestResultsFiles View Source. + /// + public ICollectionView RmlExtensionTestResultsFilesViewSource + { + get + { + return _rmlextensiontestresultsfilesViewSource; + } + + set + { + _rmlextensiontestresultsfilesViewSource = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFilesViewSource)); + } + + } + private ObservableCollection _rmls; /// /// Gets or sets the Rmls. @@ -4383,6 +4419,8 @@ namespace Tango.BL RmlExtensionColorShadesTestsDataViewSource = CreateCollectionView(RmlExtensionColorShadesTestsData); + RmlExtensionTestResultsFilesViewSource = CreateCollectionView(RmlExtensionTestResultsFiles); + RmlsViewSource = CreateCollectionView(Rmls); RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index bcc6e303e..76f521843 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -305,6 +305,8 @@ + + @@ -489,6 +491,8 @@ + + @@ -803,7 +807,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs index b1a5ae94f..c530978d8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs @@ -18,6 +18,7 @@ namespace Tango.DAL.Remote.DB public RML_EXTENSION_TEST_RESULTS() { this.TENSILE_RESULTS = new HashSet(); + this.RML_EXTENSION_TEST_RESULTS_FILES = new HashSet(); this.RUBBING_RESULTS = new HashSet(); } @@ -62,6 +63,8 @@ namespace Tango.DAL.Remote.DB public virtual ICollection TENSILE_RESULTS { get; set; } public virtual MACHINE MACHINE { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection RML_EXTENSION_TEST_RESULTS_FILES { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection RUBBING_RESULTS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs new file mode 100644 index 000000000..5d51a4c8a --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class RML_EXTENSION_TEST_RESULTS_FILES + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public string RML_EXTENSION_TEST_RESULTS_GUID { get; set; } + public string FILE_NAME { get; set; } + public string FILE_PATH { get; set; } + + public virtual RML_EXTENSION_TEST_RESULTS RML_EXTENSION_TEST_RESULTS { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index c89fc2a1f..17f6c87f0 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -117,6 +117,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet RML_EXTENSION_COLOR_SHADES { get; set; } public virtual DbSet RML_EXTENSION_COLOR_SHADES_TESTS { get; set; } public virtual DbSet RML_EXTENSION_COLOR_SHADES_TESTS_DATA { get; set; } + public virtual DbSet RML_EXTENSION_TEST_RESULTS_FILES { get; set; } public virtual DbSet RMLS { get; set; } public virtual DbSet RMLS_SPOOLS { get; set; } public virtual DbSet ROLES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index ae70f1ed6..09dded898 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1219,6 +1219,17 @@ + + + + + + + + + + + @@ -2776,6 +2787,20 @@ + + + + + + + + + + + + + + @@ -3435,6 +3460,7 @@ + @@ -3785,6 +3811,10 @@ + + + + @@ -4123,6 +4153,7 @@ + @@ -4523,6 +4554,10 @@ + + + + @@ -4679,6 +4714,7 @@ + @@ -6333,6 +6369,18 @@ + + + + + + + + + + + + @@ -7983,6 +8031,20 @@ + + + + + + + + + + + + + + @@ -9649,6 +9711,18 @@ + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index a72a68e1f..859ff927d 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,104 +5,105 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 10f151494..da4624d61 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -324,6 +324,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt @@ -479,7 +482,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From 4439a039bdaf8e59e0f450e2e4fbbd52b50261fd Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 30 Jan 2022 19:30:33 +0200 Subject: GUI binding bug --- .../Views/ColorShadeView.xaml | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml index f8aaa5e24..b9341d0de 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -144,20 +144,20 @@ - + - - - - - - - - - + + + + + + + + + -- cgit v1.3.1