From 0761a2cd1d82b48ea8e645b270d78679711f28a1 Mon Sep 17 00:00:00 2001 From: zby <24947@USER> Date: Fri, 13 Sep 2024 14:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=A2=E7=BB=BF=E7=81=AF?= =?UTF-8?q?=E5=B8=A7=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Execute/Step/CarCtrlState.cs | 4 +- Service/Execute/Step/CarPrepareState.cs | 6 +-- Service/Execute/Step/DoSwappingState.cs | 2 +- Service/Execute/Step/StationReadyState.cs | 45 +++++++++++++-------- Service/Execute/Step/SwapDoneState.cs | 6 +-- Service/Execute/SwappingStateMachine.cs | 23 ++++++----- Service/Plc/Codec/Decoder.cs | 2 +- Service/Plc/Msg/Host/Req/TrafficLightReq.cs | 2 +- WebStarter/appsettings.prod.json | 2 +- 9 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 19c7959..98f8a4b 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -58,13 +58,13 @@ public class CarCtrlState : IState return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled, () => machine.VelUnlockFlag, () => { - Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); var resultHeartBeatMsg = carInfo.Result.CarStatus; if (resultHeartBeatMsg?.LockStatus == 1 || machine.ManualConfirmCarUnlockFlag) { diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index ec13071..2178d2f 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -166,7 +166,7 @@ public class CarPrepareState : IState return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { - Task result = TBoxApi.IsConnected(machine.RfidReadModel.VelNo); + Task result = TBoxApi.IsConnected(machine.RfidReadModel.VelVin); // result.Wait(); bool isConnect = result.Result; @@ -213,12 +213,12 @@ public class CarPrepareState : IState return Invoker.Invoke("TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { - Task result = TBoxApi.Connect(machine.RfidReadModel.VelNo); + Task result = TBoxApi.Connect(machine.RfidReadModel.VelVin); bool isConnect = result.Result; if (isConnect) { //读取车辆carNo=carVin - Task carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); + Task carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); var tboxCarInfoModel = carInfoResult.Result; var carInfo = tboxCarInfoModel?.CarInfo; if (carInfo != null) diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 489315f..50fc156 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -162,7 +162,7 @@ public class DoSwappingState : IState return Invoker.Invoke("StartSwapping", 1000, 5, machine.IsCanceled, () => machine.StartSwappingFlag, () => { - Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index ee7e741..22a4e5e 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -47,6 +47,9 @@ public class StationReadyState : IState return null; } + + + //plc是否是自动模式 var plcIsAuto = PlcIsAuto(machine); if (InvokeStatus.Done != plcIsAuto) @@ -61,26 +64,24 @@ public class StationReadyState : IState return SwappingStateMachine.ReturnWithInvokeErr(plcIsRemote, ExceptionReason.None); } + ////开启雷达 + //var beginRadar = ControlRadar(machine, 1); + //if (InvokeStatus.Done != beginRadar) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(beginRadar, ExceptionReason.None); + //} - //开启雷达 - var beginRadar = ControlRadar(machine, 1); - if (InvokeStatus.Done != beginRadar) - { - return SwappingStateMachine.ReturnWithInvokeErr(beginRadar, ExceptionReason.None); - } - - //调整车辆 - var adjustCarByRadar = AdjustCarByRadar(machine); - if (InvokeStatus.Done != adjustCarByRadar) - { - return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); - } - + ////调整车辆 + //var adjustCarByRadar = AdjustCarByRadar(machine); + //if (InvokeStatus.Done != adjustCarByRadar) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); + //} //手动模式 if (StaticStationInfo.VehicleManually == 1) { - + var rfidPrepared = WaitVinPrepare(machine); if (InvokeStatus.Done != rfidPrepared) { @@ -102,10 +103,16 @@ public class StationReadyState : IState if (InvokeStatus.Done != readRfid) { return SwappingStateMachine.ReturnWithInvokeErr(readRfid, ExceptionReason.ReadRfidError); - } + } } + + + + + + return new StateResult() { SwappingState = SwappingState.CarPrepare, @@ -139,7 +146,11 @@ public class StationReadyState : IState //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoStationModel) ; LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoStationModel.GetLed()); - }, true, () => { }, 5, InvokeStatus.None); + }, true, + () => + { + + }, 5, InvokeStatus.None); } diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index df088f6..bf5925c 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -29,13 +29,11 @@ public class SwapDoneState : IState public StateResult Handle(SwappingStateMachine machine) { //更新换电订单 - machine.SwapOrder!.SwapResult = machine.SwapStatus; machine.SwapOrder.SwapEndTime = DateTime.Now; machine.SwapOrder.FailReason = machine.SwapFailReason; _CommonMgr.UpdateSwapOrder(machine); - ////修改预约单 if (machine.SwapOrderBatteryInfo!.swapAmtOrder != null) { @@ -215,13 +213,13 @@ public class SwapDoneState : IState return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, machine.IsManualSwapSucc, () => machine.VelLockFlag, () => { - Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); if (carInfo.Result?.CarStatus?.LockStatus == 2 || machine.ManualConfirmCarLockFlag) { diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs index 12b6a7d..eff75fa 100644 --- a/Service/Execute/SwappingStateMachine.cs +++ b/Service/Execute/SwappingStateMachine.cs @@ -331,17 +331,22 @@ public class SwappingStateMachine : IDisposable StepSort = 0; Array values = Enum.GetValues(typeof(InfoEnum.BusinessSwappingStep)); - foreach (var value in values) + foreach (var key in StepModel.Keys.ToList()) { - StepModel[(string)value] = new StepModel() - { - StepNo = (int)value, - Status = 0, - StepName = BaseEnumExtensions.GetEnumDescriptionByCode((int)value) - } - ; - ; + StepModel[key].Status = 0; + StepModel[key].StartTime = null; } + //foreach (var value in values) + //{ + // StepModel[(string)value] = new StepModel() + // { + // StepNo = (int)value, + // Status = 0, + // StepName = BaseEnumExtensions.GetEnumDescriptionByCode((int)value) + // } + // ; + // ; + //} PlcSwapFlag = false; ManualSwapSuccFlag = false; diff --git a/Service/Plc/Codec/Decoder.cs b/Service/Plc/Codec/Decoder.cs index e2a23ac..094314f 100644 --- a/Service/Plc/Codec/Decoder.cs +++ b/Service/Plc/Codec/Decoder.cs @@ -197,7 +197,7 @@ public class Decoder : ByteToMessageDecoder /*0x*/ 94 => ModelConvert.Decode(bytes), - 119=> ModelConvert.Decode < TrafficLightResq>(bytes), + 121=> ModelConvert.Decode < TrafficLightResq>(bytes), _ => new ASDU() }; diff --git a/Service/Plc/Msg/Host/Req/TrafficLightReq.cs b/Service/Plc/Msg/Host/Req/TrafficLightReq.cs index 87035b4..8fa03b7 100644 --- a/Service/Plc/Msg/Host/Req/TrafficLightReq.cs +++ b/Service/Plc/Msg/Host/Req/TrafficLightReq.cs @@ -16,7 +16,7 @@ public class TrafficLightReq: ASDU { public TrafficLightReq(byte trafficLight) { - FrameTypeNo = 118; + FrameTypeNo = 120; MsgBodyCount = 1; TransReason = 3; PublicAddr = 0; diff --git a/WebStarter/appsettings.prod.json b/WebStarter/appsettings.prod.json index 6b36c37..581f8c5 100644 --- a/WebStarter/appsettings.prod.json +++ b/WebStarter/appsettings.prod.json @@ -143,7 +143,7 @@ "Enabled": false }, "led": { - "enable": true, + "enable": false, "ip": "192.168.3.79", "port": 10000 }