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")] public Result SendInitializeCommandReq() { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendInitializeCommandReq(); } return Result.Fail("充电机未连接"); } ///// ///// 发送出库命令 ///// ///// 充电机编号 ///// 消息 [HttpGet] [Route("SendOutboundCommandReq/{outboundMode}/{takePositionNumber}")] public Result SendOutboundCommandReq( 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/{takePositionNumber}/{positionNumber}")] public Result SendStartBatterySwapReq( 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/{takeBatteryShelfNumber}/{saveBatteryShelfNumber}")] public Result SendStartMovElectricityReq( 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/{cartNo}")] public Result SendVehicleModelReq( byte cartNo) { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendVehicleModelReq(cartNo); } return Result.Fail("充电机未连接"); } /// /// 发送移库命令 /// /// 充电机编号 /// 消息 [HttpGet] [Route("SendMoveCommandReq/{takePositionNumber}/{positionNumber}")] public Result SendMoveCommandReq( 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")] public Result SendContinueCommandReq() { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendContinueCommandReq(); } return Result.Fail("充电机未连接"); } /// /// 发送暂停命令 /// /// 充电机编号 /// 消息 [HttpGet] [Route("SendPauseCommandReq")] public Result SendPauseCommandReq( ) { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendPauseCommandReq(); } return Result.Fail("充电机未连接"); } /// /// 发送入库命令 /// /// 充电机编号 /// 消息 [HttpGet] [Route("SendInboundCommandsReq/{positionNumber}")] public Result SendInboundCommandsReq(byte positionNumber) { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendInboundCommandsReq(positionNumber); } return Result.Fail("充电机未连接"); } /// /// 发送终止命令 /// /// 充电机编号 /// 消息 [HttpGet] [Route("SendTerminationOrderReq")] public Result SendTerminationOrderReq() { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendTerminationOrderReq(); } return Result.Fail("充电机未连接"); } /// /// 发送故障复位命令 /// /// 充电机编号 /// 消息 [HttpGet] [Route("SendFaultResetReq")] public Result SendFaultResetReq() { 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/{parameterType}/{parameter}")] public Result SendParameterSettingsReq( 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/{readyBatterySign}/{takePositionNumber}")] public Result SendPrepareBatteryOnReq( byte readyBatterySign, byte takePositionNumber) { Service.Charger.Server.PlcClient? chargerClient = ClientMgr.PlcClient; if (chargerClient != null) { return chargerClient.SendPrepareBatteryOnReq(readyBatterySign, takePositionNumber); } return Result.Fail("充电机未连接"); } #endregion }