using HardwareWeb.Models; using HardwareWeb.Services; using Microsoft.AspNetCore.Mvc; namespace HardwareWeb.Controllers { /// 硬件设备连接状态与重试。 [ApiController] [Route("api/devices")] public class DeviceController : ControllerBase { private readonly DeviceConnectionService _devices; public DeviceController(DeviceConnectionService devices) { _devices = devices; } /// 读取位移台/对焦系统/光谱仪/相机的连接状态。 [HttpGet("status")] [ProducesResponseType(typeof(DeviceStatusPayload), StatusCodes.Status200OK)] public IActionResult Status() => Ok(_devices.GetSnapshot()); /// 重试连接所有未连接的设备。 [HttpPost("retry")] [ProducesResponseType(typeof(DeviceStatusPayload), StatusCodes.Status200OK)] public async Task Retry(CancellationToken ct) => Ok(await _devices.RetryFailedAsync(ct)); } }