refactor: move ProgramVariableManager to Core, add config file support

- Move ProgramVariable and ProgramVariableManager from
  OpenNest.Posts.Cincinnati to OpenNest.Core/CNC (namespace OpenNest.CNC)
  so they can be used internally in nest programs
- Add parameterless constructor to CincinnatiPostProcessor that loads
  config from a .json file next to the DLL (creates defaults on first run)
- Enums serialize as readable strings (e.g., "Inches", "ControllerSide")
- Config file: OpenNest.Posts.Cincinnati.json in the Posts/ directory

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 00:08:31 -04:00
parent da8e7e6fd3
commit 5936272ce4
7 changed files with 88 additions and 3 deletions
@@ -1,5 +1,7 @@
using System.IO;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using OpenNest.CNC;
using OpenNest.Geometry;
using OpenNest.Posts.Cincinnati;
@@ -96,6 +98,47 @@ public class CincinnatiPostProcessorTests
}
}
[Fact]
public void Config_RoundTripsAsJson()
{
var config = new CincinnatiPostConfig
{
ConfigurationName = "CL940_CORONA",
DefaultLibraryFile = "MS135N2PANEL.lib",
PostedUnits = Units.Inches,
KerfCompensation = KerfMode.ControllerSide,
UseAntiDive = true
};
var opts = new JsonSerializerOptions
{
WriteIndented = true,
Converters = { new JsonStringEnumConverter() }
};
var json = JsonSerializer.Serialize(config, opts);
var deserialized = JsonSerializer.Deserialize<CincinnatiPostConfig>(json, opts);
Assert.Equal("CL940_CORONA", deserialized.ConfigurationName);
Assert.Equal("MS135N2PANEL.lib", deserialized.DefaultLibraryFile);
Assert.Equal(Units.Inches, deserialized.PostedUnits);
Assert.Equal(KerfMode.ControllerSide, deserialized.KerfCompensation);
Assert.True(deserialized.UseAntiDive);
// Enums serialize as strings
Assert.Contains("\"Inches\"", json);
Assert.Contains("\"ControllerSide\"", json);
}
[Fact]
public void ParameterlessConstructor_LoadsOrCreatesConfig()
{
// The parameterless constructor reads from a .json file next to the assembly,
// or creates defaults if none exists. Either way, Config should be non-null.
var post = new CincinnatiPostProcessor();
Assert.NotNull(post.Config);
Assert.Equal("CL940", post.Config.ConfigurationName);
}
private static Nest CreateTestNest()
{
var nest = new Nest("TestNest");
@@ -1,5 +1,6 @@
using System.IO;
using System.Text;
using OpenNest.CNC;
using OpenNest.Posts.Cincinnati;
namespace OpenNest.Tests.Cincinnati;
@@ -1,4 +1,4 @@
using OpenNest.Posts.Cincinnati;
using OpenNest.CNC;
namespace OpenNest.Tests.Cincinnati;