mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 10:21:08 -04:00
A Grbl-style lookahead planner re-times the cut simulation with trapezoidal acceleration, junction-deviation corner speeds and a centripetal cap on arcs. Machines gain cut/rapid acceleration and corner deviation in Machine Configuration, with placeholder values until the controller's are entered. The simulator and Calculate Cut Time pick the machine (or full speed), and the simulator shows the live head speed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.0 KiB
C#
48 lines
2.0 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; }
|
|
|
|
public MotionConfig GetMotionOrPlaceholder() => Motion ?? MotionConfig.Placeholder(Units);
|
|
|
|
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));
|
|
}
|