using Application.Models; using IoT.Shared.Controllers; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using System; namespace FBeeService.Controllers { [SwaggerTag("3路开关")] public class Switch3Controller : BaseDeviceController { private readonly DeviceService _deviceService; public Switch3Controller(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices) { this._deviceService = deviceService; } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("全开")] public ApiResponse On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 1, 0x10); this._deviceService.X82(gateway, number, 1, 0x11); this._deviceService.X82(gateway, number, 1, 0x12); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("全关")] public ApiResponse Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 0, 0x10); this._deviceService.X82(gateway, number, 0, 0x11); this._deviceService.X82(gateway, number, 0, 0x12); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1开")] public ApiResponse L1On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 1, 0x10); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1关")] public ApiResponse L1Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 0, 0x10); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2开")] public ApiResponse L2On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 1, 0x11); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2关")] public ApiResponse L2Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 0, 0x11); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3开")] public ApiResponse L3On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 1, 0x12); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3关")] public ApiResponse L3Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number) { return this.AsyncAction(() => { this._deviceService.X82(gateway, number, 0, 0x12); }); } } }