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