diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-12-20 15:47:33 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-12-20 15:47:33 +0200 |
| commit | 5ab11fca7d8094678b1c675cf6a42011f7f2c3de (patch) | |
| tree | 9d1fc6c52f47d4d06421a31d22223640d34c3a42 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels | |
| parent | fd24c47e3c812d00e5d3889dd646ba9f3d834297 (diff) | |
| parent | ad251a8c9af9b1728cc53acfe672cee83949c71b (diff) | |
| download | Tango-5ab11fca7d8094678b1c675cf6a42011f7f2c3de.tar.gz Tango-5ab11fca7d8094678b1c675cf6a42011f7f2c3de.zip | |
Merged Thread Extensions Bugs branch.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels')
4 files changed, 485 insertions, 199 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs index a89a2e33c..e13e016c5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs @@ -138,35 +138,18 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } } - private ObservableCollection<ColorProcessFactor> _minInkUptake; - public ObservableCollection<ColorProcessFactor> MinInkUptake - { - get - { - return _minInkUptake; - } - set - { - _minInkUptake = value; - RaisePropertyChangedAuto(); - } - } - private ObservableCollection<ColorProcessFactor> _maxInkUptake; - public ObservableCollection<ColorProcessFactor> MaxInkUptake + private ObservableCollection<ColorProcessInkUptake> _colorProcessInkUptakeData; + + public ObservableCollection<ColorProcessInkUptake> ColorProcessInkUptakeData { - get - { - return _maxInkUptake; - } - set - { - _maxInkUptake = value; + get { return _colorProcessInkUptakeData; } + set { + _colorProcessInkUptakeData = value; RaisePropertyChangedAuto(); } } - - + private PlotProperties _cyanPlot; public PlotProperties CyanPlot @@ -456,7 +439,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var currentcolorProcessParameter = _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == RMLExtemtionGUID && x.MachineGuid == SelectedMachineGUID).FirstOrDefault(); if (currentcolorProcessParameter != null) { - SelectedColorProcessParameter = new ColorProcessParametersBuilder(_active_context).Set(currentcolorProcessParameter.Guid).WithColorProcessData().WithColorProcessFactor().Build(); + SelectedColorProcessParameter = new ColorProcessParametersBuilder(_active_context).Set(currentcolorProcessParameter.Guid).WithColorProcessData().WithColorProcessFactor().WithColorProcessInkUptake().Build(); } if (SelectedColorProcessParameter == null) @@ -473,17 +456,20 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); - SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MININKUPTAKEZONE1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MAXINKUPTAKEZONE1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MININKUPTAKEZONE2, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MAXINKUPTAKEZONE2, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); _active_context.ColorProcessParameters.Add(SelectedColorProcessParameter); _active_context.SaveChangesAsync(); } + else if(SelectedColorProcessParameter.ColorProcessInkUptake.Count == 0) + { + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MININKUPTAKEZONE1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MAXINKUPTAKEZONE1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MININKUPTAKEZONE2, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessInkUptake.Add(new ColorProcessInkUptake() { InkUptakeZoneType = InkUptakeZoneTypes.MAXINKUPTAKEZONE2, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + } } }); @@ -498,10 +484,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels Factor200ProcessData = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 200).ToObservableCollection(); - MinInkUptake = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 1).ToObservableCollection(); - - MaxInkUptake = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 1111).ToObservableCollection(); - + ColorProcessInkUptakeData = SelectedColorProcessParameter.ColorProcessInkUptake.ToObservableCollection(); + RemovedColorProcessDataBeforeSave.Clear(); var cyanDataList = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == FactorColors.CYAN).ToList().OrderBy(x => x.InkNlCm).ToList(); @@ -672,31 +656,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var processData = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == color).ToList(); double target100 = FactorTarget.GetFactor100(color); double target200 = FactorTarget.GetFactor200(color); - //ColorProcessData closest100 = null; - //ColorProcessData closest200 = null; - - //var minDifference100 = double.MaxValue; - //var minDifference200 = double.MaxValue; - + if (processData.Count == 0) return; - - //foreach (var item in processData) - //{ - // var colorvalue = isLtype ? item.L : item.B; - // var difference100 = Math.Abs(colorvalue - target100); - // if (minDifference100 > difference100) - // { - // minDifference100 = (int)difference100; - // closest100 = item; - // } - // var difference200 = Math.Abs(colorvalue - target200); - // if (minDifference200 > difference200) - // { - // minDifference200 = (int)difference200; - // closest200 = item; - // } - //} + var point100 = GetTargetPoint(processData, target100, isLtype); UpdateFactor(Factor100ProcessData.FirstOrDefault(x => x.FactorColor == color), point100); var point200 = GetTargetPoint(processData, target200, isLtype); @@ -716,12 +679,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels for (int index = 1; index < distinctItems.Count; index++) { var item = distinctItems[index]; + if (prevItem.L > item.L && (factor > prevItem.L || (factor <= prevItem.L && factor >= item.L)) || (prevItem.L <= item.L && (factor > prevItem.L || (factor >= prevItem.L && factor <= item.L))) || ((index + 1) == distinctItems.Count && calculatedX == 0.0)) { calculatedX = CalculateXValue(factor, new DataPoint(prevItem.InkNlCm, prevItem.L), new DataPoint(item.InkNlCm, item.L)); - break; + //Yellow line is ascending line( up line), others - descending line(down) + if (isLtype) + break; } prevItem = item; @@ -793,10 +759,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { factordata.LastUpdated = DateTime.UtcNow; } + foreach (var inkdata in SelectedColorProcessParameter.ColorProcessInkUptake) + { + inkdata.LastUpdated = DateTime.UtcNow; + } await _active_context.SaveChangesAsync(); - LoadColorParameters(); + // LoadColorParameters(); } catch (Exception ex) { @@ -812,6 +782,104 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #endregion + + #region export to excel + + public void WritetoExcel(ColorParametrsExcelModel colorParametrsExcelModel, string machineGuid) + { + if (_active_context == null) + { + _active_context = ObservablesContext.CreateDefault(); + } + var colorProcessParametercur = _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == RMLExtemtionGUID && x.MachineGuid == machineGuid).FirstOrDefault(); + if (colorProcessParametercur == null) + return; + var colorProcessParameter = new ColorProcessParametersBuilder(_active_context).Set(colorProcessParametercur.Guid).WithColorProcessData().WithColorProcessFactor().WithColorProcessInkUptake().Build(); + var factor_cyan100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.CYAN && x.FactorPercent == 100).FirstOrDefault(); + if (factor_cyan100 != null) + { + colorParametrsExcelModel.Factor_100__C = factor_cyan100.InkNlCm; + colorParametrsExcelModel.Factor_100__Cyan_L = factor_cyan100.L; + colorParametrsExcelModel.Factor_100__Cyan_A = factor_cyan100.A; + colorParametrsExcelModel.Factor_100__Cyan_B = factor_cyan100.B; + } + + var factor_magenta100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.MAGENTA && x.FactorPercent == 100).FirstOrDefault(); + if (factor_magenta100 != null) + { + colorParametrsExcelModel.Factor_100__M = factor_magenta100.InkNlCm; + colorParametrsExcelModel.Factor_100__Magenta_L = factor_magenta100.L; + colorParametrsExcelModel.Factor_100__Magenta_A = factor_magenta100.A; + colorParametrsExcelModel.Factor_100__Magenta_B = factor_magenta100.B; + } + + var factor_yellow100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.YELLOW && x.FactorPercent == 100).FirstOrDefault(); + if (factor_yellow100 != null) + { + colorParametrsExcelModel.Factor_100__Y = factor_yellow100.InkNlCm; + colorParametrsExcelModel.Factor_100__Yellow_L = factor_yellow100.L; + colorParametrsExcelModel.Factor_100__Yellow_A = factor_yellow100.A; + colorParametrsExcelModel.Factor_100__Yellow_B = factor_yellow100.B; + } + + var factor_key100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.BLACK && x.FactorPercent == 100).FirstOrDefault(); + if (factor_key100 != null) + { + colorParametrsExcelModel.Factor_100_K = factor_key100.InkNlCm; + colorParametrsExcelModel.Factor_100__Key_L = factor_key100.L; + colorParametrsExcelModel.Factor_100__Key_A = factor_key100.A; + colorParametrsExcelModel.Factor_100__Key_B = factor_key100.B; + } + + var factor_cyan200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.CYAN && x.FactorPercent == 200).FirstOrDefault(); + if (factor_cyan200 != null) + { + colorParametrsExcelModel.Factor_200_C = factor_cyan200.InkNlCm; + colorParametrsExcelModel.Factor_200__Cyan_L = factor_cyan200.L; + colorParametrsExcelModel.Factor_200__Cyan_A = factor_cyan200.A; + colorParametrsExcelModel.Factor_200__Cyan_B = factor_cyan200.B; + } + + var factor_magenta200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.MAGENTA && x.FactorPercent == 200).FirstOrDefault(); + if (factor_magenta200 != null) + { + colorParametrsExcelModel.Factor_200__Magenta = factor_magenta200.InkNlCm; + colorParametrsExcelModel.Factor_200__Magenta_L = factor_magenta200.L; + colorParametrsExcelModel.Factor_200__Magenta_A = factor_magenta200.A; + colorParametrsExcelModel.Factor_200__Magenta_B = factor_magenta200.B; + } + + var factor_yellow200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.YELLOW && x.FactorPercent == 200).FirstOrDefault(); + if (factor_yellow200 != null) + { + colorParametrsExcelModel.Factor_200__Yellow = factor_yellow200.InkNlCm; + colorParametrsExcelModel.Factor_200__Yellow_L = factor_yellow200.L; + colorParametrsExcelModel.Factor_200__Yellow_A = factor_yellow200.A; + colorParametrsExcelModel.Factor_200__Yellow_B = factor_yellow200.B; + } + + var factor_key200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.BLACK && x.FactorPercent == 200).FirstOrDefault(); + if (factor_key200 != null) + { + colorParametrsExcelModel.Factor_200__Key = factor_key200.InkNlCm; + colorParametrsExcelModel.Factor_200__Key_L = factor_key200.L; + colorParametrsExcelModel.Factor_200__Key_A = factor_key200.A; + colorParametrsExcelModel.Factor_200__Key_B = factor_key200.B; + } + + foreach (var inkUptakeZone in colorProcessParameter.ColorProcessInkUptake) + { + if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MININKUPTAKEZONE1) + colorParametrsExcelModel.Min_Ink_Uptake_Zone1 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MININKUPTAKEZONE2) + colorParametrsExcelModel.Min_Ink_Uptake_Zone2 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MAXINKUPTAKEZONE1) + colorParametrsExcelModel.Max_Ink_Uptake_Zone1 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MAXINKUPTAKEZONE2) + colorParametrsExcelModel.Max_ink_uptake__Zone2 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + } + } + #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 b33ead70a..4802e0af1 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 @@ -28,11 +28,19 @@ using Tango.MachineStudio.ThreadExtensions.Views; using Tango.MachineStudio.ThreadExtensions.Models; using Tango.Settings; using System.Reflection; +using Tango.Core.Helpers; +using Tango.Documents; namespace Tango.MachineStudio.ThreadExtensions.ViewModels { public class MainViewVM : StudioViewModel<IMainView> { + public enum MachineTestResultsTabs + { + ColorParameters, + TestResults + } + private INotificationProvider _notification; private IAuthenticationProvider _authentication; private IActionLogManager _actionLogManager; @@ -286,11 +294,27 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } + private MachineTestResultsTabs PreviosSelectedTab { get; set; } + + private MachineTestResultsTabs _selectedTab; + + public MachineTestResultsTabs SelectedTab + { + get { return _selectedTab; } + set { + PreviosSelectedTab = _selectedTab; + _selectedTab = value; + OnSelectedMachineTestResultsTabChanged(); + RaisePropertyChangedAuto(); + } + } + #endregion #region commands public RelayCommand SaveCommand { get; set; } + public RelayCommand ExportToFileCommand { get; set; } public RelayCommand ManageRmlExtensionCommand { get; set; } @@ -298,8 +322,11 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private async void BackToThreadExtensionViews(object obj) { - View.NavigateTo(RMLExtensionNavigationView.RMLExtensionsView); - await LoadRmlExtentions(); + if (_notification.ShowQuestion("Are you sure you want to exit the RML without saving changes?")) + { + View.NavigateTo(RMLExtensionNavigationView.RMLExtensionsView); + await LoadRmlExtentions(); + } } public RelayCommand AddManufacturerItemCommand { get; set; } @@ -766,14 +793,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels BackToThreadExtensionViewsCommand = new RelayCommand(BackToThreadExtensionViews, () => IsFree); SaveCommand = new RelayCommand(Save, () => IsFree); + ExportToFileCommand = new RelayCommand(ExportRMLToExcel, () => IsFree); ManageRmlExtensionCommand = new RelayCommand(() => LoadActiveRMLExtension(SelectedRMLExtension.Guid), () => SelectedRMLExtension != null); AddManufacturerItemCommand = new RelayCommand(AddManufacturerItem); - EditManufacturerItemCommand = new RelayCommand(EditManufacturerItem, () => ActiveRML.Manufacturer != ""); + EditManufacturerItemCommand = new RelayCommand(EditManufacturerItem, () => ActiveRML !=null && ActiveRML.Manufacturer != ""); AddBrandItemCommand = new RelayCommand(AddBrandItem); - EditBrandItemCommand = new RelayCommand(EditBrandItem, () => ActiveRMLExtension.YarnBrand != null); + EditBrandItemCommand = new RelayCommand(EditBrandItem, () => ActiveRMLExtension != null && ActiveRMLExtension.YarnBrand != null); AddEndUseItemCommand = new RelayCommand(AddEndUseItem); EditEndUseItemCommand = new RelayCommand(EditEndUseItem); @@ -1102,6 +1130,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorParametersVewVM.SelectedMachineGUID = SelectedMachine.Guid; } + if(TestResultsViewVM != null) + { + TestResultsViewVM.SelectedMachineGUID = SelectedMachine.Guid; + } } #endregion @@ -1148,5 +1180,161 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #endregion + + #region selections + + private void OnSelectedMachineTestResultsTabChanged() + { + if(SelectedTab == MachineTestResultsTabs.ColorParameters) + { + //if(PreviosSelectedTab == MachineTestResultsTabs.TestResults && TestResultsViewVM != null) + //{ + // TestResultsViewVM.Save(); + //} + //save + //if (_notification.ShowQuestion("Are you sure you want to exit this page without saving changes?")) + + } + else if(SelectedTab == MachineTestResultsTabs.TestResults) + { + //if (PreviosSelectedTab == MachineTestResultsTabs.ColorParameters && ColorParametersVewVM != null) + //{ + // ColorParametersVewVM.Save(); + //} + } + } + + #endregion + + #region Export / Import Excel + + public void ExportRMLToExcel() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel Documents|*.xlsx"; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem("Exporting RML to file...")) + { + Task.Factory.StartNew(() => + { + try + { + IsFree = false; + + Stream stream = null; + bool dispose = false; + String file = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Templates\\ExportRMLTemplate.xlsx"; + + if (File.Exists(file)) + { + stream = File.OpenRead(file); + dispose = true; + } + else + { + stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.ThreadExtensions.Templates.ExportRMLTemplate.xlsx"); + } + + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, data.Length); + File.WriteAllBytes(dlg.FileName, data); + + if (dispose) + { + stream.Dispose(); + } + + ExcelWriter writer = new ExcelWriter(dlg.FileName); + //ActiveRMLExtension = await new RmlExtensionsBuilder(_active_context) + // .Set(guid) + // .WithUser() + // .BuildAsync(); + + //ActiveRML = new RmlBuilder(_active_context) + // .Set(SelectedRMLExtension.RMLGuid) + // .Build(); + + List<ThreadCharacteristicsExcelModel> threadCharacteristicsExelModels = new List<ThreadCharacteristicsExcelModel>(); + ThreadCharacteristicsExcelModel model = new ThreadCharacteristicsExcelModel(); + model.ThreadName = ActiveRML.Name; + model.Manufacturer = ActiveRML.Manufacturer == null? "": ActiveRML.Manufacturer; + model.Brand = ActiveRMLExtension.YarnBrand == null ? "": ActiveRMLExtension.YarnBrand.Name; + model.Country = ActiveRMLExtension.Country == null? "" : ActiveRMLExtension.Country; + model.EndUse = ActiveRML.MediaPurpose == null ? "" : ActiveRML.MediaPurpose.Name; + model.Applications = ActiveRMLExtension.YarnApplication == null ? "" : ActiveRMLExtension.YarnApplication.Name; + model.IndustrySector = ActiveRMLExtension.YarnIndustrysector == null ? "" : ActiveRMLExtension.YarnIndustrysector.Name; + model.Material = ActiveRML.MediaMaterial == null ? "" : ActiveRML.MediaMaterial.Name; + model.Type = ActiveRMLExtension.YarnType == null ? "" : ActiveRMLExtension.YarnType.Name; + model.SubFamily = ActiveRMLExtension.YarnSubFamily == null ? "" : ActiveRMLExtension.YarnSubFamily.Name; + model.Family = ActiveRMLExtension.YarnFamily == null ? "" : ActiveRMLExtension.YarnFamily.Name; + model.Group = ActiveRMLExtension.YarnGroup == null ? "" : ActiveRMLExtension.YarnGroup.Name; + model.Texturing = ActiveRMLExtension.YarnTexturing == null ? "" : ActiveRMLExtension.YarnTexturing.Name; + model.Geometry = ActiveRML.FiberShape == null ? "" : ActiveRML.FiberShape.Name; + model.Color = ActiveRMLExtension.YarnWhiteShade == null ? "" : ActiveRMLExtension.YarnWhiteShade.Name; + model.GlossLevel = ActiveRMLExtension.YarnGlossLevel == null ? "" : ActiveRMLExtension.YarnGlossLevel.Name; + model.LinearDensity = ActiveRML.FiberSize; + model.Unit = ActiveRML.LinearMassDensityUnit == null ? "" : ActiveRML.LinearMassDensityUnit.Name; + model.Plies = (int) ActiveRML.RMLPlies; + model.FilamentCountPerPlie = ActiveRML.PliesPerFiber; + model.LinearDensityCount = ActiveRML.DencityCount; + model.CountDen = ActiveRML.DencityCount; + model.FiberCount = ActiveRML.FiberCount; + model.Twist = ActiveRMLExtension.TwistTpm; + model.TwistDirection = ActiveRMLExtension.YarnTwistDirections.ToDescription(); + threadCharacteristicsExelModels.Add(model); + writer.WriteData(threadCharacteristicsExelModels, "Thread characteristics", 2); + + List<ColorParametrsExcelModel> colorParametrsExcelList = new List<ColorParametrsExcelModel>(); + + List<TestResultsExcelModel> testResultsExcelModelList = new List<TestResultsExcelModel>(); + + foreach(var machine in Machines) + { + if (machine.HasRMLTest) + { + ColorParametrsExcelModel colorParametrsExcelModel = new ColorParametrsExcelModel(); + colorParametrsExcelModel.Thread_name = ActiveRML.Name; + colorParametrsExcelModel.MachineNumber = machine.SerialNumber.ToString(); + colorParametrsExcelModel.White_point_L = ActiveRML.WhitePointL; + colorParametrsExcelModel.White_point_a = ActiveRML.WhitePointA; + colorParametrsExcelModel.White_point_B = ActiveRML.WhitePointB; + ColorParametersVewVM.WritetoExcel(colorParametrsExcelModel, machine.Guid); + + colorParametrsExcelList.Add(colorParametrsExcelModel); + + TestResultsViewVM.LoadTestResultsExcel(testResultsExcelModelList, machine.Guid, machine.SerialNumber); + } + } + + writer.WriteData(colorParametrsExcelList, "Color parameters"); + writer.WriteData(testResultsExcelModelList.OrderBy(x => x.Machine_number), "Machine tests results"); + + writer.Dispose(); + + InvokeUI(() => + { + _notification.ShowInfo("RML extensions exported successfully."); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error exporting RML extensions to {dlg.FileName}"); + + InvokeUI(() => + { + _notification.ShowError($"An error occurred while trying to export the RML extensions. Make sure the selected excel file is closed and data is valid.\n{ex.FlattenMessage()}"); + }); + } + finally + { + IsFree = true; + } + }); + } + } + } + + #endregion } } 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 4e7d84e7f..41be789ed 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 @@ -12,6 +12,7 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.ThreadExtensions.Models; using Tango.SharedUI; namespace Tango.MachineStudio.ThreadExtensions.ViewModels @@ -63,139 +64,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - public RelayCommand ExportToFileCommand { get; set; } + public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; - ExportToFileCommand = new RelayCommand(ExportToFile); - } - - #region save - // public void Save(ObservablesContext active_context) - //{ - // try - // { - // IsFree = false; - - // TestResult.LastUpdated = DateTime.UtcNow; - - // var RmlExtensionTestResultAfterChange = RmlExtensionTestResultDTO.FromObservable(TestResult); - - // active_context.SaveChanges(); - // } - // catch (Exception ex) - // { - // LogManager.Log(ex, "Could not update RmlExtension TestResult."); - // _notification.ShowError($"An error occurred while trying to save RmlExtension TestResult.\n{ex.Message}"); - // } - // finally - // { - // IsFree = true; - // } - //} - #endregion - - private void ExportToFile() - { - SaveFileDialog dlg = new SaveFileDialog(); - try - { - dlg.Title = $"Export excel calibration file for {TestResult.Name}"; - dlg.Filter = "Text Files|*.txt"; - dlg.DefaultExt = ".txt"; - dlg.FileName = $"RML_EXTENSION_{TestResult.Name}.txt"; - if (dlg.ShowDialog().Value) - { - using (StreamWriter outputFile = new StreamWriter(dlg.FileName)) - { - outputFile.WriteLine(String.Format($" {TestResult.Name.ToUpper()} ")); - outputFile.WriteLine(""); - outputFile.WriteLine(""); - outputFile.WriteLine(" Dryer temperature"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Dryer temperature : {TestResult.DryerTemperature.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel temperature : {TestResult.TunnelTemperature.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel flow : {TestResult.TunnelFlow.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel AVG temperature : {TestResult.TunnelAvgTemperature.ToString()}")); - outputFile.WriteLine(""); - outputFile.WriteLine(""); - outputFile.WriteLine(" Tension through the thread path"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Head : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); - outputFile.WriteLine(String.Format($" After dryer : {TestResult.TensionAfterDryerMin.ToString()} - {TestResult.TensioinAfterDryerMax.ToString()}")); - outputFile.WriteLine(String.Format($" Winder : {TestResult.BtsrMin.ToString()} - {TestResult.BtsrMax.ToString()}")); - outputFile.WriteLine(String.Format($" BTSR : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); - outputFile.WriteLine(String.Format($" Puller tension : {TestResult.PullerTensionMin.ToString()} - {TestResult.PullerTensionMax.ToString()}")); - outputFile.WriteLine(String.Format($" Winder exit tension: {TestResult.ExitTensionMin.ToString()} - {TestResult.ExitTensionMax.ToString()}")); - - outputFile.WriteLine(""); - outputFile.WriteLine(" Rubbing results"); - outputFile.WriteLine(""); - outputFile.WriteLine(" Color DeltaE CIE 100 % GS 100% DeltaETestResult CIE 200 % GS 200% "); - foreach (var rubbingResult in TestResult.RubbingResults) - { - StringBuilder sb = new StringBuilder(); - //sb.Append(" Color: "); - sb.Append($" { rubbingResult.TestResultColor.ToString()} "); - //sb.Append(" DeltaE CIE 100 % : "); - sb.Append($" { rubbingResult.DeltaeCie100.ToString()} "); - //sb.Append(" GS 100% : "); - sb.Append($" { rubbingResult.Gs100Min.ToString()}-{rubbingResult.Gs100Max.ToString()} "); - //sb.Append(" DeltaE CIE 200 % : "); - sb.Append($" { rubbingResult.DeltaeCie200.ToString()} "); - //sb.Append(" GS 200% : "); - sb.Append($" { rubbingResult.Gs200Min.ToString()}-{rubbingResult.Gs200Max.ToString()} "); - outputFile.WriteLine(sb); - } - outputFile.WriteLine(""); - outputFile.WriteLine(" Mechanical properties"); - outputFile.WriteLine(""); - outputFile.WriteLine(" %Color Color Load at Maximum Load(N) STDEV Percentage Strain at Maximum Load STDEV "); - foreach (var result in TestResult.TensileResults) - { - StringBuilder sb = new StringBuilder(); - //sb.Append(" % Color: "); - sb.Append($" { result.ColorPercent.ToString()}"); - //sb.Append(" Color : "); - sb.Append($" { result.TestResultColor.ToString()}"); - //sb.Append(" Load at Maximum Load(N) : "); - sb.Append($" { result.MaxLoad.ToString()}"); - //sb.Append(" STDEV : "); - sb.Append($" { result.StdevMaxLoad.ToString()}"); - //sb.Append(" Percentage Strain at Maximum Load: "); - sb.Append($" {result.StrainMaxLoad.ToString()}"); - //sb.Append(" STDEV : "); - sb.Append($" { result.StdevStrainMaxLoad.ToString()}"); - outputFile.WriteLine(sb); - } - outputFile.WriteLine(""); - outputFile.WriteLine(" Uniformity"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Zone1 : {TestResult.SeverityZone1Min.ToString()} - {TestResult.SeverityZone1Max.ToString()}")); - outputFile.WriteLine(String.Format($" Zone2 : {TestResult.SeverityZone2Min.ToString()} - {TestResult.SeverityZone2Max.ToString()}")); - outputFile.WriteLine(""); - outputFile.WriteLine(" COF"); - outputFile.WriteLine(""); - outputFile.WriteLine(" Thread name Lub Version COF Lub amount "); - outputFile.WriteLine(String.Format($" REF {TestResult.RefLubVersion} {TestResult.RefCof.ToString()} {TestResult.RefLub.ToString()}")); - outputFile.WriteLine(String.Format($" {ThreadName} {TestResult.ThreadLubVersion} {TestResult.ThreadCof.ToString()} {TestResult.ThreadLub.ToString()}")); - - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Comments: {TestResult.Comment}")); - outputFile.WriteLine(String.Format($" Conclusion: {TestResult.Conclusions}")); - outputFile.WriteLine(""); - outputFile.Flush(); - } - - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error exporting excel file " + dlg.FileName); - _notification.ShowError("An error occurred while trying to export the test result data."); - } } + + } } 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 cc3a49a23..c1fb4497f 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 @@ -352,10 +352,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var processParametersTables = activeProcessParametersGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToSynchronizedObservableCollection().FirstOrDefault(); processParametersTables.DryerZone1Temp = SelectedTab.TestResult.DryerTemperature == null? 0 : (double)SelectedTab.TestResult.DryerTemperature; - processParametersTables.RBlowerFlow = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; - processParametersTables.RBlowerTemp = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; ; - processParametersTables.LBlowerFlow = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; ; - processParametersTables.LBlowerTemp = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; ; + processParametersTables.RBlowerFlow = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; + processParametersTables.RBlowerTemp = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; + processParametersTables.LBlowerFlow = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; + processParametersTables.LBlowerTemp = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; await context.SaveChangesAsync(); } } @@ -386,7 +386,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels _active_context.SaveChanges(); }); - LoadTestResults(); + // LoadTestResults(); } catch (Exception ex) { @@ -402,5 +402,159 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #endregion + + public async void LoadTestResultsExcel(List<TestResultsExcelModel> testResultsExcelModelList, string machineGUID, string machineSerialNumber) + { + try + { + IsFree = false; + if (_active_context == null) + { + _active_context = ObservablesContext.CreateDefault(); + } + + using (_notification.PushTaskItem("Loading Test Results Parameters for save in Excel file ...")) + { + SynchronizedObservableCollection<RmlExtensionTestResult> testResults = SelectedTestResults; + if (SelectedMachineGUID != machineGUID) + { + var loadedtestResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(machineGUID).WithRubbingAndTensileResults().BuildAsync(); + testResults = loadedtestResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); + + } + foreach (var testresult in testResults) + { + TestResultsExcelModel testResultsExcelModel = new TestResultsExcelModel(); + testResultsExcelModel.Thread_name_test_results = ThreadName; + testResultsExcelModel.Machine_number = machineSerialNumber; + testResultsExcelModel.Test_results_name__tab = testresult.Name; + + testResultsExcelModel.Dryer_temp = testresult.DryerTemperature == null ? 0 : (int)testresult.DryerTemperature; + testResultsExcelModel.Dryer_flow = 0; + testResultsExcelModel.Tunnel_temp = testresult.TunnelTemperature == null ? 0 : (int)testresult.TunnelTemperature; + testResultsExcelModel.Tunnel_flow = testresult.TunnelFlow == null ? 0 : (int)testresult.TunnelFlow; + + testResultsExcelModel.Tension_in_head = testresult.TensionHeadMin == null ? "" : testresult.TensionHeadMin.ToString(); + testResultsExcelModel.Tension_after_dryer = testresult.TensionAfterDryerMin == null ? "" : testresult.TensionAfterDryerMin.ToString(); + testResultsExcelModel.Tension_in_winder = testresult.TensionWinderMin == null ? "" : testresult.TensionWinderMin.ToString(); + testResultsExcelModel.BTSR = testresult.BtsrMin == null ? "" : testresult.BtsrMin.ToString(); + testResultsExcelModel.Puller_tension = testresult.PullerTensionMin == null ? "" : testresult.PullerTensionMin.ToString(); + testResultsExcelModel.Winder_tension = testresult.ExitTensionMin == null ? "" : testresult.ExitTensionMin.ToString(); + + foreach (var tensileResult in testresult.TensileResults) + { + if (tensileResult.TestResultColor == TestResultColors.CYAN) + { + if (tensileResult.ColorPercent == 100) + { + testResultsExcelModel.Load_N_100_C = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_100_C = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_100_C = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_100_C = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_100_C_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_100_C_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + else if (tensileResult.ColorPercent == 200) + { + testResultsExcelModel.Load__N_200_C = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_200_C = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_200_C = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_200_C = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_200_C_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_200_C_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + } + else if (tensileResult.TestResultColor == TestResultColors.BLACK) + { + if (tensileResult.ColorPercent == 100) + { + testResultsExcelModel.Load__N_100_K = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_100_K = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change__100_K = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_100_K = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_100_K_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_100_K_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + else if (tensileResult.ColorPercent == 200) + { + testResultsExcelModel.Load__N_200_K = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_200_K = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_200_K = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_200_K = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_200_K_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_200_K_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + + } + else if (tensileResult.IsWhiteColor) + { + testResultsExcelModel.Load__N_REF = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_REF = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.STDEV_Strain_REF = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.REF_Strain = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + } + + } + + foreach (var rubbingresult in testresult.RubbingResults) + { + if (rubbingresult.TestResultColor == TestResultColors.CYAN) + { + testResultsExcelModel.Rubbing_C_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_C_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_C_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_C_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.MAGENTA) + { + testResultsExcelModel.Rubbing_M_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_M_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_M_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_M_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.YELLOW) + { + testResultsExcelModel.Rubbing_Y_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_Y_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_Y_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_Y_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.BLACK) + { + testResultsExcelModel.Rubbing_K_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_K_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_K_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_K_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + } + string minZone = testresult.SeverityZone1Min == null ? "" : ((double)testresult.SeverityZone1Min).ToString(); + string maxZone = testresult.SeverityZone1Max == null ? "" : ((double)testresult.SeverityZone1Max).ToString(); + testResultsExcelModel.Uniformity_Zone_1 = $"{minZone} - {maxZone}"; + minZone = testresult.SeverityZone2Min == null ? "" : ((double)testresult.SeverityZone2Min).ToString(); + maxZone = testresult.SeverityZone2Max == null ? "" : ((double)testresult.SeverityZone2Max).ToString(); + testResultsExcelModel.Uniformity_Zone_2 = $"{minZone} - {maxZone}"; + + testResultsExcelModel.COF_REF = testresult.RefCof == null ? 0.0 : (double)testresult.RefCof; + testResultsExcelModel.CV_REF = 0.0; + testResultsExcelModel.COF_Black = testresult.ThreadCof == null ? 0.0 : (double)testresult.ThreadCof; + testResultsExcelModel.CV_Black = 0.0; + testResultsExcelModel.lub_amount = testresult.ThreadLub == null ? 0.0 : (double)testresult.ThreadLub; + + testResultsExcelModel.Comments = testresult.Comment; + testResultsExcelModel.Conclusion = testresult.Conclusions; + testResultsExcelModelList.Add(testResultsExcelModel); + } + } + IsFree = true; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading TestResults for saving in Excel file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } } } |
