using OrpaonVision.Core.Results; using OrpaonVision.SiteApp.Runtime.Contracts; using OrpaonVision.SiteApp.Runtime.Options; namespace OrpaonVision.SiteApp.Runtime.Services { /// /// 运行状态机简化实现(MVP 阶段)。 /// public sealed class SimpleRuntimeStateMachineService : IRuntimeStateMachineService { private readonly RuntimeOptions _options; private int _currentLayer; /// /// 构造函数。 /// public SimpleRuntimeStateMachineService(RuntimeOptions options) { _options = options; _currentLayer = 1; } /// public RuntimeStateSnapshotDto GetSnapshot() { return new RuntimeStateSnapshotDto { CurrentLayer = _currentLayer, TotalLayers = _options.TotalLayers, StateText = _currentLayer > _options.TotalLayers ? "工位完成" : "运行中" }; } /// public Result MoveToNextLayer() { if (_currentLayer >= _options.TotalLayers) { return Result.Fail("STATE_MACHINE_FINISHED", "当前已到最后一层,无法继续切层。"); } _currentLayer += 1; return Result.Success("STATE_MACHINE_MOVED", $"已切换到第 {_currentLayer} 层。"); } /// public void Reset() { _currentLayer = 1; } } }