using Application.Models; using IoT.Shared.Controllers; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using System; namespace FBeeService.Controllers { [SwaggerTag("红外转发器")] public class IrController : BaseDeviceController { private readonly DeviceService _deviceService; public IrController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices) { this._deviceService = deviceService; } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("发送指令")] public ApiResponse Send([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值")]ushort code) { return this.AsyncAction(() => { this._deviceService.XA70082(gateway, number, type, code); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("学习")] public ApiResponse Study([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值")]ushort code) { return this.AsyncAction(() => { this._deviceService.XA70083(gateway, number, type, code); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("启用空调")] public ApiResponse KeyCodeType1On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType1", "开"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("禁用空调")] public ApiResponse KeyCodeType1Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType1", "关"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("启用电视")] public ApiResponse KeyCodeType2On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType2", "开"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("禁用电视")] public ApiResponse KeyCodeType2Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType2", "关"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("启用图影仪")] public ApiResponse KeyCodeType3On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType3", "开"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("禁用图影仪")] public ApiResponse KeyCodeType3Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType3", "关"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("启用机顶盒")] public ApiResponse KeyCodeType4On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType4", "开"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("禁用机顶盒")] public ApiResponse KeyCodeType4Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType4", "关"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("启用自定义")] public ApiResponse KeyCodeType5On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType5", "开"); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("禁用自定义")] public ApiResponse KeyCodeType5Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType5", "关"); }); } } }