|
|
|
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")]
|
|
|
|
public Result<bool> SendInitializeCommandReq()
|
|
|
|
{
|
|
|
|
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/{outboundMode}/{takePositionNumber}")]
|
|
|
|
public Result<bool> SendOutboundCommandReq( 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/{takePositionNumber}/{positionNumber}")]
|
|
|
|
public Result<bool> SendStartBatterySwapReq( 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/{takeBatteryShelfNumber}/{saveBatteryShelfNumber}")]
|
|
|
|
public Result<bool> SendStartMovElectricityReq( 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/{cartNo}")]
|
|
|
|
public Result<bool> SendVehicleModelReq( 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/{takePositionNumber}/{positionNumber}")]
|
|
|
|
public Result<bool> SendMoveCommandReq( 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("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("充电机未连接");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 发送继续命令
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sn">充电机编号</param>
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("SendContinueCommandReq")]
|
|
|
|
public Result<bool> SendContinueCommandReq()
|
|
|
|
{
|
|
|
|
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")]
|
|
|
|
public Result<bool> SendPauseCommandReq()
|
|
|
|
{
|
|
|
|
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/{positionNumber}")]
|
|
|
|
public Result<bool> SendInboundCommandsReq(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")]
|
|
|
|
public Result<bool> SendTerminationOrderReq()
|
|
|
|
{
|
|
|
|
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")]
|
|
|
|
public Result<bool> SendFaultResetReq()
|
|
|
|
{
|
|
|
|
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.Plc.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/{parameterType}/{parameter}")]
|
|
|
|
public Result<bool> SendParameterSettingsReq( 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/{readyBatterySign}/{takePositionNumber}")]
|
|
|
|
public Result<bool> SendPrepareBatteryOnReq( byte readyBatterySign, byte takePositionNumber)
|
|
|
|
{
|
|
|
|
Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient;
|
|
|
|
if (chargerClient != null)
|
|
|
|
{
|
|
|
|
return chargerClient.SendPrepareBatteryOnReq(readyBatterySign, takePositionNumber);
|
|
|
|
}
|
|
|
|
return Result<bool>.Fail("充电机未连接");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|