You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.9 KiB
78 lines
2.9 KiB
using IoTNode.DeviceServices.FBee;
|
|
using IoT.Shared.Application.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace IoTNode.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("设备编号"), Required] string number, [SwaggerParameter("按键类型"), Required] byte type, [SwaggerParameter("键值"), Required] 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("设备编号"), Required] string number, [SwaggerParameter("按键类型"), Required] byte type, [SwaggerParameter("键值"), Required, Range(603, 703)] 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 Buttons([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("指令"), Required] string buttons)
|
|
{
|
|
return this.AsyncAction(() =>
|
|
{
|
|
this._deviceService.UpdateButtons(number, buttons);
|
|
});
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("空调匹配")]
|
|
public ApiResponse Match1([SwaggerParameter("设备编号"), Required] string number)
|
|
{
|
|
return this.AsyncAction(() =>
|
|
{
|
|
this._deviceService.IRMath(number, 1);
|
|
});
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("电视匹配")]
|
|
public ApiResponse Match2([SwaggerParameter("设备编号"), Required] string number)
|
|
{
|
|
return this.AsyncAction(() =>
|
|
{
|
|
this._deviceService.IRMath(number, 2);
|
|
});
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("机顶盒匹配")]
|
|
public ApiResponse Match3([SwaggerParameter("设备编号"), Required] string number)
|
|
{
|
|
return this.AsyncAction(() =>
|
|
{
|
|
this._deviceService.IRMath(number, 3);
|
|
});
|
|
}
|
|
}
|
|
}
|