diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2022-07-26 12:09:33 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2022-07-26 12:09:33 +0300 |
| commit | 27605ffd1ec7496767c215249ebd6898fe4beb8b (patch) | |
| tree | 6d381d8e3b61a91b8246255d0340c0e9ffda9ff6 /Software/Visual_Studio/MachineStudio | |
| parent | 729aba268c416391525ba6a16347d24a59ec8f91 (diff) | |
| parent | c3dd2cc1ca8f06c905a80216bb306049235f3c9f (diff) | |
| download | Tango-27605ffd1ec7496767c215249ebd6898fe4beb8b.tar.gz Tango-27605ffd1ec7496767c215249ebd6898fe4beb8b.zip | |
Merge branch 'software' of https://twinetfs.visualstudio.com/Tango/_git/Tango into software
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
14 files changed, 416 insertions, 28 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs index 8a33f15ef..ac00af5b0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -245,6 +245,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels IsFree = false; await SelectedCatalog.DeleteCascadeAsync(_catalogsContext); _actionLogManager.InsertLog(ActionLogType.CatalogDeleted, _authentication.CurrentUser, SelectedCatalog.Name, SelectedCatalog, "Catalog deleted using Machine Studio.", false); + Catalogs.Remove(SelectedCatalog); SelectedCatalog = null; } catch (Exception ex) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelIn.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelIn.cs new file mode 100644 index 000000000..7dfab5d5c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelIn.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.RML.Models +{ + public class BatchConversionCsvModelIn + { + public string Index { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelOut.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelOut.cs new file mode 100644 index 000000000..f4881ce00 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/BatchConversionCsvModelOut.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.RML.Models +{ + public class BatchConversionCsvModelOut + { + public string Index { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + + public double SuggestionL { get; set; } + public double SuggestionA { get; set; } + public double SuggestionB { get; set; } + public double SuggestionDeltaE { get; set; } + + public double OutputL { get; set; } + public double OutputA { get; set; } + public double OutputB { get; set; } + public double OutputDeltaE { get; set; } + + public double Cyan { get; set; } + public double Magenta { get; set; } + public double Yellow { get; set; } + public double Black { get; set; } + + public double LightCyan { get; set; } + public double LightMagenta { get; set; } + public double LightYellow { get; set; } + + public bool OutOfGamut { get; set; } + + public static double MirtaDeltaE(double L1, double a1, double b1, double L2, double a2, double b2) + { + double h1 = Math.Atan2(b1, a1) * (180 / Math.PI); + if (h1 < 0) + h1 = h1 + 360; + double h2 = Math.Atan2(b2, a2) * (180 / Math.PI); + if (h2 < 0) + h2 = h2 + 360; + double refX_H = h1; + //chroma calculation + double refX_C = Math.Sqrt(a1 * a1 + b1 * b1); + //reference SL parameter + double refX_SL; + if (L1 <= 16) + refX_SL = 0.511; + else + refX_SL = L1 * 0.040975 / (1 + 0.01765 * L1); + //reference SC parameter + double refX_SC = (0.638 + 0.0638 * refX_C / (1 + 0.0131 * refX_C)); + //reference CQ parameter + double refX_CQ = Math.Pow(refX_C, 4); + //reference F parameter + double refX_F = Math.Sqrt(refX_CQ / (refX_CQ + 1900)); + // reference T parameter + double refX_T = 0; + if ((refX_H > 164) & (refX_H < 345)) + refX_T = 0.56 + Math.Abs(0.2 * Math.Cos(Math.PI * (refX_H + 168) / 180)); + else if ((refX_H >= 345) | (refX_H <= 164)) + refX_T = 0.36 + Math.Abs(0.4 * Math.Cos(Math.PI * (refX_H + 35) / 180)); + // reference SH parameter + double refX_SH = refX_SC * (refX_T * refX_F + 1 - refX_F); + + //sample parameter calculations + //hue calculation + double samX_H = h2; + //chroma calculation + double samX_C = Math.Sqrt(a2 * a2 + b2 * b2); + + double dL = L1 - L2; + double dC = samX_C - refX_C; + double da = a1 - a2; + double db = b1 - b2; + double dH = Math.Sqrt(Math.Max(da * da + db * db - dC * dC, 0.0)); + + double dECMC = Math.Sqrt(Math.Pow(dL / (2 * refX_SL), 2) + Math.Pow(dC / refX_SC, 2) + Math.Pow(dH / refX_SH, 2)); + return dECMC; + + } + } + + +} 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 05e95ccfb..c8b778cc7 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 @@ -79,6 +79,8 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="Contracts\IMainView.cs" /> + <Compile Include="Models\BatchConversionCsvModelIn.cs" /> + <Compile Include="Models\BatchConversionCsvModelOut.cs" /> <Compile Include="Models\CalibrationMeasurementModel.cs" /> <Compile Include="Models\CctModel.cs" /> <Compile Include="Models\ColorLinearizationModel.cs" /> 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 bde174f07..deb162687 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 @@ -25,6 +25,9 @@ using Tango.MachineStudio.Common.Authentication; using Tango.BL.ActionLogs; using Tango.BL.DTO; using Tango.BL.Enumerations; +using Google.Protobuf; +using Tango.ColorConversion; +using Tango.CSV; namespace Tango.MachineStudio.RML.ViewModels { @@ -257,6 +260,8 @@ namespace Tango.MachineStudio.RML.ViewModels /// </summary> public RelayCommand RemoveSpoolCommand { get; set; } + public RelayCommand BatchConversionCommand { get; set; } + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; @@ -283,6 +288,8 @@ namespace Tango.MachineStudio.RML.ViewModels AddSpoolCommand = new RelayCommand(AddNewSpool); RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); + + BatchConversionCommand = new RelayCommand(BatchConversion); } public override void OnApplicationReady() @@ -916,6 +923,235 @@ namespace Tango.MachineStudio.RML.ViewModels LoadRmls(); } + #region Batch Conversion + + private void BatchConversion() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select CSV file with LAB data"; + dlg.Filter = "CSV Files|*.csv"; + if (!dlg.ShowDialogCenter()) + { + return; + } + + String fileName = dlg.FileName; + + try + { + ConversionInput input = new ConversionInput(); + input.ColorSpace = PMR.ColorLab.ColorSpace.Lab; + input.ForwardData = ByteString.CopyFrom(SelectedCCT.Data); + + input.InputCoordinates = new InputCoordinates(); + + input.ThreadL = ActiveRML.WhitePointL; + input.ThreadA = ActiveRML.WhitePointA; + input.ThreadB = ActiveRML.WhitePointB; + + input.UseLightInks = ActiveRML.UseLightInks; + input.VMax = ActiveRML.VMax; + + //Validate calibration data + foreach (var vm in CalibrationDataViewVM.LiquidsCalibrationData.Where(x => x.LiquidType.HasPigment)) + { + if (vm.CalibrationPoints.Count == 0) + { + InvokeUI(() => + { + _notification.ShowError($"No calibration data for liquid '{vm.LiquidType.Name}'. Could not convert source color."); + }); + return; + } + else if (!(vm.CalibrationPoints.First().X == 0 && vm.CalibrationPoints.First().Y == 0 && vm.CalibrationPoints.Last().X >= 100 && vm.CalibrationPoints.Last().Y >= 100)) + { + InvokeUI(() => + { + _notification.ShowError($"Invalid calibration data for liquid '{vm.LiquidType.Name}'. Could not convert source color."); + }); + return; + } + } + + foreach (var vm in CalibrationDataViewVM.LiquidsCalibrationData) + { + InputLiquid inputLiquid = new InputLiquid(); + + + CalibrationData calData = new CalibrationData(); + calData.LiquidType = (PMR.ColorLab.LiquidType)vm.LiquidType.Code; + calData.CalibrationPoints.AddRange(vm.CalibrationPoints.Select(x => new CalibrationPoint() { X = x.X, Y = x.Y })); + + inputLiquid.CalibrationData = calData; + + inputLiquid.LiquidType = (PMR.ColorLab.LiquidType)vm.LiquidType.Code; + inputLiquid.MaxNanoliterPerCentimeter = LiquidTypesRmls.SingleOrDefault(x => x.LiquidType.Code == vm.LiquidType.Code).MaxNlPerCm; + + input.InputCoordinates.InputLiquids.Add(inputLiquid); + } + + foreach (var process in ActiveRML.GetActiveProcessGroup().ProcessParametersTables) + { + input.ProcessRanges.Add(new ProcessRange() + { + MinInkUptake = process.MinInkUptake, + MaxInkUptake = process.MaxInkUptake, + }); + } + + input.GenerateHive = false; + + IColorConverter converter = new DefaultColorConverter(); + + List<BatchConversionCsvModelIn> labList = CsvFile.Read<BatchConversionCsvModelIn>(new CsvSource(fileName)).ToList(); + + List<BatchConversionCsvModelOut> resultsList = new List<BatchConversionCsvModelOut>(); + + using (_notification.PushTaskItem("Converting...")) + { + foreach (var lab in labList) + { + input.InputCoordinates.L = lab.L; + input.InputCoordinates.A = lab.A; + input.InputCoordinates.B = lab.B; + input.ColorSpace = PMR.ColorLab.ColorSpace.Lab; + var output = converter.Convert(input, ActiveRML.ColorConversionVersion); + + BatchConversionCsvModelOut result = new BatchConversionCsvModelOut(); + + result.Index = lab.Index; + result.L = lab.L; + result.A = lab.A; + result.B = lab.B; + result.SuggestionL = output.CreateSingleSuggestion().Coordinates.L; + result.SuggestionA = output.CreateSingleSuggestion().Coordinates.A; + result.SuggestionB = output.CreateSingleSuggestion().Coordinates.B; + var cyanVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan); + + if (cyanVolume != null) + { + result.Cyan = cyanVolume.Volume; + } + + var magentaVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta); + + if (magentaVolume != null) + { + result.Magenta = magentaVolume.Volume; + } + + var yellowVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow); + + if (yellowVolume != null) + { + result.Yellow = yellowVolume.Volume; + } + + var blackVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Black); + + if (blackVolume != null) + { + result.Black = blackVolume.Volume; + } + + var lightCyanVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightCyan); + + if (lightCyanVolume != null) + { + result.LightCyan = lightCyanVolume.Volume; + } + + var lightMagentaVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightMagenta); + + if (lightMagentaVolume != null) + { + result.LightMagenta = lightMagentaVolume.Volume; + } + + var lightYellowVolume = output.CreateSingleSuggestion().Coordinates.OutputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightYellow); + + if (lightYellowVolume != null) + { + result.LightYellow = lightYellowVolume.Volume; + } + foreach (var item in input.InputCoordinates.InputLiquids) + { + switch (item.LiquidType) + { + case PMR.ColorLab.LiquidType.Cyan: + item.Volume = result.Cyan; + break; + case PMR.ColorLab.LiquidType.Magenta: + item.Volume = result.Magenta; + break; + case PMR.ColorLab.LiquidType.Yellow: + item.Volume = result.Yellow; + break; + case PMR.ColorLab.LiquidType.Black: + item.Volume = result.Black; + break; + case PMR.ColorLab.LiquidType.TransparentInk: + break; + case PMR.ColorLab.LiquidType.Lubricant: + break; + case PMR.ColorLab.LiquidType.Cleaner: + break; + case PMR.ColorLab.LiquidType.LightCyan: + item.Volume = result.LightCyan; + break; + case PMR.ColorLab.LiquidType.LightMagenta: + item.Volume= result.LightMagenta; + break; + case PMR.ColorLab.LiquidType.LightYellow: + item.Volume = result.LightYellow; + break; + default: + break; + } + } + + result.OutOfGamut = output.OutOfGamut; + input.ColorSpace = PMR.ColorLab.ColorSpace.Volume; + output = converter.Convert(input, ActiveRML.ColorConversionVersion); + result.OutputL = output.CreateSingleSuggestion().Coordinates.L; + result.OutputA = output.CreateSingleSuggestion().Coordinates.A; + result.OutputB = output.CreateSingleSuggestion().Coordinates.B; + result.SuggestionDeltaE = BatchConversionCsvModelOut.MirtaDeltaE(result.L, result.A, result.B, result.SuggestionL, result.SuggestionA, result.SuggestionB); + result.OutputDeltaE = BatchConversionCsvModelOut.MirtaDeltaE(result.L, result.A, result.B, result.OutputL, result.OutputA, result.OutputB); + + + resultsList.Add(result); + } + } + + SaveFileDialog dlgOut = new SaveFileDialog(); + dlgOut.Title = "Select results CSV file"; + dlgOut.Filter = "CSV Files|*.csv"; + dlgOut.FileName = Path.GetFileNameWithoutExtension(fileName) + " - Results"; + dlgOut.DefaultExt = ".csv"; + if (!dlgOut.ShowDialogCenter()) + { + return; + } + + using (CsvFile<BatchConversionCsvModelOut> outFile = new CsvFile<BatchConversionCsvModelOut>(new CsvDestination(dlgOut.FileName))) + { + foreach (var result in resultsList) + { + outFile.Append(result); + } + } + } + catch (Exception ex) + { + _notification.ShowError($"Error converting the selected file. Please check all data is valid.\n{ex.FlattenMessage()}"); + } + + _notification.ShowInfo("Batch Conversion Completed."); + } + + #endregion + #region Import / Export Color Conversion Data private void ImportCCTData() 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 6a5c4de9b..a9b943525 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 @@ -179,6 +179,13 @@ </Border.Effect> <Grid> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">COLOR CONVERSION</TextBlock> + + <Button ToolTip="Import LAB data from CSV and export the conversion results to a new CSV file" FontSize="11" Foreground="{StaticResource DarkGrayBrush200}" HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" VerticalAlignment="Bottom" Padding="0" Command="{Binding BatchConversionCommand}" Margin="0 0 5 0"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="FolderMultipleOutline" Foreground="{StaticResource DimGrayBrush}" Width="16" Height="26" /> + <TextBlock VerticalAlignment="Center" Margin="5 0 0 0">Batch Conversion</TextBlock> + </StackPanel> + </Button> </Grid> </Border> <local:ColorConversionView x:Name="colorConversionView" Margin="0 0 0 0" Grid.Column="0" DataContext="{Binding ColorConversionViewVM}"/> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs index 869fadb3a..364984375 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs @@ -22,6 +22,7 @@ namespace Tango.MachineStudio.Statistics.Models public String GR { get; set; } public String Status { get; set; } public String EndTime { get; set; } + public String TotalDyeingTime { get; set; } public String EndPosition { get; set; } public String Cyan { get; set; } public String Magenta { get; set; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index c8556960d..9dcce7d05 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -300,7 +300,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels JobRuns = new ObservableCollection<JobRunModel>(); LoadJobRunsCommand = new RelayCommand(async () => await LoadJobRuns(), () => IsFree && SelectedMachines!= null && SelectedMachines.Source.Count >0); ExportToExcelCommand = new RelayCommand(ExportToExcel, () => IsFree); - LengthUpperValue = 10000.0; + LengthUpperValue = 100000.0; LengthLowerValue = 0.0; DateTime now = DateTime.Now; StartSelectedDate = now.AddMonths(-1); @@ -646,6 +646,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels "Gradient Resolution", "Status", "End Date", + "Total dyeing time", "End Position", "Cyan", "Magenta", @@ -677,6 +678,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels excel_model.GR = jobRunModel.JobRun.GradientResolutionCm.ToString(); excel_model.Status = jobRunModel.JobRun.JobRunStatus.ToString(); excel_model.EndTime = jobRunModel.JobRun.EndDate != null ? ((DateTime)jobRunModel.JobRun.EndDate).ToLocalTime().ToString("MM/dd/yy HH:mm"): ""; + excel_model.TotalDyeingTime = jobRunModel.JobRun.TotalDyeingTime != default(TimeSpan) ? ((TimeSpan)jobRunModel.JobRun.TotalDyeingTime).ToString(@"hh\:mm\:ss") : TimeSpan.FromSeconds(0).ToString(@"hh\:mm\:ss"); excel_model.EndPosition = String.Format("{0:0.##}", jobRunModel.JobRun.EndPosition); excel_model.Cyan = jobRunModel.JobRun.CyanQuantity < 0 ? "" :jobRunModel.JobRun.CyanQuantity.ToString(); excel_model.Magenta = jobRunModel.JobRun.MagentaQuantity < 0 ? "" : jobRunModel.JobRun.MagentaQuantity.ToString(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index 1184622f6..9d6d41778 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -35,6 +35,7 @@ <localConverters:NanoLiterToLiterFormatConverter x:Key="NanoLiterToLiterFormatConverter"/> <localConverters:LiquidQuantityToFormatStringConverter x:Key="LiquidQuantityToFormatStringConverter"/> <localConverters:TooltipLiquidQuantityFormatConverter x:Key="TooltipLiquidQuantityFormatConverter"/> + <sharedConverters:TimeSpanToMinutesConverter x:Key="TimeSpanToMinutesConverter" /> <ResourceDictionary x:Key="SelectAllTextBoxResource"> <Style TargetType="TextBox"> @@ -89,8 +90,8 @@ <Grid IsEnabled="{Binding IsFree}" > <Grid.ColumnDefinitions> - <ColumnDefinition Width="3*"/> <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="390"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> @@ -358,7 +359,7 @@ <Border BorderThickness="1" CornerRadius="3" BorderBrush="{StaticResource borderBrush}" Margin="0 10 0 0" Height="24" Padding="10 0"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding LengthLowerValue, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" FontSize="11" Width="40"></TextBlock> - <mahapps:RangeSlider Focusable="True" Height="40" Margin="5 5 5 5" Minimum="0" Maximum="10000" Width="140" ExtendedMode="True" + <mahapps:RangeSlider Focusable="True" Height="40" Margin="5 5 5 5" Minimum="0" Maximum="100000" Width="140" ExtendedMode="True" LowerValue="{Binding LengthLowerValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" UpperValue="{Binding LengthUpperValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" IsSnapToTickEnabled="True" FontSize="8"/> @@ -599,6 +600,7 @@ <DataGridTextColumn Header="GR" Binding="{Binding JobRun.GradientResolutionCm}" Width="30" /> <DataGridTextColumn Header="Status" Binding="{Binding JobRun.JobRunStatus, Converter={StaticResource EnumToDescriptionConverter}}" Width="70"/> <DataGridTextColumn Header="End Time" Binding="{Binding JobRun.EndDate, Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="95" /> + <DataGridTextColumn Header="Total dyeing time" Binding="{Binding JobRun.TotalDyeingTime, Converter={StaticResource DateTimeToStringFormatConverter}}" Width="95" /> <DataGridTextColumn Header="End Position" Binding="{Binding JobRun.EndPosition, StringFormat={}{0:0.00}}" Width="70" /> <DataGridTemplateColumn Header="Liquid Quantities" Width="1*"> <DataGridTemplateColumn.CellStyle> @@ -632,7 +634,7 @@ <RowDefinition Height="20"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*" MaxWidth="200"/> + <ColumnDefinition Width="1*" MaxWidth="250"/> </Grid.ColumnDefinitions> <ItemsControl ItemsSource="{Binding JobRun.LiquidQuantitiesFast,Mode=OneWay}" Margin="0 0 0 0" Height="70"> <ItemsControl.ItemContainerStyle> 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 e13e016c5..2ab1f81f1 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 @@ -419,7 +419,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { if (SelectedMachineGUID == null) { - _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + // _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); IsFree = false; return; } @@ -671,47 +671,80 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels if (listValues.Count < 2 || factor <= 0) return new DataPoint(0, 0); - var test = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value.Average() }).ToList(); - var distinctItems = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value }).Select(y => new ColorProcessData { InkNlCm = y.InkValuep, L = y.ColorValue.Average() }).ToList(); - + //var test = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value.Average() }).ToList(); + //var distinctItems = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value }).Select(y => new ColorProcessData { InkNlCm = y.InkValuep, L = y.ColorValue.Average() }).ToList(); + + var sortedItems = isLtype? listValues.OrderBy(x=>x.InkNlCm).ThenByDescending(x=>x.L).ToList() : listValues.OrderBy(x => x.InkNlCm).ThenBy(x => x.B).Select(y => new ColorProcessData { InkNlCm = y.InkNlCm, L = isLtype ? y.L : y.B }).ToList(); double calculatedX = 0.0; - ColorProcessData prevItem = distinctItems[0]; - for (int index = 1; index < distinctItems.Count; index++) + ColorProcessData prevItem = sortedItems[0]; + for (int index = 1; index < sortedItems.Count; index++) { - var item = distinctItems[index]; + var item = sortedItems[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)) + //if (prevItem.L > item.L && (factor > prevItem.L || (factor <= prevItem.L && factor >= item.L)) + // || (prevItem.L <= item.L && + // ( (factor >= prevItem.L && factor <= item.L) || (factor <= prevItem.L && !isLtype))) + // || ((index + 1) == distinctItems.Count && calculatedX == 0.0)) + //{ + // calculatedX = CalculateXValue(factor, new DataPoint(prevItem.InkNlCm, prevItem.L), new DataPoint(item.InkNlCm, item.L)); + // //Yellow line is ascending line( up line), others - descending line(down) + // // if (isLtype) + // break; + + //} + if ((prevItem.L > item.L && (factor <= prevItem.L && factor >= item.L)) + || (prevItem.L <= item.L && (factor >= prevItem.L && factor <= item.L))) { calculatedX = CalculateXValue(factor, new DataPoint(prevItem.InkNlCm, prevItem.L), new DataPoint(item.InkNlCm, item.L)); //Yellow line is ascending line( up line), others - descending line(down) - if (isLtype) - break; + // if (isLtype) + break; } - prevItem = item; + if(prevItem.InkNlCm != item.InkNlCm) + prevItem = item; } return new DataPoint(calculatedX, factor); ; } + /// <summary> + /// Calculates the x value - Point of Intersection of Two Lines, factor = y of second line + /// </summary> private double CalculateXValue(double factor, DataPoint leftPoint, DataPoint rightPoint) { - double deltaX = rightPoint.X - leftPoint.X; + //double deltaX = rightPoint.X - leftPoint.X; + double deltaX = leftPoint.X - rightPoint.X; double deltaY = rightPoint.Y - leftPoint.Y; + + double a1 = deltaY; + double b1 = deltaX; + double c1 = a1 * (leftPoint.X) + b1 * (leftPoint.Y); - // prevents division by zero exceptions. - if (deltaX == 0) - return 0.0; + double a2 = 0.0; + double b2 = deltaX; + double c2 = b2 * (factor); - double slope = deltaY / deltaX; + double determinant = a1 * b2; + if (determinant == 0) + { + return leftPoint.X; + } + + double x = (b2 * c1 - b1 * c2) / determinant; + double y = (a1 * c2 - a2 * c1) / determinant; + + // prevents division by zero exceptions. + //if (deltaX == 0) + // return leftPoint.X; + // double slope = deltaY / deltaX; // double c = leftPoint.Y - slope * leftPoint.X; // double cX = (factor - c) / slope; - return (leftPoint.X + (factor - leftPoint.Y) / slope); - + //return (leftPoint.X + (factor - leftPoint.Y) / slope); + //double y = (a1 * c2 - a2 * c1) / determinant; + return (b2 * c1 - b1 * c2) / determinant; } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs index f305d5139..9841ee674 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -165,7 +165,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { if (SelectedMachineGUID == null) { - _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + // _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); IsFree = false; return; } 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 853a415a3..164d37b74 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 @@ -1046,7 +1046,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { SelectedMachine = Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); } - else + if(SelectedMachine == null) { SelectedMachine = Machines.First(); } 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 f639eb6e7..8a75c526f 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 @@ -256,7 +256,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { if (String.IsNullOrEmpty(SelectedMachineGUID)) { - _notification.ShowWarning(LogManager.Log($" Please, select machine.", LogCategory.Warning)); + // _notification.ShowWarning(LogManager.Log($" Please, select machine.", LogCategory.Warning)); return; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 38784b905..217c6fd93 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("4.8.4.0")] +[assembly: AssemblyVersion("4.8.11.0")] [assembly: ComVisible(false)]
\ No newline at end of file |
