From 612c2ee9b1c4f8114c0f8da5524e67879b2ffdd8 Mon Sep 17 00:00:00 2001 From: lxw Date: Wed, 29 May 2024 19:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=BE=E5=A0=B4=E6=B8=AC=E8=A9=A6=E4=B8=BB?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Constant/InfoEnum.cs | 4 ++-- Service/Execute/Step/CarPrepareState.cs | 4 ++-- Service/Execute/Step/DoSwappingState.cs | 8 ++++--- Service/Plc/Client/PlcClient.cs | 31 +++++-------------------- Service/Station/SwapOrderStepService.cs | 2 +- WebStarter/Program.cs | 2 +- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Entity/Constant/InfoEnum.cs b/Entity/Constant/InfoEnum.cs index 6376549..536064e 100644 --- a/Entity/Constant/InfoEnum.cs +++ b/Entity/Constant/InfoEnum.cs @@ -31,8 +31,8 @@ public class InfoEnum [Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition , [Info("换电已完成,请驶离", "换电已完成,请驶离")] InfoCarLeave , [Info("换电失败,请驶离", "换电失败,请驶离")] ErrInfoCarLeave , - [Info("旧电池搬运中,请稍后", "旧电池搬运中,请稍后")] InfoOldBatteryCarryIn , - [Info("新电池搬运中,请稍后", "新电池搬运中,请稍后")] InfoNewBatteryCarryOut , + [Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn , + [Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut , [Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar , [Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr, [Info("结束充电电池数量不足","通道的电池仓无可用换电电池")] LessOfFinishChargingErr, diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 4cd9cc4..383bd41 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -184,7 +184,7 @@ public class CarPrepareState : IState /// public InvokeStatus CheckTBoxConnectFlag(SwappingStateMachine machine) { - return Invoker.Invoke("check TBox connect", 1000, 100, machine.IsCanceled, + return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { Task result = TBoxApi.IsConnected(); @@ -200,7 +200,7 @@ public class CarPrepareState : IState // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); } - , 30, InvokeStatus.None); + , 20, InvokeStatus.None); } diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index ccbbd0d..098e1d5 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -340,13 +340,15 @@ public class DoSwappingState : IState while (!machine.ChannelStatusOkFlag) { _log.Info("begin plc CheckChannelStatus"); - Thread.Sleep(1000); + Thread.Sleep(2000); var channelStatus = PlcApi.ChannelStatus(); if (count % 10 == 0) { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo); } + count++; + if (channelStatus == 1000) { machine.ChannelStatusOkFlag = true; @@ -360,8 +362,8 @@ public class DoSwappingState : IState { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus); - //等待3分钟 - Thread.Sleep(3000); + //等待2分钟 + Thread.Sleep(60000); machine.VehiclesInPlace2Flag = false; machine.StartSwappingFlag = false; machine.PlcHoldFlag = false; diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index 00c0783..4cd54bc 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -41,45 +41,26 @@ public class PlcClient : ModbusTcpMaster { PlcMgr.DataValidityTime = DateTime.Now; ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData); - if (PlcMgr.PlcToHostData.MaterialDetec01.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "1"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1"); - if (PlcMgr.PlcToHostData.MaterialDetec02.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "2"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value, it => it.No == "2"); - if (PlcMgr.PlcToHostData.MaterialDetec03.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "3"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value, it => it.No == "3"); - if (PlcMgr.PlcToHostData.MaterialDetec04.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "4"); - else _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value, it => it.No == "4"); - if (PlcMgr.PlcToHostData.MaterialDetec05.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "5"); - else _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value, it => it.No == "5"); - if (PlcMgr.PlcToHostData.MaterialDetec06.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "6"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value, it => it.No == "6"); - if (PlcMgr.PlcToHostData.MaterialDetec07.Value == 1) - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "7"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value, it => it.No == "7"); - if (PlcMgr.PlcToHostData.MaterialDetec08.Value == 1) - - _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "8"); - else + _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value, it => it.No == "8"); } diff --git a/Service/Station/SwapOrderStepService.cs b/Service/Station/SwapOrderStepService.cs index 65300ee..fd44d4b 100644 --- a/Service/Station/SwapOrderStepService.cs +++ b/Service/Station/SwapOrderStepService.cs @@ -82,7 +82,7 @@ public class SwapOrderStepService : BaseServices { SwapOrderStep swapOrderStep = new () { - StepName = BaseEnumExtensions.GetNameByEnum(step), + StepName = BaseEnumExtensions.GetDescription(step), Step = (int)step, Sort = sort, SwapOrderSn = swapOrderSn, diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 6ea7d1b..b8ef083 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -156,6 +156,6 @@ CloudClientMgr.Init(); //PLC PlcMgr.Init(); //启动换电流程 -StationSoftMgr.SwappingStateMachineStart(); +//StationSoftMgr.SwappingStateMachineStart(); //StationSoftMgr.StartTasks(); app.Run(); \ No newline at end of file