Fixed utilization greater than 100 percent

This commit is contained in:
AJ
2021-11-15 09:10:20 -05:00
parent 029414099e
commit 90d770e10c
2 changed files with 12 additions and 1 deletions

View File

@@ -63,6 +63,8 @@ namespace CutList.Forms
foreach (var bin in Bins) foreach (var bin in Bins)
{ {
var idString = id++.ToString();
var binDescription = $"{idString}. {bin.ToString()}";
writer.WriteLine(id++.ToString() + ". " + bin.ToString()); writer.WriteLine(id++.ToString() + ". " + bin.ToString());
var groups = bin.Items.GroupBy(i => $"{i.Name} {i.Length}"); var groups = bin.Items.GroupBy(i => $"{i.Name} {i.Length}");

View File

@@ -22,6 +22,11 @@ namespace SawCut
{ {
get get
{ {
var usedLength = Math.Round(Items.Sum(i => i.Length) + Spacing * Items.Count, 8);
if (usedLength > Length && (usedLength - Length) <= Spacing)
return Length;
return Math.Round(Items.Sum(i => i.Length) + Spacing * Items.Count, 8); return Math.Round(Items.Sum(i => i.Length) + Spacing * Items.Count, 8);
} }
} }
@@ -31,9 +36,13 @@ namespace SawCut
get { return Math.Round(Length - UsedLength, 8); } get { return Math.Round(Length - UsedLength, 8); }
} }
/// <summary>
/// Returns a ratio of UsedLength to TotalLength
/// 1.0 = 100% utilization
/// </summary>
public double Utilization public double Utilization
{ {
get { return UsedLength / Length; } get { return UsedLength / Length; }
} }
public override string ToString() public override string ToString()