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.
iot/projects/IoT/IoTServices/FBeeService/Controllers/Switch3Controller.cs

95 lines
3.1 KiB

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(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 1, 0x10);
this._deviceService.X82(gateway, id, 1, 0x11);
this._deviceService.X82(gateway, id, 1, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 0, 0x10);
this._deviceService.X82(gateway, id, 0, 0x11);
this._deviceService.X82(gateway, id, 0, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1On(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 1, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1Off(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 0, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2On(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 1, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2Off(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 0, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3On(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 1, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3Off(string gateway, string id)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, id, 0, 0x12);
});
}
}
}