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.

285 lines
9.0 KiB

5 months ago
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]
5 months ago
[Route("SendInitializeCommandReq")]
public Result<bool> SendInitializeCommandReq()
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendInitializeCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
///// <summary>
///// 发送出库命令
///// </summary>
///// <param name="sn">充电机编号</param>
///// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendOutboundCommandReq/{outboundMode}/{takePositionNumber}")]
public Result<bool> SendOutboundCommandReq( byte outboundMode, byte takePositionNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendOutboundCommandReq(outboundMode, takePositionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送开始换电命令
/// </summary>
/// <param name="sn">充电机编号</param>`
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendStartBatterySwapReq/{takePositionNumber}/{positionNumber}")]
public Result<bool> SendStartBatterySwapReq( byte takePositionNumber, byte positionNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendStartBatterySwapReq(takePositionNumber, positionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送开始搬电命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendStartMovElectricityReq/{takeBatteryShelfNumber}/{saveBatteryShelfNumber}")]
public Result<bool> SendStartMovElectricityReq( byte takeBatteryShelfNumber, byte saveBatteryShelfNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendStartMovElectricityReq(takeBatteryShelfNumber, saveBatteryShelfNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送车辆型号
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendVehicleModelReq/{cartNo}")]
public Result<bool> SendVehicleModelReq( byte cartNo)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendVehicleModelReq(cartNo);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送移库命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendMoveCommandReq/{takePositionNumber}/{positionNumber}")]
public Result<bool> SendMoveCommandReq( byte takePositionNumber, byte positionNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendMoveCommandReq(takePositionNumber, positionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送红绿灯命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
[Route("SendTrafficLightReq/{trafficLight}")]
public Result<bool> SendTrafficLightReq(byte trafficLight)
{
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
if (chargerClient != null)
{
return chargerClient.SendTrafficLightReq(trafficLight);
}
return Result<bool>.Fail("PLC未连接");
}
5 months ago
/// <summary>
/// 发送继续命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendContinueCommandReq")]
public Result<bool> SendContinueCommandReq()
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendContinueCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送暂停命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendPauseCommandReq")]
public Result<bool> SendPauseCommandReq()
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendPauseCommandReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送入库命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendInboundCommandsReq/{positionNumber}")]
public Result<bool> SendInboundCommandsReq(byte positionNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendInboundCommandsReq(positionNumber);
}
return Result<bool>.Fail("PLC未连接");
5 months ago
}
5 months ago
/// <summary>
/// 发送终止命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendTerminationOrderReq")]
public Result<bool> SendTerminationOrderReq()
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendTerminationOrderReq();
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送故障复位命令
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendFaultResetReq")]
public Result<bool> SendFaultResetReq()
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
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.Plc.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
// if (chargerClient != null)
// {
// return chargerClient.SendParameterSettingsReq(messageBodyAddress, parameterType, parameter);
// }
// return Result<bool>.Fail("充电机未连接");
//}
/// <summary>
/// 发送参数设置
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendParameterSettingsReq/{parameterType}/{parameter}")]
public Result<bool> SendParameterSettingsReq( byte parameterType, byte parameter)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendParameterSettingsReq( parameterType, parameter);
5 months ago
}
5 months ago
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 发送准备电池开启
/// </summary>
/// <param name="sn">充电机编号</param>
/// <param name="msg">消息</param>
[HttpGet]
5 months ago
[Route("SendPrepareBatteryOnReq/{readyBatterySign}/{takePositionNumber}")]
public Result<bool> SendPrepareBatteryOnReq( byte readyBatterySign, byte takePositionNumber)
5 months ago
{
5 months ago
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
5 months ago
if (chargerClient != null)
{
return chargerClient.SendPrepareBatteryOnReq(readyBatterySign, takePositionNumber);
}
return Result<bool>.Fail("充电机未连接");
}
#endregion
}