From ac5c571dcf6bde61ff0125277750373235a99d8f Mon Sep 17 00:00:00 2001 From: zby <2494737567@qq.com> Date: Tue, 22 Oct 2024 13:37:26 +0800 Subject: [PATCH] =?UTF-8?q?LED=E4=BF=AE=E6=94=B9?= 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 | 27 ++++++++++------ Service/Execute/Step/StationReadyState.cs | 38 +++++++++++------------ Service/Execute/Step/SwapDoneState.cs | 4 +-- Service/Led/LedClient.cs | 1 + Service/Plc/Client/ClientMgr.cs | 4 +-- 7 files changed, 45 insertions(+), 39 deletions(-) diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 232c2be..1b7c9df 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -47,7 +47,7 @@ public class CarCtrlState : IState /// public InvokeStatus UnLockCar(SwappingStateMachine machine) { - return Invoker.Invoke("UnLockCar", 500, 7, machine.IsCanceled, + return Invoker.Invoke("UnLockCar", 500, 4, machine.IsCanceled, () => machine.VelUnlockFlag, () => { Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); @@ -88,6 +88,6 @@ public class CarCtrlState : IState }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } - , 5, InvokeStatus.None); + , 3, InvokeStatus.None); } } \ No newline at end of file diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 7a61556..bb33fb7 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -228,8 +228,7 @@ public class CarPrepareState : IState i = 1; } LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); + Thread.Sleep(1000); break; case 5: _log.Info("radar 车辆靠前"); @@ -242,8 +241,7 @@ public class CarPrepareState : IState a = 1; } LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); + Thread.Sleep(1000); break; } }); diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 7248a52..52b5d92 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -30,7 +30,8 @@ public class DoSwappingState : IState public static SoundClient? SoundClient { get; set; } - + private int a = 0; + private int b = 0; public StateResult Handle(SwappingStateMachine machine) { //上报云平台换电开始 @@ -38,7 +39,7 @@ public class DoSwappingState : IState //记录为 换电任务 - + //下发启动换电 InvokeStatus startSwapping = StartSwapping(machine); if (startSwapping != InvokeStatus.Done) @@ -142,8 +143,14 @@ public class DoSwappingState : IState _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag, machine); - - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); + if (a == 0) + { + LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); + a = 1; + } + + + Thread.Sleep(1000); //LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); //查詢當前任務狀態是否被更改 if (startSwapping) @@ -186,12 +193,12 @@ public class DoSwappingState : IState return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, () => machine.UnOldBatteryFlag, () => { - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); + if (b==0) + { + LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); + b = 1; + } + SoundClient = AppInfo.Container.Resolve(); machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone; diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index fad6ad6..2aa686f 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -216,18 +216,9 @@ public class StationReadyState : IState PlcApi.Traffic(0); i = 0; a = 0; - - LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed()); - - - - _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag, machine,type: machine.ManualSkipRadar? (int)SwapConstant.StepType.MANUAL :(int)SwapConstant.StepType.AUTO); - } return PadarMgr._PadarClient?.CarState == 6 || machine.ManualSkipRadar; @@ -247,15 +238,12 @@ public class StationReadyState : IState che++; if (che == 10) { - LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed()); SoundClient.SoundPlay(SoundEnum.music100); Thread.Sleep(6000); SoundClient.SoundPlay(SoundEnum.music101); che = 1; } - break; case 4: _log.Info("radar 车辆靠后"); @@ -268,8 +256,7 @@ public class StationReadyState : IState i = 1; } LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); + Thread.Sleep(1000); break; case 5: _log.Info("radar 车辆靠前"); @@ -281,9 +268,9 @@ public class StationReadyState : IState SoundClient.SoundPlay(SoundEnum.music101); a = 0; } + LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); + Thread.Sleep(1000); break; } }); @@ -296,7 +283,6 @@ public class StationReadyState : IState { // Task open = RfidApi.Connect(); - machine.RfidConnectFlag = true; Task beginRead = RfidApi.BeginRead(); beginRead.Wait(); @@ -311,8 +297,6 @@ public class StationReadyState : IState machine.BeginRfidReadFlag = true; } - - }, () => { // machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); @@ -390,6 +374,21 @@ public class StationReadyState : IState // machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); SoundClient = AppInfo.Container.Resolve(); SoundClient.SoundPlay(SoundEnum.music42); + + Task beginRead = RfidApi.BeginRead(); + beginRead.Wait(); + if (!beginRead.Result) + { + _log.Info("begin read rfid error"); + } + else + { + machine.ExceptionReason = ExceptionReason.None; + _log.Info("begin read done"); + machine.BeginRfidReadFlag = true; + } + + }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30, InvokeStatus.None); } @@ -427,6 +426,7 @@ public class StationReadyState : IState SoundClient = AppInfo.Container.Resolve(); SoundClient.SoundPlay(SoundEnum.music42); + }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30, InvokeStatus.None); } diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index 9a0e9fa..59e6a42 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -216,9 +216,9 @@ public class SwapDoneState : IState // machine); var SoundClient = AppInfo.Container.Resolve(); - // LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeave.GetLed()); + LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeaveflushed.GetLed()); - + Thread.Sleep(1000); SoundClient.SoundPlay(SoundEnum.music76); Thread.Sleep(7000); SoundClient.SoundPlay(SoundEnum.music77); diff --git a/Service/Led/LedClient.cs b/Service/Led/LedClient.cs index 4f39f78..6c42acd 100644 --- a/Service/Led/LedClient.cs +++ b/Service/Led/LedClient.cs @@ -176,6 +176,7 @@ public class LedClient private static readonly ILog Log = LogManager.GetLogger(typeof(LedClient)); private static Socket? _socket; private static string _ip = "192.168.3.79"; + //private static string _ip = "127.0.0.1"; private static int _port = 10000; public static bool Init(string ip, int port) diff --git a/Service/Plc/Client/ClientMgr.cs b/Service/Plc/Client/ClientMgr.cs index c802da2..f7836d1 100644 --- a/Service/Plc/Client/ClientMgr.cs +++ b/Service/Plc/Client/ClientMgr.cs @@ -30,10 +30,10 @@ public static class ClientMgr { EquipNetInfo netInfo = new EquipNetInfo() { - // NetAddr = "192.168.251.199", + //NetAddr = "127.0.0.1", NetAddr = "192.168.3.20", NetPort = "2000", - //NetPort = "1689", + //NetPort = "10000", Code = PlcConst.ChargeEqpCode, DestAddr = "132,208,208,224" };