From 09d58ce064d7de0ad843596a0737d1280fed82a4 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 21 Oct 2026 18:36:35 -0400 Subject: [PATCH] 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. --- .../CIFiberMaterialNameTests.cs | 63 +++++++++++++++++++ .../CIFiberPostConfig.cs | 1 + .../OpenNest.Posts.CincinnatiCIFiber.json | 1 + docs/cincinnati-ci-fiber-post-output.md | 6 ++ 4 files changed, 71 insertions(+) create mode 100644 OpenNest.Tests/CincinnatiCIFiber/CIFiberMaterialNameTests.cs diff --git a/OpenNest.Tests/CincinnatiCIFiber/CIFiberMaterialNameTests.cs b/OpenNest.Tests/CincinnatiCIFiber/CIFiberMaterialNameTests.cs new file mode 100644 index 00000000..1c78b415 --- /dev/null +++ b/OpenNest.Tests/CincinnatiCIFiber/CIFiberMaterialNameTests.cs @@ -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; + +/// +/// 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. +/// +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(File.ReadAllText(path), options)!; + } + + public static IEnumerable 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); + } +} diff --git a/Posts/OpenNest.Posts.CincinnatiCIFiber/CIFiberPostConfig.cs b/Posts/OpenNest.Posts.CincinnatiCIFiber/CIFiberPostConfig.cs index ecd087fb..aca43e1d 100644 --- a/Posts/OpenNest.Posts.CincinnatiCIFiber/CIFiberPostConfig.cs +++ b/Posts/OpenNest.Posts.CincinnatiCIFiber/CIFiberPostConfig.cs @@ -188,6 +188,7 @@ namespace OpenNest.Posts.CincinnatiCIFiber private Dictionary _materialCodes = new(StringComparer.OrdinalIgnoreCase) { + ["Carbon Steel"] = "MSN", ["Mild Steel"] = "MSN", }; diff --git a/Posts/OpenNest.Posts.CincinnatiCIFiber/OpenNest.Posts.CincinnatiCIFiber.json b/Posts/OpenNest.Posts.CincinnatiCIFiber/OpenNest.Posts.CincinnatiCIFiber.json index 5770b6b7..28370359 100644 --- a/Posts/OpenNest.Posts.CincinnatiCIFiber/OpenNest.Posts.CincinnatiCIFiber.json +++ b/Posts/OpenNest.Posts.CincinnatiCIFiber/OpenNest.Posts.CincinnatiCIFiber.json @@ -17,6 +17,7 @@ "ProgramStartMacro": "PROGRAMSTART.NC", "ProgramEndMacro": "PROGRAMEND.NC", "MaterialCodes": { + "Carbon Steel": "MSN", "Mild Steel": "MSN" }, "DefaultMaterialCode": "MSN" diff --git a/docs/cincinnati-ci-fiber-post-output.md b/docs/cincinnati-ci-fiber-post-output.md index f5daceaf..09cf984e 100644 --- a/docs/cincinnati-ci-fiber-post-output.md +++ b/docs/cincinnati-ci-fiber-post-output.md @@ -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