feat: add bounded visualization snapshots

This commit is contained in:
梁薄云
2026-08-06 09:27:58 +08:00
parent 55d8e1eebf
commit ab8e4010f8
6 changed files with 269 additions and 0 deletions
@@ -0,0 +1,45 @@
using System;
namespace TrajectoryPlanningVisualization;
public sealed class PlanningVisualizationOptions
{
public int Port { get; set; } = 0;
public int RefreshRateHz { get; set; } = 10;
public int HistoryCycleLimit { get; set; } = 60;
public PlanningVisualizationOptionsSnapshot CreateValidatedSnapshot()
{
if (Port < 0 || Port > 65535)
{
throw new ArgumentOutOfRangeException(nameof(Port), "Port must be in the range 0 to 65535.");
}
if (RefreshRateHz <= 0)
{
throw new ArgumentOutOfRangeException(nameof(RefreshRateHz), "Refresh rate must be positive.");
}
if (HistoryCycleLimit <= 0)
{
throw new ArgumentOutOfRangeException(nameof(HistoryCycleLimit), "History cycle limit must be positive.");
}
return new PlanningVisualizationOptionsSnapshot(Port, RefreshRateHz, HistoryCycleLimit);
}
}
public sealed class PlanningVisualizationOptionsSnapshot
{
internal PlanningVisualizationOptionsSnapshot(int port, int refreshRateHz, int historyCycleLimit)
{
Port = port;
RefreshRateHz = refreshRateHz;
HistoryCycleLimit = historyCycleLimit;
}
public int Port { get; }
public int RefreshRateHz { get; }
public int HistoryCycleLimit { get; }
public int MaximumClients => 2;
}