From 365f7a9bf1a11f996846c01adcd8095e480c2f0f Mon Sep 17 00:00:00 2001 From: zby <24947@USER> Date: Mon, 9 Sep 2024 22:06:30 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E5=85=A8=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E7=AD=89"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 53c75f1c14bfc3c974992a8de0f4289433572954. --- Entity/Constant/InfoEnum.cs | 1 - Service/Execute/Api/RfidApi.cs | 4 +- Service/Execute/Step/CarCtrlState.cs | 18 ++---- Service/Execute/Step/CarPrepareState.cs | 58 +++---------------- Service/Execute/Step/DoSwappingState.cs | 55 +++++++++++++++--- Service/Execute/Step/StationReadyState.cs | 27 ++------- Service/Execute/Step/SwapDoneState.cs | 48 ++++++--------- Service/Led/LedClient.cs | 16 +---- .../BatteryStatusReportedReqHandler.cs | 2 +- .../Plc/Handler/SummaryFailuresReqHandler.cs | 1 - Service/Sound/SoundClient/SoundClient.cs | 11 ---- Service/Ups/Client/UpsClient.cs | 7 +-- WebStarter/Program.cs | 4 -- WebStarter/appsettings.prod.json | 2 +- 14 files changed, 89 insertions(+), 165 deletions(-) diff --git a/Entity/Constant/InfoEnum.cs b/Entity/Constant/InfoEnum.cs index 29cc499..fc4d1e8 100644 --- a/Entity/Constant/InfoEnum.cs +++ b/Entity/Constant/InfoEnum.cs @@ -58,7 +58,6 @@ public class InfoEnum [Info("前进","前进")] advance,//34 [Info("后退", "后退")] Backoff, [Info("停好了", "停好了")] Itparked, - [Info("退出重新停车", "退出重新停车")] upcar, } diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs index a7fc1f0..a7fc8e1 100644 --- a/Service/Execute/Api/RfidApi.cs +++ b/Service/Execute/Api/RfidApi.cs @@ -103,11 +103,11 @@ public class RfidApi Log.Info("RfidApi ReadRfid"); - // string readUrl = BASE_URL + "/Api/BeginRead"; + string readUrl = BASE_URL + "/Api/BeginRead"; string url = BASE_URL + "/Api/ReadRfidData"; try { - // var vBeginRead = await _httpClient.GetStringAsync(readUrl); + var vBeginRead = await _httpClient.GetStringAsync(readUrl); string s = await _httpClient.GetStringAsync(url); Log.Info($"ReadRfid resp={s}"); if (s != String.Empty) diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 8de4718..df4524a 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -91,22 +91,12 @@ public class CarCtrlState : IState // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar); LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); SoundClient = AppInfo.Container.Resolve(); - - - }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; - if (b == 0) - { - - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music104); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music105); - Thread.Sleep(3000); + if (b == 0) { + SoundClient.SoundPlay(SoundEnum.music48); b = 1; - } - } - + + }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } , 10, InvokeStatus.None); } } diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 8a98ae8..9a56b2c 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -7,7 +7,6 @@ using Entity.Dto; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using log4net; -using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using Repository.Station; using Service.Execute.Api; using Service.Execute.Model; @@ -162,7 +161,6 @@ public class CarPrepareState : IState /// public InvokeStatus CheckTBoxConnectFlag(SwappingStateMachine machine) { - int t = 0; return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { @@ -174,30 +172,15 @@ public class CarPrepareState : IState } }, () => { - - if (t==0) - { - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music102); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music103); - Thread.Sleep(3000); - } - + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music43); //machine.ExceptionReason = ExceptionReason.ConnTBoxError; //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); }, false, () => { - + SoundClient = AppInfo.Container.Resolve(); //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03")); - if (t == 0) - { - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music102); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music103); - Thread.Sleep(3000); - } + SoundClient.SoundPlay(SoundEnum.music43); //machine.ExceptionReason = ExceptionReason.ConnTBoxError; LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); @@ -256,7 +239,6 @@ public class CarPrepareState : IState /// public InvokeStatus CheckTBoxVelLocalFlag(SwappingStateMachine machine) { - int q = 0; return Invoker.Invoke("check TBox VelLocal", 1000, 20, machine.IsCanceled, () => machine.BoxLocalCheckFlag, () => { @@ -265,22 +247,12 @@ public class CarPrepareState : IState if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelVin.Trim())) { - machine.BoxLocalCheckFlag = true; machine.BoxCarInfoModel = tBoxCarInfoModel; } }, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; }, true, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; - if (q == 0) - { - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music108); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music109); - Thread.Sleep(3000); - q = 1; - } } , 3, InvokeStatus.TimeOut); } @@ -332,7 +304,6 @@ public class CarPrepareState : IState /// public InvokeStatus SelectPack(SwappingStateMachine machine) { - int e = 0; SwapAmtOrder? swapAmtOrder = _CommonMgr.QueryAmtOrder(machine); @@ -356,18 +327,8 @@ public class CarPrepareState : IState LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); SoundClient = AppInfo.Container.Resolve(); - if (e==0) - { - - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music106); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music107); - Thread.Sleep(3000); - - e = 1; - } - + SoundClient.SoundPlay(SoundEnum.music49); + // _log.Info($"SelectPack error CanSwap={machine.SwapOrderBatteryInfo.CanSwap}"); @@ -385,12 +346,7 @@ public class CarPrepareState : IState machine.ExceptionReason = ExceptionReason.SelectPackError; SoundClient = AppInfo.Container.Resolve(); //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address09")); - if (e == 0) - { - SoundClient.SoundPlay(SoundEnum.music49); - e = 1; - } - + SoundClient.SoundPlay(SoundEnum.music49); // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorSelectPack); } , false, () => { }, 10, InvokeStatus.None); diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 4f9ab08..08fa183 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -144,7 +144,13 @@ public class DoSwappingState : IState return SwappingStateMachine.ReturnWithInvokeErr(beginRadar, ExceptionReason.None); } - + //车辆离开 + var adjustCarByRadar = AdjustCarByRadar(machine); + machine.Reset(); + if (InvokeStatus.Done != adjustCarByRadar) + { + return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); + } @@ -198,7 +204,29 @@ public class DoSwappingState : IState //} - + public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) + { + + return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, + () => + { + //新增小步 + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag, + machine); + var carState = PadarMgr._PadarClient?.CarState; + return carState.HasValue && (carState.Value == 1 || carState.Value == 2 || carState.Value == 3 || carState.Value == 4 || carState.Value == 5); + }, + () => + { + switch (PadarMgr._PadarClient?.CarState) + { + case 6: + _log.Info("车辆未驶离"); + break; + + } + }); + } /// /// 下发plc启动换电 @@ -216,7 +244,17 @@ public class DoSwappingState : IState { var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No, machine.SwapOrderBatteryInfo.UpBinInfo.No); - + if (c==0) + { + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag, + machine); + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag, + machine); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music91); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music90); + } //查詢當前任務狀態是否被更改 if (startSwapping) @@ -280,7 +318,6 @@ public class DoSwappingState : IState if(i==0) { SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music51); //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); i = 1; @@ -401,14 +438,16 @@ public class DoSwappingState : IState //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19")); if (v == 0) { - SoundClient.SoundPlay(SoundEnum.music76); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music77); + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, machine); _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag, machine); - + + SoundClient.SoundPlay(SoundEnum.music77); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music76); + v = 1; } //断连Tbox diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index 18d3455..845482e 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -190,7 +190,8 @@ public class StationReadyState : IState /// public InvokeStatus ControlRadar(SwappingStateMachine machine, byte flag) { - + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag, + machine); return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => PadarMgr._PadarClient?.CarState > 0, () => { PadarMgr._PadarClient?.PadarControl(flag); }); @@ -201,7 +202,6 @@ public class StationReadyState : IState public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) { - int che = 0; return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => @@ -210,8 +210,6 @@ public class StationReadyState : IState if (PadarMgr._PadarClient?.CarState==6) { - _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag, - machine); LedClient.SendMsgByKey(InfoEnum.SwapInfo.Backoff.GetLed()); } @@ -229,16 +227,6 @@ public class StationReadyState : IState break; case 3: _log.Info("radar 角度偏移过大"); - SoundClient = AppInfo.Container.Resolve(); - //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address25")); - if (che == 0) - { - LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed()); - SoundClient.SoundPlay(SoundEnum.music100); - Thread.Sleep(3000); - SoundClient.SoundPlay(SoundEnum.music101); - che = 1; - } break; case 4: _log.Info("radar 车辆靠后"); @@ -315,12 +303,10 @@ public class StationReadyState : IState private InvokeStatus ReadRfid(SwappingStateMachine machine) { - int e = 0; //开始读rifd return Invoker.Invoke("read rfid", 3000, 20, machine.IsCanceled, - () => machine.RfidReadFlag,() => + () => machine.RfidReadFlag, () => { - Task rfidReadModel = RfidApi.ReadRfid(); rfidReadModel.Wait(); var machineRfidReadModel = rfidReadModel.Result; @@ -360,12 +346,7 @@ public class StationReadyState : IState machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); SoundClient = AppInfo.Container.Resolve(); //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address02")); - if (e == 0) - { - SoundClient.SoundPlay(SoundEnum.music42); - e = 1; - } - + SoundClient.SoundPlay(SoundEnum.music42); //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid); //LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 10, diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index 5fc778a..b5ffed5 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -57,16 +57,16 @@ public class SwapDoneState : IState }); - //if (machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success) - //{ - // //上传云平台换电状态 - // // machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.SwapDoneWithVel; - // // CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState); - //} + if (machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success) + { + //上传云平台换电状态 + // machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.SwapDoneWithVel; + // CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState); + } ////云平台没有匹配的失败状态 ////车辆上锁 ,提示请驶离 - InvokeStatus lockCar = LockCar(machine); + //InvokeStatus lockCar = LockCar(machine); //if (lockCar != InvokeStatus.Done) //{ @@ -75,30 +75,18 @@ public class SwapDoneState : IState LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeave.GetLed()); - - - //车辆离开 - var adjustCarByRadar = AdjustCarByRadar(machine); - machine.Reset(); - if (InvokeStatus.Done != adjustCarByRadar) - { - return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); - } - - - //出口雷达监测 - //InvokeStatus existRadar = ExistRadar(machine); - //if (existRadar != InvokeStatus.Done) - //{ - // return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None); - //} - ////关闭雷达 - //var closeRadar = ControlRadar(machine, 0); - //if (InvokeStatus.Done != closeRadar) - //{ - // return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None); - //} + //InvokeStatus existRadar = ExistRadar(machine); + //if (existRadar != InvokeStatus.Done) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None); + //} + ////关闭雷达 + //var closeRadar = ControlRadar(machine, 0); + //if (InvokeStatus.Done != closeRadar) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None); + //} diff --git a/Service/Led/LedClient.cs b/Service/Led/LedClient.cs index 4e7d1cd..80ce61c 100644 --- a/Service/Led/LedClient.cs +++ b/Service/Led/LedClient.cs @@ -1,7 +1,6 @@ using System.Net.Sockets; using HybirdFrameworkCore.Utils; using log4net; -using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; namespace Service.Led; @@ -92,8 +91,7 @@ public class LedClient {"前进",new byte[]{0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x0C,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x4D,0x75,0x6B,0x61,0x00,0x00,0x0D,0x0A, }}, {"后退",new byte[]{ 0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x0E,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x4D,0x75,0x6E,0x64,0x75,0x72,0x00,0x00,0x0D,0x0A, }}, {"停好了",new byte[]{ 0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x49,0x74,0x75,0x20,0x64,0x69,0x70,0x61,0x72,0x6B,0x69,0x72,0x00,0x00,0x0D,0x0A,}}, - - {"退出重新停车",new byte[]{ 0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x21, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3B, 0x3A, 0x4B, 0x65, 0x6C, 0x75, 0x61, 0x72, 0x20, 0x64, 0x61, 0x6E, 0x20, 0x70, 0x61, 0x72, 0x6B, 0x69, 0x72, 0x20, 0x6B, 0x65, 0x6D, 0x62, 0x61, 0x6C, 0x69, 0x00, 0x00, 0x0D, 0x0A, }}, + }; #endregion @@ -107,17 +105,10 @@ public class LedClient { _ip = ip; _port = port; - InitClient(); - // Connect(); + Connect(); return _socket.Connected; } - public static void InitClient() - { - Task.Run(Connect); - } - - private static void Connect() { Log.Info($"begin connect {_ip}:{_port}"); @@ -129,8 +120,7 @@ public class LedClient public static bool InnerSend(byte[] bytes) { - InitClient(); - // Connect(); + Connect(); if (_socket?.Connected ?? true) { _socket?.Send(bytes); diff --git a/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs b/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs index f53fc85..e918605 100644 --- a/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs +++ b/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs @@ -44,7 +44,7 @@ public class BatteryStatusReportedReqHandler : SimpleChannelInboundHandler(); public EquipAlarmRecordRepository _equipAlarmRecordRepository=AppInfo.Container.Resolve(); public EquipAlarmProcessRecordRepository _equipAlarmProcessRecordRepository=AppInfo.Container.Resolve(); - - - - + public UpsClient() { ReadAction = BatchRead; Ip = "192.168.3.100"; - Port = 44; + Port = 23; Duration = 1000; AutoReConnect = true; ByteSeq = EndingConst.ByteSeq.BA; diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 3420b64..865ecb2 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -186,7 +186,6 @@ if (AppSettingsHelper.GetBool("padar", "enable")) } - if (AppSettingsHelper.GetBool("led", "enable")) { LedClient.Init(AppSettingsHelper.GetContent("led", "ip"), Convert.ToInt32(AppSettingsHelper.GetContent("led", "port"))); @@ -205,9 +204,6 @@ if (AppSettingsHelper.GetBool("swap", "enable")) AppInfo.Container = app.Services.GetAutofacRoot(); //ClientMgr.InitClient(); - - -//UpsMgr.UpsInit(); //ups if (AppSettingsHelper.GetBool("ups", "enable")) { diff --git a/WebStarter/appsettings.prod.json b/WebStarter/appsettings.prod.json index 581f8c5..6b36c37 100644 --- a/WebStarter/appsettings.prod.json +++ b/WebStarter/appsettings.prod.json @@ -143,7 +143,7 @@ "Enabled": false }, "led": { - "enable": false, + "enable": true, "ip": "192.168.3.79", "port": 10000 }