using Autofac.Core;
|
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using WIDESEA_ISerialPortService;
|
using WIDESEA_SerialPortService;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseController;
|
using WIDESEAWCS_Model.Models.SerialPort;
|
using WIDESEAWCS_QuartzJob.Service;
|
//using WIDESEA_ISerialPortService.ISerialPortService;
|
|
namespace WIDESEAWCS_Server.Controllers.SerialPort
|
{
|
[Route("api/[controller]")]
|
[ApiController]
|
public class SerialPortController : ApiBaseController<ISerialPortService, Dt_TorqueOp>
|
{
|
private readonly ISerialPortService _serialPortService;
|
// 构造函数注入服务
|
public SerialPortController(ISerialPortService serialPortService):base(serialPortService)
|
{
|
_serialPortService = serialPortService;
|
}
|
|
|
[HttpPost, Route("AddStudent"), AllowAnonymous]
|
public WebResponseContent AddStudent([FromBody] Dt_TorqueOp TorqueOp)
|
{
|
return Service.AddSerialPort(TorqueOp);
|
}
|
|
/// <summary>
|
/// 开启
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost, Route("StartSerialPortCom"), AllowAnonymous]
|
public IActionResult StartSerialPortCom()
|
{
|
Service.StartSerialPortCom();
|
return Ok(new { messga = "开启成功" });
|
}
|
|
/// <summary>
|
/// 关
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost,Route("StopSerialPortCom"),AllowAnonymous]
|
public IActionResult StopSerialPortCom()
|
{
|
_serialPortService.StopSerialPortCom();
|
return Ok(new { messga = "关闭成功" });
|
}
|
|
/// <summary>
|
/// 查
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet, Route("GetSerialPortCom"), AllowAnonymous]
|
public IActionResult GetSerialPortCom()
|
{
|
|
var receivedData = _serialPortService.GetSerialPortCom(); // 调用 SerialPortService 的 GetReceivedData 方法
|
return Ok(receivedData); // 返回接收到的数据
|
|
}
|
}
|
}
|