feat(posts): map Carbon Steel to the CI Fiber MSN material code

Steel is "Carbon Steel" in OpenNest, matching the Cincinnati post's cut
libraries. The CI Fiber material-code table only listed "Mild Steel", so a
Carbon Steel nest reached MSN only by falling through to the default code.
List "Carbon Steel" explicitly in the shipped JSON and the built-in
default, and keep "Mild Steel" for nests that already use it.

Tests check both names against the shipped config and the built-in
default; the Carbon Steel rows failed before this change. Posted output
is unchanged, since the default code was already MSN.
This commit is contained in:
aj committed 2026-10-21 18:36:35 -04:00
1 parent 64eca9775f
commit 09d58ce064
4 files changed
+71

No files matched your search

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using OpenNest.Posts.CincinnatiCIFiber;
namespace OpenNest.Tests.CincinnatiCIFiber;
/// <summary>
/// Steel is named "Carbon Steel" across OpenNest (the Cincinnati post's libraries and
/// the company material list), so the CI Fiber post must list it explicitly rather
/// than reach MSN only through DefaultMaterialCode. "Mild Steel" stays for
/// nests that already use it.
/// </summary>
public class CIFiberMaterialNameTests
{
private static CIFiberPostConfig LoadShipped()
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
while (dir != null && !File.Exists(Path.Combine(dir.FullName, "OpenNest.sln")))
dir = dir.Parent;
Assert.NotNull(dir);
var path = Path.Combine(
dir!.FullName,
"Posts",
"OpenNest.Posts.CincinnatiCIFiber",
"OpenNest.Posts.CincinnatiCIFiber.json"
);
var options = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } };
return JsonSerializer.Deserialize<CIFiberPostConfig>(File.ReadAllText(path), options)!;
}
public static IEnumerable<object[]> Configs()
{
yield return new object[] { "shipped json" };
yield return new object[] { "built-in default" };
}
private static CIFiberPostConfig For(string source) =>
source == "shipped json" ? LoadShipped() : new CIFiberPostConfig();
[Theory]
[MemberData(nameof(Configs))]
public void CarbonSteel_IsListedAsMSN(string source)
{
var codes = For(source).MaterialCodes;
Assert.True(codes.TryGetValue("Carbon Steel", out var code), $"{source}: no Carbon Steel entry");
Assert.Equal("MSN", code);
}
[Theory]
[MemberData(nameof(Configs))]
public void MildSteel_StillMapsToMSN(string source)
{
var codes = For(source).MaterialCodes;
Assert.True(codes.TryGetValue("Mild Steel", out var code), $"{source}: no Mild Steel entry");
Assert.Equal("MSN", code);
}
}
@@ -188,6 +188,7 @@ namespace OpenNest.Posts.CincinnatiCIFiber
private Dictionary<string, string> _materialCodes = new(StringComparer.OrdinalIgnoreCase)
{
["Carbon Steel"] = "MSN",
["Mild Steel"] = "MSN",
};
@@ -17,6 +17,7 @@
"ProgramStartMacro": "PROGRAMSTART.NC",
"ProgramEndMacro": "PROGRAMEND.NC",
"MaterialCodes": {
"Carbon Steel": "MSN",
"Mild Steel": "MSN"
},
"DefaultMaterialCode": "MSN"
+6
View File
@@ -61,6 +61,12 @@ In the desktop app these settings open in a sectioned editor (Machine, Sheets,
Material, Program output, Macros) with a material-code table; values are
validated and saved only when OK is pressed.
Steel is "Carbon Steel" in OpenNest, as in the Cincinnati post's cut libraries.
The material-code table maps both "Carbon Steel" and "Mild Steel" to `MSN`. A
deployed config is copied from the shipped JSON only when a PC has none, so an
existing PC needs the "Carbon Steel" row added in the material-code table.
Until then such nests still post `MSN` through `DefaultMaterialCode`.
- Assign linear lead-ins before posting, including circular holes. The writer
rejects missing or arc-first lead-ins. Its conservative rule cites the G238
compensation-selection restriction in TF5200 §13.2.4.1; do not generalize it