From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Models/CalibrationMeasurementModel.cs | 90 ---- .../Models/ColorLinearizationModel.cs | 43 -- .../Tango.MachineStudio.RML.csproj | 49 -- .../ViewModels/CalibrationDataViewVM.cs | 10 - .../ViewModels/ColorCalibrationViewVM.cs | 551 --------------------- .../ViewModels/ColorConversionViewVM.cs | 16 +- .../ViewModels/LiquidVolumeVM.cs | 13 - .../ViewModels/MainViewVM.cs | 420 ++++------------ .../ViewModels/RmlDeleteDialogViewVM.cs | 95 ---- .../Views/ColorCalibrationView.xaml | 213 -------- .../Views/ColorCalibrationView.xaml.cs | 42 -- .../Views/HeadCleaningParametersView.xaml | 59 --- .../Views/HeadCleaningParametersView.xaml.cs | 28 -- .../Tango.MachineStudio.RML/Views/MainView.xaml | 2 +- .../Views/ProcessParametersView.xaml | 4 +- .../Views/RmlDeleteDialogView.xaml | 82 --- .../Views/RmlDeleteDialogView.xaml.cs | 28 -- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 47 +- .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 8 +- .../Tango.MachineStudio.RML/Views/SpoolsView.xaml | 85 ---- .../Views/SpoolsView.xaml.cs | 28 -- .../Views/ThreadParametersView.xaml | 121 ----- .../Views/ThreadParametersView.xaml.cs | 28 -- 23 files changed, 114 insertions(+), 1948 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RmlDeleteDialogViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs deleted file mode 100644 index 6345d5f59..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; -using Tango.BL.Enumerations; -using Tango.PMR.Printing; - -namespace Tango.MachineStudio.RML.Models -{ - public static class ColorCalibrationExt - { - public static Dictionary TargetLiquidTypeToLAB = new Dictionary - { - {LiquidTypes.Cyan, new LAB(51.94591,-18.3438,-39.0577)}, - {LiquidTypes.Magenta, new LAB(47.46248, 65.84478, 3.922838)}, - {LiquidTypes.Yellow, new LAB(84.41956,-0.27005, 94.05445)}, - {LiquidTypes.Black, new LAB(26.57986, -0.13567, 0.948574)}, - }; - public static Dictionary DisplayLiquidTypeToLABType = new Dictionary - { - {LiquidTypes.Cyan, "L"}, - {LiquidTypes.Magenta, "L"}, - {LiquidTypes.Yellow, "B"}, - {LiquidTypes.Black, "L"}, - }; - }; - - public class LAB - { - public double L { get; set; } - public double A { get; set; } - public double B { get; set; } - - public LAB( double l, double a, double b) - { - L = l; B = b; A = a; - } - }; - - public class CalibrationMeasurementModel : ExtendedObject - { - #region properties - private double _l; - - public double L - { - get { return _l; } - set { _l = value; RaisePropertyChangedAuto(); } - } - - private double _a; - - public double A - { - get { return _a; } - set { _a = value; RaisePropertyChangedAuto(); } - } - - private double _b; - - public double B - { - get { return _b; } - set { _b = value; RaisePropertyChangedAuto(); } - } - - private double _ink; - - public double Ink - { - get { return _ink; } - set { _ink = value; RaisePropertyChangedAuto(); } - } - #endregion - - public CalibrationMeasurementModel() - { - - } - public CalibrationMeasurementModel(Tango.MachineStudio.RML.Models.ColorLinearizationModel.LinearizationDataItem model) - { - L = model.L; - A = model.A; - B = model.B; - Ink = model.InkPercentage; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs deleted file mode 100644 index 23179b3f2..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs +++ /dev/null @@ -1,43 +0,0 @@ -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.RML.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.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 38d289c58..2ff9ab0a3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -49,12 +49,6 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll - - ..\..\..\packages\OxyPlot.Core.2.0.0\lib\net45\OxyPlot.dll - - - ..\..\..\packages\OxyPlot.Wpf.2.0.0\lib\net45\OxyPlot.Wpf.dll - @@ -79,9 +73,7 @@ GlobalVersionInfo.cs - - Code @@ -101,21 +93,16 @@ - - AddLiquidFactorView.xaml CalibrationDataView.xaml - - ColorCalibrationView.xaml - ColorConversionView.xaml @@ -125,24 +112,12 @@ ProcessParametersView.xaml - - RmlDeleteDialogView.xaml - RmlsView.xaml RmlView.xaml - - HeadCleaningParametersView.xaml - - - ThreadParametersView.xaml - - - SpoolsView.xaml - ResXFileCodeGenerator Resources.Designer.cs @@ -167,10 +142,6 @@ {40085232-aced-4cbe-945b-90ba8153c151} Tango.BrushPicker - - {b60c695c-61e8-4091-b506-4c45349c04aa} - Tango.ColorCalibration - {b4fe6485-4161-4b36-bc08-67e0b53d01b7} Tango.ColorConversion @@ -232,10 +203,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -248,10 +215,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -260,18 +223,6 @@ Designer MSBuild:Compile - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs index fd69fef35..b34ef83bc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Calibration; -using Tango.BL.Entities; using Tango.Core.Commands; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; @@ -107,14 +106,5 @@ namespace Tango.MachineStudio.RML.ViewModels _notification.ShowError("An error occurred while trying to export the calibration data."); } } - - public void ApplyCalibrationData(LiquidType liquidType, List newpoints) - { - CalibrationDataVM vm = LiquidsCalibrationData.FirstOrDefault(x => x.LiquidType == liquidType); - if(vm != null) - { - newpoints.ForEach(x => vm.CalibrationPoints.Add(x)); - } - } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs deleted file mode 100644 index f04eccd90..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs +++ /dev/null @@ -1,551 +0,0 @@ -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.Core.Commands; -using Tango.MachineStudio.RML.Models; -using Tango.SharedUI; -using OxyPlot; -using OxyPlot.Wpf; -using OxyPlot.Annotations; -using Tango.ColorCalibration; -using Tango.PMR.ColorLab; -using Tango.Logging; -using Tango.MachineStudio.Common.Notifications; -using System.Text.RegularExpressions; -using Microsoft.Win32; - -namespace Tango.MachineStudio.RML.ViewModels -{ - public class ColorCalibrationViewVM : ExtendedObject - { - private IColorCalibrator _calibrator; - private ILinearizationMeasurements _linearizationMeasurementscalibrator; - private INotificationProvider _notification; - - #region Properties - - private Rml _rml; - public Rml RML - { - get { return _rml; } - set { _rml = value; RaisePropertyChangedAuto(); } - } - - private BL.Entities.LiquidType _liquidType; - - public BL.Entities.LiquidType LiquidType - { - get { return _liquidType; } - set { _liquidType = value; RaisePropertyChangedAuto(); RaisePropertyChanged("LiquidTypeName"); } - } - - private List _liquidTypes; - - public List LiquidTypes - { - get { return _liquidTypes; } - set { _liquidTypes = value; } - } - - - private ObservableCollection _measurements; - public ObservableCollection Measurements - { - get - { - return _measurements; - } - set - { - _measurements = value; RaisePropertyChangedAuto(); - } - } - - - private double _factor; - - public double Factor - { - get { return _factor; } - set { _factor = value; RaisePropertyChangedAuto(); } - } - - private string _errorMessage; - - public string ErrorMessage - { - get { return _errorMessage; } - set { _errorMessage = value; RaisePropertyChangedAuto(); } - } - private bool _hasError; - - public bool HasError - { - get { return _hasError; } - set { _hasError = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand ImportDataCommand { get; set; } - public RelayCommand CreateGraphCommand { get; set; } - public RelayCommand CreateLinearizationGraphCommand { get; set; } - public RelayCommand ExportGraphCommand { get; set; } - public RelayCommand ApplyCalibrationDataCommand { get; set; } - - - public string LiquidTypeName - { - get { return LiquidType == null ?"" : LiquidType.Name; } - } - - public Plot PlotControl { get; set; } - private IList _points; - /// - /// Binding to ItemsSource of line chart. - /// - public IList Points - { - get { return _points; } - set - { - _points = value; - RaisePropertyChangedAuto(); - } - } - private IList _targetPoints; - /// - /// Binding to ItemsSource of line chart. - /// - public IList TargetPoints - { - get { return _targetPoints; } - set - { - _targetPoints = value; - RaisePropertyChangedAuto(); - } - } - private int _step; - public int XStep - { - get { return _step; } - set { _step = value; RaisePropertyChangedAuto(); } - } - - private double _from; - /// - /// From use to binding to bottom axis min value - /// - public double From - { - get { return _from; } - set - { - _from = value; RaisePropertyChangedAuto(); - } - } - - private double _to; - /// - /// To use to binding to bottom axis max value - /// - public double To - { - get { return _to; } - set - { - _to = value; RaisePropertyChangedAuto(); - } - } - - private double _LabMinVal; - - public double LabMinVal - { - get { return _LabMinVal; } - set { _LabMinVal = value; RaisePropertyChangedAuto(); } - } - - private double _LabMaxVal; - - public double LabMaxVal - { - get { return _LabMaxVal; } - set { _LabMaxVal = value; RaisePropertyChangedAuto(); } - } - - public Plot LABLinearizationPlotControl { get; set; } - public Plot LinearizationPlotControl { get; set; } - private IList _linearizationPoints; - /// - /// Binding to ItemsSource of line chart. - /// - public IList LinearizationPoints - { - get { return _linearizationPoints; } - set - { - _linearizationPoints = value; - RaisePropertyChangedAuto(); - } - } - - 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; } - } - - - #endregion - - public ColorCalibrationViewVM(INotificationProvider notification) - { - _notification = notification; - Measurements = new ObservableCollection() - { - new CalibrationMeasurementModel(), - new CalibrationMeasurementModel(), - new CalibrationMeasurementModel(), - }; - Factor = 0; - HasError = false; - ImportDataCommand = new RelayCommand(ImportDataForCalcFactorExcel); - CreateGraphCommand = new RelayCommand(CreateGraph); - CreateLinearizationGraphCommand = new RelayCommand(CreateLinearizationGraph); - ExportGraphCommand = new RelayCommand(ExportGraph); - ApplyCalibrationDataCommand = new RelayCommand(ApplyCalibrationData); - this.Points = new List(); - TargetPoints = new List(); - LinearizationPoints = new List(); - LPoints = new List(); - APoints = new List(); - BPoints = new List(); - } - - public void Loading() - { - LiquidType = LiquidTypes.Count > 0 ? LiquidTypes[0] : null; - _calibrator = new DefaultColorCalibrator(); - _linearizationMeasurementscalibrator = new DefaultColorCalibrator(); - - } - - public void ClearResults() - { - Points.Clear(); - TargetPoints.Clear(); - ErrorMessage = ""; - HasError = false; - Factor = 0.0; - } - - private double GetLiquidFactor() - { - try - { - CalibrationInput conversionInput = new CalibrationInput(); - Measurements.ToList().ForEach(x => conversionInput.Measurements.Add(new CalibrationMeasurement { L = x.L, A = x.A, B = x.B, NanoliterPerCentimeter = x.Ink })); - conversionInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; - - - LAB lab; - if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) - { - conversionInput.TargetL = lab.L; - conversionInput.TargetA = lab.A; - conversionInput.TargetB = lab.B; - } - CalibrationOutput result = _calibrator.GetLiquidFactor(conversionInput); - - ErrorMessage = result.ErrorMessage; - HasError = false == String.IsNullOrEmpty(ErrorMessage); - - return result.LiquidFactor; - } - catch (Exception ex ) - { - HasError = true; - ErrorMessage = "Error occurred while trying to call GetLiquidFactor."; - LogManager.Log(ex, "Error occurred while trying to call GetLiquidFactor."); - } - return 0.0; - } - - private void ImportDataForCalcFactorExcel() - { - OpenFileDialog dlg = new OpenFileDialog(); - - try - { - dlg.Title = $"Import excel file for calculate Factor"; - dlg.Filter = "Excel Files|*.xlsx"; - if (dlg.ShowDialog().Value) - { - ClearResults(); - - List items;//List items - ColorLinearizationModel model = new ColorLinearizationModel(); - string error = ""; - model.GetDataFromFile(dlg.FileName, out items, ref error); - if (false == String.IsNullOrEmpty(error) || items == null || items.Count == 0) - { - _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); - return; - } - Measurements.Clear(); - items.ForEach(x => Measurements.Add(new CalibrationMeasurementModel(x))); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error importing excel file " + dlg.FileName); - _notification.ShowError("An error occurred while trying to import the selected excel file. Please check the file format if valid and is available to read."); - } - } - #region CreateGraph - - private async void CreateGraph(object obj) - { - if (_liquidType == null) - return; - ClearResults(); - PlotControl.InvalidatePlot(true); - string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; - await Task.Factory.StartNew(() => - { - Factor = GetLiquidFactor( ); - }); - - DataPoint targetPoint = GetTargetPoint(); - - To = 0; - From = 0; - - Measurements.ToList().ForEach(x =>{ Points.Add(new DataPoint(x.Ink, labType == "L" ? x.L : x.B)); - TargetPoints.Add(new DataPoint(x.Ink, targetPoint.Y)); }); - - _to = labType == "L"? 100 : 128; - _from = labType == "L" ? 0 : -127; - - RaisePropertyChanged("To"); - RaisePropertyChanged("From"); - XStep = (int)(Points.Count / 6); - RaisePropertyChanged("CalibrationType"); - PlotControl.InvalidatePlot(true); - - } - - private DataPoint GetTargetPoint() - { - var listValues = Measurements.ToList(); - if (listValues.Count == 0 || Factor <=0) - return new DataPoint(0, 0); - - string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; - - var left = listValues.Where(y => y.Ink == listValues.Min(x => x.Ink)).ToList().First(); - var right = listValues.Where(y => y.Ink == listValues.Max(x => x.Ink)).ToList().First(); - // Normalize start/end to left right to make the offset calc simpler. - DataPoint leftPoint = new DataPoint(left.Ink, labType == "L" ? left.L : left.B); - DataPoint rightPoint = new DataPoint(right.Ink, labType == "L" ? right.L : right.B); - - double deltaX = rightPoint.X - leftPoint.X; - double deltaY = rightPoint.Y - leftPoint.Y; - - // prevents division by zero exceptions. - if (deltaX == 0 ) - return new DataPoint(0, 0); - - double slope = deltaY / deltaX; - double offset = leftPoint.Y - leftPoint.X * slope; - double calculatedY = Factor * slope + offset; - - return new DataPoint(Factor, calculatedY); ; - } - - #endregion - #region CreateLinearizationGraph - - private async void CreateLinearizationGraph(object obj) - { - if (_liquidType == null ) - return; - - string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; - - ColorLinearizationModel model = new ColorLinearizationModel(); - string fileName = GetInkDataFileOpen();// @"C:\Test\Test Input Lineration.xlsx";//dialog to open file - if (fileName == null) - return; - - LinearizationPoints.Clear(); - LinearizationPlotControl.InvalidatePlot(true); - LPoints.Clear(); - APoints.Clear(); - BPoints.Clear(); - LabMinVal = LabMaxVal = 0; - LABLinearizationPlotControl.InvalidatePlot(true); - - List items; - string errors = ""; - model.GetDataFromFile(fileName, out items, ref errors); - if(false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) - { - _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); - return; - } - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => - { - outputPoints = GetLinearizationMeasurements(items); - }); - - LabMinVal = items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B))); - LabMaxVal = items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B))); - foreach (var labItem in items) - { - LPoints.Add(new DataPoint(labItem.InkPercentage, labItem.L)); - APoints.Add(new DataPoint(labItem.InkPercentage, labItem.A)); - BPoints.Add(new DataPoint(labItem.InkPercentage, labItem.B)); - } - LABLinearizationPlotControl.InvalidatePlot(true); - - if (outputPoints == null || outputPoints.Count != items.Count) - return; - - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); - } - - LinearizationPlotControl.InvalidatePlot(true); - } - - /// - /// Open file dialog and get name of file - /// - /// - private String GetInkDataFileOpen() - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Select Ink data file"; - dlg.Filter = "Excel |*.xlsx"; - if (dlg.ShowDialogCenter()) - { - return dlg.FileName; - } - - return null; - } - - private List GetLinearizationMeasurements(List items) - { - 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 = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; - - LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); - - if(!String.IsNullOrEmpty(result.ErrorMessage)) - { - LogManager.Log(result.ErrorMessage, "GetLinearizationMeasurements returns error." + result.ErrorMessage); - InvokeUI(() => - { - _notification.ShowError("Linearization failed. " + result.ErrorMessage); - }); - } - - LAB lab; - if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) - { - linearizationInput.TargetL = lab.L; - linearizationInput.TargetA = lab.A; - linearizationInput.TargetB = lab.B; - } - return result.InkPercentage.ToList(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error occurred while trying to call GetLinearizationMeasurements."); - } - return null; - } - #endregion - - #region Export graph - /// - /// Exports the graph point to Excel file. - /// - protected void ExportGraph() - { - SaveFileDialog dlg = new SaveFileDialog(); - try - { - dlg.Title = $"Export excel calibration file for {LiquidType.Name}"; - dlg.Filter = "Excel Files|*.xlsx"; - dlg.DefaultExt = ".xlsx"; - dlg.FileName = $"CData_{LiquidType.Name}_v{LiquidType.Version}.xlsx"; - if (dlg.ShowDialog().Value) - { - List points = new List(); - LinearizationPoints.ToList().ForEach(x=> points.Add(ToCalibrationPoint(x))); - BL.Calibration.CalibrationHelper.ExportCalibrationDataToExcel(points, dlg.FileName); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error exporting excel file " + dlg.FileName); - _notification.ShowError("An error occurred while trying to export the calibration data."); - } - } - public CalibrationPoint ToCalibrationPoint(DataPoint point) - { - return new CalibrationPoint() - { - X = point.X, - Y = point.Y, - }; - } - - /// - /// Applies the calibration data. - /// - protected void ApplyCalibrationData() - { - if (LinearizationPoints.Count == 0) - return; - - List points = new List(); - LinearizationPoints.ToList().ForEach(x => points.Add(new CalibrationDataPointVM(x.X, x.Y))); - ViewModelLocator.MainViewVM.CalibrationDataViewVM.ApplyCalibrationData(LiquidType, points); - } - #endregion - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs index 95de19f42..b68239b4b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs @@ -111,7 +111,6 @@ namespace Tango.MachineStudio.RML.ViewModels Color = x.LiquidType.Color, Name = x.LiquidType.Name, LiquidType = x.LiquidType, - MaxNanoliterPerCentimeter = x.MaxNlPerCm, }).ToObservableCollection(); } @@ -310,19 +309,6 @@ namespace Tango.MachineStudio.RML.ViewModels } } - private double GetTotalMaximumLiquidNlPerCMLimit() - { - try - { - var tables = RML.GetActiveProcessGroup().ProcessParametersTables.OrderBy(x => x.TableIndex).ToList(); - return tables.Max(x => x.MaxInkUptake); - } - catch - { - return BrushStop.MAX_INK_UPTAKE; - } - } - private void OnLiquidVolumeChanged() { try @@ -330,7 +316,7 @@ namespace Tango.MachineStudio.RML.ViewModels if (LiquidsCalibrationData == null || _prevent_inverse_conversion) return; //TODO: This is temporary because of out of range volumes. - if (LiquidVolumes.Where(x => x.LiquidType.HasPigment).Sum(x => x.NanoliterPerCentimeter) > GetTotalMaximumLiquidNlPerCMLimit()) + if (LiquidVolumes.Where(x => x.LiquidType.HasPigment).Sum(x => x.Volume) > 200) { IsVolumesOutOfRange = true; return; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/LiquidVolumeVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/LiquidVolumeVM.cs index 27b811bb6..7399d62af 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/LiquidVolumeVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/LiquidVolumeVM.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.BL.Dispensing; using Tango.BL.Entities; using Tango.Core; using Tango.SharedUI; @@ -48,17 +47,5 @@ namespace Tango.MachineStudio.RML.ViewModels get { return _liquidType; } set { _liquidType = value; RaisePropertyChangedAuto(); } } - - public double MaxNanoliterPerCentimeter { get; set; } - - public double NanoliterPerCentimeter - { - get - { - StandardColorDispensingCalc calc = new StandardColorDispensingCalc(); - return calc.CalculateNanoliterPerCentimeter(Volume, MaxNanoliterPerCentimeter); - } - } - } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index cadd1fb95..ee21b9ac3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -21,19 +21,12 @@ using Tango.MachineStudio.RML.Views; using Tango.PMR.ColorLab; using System.Data.Entity; using Tango.Core.ExtensionMethods; -using Tango.MachineStudio.Common.Authentication; -using Tango.BL.ActionLogs; -using Tango.BL.DTO; -using Tango.BL.Enumerations; namespace Tango.MachineStudio.RML.ViewModels { public class MainViewVM : StudioViewModel { private INotificationProvider _notification; - private IAuthenticationProvider _authentication; - private IActionLogManager _actionLogManager; - private RmlDTO _rmlBeforeSave; private ObservablesContext _rmls_context; private ObservablesContext _active_context; @@ -45,20 +38,6 @@ namespace Tango.MachineStudio.RML.ViewModels set { _rmls = value; RaisePropertyChangedAuto(); } } - private ICollectionView _rmlssCollectionView; - /// - /// Gets or sets the RML collection view. - /// - public ICollectionView RmlsCollectionView - { - get { return _rmlssCollectionView; } - set - { - _rmlssCollectionView = value; - RaisePropertyChangedAuto(); - } - } - private ObservableCollection _materials; public ObservableCollection Materials { @@ -101,13 +80,6 @@ namespace Tango.MachineStudio.RML.ViewModels set { _fiberSynths = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _spoolTypes; - public ObservableCollection SpoolTypes - { - get { return _spoolTypes; } - set { _spoolTypes = value; RaisePropertyChangedAuto(); } - } - private Rml _selectedRML; public Rml SelectedRML { @@ -171,30 +143,6 @@ namespace Tango.MachineStudio.RML.ViewModels set { _colorConversionViewVM = value; RaisePropertyChangedAuto(); } } - private RmlsSpool _selectedSpool; - public RmlsSpool SelectedSpool - { - get { return _selectedSpool; } - set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } - } - - private ColorCalibrationViewVM _colorCalibrationVM; - public ColorCalibrationViewVM ColorCalibrationVM - { - get { return _colorCalibrationVM; } - set { _colorCalibrationVM = value; RaisePropertyChangedAuto(); } - } - - private String _RMLFilter; - /// - /// Gets or sets the job filter. - /// - public String RMLFilter - { - get { return _RMLFilter; } - set { _RMLFilter = value; RaisePropertyChangedAuto(); OnRMLFilterChanged(); } - } - /// /// Gets or sets the manage RML command. /// @@ -237,21 +185,9 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand ImportRMLFileCommand { get; set; } - /// - /// Gets or sets the add spool command. - /// - public RelayCommand AddSpoolCommand { get; set; } - - /// - /// Gets or sets the remove spool command. - /// - public RelayCommand RemoveSpoolCommand { get; set; } - - public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) + public MainViewVM(INotificationProvider notificationProvider) { _notification = notificationProvider; - _authentication = authentication; - _actionLogManager = actionLogManager; ManageRmlCommand = new RelayCommand(() => LoadActiveRML(SelectedRML.Guid), () => SelectedRML != null); RemoveRmlCommand = new RelayCommand(RemoveSelectedRml, () => SelectedRML != null); CloneRmlCommand = new RelayCommand(CloneSelectedRml, () => SelectedRML != null); @@ -270,9 +206,6 @@ namespace Tango.MachineStudio.RML.ViewModels ExportRMLFileCommand = new RelayCommand(ExportRmlFile, () => SelectedRML != null && IsFree); ImportRMLFileCommand = new RelayCommand(ImportRmlFile, () => IsFree); - - AddSpoolCommand = new RelayCommand(AddNewSpool); - RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); } public override void OnApplicationReady() @@ -282,177 +215,130 @@ namespace Tango.MachineStudio.RML.ViewModels private async void LoadRmls() { - try - { - IsFree = false; + if (_rmls_context != null) _rmls_context.Dispose(); - using (_notification.PushTaskItem("Loading Rmls...")) - { - if (_rmls_context != null) _rmls_context.Dispose(); + _rmls_context = ObservablesContext.CreateDefault(); + Rmls = await new RmlsCollectionBuilder(_rmls_context).SetAll().WithLiquidFactors().WithMediaProperties().BuildAsync(); - _rmls_context = ObservablesContext.CreateDefault(); - Rmls = await new RmlsCollectionBuilder(_rmls_context).SetAll().WithLiquidFactors().WithMediaProperties().BuildAsync(); - //Load CCT file names... - var ccts = await _rmls_context.Ccts.Select(x => new - { - x.Guid, - x.FileName - }).ToListAsync(); - - foreach (var rml in Rmls) - { - var cct = ccts.SingleOrDefault(x => x.Guid == rml.CctGuid); + //Load CCT file names... + var ccts = await _rmls_context.Ccts.Select(x => new + { + x.Guid, + x.FileName + }).ToListAsync(); - if (cct != null) - { - rml.Cct = new Cct() - { - Guid = cct.Guid, - FileName = cct.FileName, - }; - } - } - RmlsCollectionView = CollectionViewSource.GetDefaultView(Rmls); - RmlsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Rml.LastUpdated), ListSortDirection.Descending)); - //RmlsCollectionView.Filter = new Predicate(FilterCollection); + foreach (var rml in Rmls) + { + var cct = ccts.SingleOrDefault(x => x.Guid == rml.CctGuid); - RmlsCollectionView.Filter = (rml) => + if (cct != null) + { + rml.Cct = new Cct() { - Rml r = rml as Rml; - return String.IsNullOrWhiteSpace(RMLFilter) - || r.Name.ToLower().Contains(RMLFilter.ToLower()); + Guid = cct.Guid, + FileName = cct.FileName, }; - } } - catch (Exception ex) - { - LogManager.Log(ex, $"Error loading RMLS.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } } private async void LoadActiveRML(String guid) { using (_notification.PushTaskItem("Loading RML...")) { - try + IsFree = false; + + if (_active_context != null) { - IsFree = false; + _active_context.Dispose(); + } - if (_active_context != null) - { - _active_context.Dispose(); - } + _active_context = ObservablesContext.CreateDefault(); - _active_context = ObservablesContext.CreateDefault(); + CCTS = _active_context.Ccts + .Select(x => new CctModel() + { + Guid = x.Guid, + FileName = x.FileName, - CCTS = _active_context.Ccts - .Select(x => new CctModel() - { - Guid = x.Guid, - FileName = x.FileName, + }).ToObservableCollection(); - }).ToObservableCollection(); + CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); - CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); + LoadRmlProperties(); - LoadRmlProperties(); + ActiveRML = await new RmlBuilder(_active_context) + .Set(guid) + .WithActiveParametersGroup() + .WithLiquidFactors() + .WithCCT() + .BuildAsync(); - ActiveRML = await new RmlBuilder(_active_context) - .Set(guid) - .WithActiveParametersGroup() - .WithLiquidFactors() - .WithCCT() - .WithSpools() - .BuildAsync(); + if (ActiveRML.Cct != null) + { + SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid); + } - if (ActiveRML.Cct != null) + if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) + { + if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) { - SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid); + _notification.ShowError("Cannot load an RML with no process group."); + IsFree = true; + return; } - - if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) + else { - if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) - { - _notification.ShowError("Cannot load an RML with no process group."); - IsFree = true; - return; - } - else + ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); + group.Name = "Active Group"; + group.Active = true; + group.ProcessParametersTables.Add(new ProcessParametersTable() { - ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); - group.Name = "Active Group"; - group.Active = true; - group.ProcessParametersTables.Add(new ProcessParametersTable() - { - Name = "Process Table 1", - }); + Name = "Process Table 1", + }); - group.Rml = ActiveRML; + group.Rml = ActiveRML; - _active_context.ProcessParametersTablesGroups.Add(group); - _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); - await _active_context.SaveChangesAsync(); - LoadActiveRML(ActiveRML.Guid); - return; - } + _active_context.ProcessParametersTablesGroups.Add(group); + _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); + await _active_context.SaveChangesAsync(); + LoadActiveRML(ActiveRML.Guid); + return; } + } - ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); - ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); - ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); - - CalibrationDataViewVM = new CalibrationDataViewVM(_notification); - LiquidTypesRmls = ActiveRML.LiquidTypesRmls; - - foreach (var liquidTypeRml in LiquidTypesRmls) - { - CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType); + ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); + ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); + ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); - if (liquidTypeRml.DefaultCatData != null) - { - catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); - } + CalibrationDataViewVM = new CalibrationDataViewVM(_notification); + LiquidTypesRmls = ActiveRML.LiquidTypesRmls; - CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM); - } + foreach (var liquidTypeRml in LiquidTypesRmls) + { + CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType); - ColorConversionViewVM = new ColorConversionViewVM(_notification) + if (liquidTypeRml.DefaultCatData != null) { - RML = ActiveRML, - CCT = SelectedCCT, - LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData, - LiquidTypesRmls = LiquidTypesRmls, - }; + catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); + } - ColorCalibrationVM = new ColorCalibrationViewVM(_notification) - { - RML = ActiveRML, - LiquidTypes = LiquidTypesRmls.Where(x => x.LiquidType.HasPigment).ToList().Select(y => y.LiquidType).ToList(), - }; + CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM); + } - _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML); + ColorConversionViewVM = new ColorConversionViewVM(_notification) + { + RML = ActiveRML, + CCT = SelectedCCT, + LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData, + LiquidTypesRmls = LiquidTypesRmls, + }; - View.NavigateTo(RmlNavigationView.RmlView); + View.NavigateTo(RmlNavigationView.RmlView); - InvalidateRelayCommands(); + InvalidateRelayCommands(); - IsFree = true; - } - catch (Exception ex) - { - LogManager.Log($"Error loading RML '{ActiveRML.Name}'..."); - _notification.ShowError($"Error loading the selected thread.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } + IsFree = true; } } @@ -485,7 +371,6 @@ namespace Tango.MachineStudio.RML.ViewModels LinearMassDensityUnits = _active_context.LinearMassDensityUnits.ToObservableCollection(); FiberShapes = _active_context.FiberShapes.ToObservableCollection(); FiberSynths = _active_context.FiberSynths.ToObservableCollection(); - SpoolTypes = _active_context.SpoolTypes.ToObservableCollection(); } private async void AddNewRml() @@ -515,10 +400,8 @@ namespace Tango.MachineStudio.RML.ViewModels Rml rml = new Rml(); rml.Name = name; - rml.DisplayName = name; - rml.QualificationDate = DateTime.UtcNow; rml.Manufacturer = "Twine"; - rml.Code = Rmls.Count > 0 ? Rmls.Max(x => x.Code) + 1 : 1; + rml.Code = Rmls.Max(x => x.Code) + 1; rml.MediaMaterial = Materials.FirstOrDefault(); rml.MediaPurpose = Purposes.FirstOrDefault(); rml.MediaCondition = Conditions.FirstOrDefault(); @@ -540,9 +423,6 @@ namespace Tango.MachineStudio.RML.ViewModels _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); _active_context.Rmls.Add(rml); await _active_context.SaveChangesAsync(); - - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, rml.Name, rml, "Rml created using Machine Studio."); - LoadActiveRML(rml.Guid); IsFree = true; @@ -552,64 +432,25 @@ namespace Tango.MachineStudio.RML.ViewModels private async void RemoveSelectedRml() { - if (_notification.ShowQuestion("Removing the selected thread will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?")) + if (_notification.ShowQuestion("Removing the selected RML will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?")) { + IsFree = false; + using (_notification.PushTaskItem("Removing RML...")) { try { - IsFree = false; - - var rml_jobs = await _rmls_context.Jobs.Where(x => x.RmlGuid == SelectedRML.Guid).Include(x => x.Machine).OrderBy(x => x.Machine.SerialNumber).ToListAsync(); - - if (rml_jobs.Count > 0) - { - var vm = new RmlDeleteDialogViewVM(SelectedRML, Rmls.ToList(), rml_jobs.ToList()); - _notification.ShowModalDialog(vm, (x) => { }, () => { }); - - if (!vm.DialogResult) - { - return; - } - - //Perform actions... - using (var db = ObservablesContext.CreateDefault()) - { - foreach (var jobAction in vm.JobsActions) - { - if (jobAction.Action == RmlDeleteDialogViewVM.RmlDeleteJobAction.Delete) - { - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.JobDeleted, _authentication.CurrentUser.Guid, jobAction.Job.Name, jobAction.Job.Guid, $"Job deleted due to RML '{SelectedRML.Name}' being removed."); - await jobAction.Job.DeleteCascadeAsync(db); - } - else if (jobAction.Action == RmlDeleteDialogViewVM.RmlDeleteJobAction.Change) - { - var job = await db.Jobs.SingleOrDefaultAsync(x => x.Guid == jobAction.Job.Guid); - job.RmlGuid = jobAction.TargetRml.Guid; - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.JobSaved, _authentication.CurrentUser.Guid, jobAction.Job.Name, jobAction.Job.Guid, $"Job RML changed to '{jobAction.TargetRml.Name}' due to RML '{SelectedRML.Name}' being removed."); - } - } - - await db.SaveChangesAsync(); - } - } - await SelectedRML.DeleteCascadeAsync(_rmls_context); - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlDeleted, _authentication.CurrentUser, SelectedRML.Name, SelectedRML, "RML deleted from Machine Studio."); - LoadRmls(); } catch (Exception ex) { - LogManager.Log(ex, $"Error removing selected RML {SelectedRML?.Name}."); - _notification.ShowError($"An error occurred while trying to remove the selected RML.\n{ex.FlattenMessage()}"); - LoadRmls(); - } - finally - { - IsFree = true; + LogManager.Log(ex, $"Error removing selected RML {SelectedRML.Name}."); + _notification.ShowError($"An error occurred while trying to remove the selected RML.\n{ex.Message}"); } } + + IsFree = true; } } @@ -627,18 +468,15 @@ namespace Tango.MachineStudio.RML.ViewModels using (var context = ObservablesContext.CreateDefault()) { - var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().WithSpools().BuildAsync(); + var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().BuildAsync(); Rml cloned = new Rml(); - rml.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes); + rml.MapPrimitivesWithStrings(cloned); cloned.Code = Rmls.Max(x => x.Code) + 1; cloned.Guid = Guid.NewGuid().ToString(); cloned.ID = 0; cloned.Name = name; - cloned.DisplayName = name; - cloned.RmlQualificationLevel = RmlQualifications.Provisional; - cloned.QualificationDate = DateTime.UtcNow; ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); group.Name = rml.GetActiveProcessGroup().Name; @@ -664,19 +502,8 @@ namespace Tango.MachineStudio.RML.ViewModels cloned.LiquidTypesRmls.Add(l); } - foreach (var spool in rml.RmlsSpools) - { - RmlsSpool s = new RmlsSpool(); - spool.MapPropertiesTo(s, MappingFlags.ValueTypesOnly); - s.RmlGuid = cloned.Guid; - s.SpoolTypeGuid = spool.SpoolTypeGuid; - cloned.RmlsSpools.Add(s); - } - context.Rmls.Add(cloned); await context.SaveChangesAsync(); - - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, cloned.Name, cloned, "RML cloned from Machine Studio."); } LoadRmls(); @@ -731,11 +558,6 @@ namespace Tango.MachineStudio.RML.ViewModels ActiveProcessParametersTableView.Refresh(); } - private void OnRMLFilterChanged() - { - RmlsCollectionView.Refresh(); - } - private void RemoveLiquidFactor(LiquidTypesRml liquidFactor) { if (_notification.ShowQuestion("Removing this liquid factor will remove the liquid type association with the RML and will drop the calibration data. Are you sure?")) @@ -826,11 +648,6 @@ namespace Tango.MachineStudio.RML.ViewModels ActiveRML.LastUpdated = DateTime.UtcNow; - if (_rmlBeforeSave.QualificationLevel != ActiveRML.QualificationLevel) - { - ActiveRML.QualificationDate = DateTime.UtcNow; - } - if (SelectedCCT != null) { if (SelectedCCT.IsNew) @@ -848,26 +665,18 @@ namespace Tango.MachineStudio.RML.ViewModels } } - var rmlAfter = RmlDTO.FromObservable(ActiveRML); - await _active_context.SaveChangesAsync(); - - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio."); - - _rmlBeforeSave = rmlAfter; - - LoadActiveRML(ActiveRML.Guid); } } catch (Exception ex) { LogManager.Log(ex, $"Error saving RML {ActiveRML.Name}"); - _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; + _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.Message}"); } + + LoadActiveRML(ActiveRML.Guid); + + IsFree = true; } private void BackToRmls() @@ -883,12 +692,6 @@ namespace Tango.MachineStudio.RML.ViewModels String file = GetCCTFileOpen(); if (file != null) { - if (CCTS.ToList().Exists(x => x.FileName == Path.GetFileName(file))) - { - _notification.ShowError("The selected CCT file already exists on the database. Please select the CCT file from the dropdown box."); - return; - } - CctModel cctModel = new CctModel(); cctModel.Guid = Guid.NewGuid().ToString(); cctModel.IsNew = true; @@ -1001,8 +804,6 @@ namespace Tango.MachineStudio.RML.ViewModels var rmlFile = await Rml.FromRmlFile(db, json); db.Rmls.Add(rmlFile); - - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlImported, _authentication.CurrentUser, rmlFile.Name, rmlFile, "RML imported from Machine Studio."); } await db.SaveChangesAsync(); @@ -1059,26 +860,5 @@ namespace Tango.MachineStudio.RML.ViewModels } #endregion - - #region Spools - - private void AddNewSpool() - { - _active_context.RmlsSpools.Add(new RmlsSpool() - { - Rml = ActiveRML, - }); - } - - private void RemoveSpool() - { - if (SelectedSpool != null) - { - _active_context.RmlsSpools.Remove(SelectedSpool); - ActiveRML.RmlsSpools.Remove(SelectedSpool); - } - } - - #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RmlDeleteDialogViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RmlDeleteDialogViewVM.cs deleted file mode 100644 index b4c6c6274..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RmlDeleteDialogViewVM.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using Tango.Core; -using Tango.SharedUI; - -namespace Tango.MachineStudio.RML.ViewModels -{ - public class RmlDeleteDialogViewVM : DialogViewVM - { - public enum RmlDeleteJobAction - { - Delete, - Change - } - - public class RmlDeleteJob : ExtendedObject - { - public Job Job { get; set; } - public Machine Machine { get; set; } - private RmlDeleteJobAction _action; - - public RmlDeleteJobAction Action - { - get { return _action; } - set { _action = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(IsDelete)); } - } - - public bool IsDelete - { - get { return Action == RmlDeleteJobAction.Delete; } - } - - - public Rml TargetRml { get; set; } - - public override string ToString() - { - return $"{Machine.SerialNumber} => {Job.Name} => {Action} {(Action == RmlDeleteJobAction.Change ? $" => {TargetRml.Name}" : String.Empty)}"; - } - } - - private List _jobsToDelete; - - private List _jobsActions; - public List JobsActions - { - get { return _jobsActions; } - set { _jobsActions = value; RaisePropertyChangedAuto(); } - } - - public Rml Rml { get; set; } - - public List Rmls { get; set; } - - public List Actions { get; set; } - - public RmlDeleteDialogViewVM(Rml rml, List rmls, List jobsToDelete) - { - Rml = rml; - Rmls = rmls.Where(x => x.Guid != rml.Guid).ToList(); - _jobsToDelete = jobsToDelete; - JobsActions = new List(); - - Actions = new List() - { - RmlDeleteJobAction.Delete, - RmlDeleteJobAction.Change - }; - } - - public override void OnShow() - { - base.OnShow(); - - List list = new List(); - - foreach (var job in _jobsToDelete) - { - RmlDeleteJob deleteJob = new RmlDeleteJob(); - deleteJob.Job = job; - deleteJob.Action = RmlDeleteJobAction.Delete; - deleteJob.Machine = job.Machine; - deleteJob.TargetRml = Rmls.FirstOrDefault(x => x.Guid != Rml.Guid); - - list.Add(deleteJob); - } - - JobsActions = list; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml deleted file mode 100644 index 116500f80..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - Liquid Type: - - - - - - - - - - - - - - LIQUID FACTOR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Factor: - - - - - - - Warning: - - - - - - - - - - - - - - - LINEARIZATION - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs deleted file mode 100644 index c29bb68fb..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs +++ /dev/null @@ -1,42 +0,0 @@ -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; -using Tango.MachineStudio.RML.ViewModels; - -namespace Tango.MachineStudio.RML.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(DataContext is ColorCalibrationViewVM) - { - ColorCalibrationViewVM vm = (ColorCalibrationViewVM)DataContext; - vm.PlotControl = CalibrationPlot; - vm.LinearizationPlotControl = LinearizationPlot; - vm.LABLinearizationPlotControl = LABLinearizationPlot; - vm.Loading(); - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml deleted file mode 100644 index aec12aa63..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - HEAD CLEANING PARAMETERS - - - - - - - - - - CLEANER - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml.cs deleted file mode 100644 index 8d036efa5..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/HeadCleaningParametersView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.RML.Views -{ - /// - /// Interaction logic for SpoolsView.xaml - /// - public partial class HeadCleaningParametersView : UserControl - { - public HeadCleaningParametersView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml index e52ac4ece..ab5207722 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineStudio.RML.Views" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml index 03bf65522..b85fd2c12 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml @@ -32,7 +32,7 @@ - ACTIVE PROCESS GROUP + ACTIVE PROCESS GROUP @@ -70,7 +70,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml deleted file mode 100644 index 7745848c1..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - DELETE - - - - - - - - - - - - - - - - - The following jobs must be removed or change thread type before the selected thread can be deleted. - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml.cs deleted file mode 100644 index 96254c03a..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlDeleteDialogView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.RML.Views -{ - /// - /// Interaction logic for RmlDeleteDialogView.xaml - /// - public partial class RmlDeleteDialogView : UserControl - { - public RmlDeleteDialogView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index b6c91f066..50f6a6297 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -4,7 +4,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.MachineStudio.RML" - xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" @@ -20,7 +19,6 @@ - @@ -30,7 +28,7 @@ - +