using System.Text.Json.Serialization;
namespace Flyshot.Core.Domain;
///
/// Describes the sampled shot-event mapping that downstream monitoring and reports consume.
///
public sealed class ShotEvent
{
///
/// Initializes a validated shot-event mapping result.
///
public ShotEvent(int waypointIndex, double triggerTime, int sampleIndex, double sampleTime, IoAddressGroup addressGroup)
{
if (waypointIndex < 0)
{
throw new ArgumentOutOfRangeException(nameof(waypointIndex), "Waypoint index must be zero or positive.");
}
if (triggerTime < 0.0)
{
throw new ArgumentOutOfRangeException(nameof(triggerTime), "Trigger time must be zero or positive.");
}
if (sampleIndex < 0)
{
throw new ArgumentOutOfRangeException(nameof(sampleIndex), "Sample index must be zero or positive.");
}
if (sampleTime < 0.0)
{
throw new ArgumentOutOfRangeException(nameof(sampleTime), "Sample time must be zero or positive.");
}
WaypointIndex = waypointIndex;
TriggerTime = triggerTime;
SampleIndex = sampleIndex;
SampleTime = sampleTime;
AddressGroup = addressGroup ?? throw new ArgumentNullException(nameof(addressGroup));
}
///
/// Gets the original teach-waypoint index.
///
[JsonPropertyName("waypointIndex")]
public int WaypointIndex { get; }
///
/// Gets the mathematically resolved trigger time.
///
[JsonPropertyName("triggerTime")]
public double TriggerTime { get; }
///
/// Gets the discrete sample index selected by the trigger scheduler.
///
[JsonPropertyName("sampleIndex")]
public int SampleIndex { get; }
///
/// Gets the sampled trigger time used by runtime outputs.
///
[JsonPropertyName("sampleTime")]
public double SampleTime { get; }
///
/// Gets the IO address group associated with the trigger.
///
[JsonPropertyName("addressGroup")]
public IoAddressGroup AddressGroup { get; }
}