diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2025-01-27 08:54:39 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2025-01-27 08:54:39 +0200 |
| commit | e204e6ac5d04114778b5b836a3e3707e819ad349 (patch) | |
| tree | 0eb03bfd253cf6f26c72b2f4ccb08b9e03369b5a /Software/Visual_Studio/PPC/Tango.PPC.UI/Converters | |
| parent | 558c9c58a8be65c2a8430a21de857b335efee491 (diff) | |
| download | Tango-e204e6ac5d04114778b5b836a3e3707e819ad349.tar.gz Tango-e204e6ac5d04114778b5b836a3e3707e819ad349.zip | |
X1 Closure.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Converters')
5 files changed, 168 insertions, 30 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthToWeightConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthToWeightConverter.cs index 82a947e97..7615f661b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthToWeightConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthToWeightConverter.cs @@ -6,19 +6,38 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; +using Tango.PPC.Common.Build; namespace Tango.PPC.UI.Converters { public class LengthToWeightConverter : IMultiValueConverter { + private static IBuildProvider _buildProvider; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { + if (_buildProvider == null) + { + _buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>(); + } + double length = System.Convert.ToDouble(values[0]); double coef = System.Convert.ToDouble(values[1]); int spools = System.Convert.ToInt32(values[2]); - var weight = ((double)length * spools * coef) / (1000 );//(g) + + double weight = 0; + + if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka) + { + weight = ((double)length * spools * coef) / (1000);//(g) + } + else + { + weight = ((double)length * coef) / (1000);//(g) + } + return weight; } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthWithSpoolsConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthWithSpoolsConverter.cs index 48e9bce7b..216efb54e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthWithSpoolsConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LengthWithSpoolsConverter.cs @@ -6,18 +6,34 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; +using Tango.PPC.Common.Build; namespace Tango.PPC.UI.Converters { public class LengthWithSpoolsConverter : IMultiValueConverter { + private static IBuildProvider _buildProvider; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { + if (_buildProvider == null) + { + _buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>(); + } + double length = System.Convert.ToDouble(values[0]); double spools = System.Convert.ToDouble(values[1]); - return length * spools; + + if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka) + { + return length * spools; + } + else + { + return length; + } } catch { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressLengthSpoolConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressLengthSpoolConverter.cs index 3dd91806d..1e7054fae 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressLengthSpoolConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressLengthSpoolConverter.cs @@ -6,46 +6,76 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; +using Tango.BL.Enumerations; +using Tango.PPC.Common.Build; namespace Tango.PPC.UI.Converters { public class ProgressLengthSpoolConverter : IMultiValueConverter { + private static IBuildProvider _buildProvider; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { + if (_buildProvider == null) + { + _buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>(); + } + if (values.Count() == 3) { double length = System.Convert.ToDouble(values[0]); bool forOneSpool = System.Convert.ToBoolean(values[1]); int number_of_spools = System.Convert.ToInt16(values[2]); - var totalBy4Spools = (double)length* number_of_spools; + var totalBy4Spools = _buildProvider.MachineType == MachineTypes.Eureka ? (double)length * number_of_spools : length; if (forOneSpool) { return (double)totalBy4Spools / number_of_spools; } return totalBy4Spools; - + } if (values.Count() == 4) { double length = System.Convert.ToDouble(values[0]); bool forOneSpool = System.Convert.ToBoolean(values[1]); - double currentProgresslength = System.Convert.ToDouble(values[2]) ; + double currentProgresslength = System.Convert.ToDouble(values[2]); int number_of_spools = System.Convert.ToInt16(values[3]); - var totalBy4Spools = (double)length * number_of_spools; - var currentProgressBy4Spools = (double)currentProgresslength * number_of_spools; - + var totalBy4Spools = _buildProvider.MachineType == MachineTypes.Eureka ? (double)length * number_of_spools : (double)length; + var currentProgressBy4Spools = _buildProvider.MachineType == MachineTypes.Eureka ? (double)currentProgresslength * number_of_spools : currentProgresslength; + int coeff = (int)currentProgressBy4Spools / (int)totalBy4Spools; var progressCurrent = (coeff == 0 || coeff == 1) ? currentProgressBy4Spools : currentProgressBy4Spools % (coeff * totalBy4Spools);//show for progress - + if (forOneSpool) { - return (double)progressCurrent / number_of_spools; - + if (_buildProvider.MachineType == MachineTypes.Eureka) + { + return (double)progressCurrent / number_of_spools; + } + else + { + double lengthPerSpool = length / number_of_spools; + + // Get the current spool + int currentSpool = (int)(Math.Floor(progressCurrent / lengthPerSpool)) + 1; + + // Calculate progress on the current spool + double spoolProgress = progressCurrent % lengthPerSpool; + + if (currentSpool > number_of_spools) + { + currentSpool = number_of_spools; + spoolProgress = lengthPerSpool; + } + + return spoolProgress; + } } + return progressCurrent; } return "-"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressUnitSpoolConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressUnitSpoolConverter.cs index 66303ab27..1742c589c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressUnitSpoolConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressUnitSpoolConverter.cs @@ -5,22 +5,38 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; +using Tango.PPC.Common.Build; namespace Tango.PPC.UI.Converters { public class ProgressUnitSpoolConverter : IMultiValueConverter { + private static IBuildProvider _buildProvider; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { + if (_buildProvider == null) + { + _buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>(); + } + if (values.Count() == 2)//may be added count of spools { int CurrentUnit = System.Convert.ToInt16(values[0]); - int number_of_spools = System.Convert.ToInt16(values[1]); - var totalBy4Spools = (double)CurrentUnit * number_of_spools; - - return totalBy4Spools.ToString(); + + if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka) + { + int number_of_spools = System.Convert.ToInt16(values[1]); + var totalBy4Spools = (double)CurrentUnit * number_of_spools; + + return totalBy4Spools.ToString(); + } + else + { + return CurrentUnit.ToString(); + } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressWeightSpoolConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressWeightSpoolConverter.cs index f93e34c7d..e0bff121e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressWeightSpoolConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/ProgressWeightSpoolConverter.cs @@ -6,30 +6,53 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; - +using Tango.PPC.Common.Build; namespace Tango.PPC.UI.Converters { public class ProgressWeightSpoolConverter : IMultiValueConverter { + private static IBuildProvider _buildProvider; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { + if (_buildProvider == null) + { + _buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>(); + } + if (values.Count() == 4) { double length = System.Convert.ToDouble(values[0]); bool forOneSpool = System.Convert.ToBoolean(values[1]); double coef = System.Convert.ToDouble(values[2]); int number_of_spools = System.Convert.ToInt16(values[3]); - var totalBy4Spools = (double)length * number_of_spools; - - var weight = ((double)totalBy4Spools * coef) / (1000);//(g) - if (forOneSpool) + + if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka) { - return (double)weight / number_of_spools; + var totalBy4Spools = (double)length * number_of_spools; + + var weight = ((double)totalBy4Spools * coef) / (1000);//(g) + + if (forOneSpool) + { + return (double)weight / number_of_spools; + } + return weight; + } + else + { + double weight = ((double)length * coef) / (1000);//(g) + + if (forOneSpool) + { + weight = ((double)length / (double)number_of_spools * coef) / (1000);//(g) + } + + return weight; } - return weight; } if (values.Count() == 5) @@ -40,18 +63,52 @@ namespace Tango.PPC.UI.Converters double coef = System.Convert.ToDouble(values[3]); int number_of_spools = System.Convert.ToInt16(values[4]); - var totalBy4Spools = (double)length * number_of_spools; - var currentProgressBy4Spools = (double)currentProgresslength * number_of_spools; + if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka) + { + var totalBy4Spools = (double)length * number_of_spools; + var currentProgressBy4Spools = (double)currentProgresslength * number_of_spools; + + int coeff = (int)currentProgressBy4Spools / (int)totalBy4Spools; + var progressCurrent = (coeff == 0 || coeff == 1) ? currentProgressBy4Spools : currentProgressBy4Spools % (coeff * totalBy4Spools);//show for progress + var weight = ((double)progressCurrent * coef) / (1000);//(g) + if (forOneSpool) + { + return (double)weight / number_of_spools; - int coeff = (int)currentProgressBy4Spools / (int)totalBy4Spools; - var progressCurrent = (coeff == 0 || coeff == 1) ? currentProgressBy4Spools : currentProgressBy4Spools % (coeff * totalBy4Spools);//show for progress - var weight = ((double)progressCurrent * coef) / (1000);//(g) - if (forOneSpool) + } + + return weight; + } + else { - return (double)weight / number_of_spools; + double weight = 0; + + if (forOneSpool) + { + double lengthPerSpool = length / number_of_spools; + // Get the current spool + int currentSpool = (int)(Math.Floor(currentProgresslength / lengthPerSpool)) + 1; + + // Calculate progress on the current spool + double spoolProgress = currentProgresslength % lengthPerSpool; + + if (currentSpool > number_of_spools) + { + currentSpool = number_of_spools; + spoolProgress = lengthPerSpool; + } + + weight = ((double)spoolProgress * coef) / (1000);//(g) + } + else + { + weight = ((double)currentProgresslength * coef) / (1000);//(g) + } + + return weight; } - return weight; + } return "-"; } |
