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