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