mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-06 22:45:45 -05:00
Tabs suit thin plate, but on anything thicker than 0.25 in the parts are too hard to break out of the sheet, and the Cutting Parameters dialog was one global set for every job. Its settings now live on the nest's machine thickness: leads on the existing Outside/Inside Cuts tabs, and lead-in angle rounding, tabs and pierce on a new Tabs & Pierce tab (ThicknessConfig.Cutting). In Database mode every workstation gets the same settings through the shared machine. The dialog and the Place Lead-in panel say what they edit, and save back to that thickness (MachineCuttingDefaults.WriteTo, converted to the machine's units). A thickness with no Tabs & Pierce of its own, or a nest the machine has no thickness for, keeps this PC's settings as before. If the machine can't be saved (server offline, a conflict), the edit is kept on this PC for that job and the user is told. Machine Configuration can copy one thickness's Tabs & Pierce to thinner or thicker ones, so the 0.25 in rule takes a few clicks. An older desktop saving a shared machine would silently erase these settings, since it doesn't know them. Machine configuration classes now keep unknown fields, and the server refuses a machine save that leaves out a field the stored machine has a value for, telling the user to update OpenNest. The Plan Cutting status line now reports tabs from SupportTabs; since "Tab every part" was retired it always said off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.9 KiB
C#
68 lines
2.9 KiB
C#
using OpenNest.Math;
|
|
|
|
namespace OpenNest.Data;
|
|
|
|
public class MachineConfig
|
|
{
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
public int SchemaVersion { get; set; } = 1;
|
|
public string Name { get; set; } = "";
|
|
public MachineType Type { get; set; } = MachineType.Laser;
|
|
public UnitSystem Units { get; set; } = UnitSystem.Inches;
|
|
public List<MaterialConfig> Materials { get; set; } = new();
|
|
|
|
/// <summary>Acceleration limits; null until entered, when <see cref="GetMotionOrPlaceholder"/> stands in.</summary>
|
|
public MotionConfig? Motion { get; set; }
|
|
|
|
/// <summary>
|
|
/// The support grid nests assigned this machine rest on; null until saved from
|
|
/// Nest > Support Grid, when the legacy shared support-grid.json stands in.
|
|
/// </summary>
|
|
public SupportGridSettings? SupportGrid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The edge-clamp rail new nests assigned this machine receive, in <see cref="Units"/>; null
|
|
/// until set (the machine then gives nests no clamps).
|
|
/// </summary>
|
|
public MachineClamps? Clamps { get; set; }
|
|
|
|
public MotionConfig GetMotionOrPlaceholder() => Motion ?? MotionConfig.Placeholder(Units);
|
|
|
|
/// <summary>The machine's clamps in its units; off, at the default clamp size, when it has none.</summary>
|
|
public ClampSettings GetClampSettings() =>
|
|
Clamps?.ToSettings(Units) ?? ClampSettings.FromRail(null, MachineClamps.UnitsOf(Units), enabled: false);
|
|
|
|
public ThicknessConfig? GetParameters(string material, double thickness) =>
|
|
GetParameters(material, null, thickness);
|
|
|
|
public ThicknessConfig? GetParameters(string material, string? grade, double thickness)
|
|
{
|
|
var mat = grade is null ? GetMaterial(material) : GetMaterial(material, grade);
|
|
return mat?.Thicknesses.FirstOrDefault(t => t.Value.IsEqualTo(thickness));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the first material matching <paramref name="name"/>, regardless of
|
|
/// grade. Use <see cref="GetMaterial(string, string)"/> when the material may
|
|
/// have more than one grade on file.
|
|
/// </summary>
|
|
public MaterialConfig? GetMaterial(string name) =>
|
|
Materials.FirstOrDefault(m => SharedListNames.Key(m.Name) == SharedListNames.Key(name));
|
|
|
|
public MaterialConfig? GetMaterial(string name, string grade) =>
|
|
Materials.FirstOrDefault(m =>
|
|
SharedListNames.Key(m.Name) == SharedListNames.Key(name)
|
|
&& SharedListNames.Key(m.Grade) == SharedListNames.Key(grade)
|
|
);
|
|
|
|
/// <summary>
|
|
/// Returns every grade on file for the given material name.
|
|
/// </summary>
|
|
public IEnumerable<MaterialConfig> GetGrades(string name) =>
|
|
Materials.Where(m => SharedListNames.Key(m.Name) == SharedListNames.Key(name));
|
|
|
|
/// <summary>Fields a newer OpenNest wrote, kept so saving here does not drop them.</summary>
|
|
[System.Text.Json.Serialization.JsonExtensionData]
|
|
public Dictionary<string, System.Text.Json.JsonElement>? Unknown { get; set; }
|
|
}
|