diff --git a/Entity/Constant/InfoEnum.cs b/Entity/Constant/InfoEnum.cs index 1da050e..e835970 100644 --- a/Entity/Constant/InfoEnum.cs +++ b/Entity/Constant/InfoEnum.cs @@ -9,50 +9,52 @@ public class InfoEnum public enum SwapInfo : ushort { - + //01 [Info("欢迎光临换电站!(正在营业)","欢迎光临换电站!,本站正在营业中")]WelcomeInfo=1, + //02 [Info("标签读写失败", "标签读写失败")] ErrorReadRfid , - + //03 [Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn , + //04 [Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck , - [Info("车辆已到位", "车辆已到位")] InfoCarInPosition , + [Info("车辆已到位", "车辆已到位")] InfoCarInPosition ,//5 //TODO:: 录音内容已改 - [Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout, - [Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError , + [Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout,//6 + [Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError ,//7 - [Info("解锁车辆失败", "解锁车辆失败")] ErrUnLockCar , - [Info("选包失败,请驶离", "选包失败,请驶离")] ErrorSelectPack , - [Info("通道拍照定位失败,请在三分钟内重新调整车辆位置", "通道拍照定位失败,请在三分钟内重新调整车辆位置")]ErrChannelStatus, + [Info("解锁车辆失败", "解锁车辆失败")] ErrUnLockCar ,//8 + [Info("选包失败,请驶离", "选包失败,请驶离")] ErrorSelectPack ,//9 + [Info("通道拍照定位失败,请在三分钟内重新调整车辆位置", "通道拍照定位失败,请在三分钟内重新调整车辆位置")]ErrChannelStatus,//10 - [Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack , + [Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack ,//11 - [Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack , - [Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish , - [Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition , - [Info("换电已完成,请驶离", "换电已完成,请驶离")] InfoCarLeave , - [Info("换电失败,请驶离", "换电失败,请驶离")] ErrInfoCarLeave , - [Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn , - [Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut , - [Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar , - [Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr, - [Info("结束充电电池数量不足","通道的电池仓无可用换电电池")] LessOfFinishChargingErr, - [Info("空仓数量不足","通道的电池仓无可用换电电池")] LessOfEmptyBinErr, - [Info("符合soc限制数量不足","通道的电池仓无可用换电电池")] LessOfSocErr, - [Info("结束充电大于3分钟的数量不足","通道的电池仓无可用换电电池")] LessOf3MinuteErr, - [Info("换电站处于手动模式,不能自动换电","换电站处于手动模式,不能自动换电")] InfoStationModel, + [Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack ,//12 + [Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish ,//13 + [Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition ,//14 + [Info("换电已完成,请驶离", "换电已完成,请驶离")] InfoCarLeave ,//15 + [Info("换电失败,请驶离", "换电失败,请驶离")] ErrInfoCarLeave ,//16 + [Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn ,//17 + [Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut ,//18 + [Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar ,//19 + [Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr,//20 + [Info("结束充电电池数量不足","通道的电池仓无可用换电电池")] LessOfFinishChargingErr,//21 + [Info("空仓数量不足","通道的电池仓无可用换电电池")] LessOfEmptyBinErr,//22 + [Info("符合soc限制数量不足","通道的电池仓无可用换电电池")] LessOfSocErr,//23 + [Info("结束充电大于3分钟的数量不足","通道的电池仓无可用换电电池")] LessOf3MinuteErr,//24 + [Info("换电站处于手动模式,不能自动换电","换电站处于手动模式,不能自动换电")] InfoStationModel,//25 - [Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr, + [Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr,//26 - [Info("车辆驶入","车辆驶入")] CarInInfo, - [Info("换电任务启动","换电任务启动")] StartSwapInfo, - [Info("航车拍照中,请稍后","航车拍照中,请稍后")] CarTakePhotoInfo, - [Info("启动换电失败,请联系站务人员","启动换电失败,请联系站务人员")] ErrStartSwap, - [Info("即将进行消防移仓,请车辆驶离","即将进行消防移仓,请车辆驶离")] InfoFireRemoveLabel, - [Info("电池移仓中","电池移仓中")] InfoBatteryMove, - [Info("消防移仓中","消防移仓中")] InfoFireRemove, - [Info("拍照失败,请在三分钟内挪车","拍照失败,请在三分钟内挪车")] ErrChannel1020, + [Info("车辆驶入","车辆驶入")] CarInInfo,//27 + [Info("换电任务启动","换电任务启动")] StartSwapInfo,//28 + [Info("航车拍照中,请稍后","航车拍照中,请稍后")] CarTakePhotoInfo,//29 + [Info("启动换电失败,请联系站务人员","启动换电失败,请联系站务人员")] ErrStartSwap,//30 + [Info("即将进行消防移仓,请车辆驶离","即将进行消防移仓,请车辆驶离")] InfoFireRemoveLabel,//31 + [Info("电池移仓中","电池移仓中")] InfoBatteryMove,//32 + [Info("消防移仓中","消防移仓中")] InfoFireRemove,//33 + [Info("拍照失败,请在三分钟内挪车","拍照失败,请在三分钟内挪车")] ErrChannel1020,//34 } diff --git a/Service/Execute/StaticTools/SoundTool.cs b/Service/Execute/StaticTools/SoundTool.cs index 2175b09..cb419a2 100644 --- a/Service/Execute/StaticTools/SoundTool.cs +++ b/Service/Execute/StaticTools/SoundTool.cs @@ -13,7 +13,7 @@ { bool bRst = false; try - { + { Task result = client.PlaySoundBySwapStepAsync(step); } catch(Exception ex) diff --git a/Service/Execute/StationSoftMgr.cs b/Service/Execute/StationSoftMgr.cs index 4731f36..a759535 100644 --- a/Service/Execute/StationSoftMgr.cs +++ b/Service/Execute/StationSoftMgr.cs @@ -1,4 +1,6 @@  +using HybirdFrameworkCore.Configuration; + namespace Service.Execute { /// @@ -7,7 +9,9 @@ namespace Service.Execute public class StationSoftMgr { public static readonly SwappingStateMachine SwappingStateMachine = SwappingStateMachine.GetInstance(); - + + + public static readonly string addr1 = AppSettingsHelper.GetContent("SoundAddr", "Address1"); #region 换电流程 diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 8967ca7..236f2b1 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -2,6 +2,7 @@ using Entity.Attr; using Entity.Constant; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Configuration; using log4net; using Service.Execute.Api; using Service.Execute.Model; @@ -10,6 +11,7 @@ using Service.Execute.StaticTools; using Service.Execute.SwapException; using Service.Execute.Utils; using Service.Led; +using Service.Sound.SoundClient; using Service.Station; namespace Service.Execute.Step; @@ -18,6 +20,7 @@ public class CarCtrlState : IState { private readonly ILog _log = LogManager.GetLogger(typeof(CarCtrlState)); private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve(); + public static SoundClient? SoundClient { get; set; } public StateResult Handle(SwappingStateMachine machine) { @@ -73,9 +76,11 @@ public class CarCtrlState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar); + LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address08")); }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } , 10, InvokeStatus.None); } diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 3979ad8..e70c709 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -5,6 +5,7 @@ using Entity.Constant; using Entity.DbModel.Station; using Entity.Dto; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Configuration; using log4net; using Repository.Station; using Service.Execute.Api; @@ -15,6 +16,7 @@ using Service.Execute.SwapException; using Service.Execute.Utils; using Service.Init; using Service.Led; +using Service.Sound.SoundClient; using Service.Station; namespace Service.Execute.Step; @@ -28,6 +30,10 @@ public class CarPrepareState : IState private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository = AppInfo.Container.Resolve(); + + public static SoundClient? SoundClient { get; set; } + + public StateResult Handle(SwappingStateMachine machine) { Thread.Sleep(500); @@ -147,8 +153,10 @@ public class CarPrepareState : IState //写入口等 :红灯 if (PlcApi.WriteEntranceLamp(1020)) { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoCarInPosition.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoCarInPosition); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address05")); + machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoCarInPosition.GetLed()); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoCarInPosition); machine.VehiclesInPlaceFlag = true; //告知云平台换电准备完成 machine.BusinessSwappingForCloudState = @@ -165,9 +173,11 @@ public class CarPrepareState : IState } }, () => { + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address06")); machine.ExceptionReason = ExceptionReason.CarInPositionError; // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout); }, false, () => { } , 10, InvokeStatus.None); } @@ -193,11 +203,15 @@ public class CarPrepareState : IState } }, () => { - machine.ExceptionReason = ExceptionReason.ConnTBoxError; - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03")); + //machine.ExceptionReason = ExceptionReason.ConnTBoxError; + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); }, false, () => { - machine.ExceptionReason = ExceptionReason.ConnTBoxError; + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03")); + //machine.ExceptionReason = ExceptionReason.ConnTBoxError; LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed()); @@ -233,8 +247,10 @@ public class CarPrepareState : IState } }, () => { - machine.ExceptionReason = ExceptionReason.ConnTBoxError; - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03")); + //machine.ExceptionReason = ExceptionReason.ConnTBoxError; + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); }, false, () => { machine.ExceptionReason = ExceptionReason.ConnTBoxError; @@ -295,7 +311,9 @@ public class CarPrepareState : IState { // machine.LedTool?.WriteProgramContent("车辆电池数据上报异常,请联系站务人员"); // SoundApi.PlayOneSound(InfoEnum.SwapInfo.ErrorSelectPack); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); + LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address09")); }, false, () => { machine.ExceptionReason = ExceptionReason.CloudCarDataUploadError; } , 20, InvokeStatus.None); } @@ -335,8 +353,9 @@ public class CarPrepareState : IState { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); - + LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address09")); _log.Info($"SelectPack error CanSwap={machine.SwapOrderBatteryInfo.CanSwap}"); } else @@ -350,7 +369,9 @@ public class CarPrepareState : IState }, () => { machine.ExceptionReason = ExceptionReason.SelectPackError; - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorSelectPack); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address09")); + // 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 3b6041c..016747d 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -2,6 +2,7 @@ using Entity.Attr; using Entity.Constant; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Configuration; using log4net; using Service.Charger.Client; using Service.Execute.Api; @@ -10,6 +11,7 @@ using Service.Execute.SwapException; using Service.Execute.Utils; using Service.Init; using Service.Led; +using Service.Sound.SoundClient; namespace Service.Execute.Step; @@ -18,6 +20,11 @@ public class DoSwappingState : IState private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState)); private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve(); + + + public static SoundClient? SoundClient { get; set; } + + public StateResult Handle(SwappingStateMachine machine) { //上报云平台换电开始 @@ -33,13 +40,12 @@ public class DoSwappingState : IState InvokeStatus startSwapping = StartSwapping(machine); if (startSwapping != InvokeStatus.Done) { + return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None); } - - //旧电池拆卸 InvokeStatus unPack = UnPack(machine); if (unPack != InvokeStatus.Done) @@ -100,8 +106,12 @@ public class DoSwappingState : IState } }, () => { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrStartSwap.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address30")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address01")); + LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrStartSwap.GetLed()); },false, () => { },10,InvokeStatus.None); } @@ -123,7 +133,9 @@ public class DoSwappingState : IState bool holdOn = PlcApi.HoldOn(); if (holdOn) { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address28")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo); machine.PlcHoldFlag = true; } } @@ -147,7 +159,8 @@ public class DoSwappingState : IState // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoUnPack.GetLed()); - + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address11")); machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone; if (machine.UnOldBatteryFlag) @@ -185,7 +198,9 @@ public class DoSwappingState : IState } }, () => { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address17")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed()); }, false, () => { }, 10, InvokeStatus.None); @@ -215,7 +230,9 @@ public class DoSwappingState : IState } }, () => { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address18")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed()); }, false, () => { }, 10, InvokeStatus.None); @@ -239,7 +256,9 @@ public class DoSwappingState : IState } }, () => { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address12")); LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPack.GetLed()); },false, () => { }, 10,InvokeStatus.None); @@ -258,7 +277,9 @@ public class DoSwappingState : IState InfoEnum.BusinessSwappingForCloudState.SwapFinish; // CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState); machine.BusinessSwappingStateUpdateTime = DateTime.Now; - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address13")); LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPackFinish.GetLed()); _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag, @@ -287,7 +308,9 @@ public class DoSwappingState : IState if (PlcApi.ReadPlcTaskStatus() == 1007) { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address14")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition); machine.ToSafePositionFlag = true; machine.BusinessSwappingStateUpdateTime = DateTime.Now; @@ -322,7 +345,9 @@ public class DoSwappingState : IState var channelStatus = PlcApi.ChannelStatus(); if (count % 10 == 0) { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address29")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo); } count++; @@ -338,8 +363,10 @@ public class DoSwappingState : IState var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); if (lockCar.Result) { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus); + machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address10")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus); //等待2分钟 Thread.Sleep(3*60 *1000); machine.VehiclesInPlace2Flag = false; @@ -422,8 +449,10 @@ public class DoSwappingState : IState }, () => { machine.ExceptionReason = ExceptionReason.CarInPositionError; - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout); + machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed()); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address06")); }, false, () => { } , 20, InvokeStatus.None); } diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index d7bb586..84443f9 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -3,6 +3,7 @@ using Entity.Attr; using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Configuration; using log4net; using Newtonsoft.Json; using Service.Execute.Api; @@ -12,7 +13,9 @@ using Service.Execute.Utils; using Service.Init; using Service.Led; using Service.Padar.Client; +using Service.Sound.SoundClient; using Swapping.Business.Common; +using System.Media; namespace Service.Execute.Step; @@ -23,6 +26,8 @@ public class StationReadyState : IState private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve(); + public static SoundClient? SoundClient { get; set; } + public static bool CanWelcomeInfo = true; public StateResult Handle(SwappingStateMachine machine) @@ -59,6 +64,7 @@ public class StationReadyState : IState if (InvokeStatus.Done != beginRfid) { return SwappingStateMachine.ReturnWithInvokeErr(beginRfid, ExceptionReason.None); + } @@ -103,7 +109,9 @@ public class StationReadyState : IState }, () => { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoStationModel) ; + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address25")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoStationModel) ; LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoStationModel.GetLed()); }, true, () => { }, 5, InvokeStatus.None); } @@ -126,15 +134,18 @@ public class StationReadyState : IState { //LED显示-欢迎光临_换电站点_正在营业 string welcomeContent = "欢迎光临换电站!(正在营业)"; - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.WelcomeInfo); + + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address01")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.WelcomeInfo); LedClient.SendMsgByKey(InfoEnum.SwapInfo.WelcomeInfo.GetLed()); isRemote = true; } } }, () => - { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoStationModelRemoteErr) + {SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address26")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoStationModelRemoteErr) ; }, true, () => { }, 5, InvokeStatus.None); } @@ -151,8 +162,12 @@ public class StationReadyState : IState () => { PadarMgr._PadarClient?.PadarControl(flag); }); } + + + public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) { + return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => PadarMgr._PadarClient?.CarState == 6, () => { @@ -188,7 +203,9 @@ public class StationReadyState : IState } else { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarInInfo); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address27")); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarInInfo); machine.ExceptionReason = ExceptionReason.None; _log.Info("entrance radar true"); machine.RadarInFlag = true; @@ -215,9 +232,12 @@ public class StationReadyState : IState } }, () => { - // machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); + machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address02")); + + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid); + //LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; } , 3, InvokeStatus.None); } @@ -288,9 +308,11 @@ public class StationReadyState : IState } }, () => { - // machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid); - LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); + machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address02")); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid); + //LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 10, InvokeStatus.None); } diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index d78f3e6..94da072 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -2,6 +2,7 @@ using Entity.Attr; using Entity.Constant; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Configuration; using log4net; using Service.Execute.Api; using Service.Execute.Model.Tbox; @@ -148,7 +149,9 @@ public class SwapDoneState : IState }, () => { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar); + // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar); + SoundClient = AppInfo.Container.Resolve(); + SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19")); LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrLockCar.GetLed()); }, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; } , 10, InvokeStatus.None); diff --git a/Service/Padar/Client/PadarClient.cs b/Service/Padar/Client/PadarClient.cs index 71fbb58..d0933a4 100644 --- a/Service/Padar/Client/PadarClient.cs +++ b/Service/Padar/Client/PadarClient.cs @@ -31,7 +31,7 @@ public class PadarClient : TcpClient } /// - /// 0-关闭雷达 1-开启 + /// 0-关闭雷达 1-开启 /// /// 0-关闭雷达 1-开启雷达 /// diff --git a/Service/Padar/PadarService.cs b/Service/Padar/PadarService.cs index 7566823..5876b9d 100644 --- a/Service/Padar/PadarService.cs +++ b/Service/Padar/PadarService.cs @@ -15,7 +15,7 @@ public class PadarService { if (PadarMgr._PadarClient == null || !PadarMgr._PadarClient.Connected) { - Result.Fail(@"充电机未连接"); + Result.Fail(@"雷达未连接"); // return; } diff --git a/Service/Plc/Client/ClientMgr.cs b/Service/Plc/Client/ClientMgr.cs index 2091706..64b4683 100644 --- a/Service/Plc/Client/ClientMgr.cs +++ b/Service/Plc/Client/ClientMgr.cs @@ -4,7 +4,7 @@ using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.Charger.Server; - +using Service.Sound.SoundClient; namespace Service.Charger.Client; /// @@ -37,7 +37,9 @@ public static class ClientMgr DestAddr = "132,208,208,224" }; Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}"); + PlcClient = AppInfo.Container.Resolve(); + PlcClient.AutoReconnect = true; PlcClient.Sn = PlcConst.ChargeEqpCode; PlcClient.ConnectedEventHandler += (sender, b) => diff --git a/Service/Plc/Handler/BatteryPackDisassembledReqHandler.cs b/Service/Plc/Handler/BatteryPackDisassembledReqHandler.cs index 60051f7..a1042de 100644 --- a/Service/Plc/Handler/BatteryPackDisassembledReqHandler.cs +++ b/Service/Plc/Handler/BatteryPackDisassembledReqHandler.cs @@ -1,9 +1,13 @@ +using Autofac; using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Configuration; using log4net; using Service.Charger.Client; using Service.Charger.Msg.Charger.Req; using Service.Charger.Msg.Host.Resp; +using Service.Sound.SoundClient; namespace Service.Charger.Handler; @@ -21,13 +25,16 @@ public class BatteryPackDisassembledReqHandler : SimpleChannelInboundHandler - /// - /// - protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackDisassembledReq msg) + public static readonly string addr1 = AppSettingsHelper.GetContent("SoundAddr", "Address27"); + public static SoundClient? SoundClient { get; set; } + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackDisassembledReq msg) { Log.Info("swap finish"); ctx.Channel.WriteAndFlushAsync(message: new BatteryPackDisassembledResq()); + ClientMgr.PlcClient.DisassembleDone = true; } diff --git a/Service/Plc/Handler/PowerTransferCompletedReqHandler.cs b/Service/Plc/Handler/PowerTransferCompletedReqHandler.cs index 19e68c2..2a347d4 100644 --- a/Service/Plc/Handler/PowerTransferCompletedReqHandler.cs +++ b/Service/Plc/Handler/PowerTransferCompletedReqHandler.cs @@ -19,13 +19,13 @@ public class PowerTransferCompletedReqHandler : SimpleChannelInboundHandler - /// + /// /// private static readonly ILog Log = LogManager.GetLogger(typeof(PowerTransferCompletedReqHandler)); /// - /// + /// /// protected override void ChannelRead0(IChannelHandlerContext ctx, PowerTransferCompletedReq msg) { diff --git a/Service/Plc/Handler/StartBatterySwapResqHandler.cs b/Service/Plc/Handler/StartBatterySwapResqHandler.cs index 0d4e6c3..92dd78a 100644 --- a/Service/Plc/Handler/StartBatterySwapResqHandler.cs +++ b/Service/Plc/Handler/StartBatterySwapResqHandler.cs @@ -1,11 +1,15 @@ +using Autofac; using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Configuration; using HybirdFrameworkCore.Utils; using log4net; using Newtonsoft.Json; using Service.Charger.Client; using Service.Charger.Msg.Charger.Req; using Service.Charger.Msg.Charger.Resp; +using Service.Sound.SoundClient; namespace Service.Charger.Handler; @@ -24,14 +28,15 @@ public class StartBatterySwapResqHandler : SimpleChannelInboundHandler /// /// protected override void ChannelRead0(IChannelHandlerContext ctx, StartBatterySwapResq msg) { Log.Info($"receive msg={msg}"); - // - + //开始换电语音播报 if (msg.AnswerResult == 0) { ClientMgr.PlcClient.SwapStart = true; diff --git a/Service/Plc/Handler/SwapBatteryFinishReqHandler.cs b/Service/Plc/Handler/SwapBatteryFinishReqHandler.cs index 3f50421..3c4a88b 100644 --- a/Service/Plc/Handler/SwapBatteryFinishReqHandler.cs +++ b/Service/Plc/Handler/SwapBatteryFinishReqHandler.cs @@ -1,9 +1,13 @@ +using Autofac; using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Configuration; using log4net; using Service.Charger.Client; using Service.Charger.Msg.Charger.Req; using Service.Charger.Msg.Host.Resp; +using Service.Sound.SoundClient; namespace Service.Charger.Handler; @@ -16,15 +20,18 @@ public class SwapBatteryFinishReqHandler : SimpleChannelInboundHandler - /// - /// - protected override void ChannelRead0(IChannelHandlerContext ctx, SwapBatteryFinishReq msg) + public static readonly string addr1 = AppSettingsHelper.GetContent("SoundAddr", "Address34"); + public static SoundClient? SoundClient { get; set; } + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, SwapBatteryFinishReq msg) { + Log.Info("swap finish"); - ctx.Channel.WriteAndFlushAsync(new SwapBatteryFinishResq()); + ctx.Channel.WriteAndFlushAsync(new SwapBatteryFinishResq()); ClientMgr.PlcClient.SwapDone = true; } diff --git a/WebStarter/appsettings.dev.json b/WebStarter/appsettings.dev.json index c3827d3..cc8ae47 100644 --- a/WebStarter/appsettings.dev.json +++ b/WebStarter/appsettings.dev.json @@ -4,6 +4,38 @@ "DbType": "MySql", "SqlConnection": "server=192.168.2.2;Port=3306;Database=eaxing_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" }, + "SoundAddr": { + "Address01": "D:\\Voice\\01.mp4", + "Address02": "D:\\Voice\\02.mp4", + "Address03": "D:\\Voice\\03.mp4", + "Address04": "D:\\Voice\\04.mp4", + "Address05": "D:\\Voice\\05.mp4", + "Address06": "D:\\Voice\\06.mp4", + "Address07": "D:\\Voice\\07.mp4", + "Address08": "D:\\Voice\\08.mp4", + "Address09": "D:\\Voice\\09.mp4", + "Address10": "D:\\Voice\\10.mp4", + "Address11": "D:\\Voice\\11.mp4", + "Address12": "D:\\Voice\\12.mp4", + "Address13": "D:\\Voice\\13.mp4", + "Address14": "D:\\Voice\\14.mp4", + "Address15": "D:\\Voice\\15.mp4", + "Address16": "D:\\Voice\\16.mp4", + "Address17": "D:\\Voice\\17.mp4", + "Address18": "D:\\Voice\\18.mp4", + "Address19": "D:\\Voice\\19.mp4", + "Address20": "D:\\Voice\\20.mp4", + "Address21": "D:\\Voice\\21.mp4", + "Address22": "D:\\Voice\\22.mp4", + "Address23": "D:\\Voice\\23.mp4", + "Address24": "D:\\Voice\\24.mp4", + "Address25": "D:\\Voice\\25.mp4", + "Address26": "D:\\Voice\\26.mp4", + "Address27": "D:\\Voice\\27.mp4", + "Address28": "D:\\Voice\\28.mp4", + "Address29": "D:\\Voice\\29.mp4", + + }, "Update": { "AutoUpdate": "false", "Version": "1.1.0.1", @@ -132,6 +164,6 @@ "Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs", "Dest": "D:\\zip", "Days": 7 - }, - + } + } diff --git a/WebStarter/appsettings.json b/WebStarter/appsettings.json index 0c208ae..9402fe5 100644 --- a/WebStarter/appsettings.json +++ b/WebStarter/appsettings.json @@ -5,4 +5,5 @@ "Microsoft.AspNetCore": "Warning" } } + }