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.

266 lines
8.7 KiB

using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Repository.Station;
using Service.Charger.Client;
using Service.Init;
namespace WebStarter.Controllers;
/// <summary>
/// 充电机管理
/// </summary>
//[Produces("application/json")]
[ApiController]
[Route("api/[controller]")]
public class PlcController : ControllerBase
{
#region send
/// <summary>
/// 发送初始化命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendInitializeCommandReq/{code}")]
public Result<bool> SendInitializeCommandReq(string code)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendInitializeCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
///// <summary>
///// 发送出库命令
///// </summary>
///// <param name="sn">充电机编号</param>
///// <param name="msg">消息</param>
[HttpGet]
[Route("SendOutboundCommandReq/{code}/{outboundMode}/{takePositionNumber}")]
public Result<bool> SendOutboundCommandReq(string code, byte outboundMode, byte takePositionNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendOutboundCommandReq(outboundMode, takePositionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送开始换电命令
/// </summary>
/// <param name="sn">充电机编号</param>`
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendStartBatterySwapReq/{code}/{takePositionNumber}/{positionNumber}")]
public Result<bool> SendStartBatterySwapReq(string code, byte takePositionNumber, byte positionNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendStartBatterySwapReq(takePositionNumber, positionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送开始搬电命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendStartMovElectricityReq/{code}/{takeBatteryShelfNumber}/{saveBatteryShelfNumber}")]
public Result<bool> SendStartMovElectricityReq(string code, byte takeBatteryShelfNumber, byte saveBatteryShelfNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendStartMovElectricityReq(takeBatteryShelfNumber, saveBatteryShelfNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送车辆型号
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendVehicleModelReq/{code}/{cartNo}")]
public Result<bool> SendVehicleModelReq(string code, byte cartNo)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendVehicleModelReq(cartNo);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送移库命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendMoveCommandReq/{code}/{takePositionNumber}/{positionNumber}")]
public Result<bool> SendMoveCommandReq(string code, byte takePositionNumber, byte positionNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendMoveCommandReq(takePositionNumber, positionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送继续命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendContinueCommandReq/{code}")]
public Result<bool> SendContinueCommandReq(string code)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendContinueCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送暂停命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendPauseCommandReq/{code}")]
public Result<bool> SendPauseCommandReq(string code)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendPauseCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送入库命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendInboundCommandsReq/{code}/{positionNumber}")]
public Result<bool> SendInboundCommandsReq(string code, byte positionNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendInboundCommandsReq(positionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送终止命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendTerminationOrderReq/{code}")]
public Result<bool> SendTerminationOrderReq(string code)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendTerminationOrderReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送故障复位命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendFaultResetReq/{code}")]
public Result<bool> SendFaultResetReq(string code)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendFaultResetReq();
}
return Result<bool>.Fail("充电机未连接");
}
///// <summary>
///// 发送参数设置
///// </summary>
///// <param name="sn">充电机编号</param>
///// <param name="msg">消息</param>
//[HttpGet]
//[Route("SendParameterSettingsReq/{code}/{messageBodyAddress}/{parameterType}/{parameter}")]
//public Result<bool> SendParameterSettingsReq(string code, byte[] messageBodyAddress, byte parameterType, byte parameter)
//{
// Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
// if (chargerClient != null)
// {
// return chargerClient.SendParameterSettingsReq(messageBodyAddress, parameterType, parameter);
// }
// return Result<bool>.Fail("充电机未连接");
//}
/// <summary>
/// 发送参数设置
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendParameterSettingsReq/{code}/{parameterType}/{parameter}")]
public Result<bool> SendParameterSettingsReq(string code, byte parameterType, byte parameter)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendParameterSettingsReq( parameterType, parameter);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送准备电池开启
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendPrepareBatteryOnReq/{code}/{readyBatterySign}/{takePositionNumber}")]
public Result<bool> SendPrepareBatteryOnReq(string code, byte readyBatterySign, byte takePositionNumber)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendPrepareBatteryOnReq(readyBatterySign, takePositionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
#endregion
}