using System;
using OpenNest.Data;
namespace OpenNest.Desktop;
///
/// The cut-time values entered in Calculate Cut Time or the simulator, with the ranges their
/// WinForms boxes take: feeds and rapid from 1 to 9999 per time unit, pierce seconds from 0 to
/// 100 in the dialog and to 999 in the simulator.
///
public static class CutTimeEntry
{
public const decimal MinimumRate = 1;
public const decimal MaximumRate = 9999;
public const decimal DialogMaximumPierce = 100;
public const decimal SimulatorMaximumPierce = 999;
/// A value shown in a box from to .
public static decimal Clamp(double value, decimal minimum, decimal maximum) =>
System.Math.Clamp((decimal)value, minimum, maximum);
///
/// The parameters the entered values time with in , with
/// 's acceleration (null for full speed).
///
public static CutParameters Parameters(
decimal feed, decimal holeFeed, decimal rapid, decimal pierceSeconds, bool skipEtch,
Units units, MachineConfig machine) =>
new()
{
Feedrate = (double)feed,
HoleFeedrate = (double)holeFeed,
RapidTravelRate = (double)rapid,
PierceTime = TimeSpan.FromSeconds((double)pierceSeconds),
SkipScribe = skipEtch,
Units = units,
Motion = CutTimeMachineChoice.Motion(machine, units),
};
}