From 9ce8c69738dc5c9da270b18710366df23ae44e20 Mon Sep 17 00:00:00 2001 From: zby <24947@USER> Date: Wed, 11 Sep 2024 16:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Constant/InfoEnum.cs | 2 +- Service/Execute/Step/CarCtrlState.cs | 9 +- Service/Execute/Step/CarPrepareState.cs | 63 +++++-- Service/Execute/Step/DoSwappingState.cs | 97 ++--------- Service/Execute/Step/StationReadyState.cs | 10 +- Service/Execute/Step/SwapDoneState.cs | 154 ++++++++++++++---- Service/Led/LedClient.cs | 6 +- .../BatteryStatusReportedReqHandler.cs | 1 + Service/Sound/SoundClient/SoundClient.cs | 16 +- Service/Station/MonitorService.cs | 101 ++++++++---- WebStarter/Program.cs | 8 +- WebStarter/Properties/launchSettings.json | 4 +- 12 files changed, 296 insertions(+), 175 deletions(-) diff --git a/Entity/Constant/InfoEnum.cs b/Entity/Constant/InfoEnum.cs index fc4d1e8..6c7a455 100644 --- a/Entity/Constant/InfoEnum.cs +++ b/Entity/Constant/InfoEnum.cs @@ -58,7 +58,7 @@ public class InfoEnum [Info("前进","前进")] advance,//34 [Info("后退", "后退")] Backoff, [Info("停好了", "停好了")] Itparked, - + [Info("退出重新停车", "退出重新停车")] upcar, } diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index df4524a..b38ddc8 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.VelVin); + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); var resultHeartBeatMsg = carInfo.Result.CarStatus; if (resultHeartBeatMsg?.LockStatus == 1 || machine.ManualConfirmCarUnlockFlag) { @@ -92,7 +92,10 @@ public class CarCtrlState : IState LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); SoundClient = AppInfo.Container.Resolve(); if (b == 0) { - SoundClient.SoundPlay(SoundEnum.music48); + SoundClient.SoundPlay(SoundEnum.music104); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music105); + Thread.Sleep(3000); b = 1; } diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 9a56b2c..ec13071 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -7,6 +7,7 @@ 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; @@ -161,27 +162,40 @@ public class CarPrepareState : IState /// public InvokeStatus CheckTBoxConnectFlag(SwappingStateMachine machine) { + int t = 0; return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { - Task result = TBoxApi.IsConnected(machine.RfidReadModel.VelVin); + Task result = TBoxApi.IsConnected(machine.RfidReadModel.VelNo); + // result.Wait(); bool isConnect = result.Result; + if (isConnect) { machine.BoxConnectFlag = true; } }, () => { - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music43); + if (t == 0) + { + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music102); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music103); + Thread.Sleep(3000); + } //machine.ExceptionReason = ExceptionReason.ConnTBoxError; //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); }, false, () => { - SoundClient = AppInfo.Container.Resolve(); - //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03")); - SoundClient.SoundPlay(SoundEnum.music43); - //machine.ExceptionReason = ExceptionReason.ConnTBoxError; + if (t == 0) + { + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music102); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music103); + Thread.Sleep(3000); + } LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); @@ -199,12 +213,12 @@ public class CarPrepareState : IState return Invoker.Invoke("TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { - Task result = TBoxApi.Connect(machine.RfidReadModel.VelVin); + Task result = TBoxApi.Connect(machine.RfidReadModel.VelNo); bool isConnect = result.Result; if (isConnect) { //读取车辆carNo=carVin - Task carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); + Task carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); var tboxCarInfoModel = carInfoResult.Result; var carInfo = tboxCarInfoModel?.CarInfo; if (carInfo != null) @@ -239,6 +253,7 @@ public class CarPrepareState : IState /// public InvokeStatus CheckTBoxVelLocalFlag(SwappingStateMachine machine) { + int q = 0; return Invoker.Invoke("check TBox VelLocal", 1000, 20, machine.IsCanceled, () => machine.BoxLocalCheckFlag, () => { @@ -253,6 +268,15 @@ public class CarPrepareState : IState }, () => { 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); } @@ -304,6 +328,7 @@ public class CarPrepareState : IState /// public InvokeStatus SelectPack(SwappingStateMachine machine) { + int e = 0; SwapAmtOrder? swapAmtOrder = _CommonMgr.QueryAmtOrder(machine); @@ -326,12 +351,22 @@ public class CarPrepareState : IState // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); - SoundClient = AppInfo.Container.Resolve(); - SoundClient.SoundPlay(SoundEnum.music49); - + // SoundClient = AppInfo.Container.Resolve(); + //SoundClient.SoundPlay(SoundEnum.music49); + if (e == 0) + { + + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music106); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music107); + Thread.Sleep(3000); + + e = 1; + } // _log.Info($"SelectPack error CanSwap={machine.SwapOrderBatteryInfo.CanSwap}"); - - + + } else { diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 08fa183..6deee3c 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -38,69 +38,6 @@ public class DoSwappingState : IState // _log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}"); // CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap); - //while (true) - //{ - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.Idel, - // machine); - // Thread.Sleep(1000); - // //_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, - // //machine); - - - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag, - // machine); - // Thread.Sleep(1000); - - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, - // machine); - // Thread.Sleep(1000); - - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag, - // machine); - // Thread.Sleep(1000); - // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, - // machine); - // Thread.Sleep(1000); - // //_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag, - // // machine); - // Thread.Sleep(10000); - - // machine.Reset(); - - //} - - - //下发启动换电 InvokeStatus startSwapping = StartSwapping(machine); @@ -131,11 +68,11 @@ public class DoSwappingState : IState } //车辆上锁 - InvokeStatus lockCar = LockCar(machine); - if (lockCar != InvokeStatus.Done) - { - return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None); - } + //InvokeStatus lockCar = LockCar(machine); + //if (lockCar != InvokeStatus.Done) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None); + //} //开启雷达 var beginRadar = ControlRadar(machine, 1); @@ -145,12 +82,12 @@ public class DoSwappingState : IState } //车辆离开 - var adjustCarByRadar = AdjustCarByRadar(machine); - machine.Reset(); - if (InvokeStatus.Done != adjustCarByRadar) - { - return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); - } + //var adjustCarByRadar = AdjustCarByRadar(machine); + //machine.Reset(); + //if (InvokeStatus.Done != adjustCarByRadar) + //{ + // return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); + //} @@ -238,11 +175,11 @@ public class DoSwappingState : IState return Invoker.Invoke("StartSwapping", 1000, 5, machine.IsCanceled, () => machine.StartSwappingFlag, () => { - Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); - bool unLock = result.Result; - if (unLock) - { - var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No, + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); + bool unLock = result.Result; + if (unLock) + { + var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No, machine.SwapOrderBatteryInfo.UpBinInfo.No); if (c==0) { @@ -266,7 +203,7 @@ public class DoSwappingState : IState } - } + } }, () => { //SoundClient = AppInfo.Container.Resolve(); diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index 845482e..3c9de56 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -202,7 +202,7 @@ public class StationReadyState : IState public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) { - + int che = 0; return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => { @@ -227,6 +227,14 @@ public class StationReadyState : IState break; case 3: _log.Info("radar 角度偏移过大"); + 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 车辆靠后"); diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index b5ffed5..12a9c30 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -29,13 +29,14 @@ 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) { machine.SwapOrderBatteryInfo.swapAmtOrder.Status = @@ -48,7 +49,7 @@ public class SwapDoneState : IState Task.Run(() => { //新增换电成功上报云平台数据 - // _CommonMgr.InsertCloudReportForSwapSuccess(machine); + // _CommonMgr.InsertCloudReportForSwapSuccess(machine); //换电成功关于bininfo表的更新 _CommonMgr.UpdateBinInfoForSwapSuccess(machine); @@ -66,27 +67,33 @@ public class SwapDoneState : IState ////云平台没有匹配的失败状态 ////车辆上锁 ,提示请驶离 - //InvokeStatus lockCar = LockCar(machine); + InvokeStatus lockCar = LockCar(machine); - //if (lockCar != InvokeStatus.Done) - //{ - // return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None); - //} + if (lockCar != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None); + } 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); + //} @@ -146,25 +153,89 @@ public class SwapDoneState : IState }); } + /// + /// 车辆上锁 + /// + /// + //public InvokeStatus LockCar(SwappingStateMachine machine) + //{ + // return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, machine.IsManualSwapSucc, + // () => machine.VelLockFlag, () => + // { + // Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); + + // bool unLock = result.Result; + // if (unLock) + // { + // //查询车辆锁止状态 + // Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); + // if (carInfo.Result?.CarStatus?.LockStatus == 2) + // { + // machine.BoxCarInfoModel = carInfo.Result; + // SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success + // ? (int)InfoEnum.SwapInfo.InfoCarLeave + // : (int)InfoEnum.SwapInfo.ErrInfoCarLeave); + + // LedClient.SendMsgByKey(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success + // ? InfoEnum.SwapInfo.InfoCarLeave.GetLed() + // : InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed()); + // machine.VelLockFlag = true; + // //断连Tbox + // if (StaticStationInfo.TboxStateDisConnect) + // { + // TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo); + // } + + // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, + // machine); + // } + // } + // }, () => + // { + // // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed()); + // // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar); + // var SoundClient = AppInfo.Container.Resolve(); + // //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19")); + // SoundClient.SoundPlay(SoundEnum.music59); + // LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrLockCar.GetLed()); + // }, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; } + // , 10, InvokeStatus.None); + //} + /// /// 车辆上锁 /// /// public InvokeStatus LockCar(SwappingStateMachine machine) { + int v = 0; return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, machine.IsManualSwapSucc, () => machine.VelLockFlag, () => { - Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); + Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelNo); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); if (carInfo.Result?.CarStatus?.LockStatus == 2) { - machine.BoxCarInfoModel = carInfo.Result; + if (v == 0) + { + var SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(SoundEnum.music77); + Thread.Sleep(3000); + SoundClient.SoundPlay(SoundEnum.music76); + Thread.Sleep(3000); + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, + machine); + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag, + machine); + + v = 1; + } + machine.BoxCarInfoModel = carInfo.Result; SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success ? (int)InfoEnum.SwapInfo.InfoCarLeave : (int)InfoEnum.SwapInfo.ErrInfoCarLeave); @@ -173,29 +244,56 @@ public class SwapDoneState : IState ? InfoEnum.SwapInfo.InfoCarLeave.GetLed() : InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed()); machine.VelLockFlag = true; + + //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19")); + //断连Tbox if (StaticStationInfo.TboxStateDisConnect) { TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo); } + //新增小步 - _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, - machine); } + } }, () => { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed()); // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar); - var SoundClient = AppInfo.Container.Resolve(); - //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19")); - SoundClient.SoundPlay(SoundEnum.music59); + + LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrLockCar.GetLed()); }, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; } , 10, InvokeStatus.None); } + + 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; + + } + }); + } + public InvokeStatus ExistRadar(SwappingStateMachine machine) { return Invoker.Invoke("wait exist radar", 1000, 5, machine.IsCanceled, machine.IsManualSwapSucc, @@ -215,8 +313,8 @@ public class SwapDoneState : IState //出口写红灯 //更新车辆离场时间,上报云平台 - machine.BusinessSwappingForCloudState = - InfoEnum.BusinessSwappingForCloudState.SwapDoneWithoutVel; + //machine.BusinessSwappingForCloudState = + // InfoEnum.BusinessSwappingForCloudState.SwapDoneWithoutVel; machine.SwapOrder!.VehicleLeaveTime = DateTime.Now; _CommonMgr.UpdateSwapOrder(machine); diff --git a/Service/Led/LedClient.cs b/Service/Led/LedClient.cs index 80ce61c..5862e3b 100644 --- a/Service/Led/LedClient.cs +++ b/Service/Led/LedClient.cs @@ -91,7 +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 @@ -105,7 +105,7 @@ public class LedClient { _ip = ip; _port = port; - Connect(); + // Connect(); return _socket.Connected; } @@ -120,7 +120,7 @@ public class LedClient public static bool InnerSend(byte[] bytes) { - Connect(); + // Connect(); if (_socket?.Connected ?? true) { _socket?.Send(bytes); diff --git a/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs b/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs index e918605..a764a30 100644 --- a/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs +++ b/Service/Plc/Handler/BatteryStatusReportedReqHandler.cs @@ -43,6 +43,7 @@ public class BatteryStatusReportedReqHandler : SimpleChannelInboundHandler i.ChargeStatus == 2 && - i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock && - i.Soc > StaticStationInfo.SwapSoc && - new TimeSpan(DateTime.Now.Ticks - - i.LastChargeFinishTime.ToDateTime().Ticks) - .TotalMinutes > - StaticStationInfo.SwapFinishChargeTime).Count() - } - }; + : null; + monitorScreenResp.VehicleInfo.VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac + : null; + monitorScreenResp.VehicleInfo.LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus?.LockStatus : null; + monitorScreenResp.VehicleInfo.KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus?.Keys : null; + monitorScreenResp.VehicleInfo.VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo + : null; + monitorScreenResp.VehicleInfo.VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin + : null; + monitorScreenResp.VehicleInfo.Break = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Break; + monitorScreenResp.VehicleInfo.Gear = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Gear; + monitorScreenResp.BatteryInfo = new(); + monitorScreenResp.BatteryInfo.BatteryTotalCount = binInfos.Count; + monitorScreenResp.BatteryInfo.UsingSwapBatteryCount = binInfos.Select(i => i.ChargeStatus == 2 && + i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock && + i.Soc > StaticStationInfo.SwapSoc && + new TimeSpan(DateTime.Now.Ticks - + i.LastChargeFinishTime.ToDateTime().Ticks) + .TotalMinutes > + StaticStationInfo.SwapFinishChargeTime).Count(); + //SwapMonitorScreenResp monitorScreenResp = new() + //{ + + // PlcSwapModel = plcSwapModel, + // StateInfo = stateInfoList, + // VehicleInfo = new SwapVehicleResp() + // { + // OrderNo = StationSoftMgr.SwappingStateMachine.SwapOrder != null + // ? StationSoftMgr.SwappingStateMachine.SwapOrder.Sn + // : null, + // VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac + // : null, + // LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.LockStatus : null, + // KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.Keys : null, + // VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo + // : null, + // VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null + // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin + // : null, + // Break = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Break, + // Gear = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Gear, + // }, + // BatteryInfo = new() + // { + // BatteryTotalCount = binInfos.Count, + // UsingSwapBatteryCount = binInfos.Select(i => i.ChargeStatus == 2 && + // i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock && + // i.Soc > StaticStationInfo.SwapSoc && + // new TimeSpan(DateTime.Now.Ticks - + // i.LastChargeFinishTime.ToDateTime().Ticks) + // .TotalMinutes > + // StaticStationInfo.SwapFinishChargeTime).Count() + // } + //}; return Result.Success(monitorScreenResp); diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 865ecb2..8a83d52 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -186,10 +186,10 @@ if (AppSettingsHelper.GetBool("padar", "enable")) } -if (AppSettingsHelper.GetBool("led", "enable")) -{ - LedClient.Init(AppSettingsHelper.GetContent("led", "ip"), Convert.ToInt32(AppSettingsHelper.GetContent("led", "port"))); -} +//if (AppSettingsHelper.GetBool("led", "enable")) +//{ +// LedClient.Init(AppSettingsHelper.GetContent("led", "ip"), Convert.ToInt32(AppSettingsHelper.GetContent("led", "port"))); +//} ////启动换电流程 if (AppSettingsHelper.GetBool("swap", "enable")) diff --git a/WebStarter/Properties/launchSettings.json b/WebStarter/Properties/launchSettings.json index e31ee95..82f39c3 100644 --- a/WebStarter/Properties/launchSettings.json +++ b/WebStarter/Properties/launchSettings.json @@ -17,7 +17,7 @@ "applicationUrl": "http://localhost:5034", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "profiles_active": "dev" + "profiles_active": "prod" } }, "IIS Express": { @@ -27,7 +27,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "applicationUrl": "http://0.0.0.0:5034", - "profiles_active": "dev" + "profiles_active": "prod" } } }