diff --git a/Entity/Constant/InfoEnum.cs b/Entity/Constant/InfoEnum.cs index 8182e5c..87fdb4d 100644 --- a/Entity/Constant/InfoEnum.cs +++ b/Entity/Constant/InfoEnum.cs @@ -26,15 +26,15 @@ public class InfoEnum [Info("通道拍照定位失败,请在三分钟内重新调整车辆位置", "通道拍照定位失败,请在三分钟内重新调整车辆位置")]ErrChannelStatus, - [Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack , + [Info("亏电电池拆卸中,请稍候", "亏电电池拆卸中,请稍候")] InfoUnPack , - [Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack , + [Info("满电电池安装中,请稍候", "满电电池安装中,请稍候")] InfoPack , [Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish , [Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition , - [Info("换电已完成,请驶离", "换电已完成,请驶离")] InfoCarLeave , + [Info("换电完成,请将车辆驶出换电站", "换电完成,请将车辆驶出换电站")] InfoCarLeave , [Info("换电失败,请驶离", "换电失败,请驶离")] ErrInfoCarLeave , - [Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn , - [Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut , + [Info("亏电池搬运中,请稍候", "亏电池搬运中,请稍候")] InfoOldBatteryCarryIn , + [Info("满电电池搬运中,请稍候", "满电电池搬运中,请稍候")] InfoNewBatteryCarryOut , [Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar , [Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr, [Info("结束充电电池数量不足","通道的电池仓无可用换电电池")] LessOfFinishChargingErr, @@ -45,7 +45,7 @@ public class InfoEnum [Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr, - [Info("车辆驶入","车辆驶入")] CarInInfo, + [Info("请将车辆行驶到指定位置,并拉起手刹","请将车辆行驶到指定位置,并拉起手刹")] CarInInfo, [Info("换电任务启动","换电任务启动")] StartSwapInfo, [Info("航车拍照中,请稍后","航车拍照中,请稍后")] CarTakePhotoInfo, [Info("启动换电失败,请联系站务人员","启动换电失败,请联系站务人员")] ErrStartSwap, @@ -53,6 +53,14 @@ public class InfoEnum [Info("电池移仓中","电池移仓中")] InfoBatteryMove, [Info("消防移仓中","消防移仓中")] InfoFireRemove, [Info("拍照失败,请在三分钟内挪车","拍照失败,请在三分钟内挪车")] ErrChannel1020, + [Info("车辆识别","车辆识别")] BeginReadRfid, + [Info("下发启动换电到车载设备超时", "下发启动换电到车载设备超时")] ErrStartSwapToTBox , + [Info("请将货箱放下", "请将货箱放下")] InfoTboxDown , + [Info("请将车辆下电", "请将车辆下电")] InfoTboxEnergyDown , + [Info("请将货箱抬起", "请将货箱抬起")] InfoTboxHandUp , + [Info("请将车辆上电", "请将车辆上电")] InfoTboxEnergyUp , + [Info("通道定位失败,车辆出站请重新进站","通道定位失败,车辆出站请重新进站")] CarTakePhotoErrRepeat, + [Info("请操作换电启动按钮","请操作换电启动按钮")] InfoManualStartSwap } @@ -106,6 +114,7 @@ public class InfoEnum [Const("云平台车辆认证")] CloudVelCheckFlag, [Const("车辆到位")] CarInPositionFlag, [Const("云平台下发换电指令")] CloudCarCanStartFlag, + [Const("换电就绪")] TBoxSwapReadyFlag, [Const("车辆解锁")] VelUnlockFlag, [Const("下发plc选包")] DistributeSelectPackFlag, diff --git a/Service/Execute/Api/TboxApi.cs b/Service/Execute/Api/TboxApi.cs index 9c6f8fe..0abfc9d 100644 --- a/Service/Execute/Api/TboxApi.cs +++ b/Service/Execute/Api/TboxApi.cs @@ -85,6 +85,34 @@ public class TBoxApi } + /// + /// 下发开始换电指令到tbox + /// + /// + public static async Task StartSwap(string carNo) + { + Log.Info($" TBoxApi start StartSwap carNo={carNo} "); + string url = BASE_URL + "/startSwap/" + carNo; + try + { + string s = await _httpClient.GetStringAsync(url); + + + Log.Info($"StartSwap resp = {s}"); + if (string.IsNullOrWhiteSpace(s)) + { + return 0; + } + + return byte.Parse(s); + } + catch (Exception e) + { + Log.Error($"StartSwap e = {e}"); + return 0; + } + } + public static async Task UnLockCarManyTimes(string carNo) { Log.Info($" TBoxApi start UnLockCarManyTimes carNo={carNo} "); @@ -149,7 +177,7 @@ public class TBoxApi return false; } } - + /// /// Tbox连接 /// /Car/unLock/ @@ -172,7 +200,7 @@ public class TBoxApi return false; } } - + /// /// Tbox断连 /// /Car/unLock/ @@ -231,7 +259,7 @@ public class TBoxApi public static async Task LockCar(string carNo) { Log.Info("LockCar"); - string url = BASE_URL +StaticStationInfo.TboxUrlLock + carNo; + string url = BASE_URL + StaticStationInfo.TboxUrlLock + carNo; try { string s = await _httpClient.GetStringAsync(url); diff --git a/Service/Execute/Model/Tbox/TboxCarInfoModel.cs b/Service/Execute/Model/Tbox/TboxCarInfoModel.cs index 01d9e60..82a9435 100644 --- a/Service/Execute/Model/Tbox/TboxCarInfoModel.cs +++ b/Service/Execute/Model/Tbox/TboxCarInfoModel.cs @@ -1,3 +1,5 @@ +using Service.Car.Msg.Car.Req; + namespace Service.Execute.Model.Tbox; /// @@ -24,4 +26,11 @@ public class TboxCarInfoModel /// 车辆状态信息 /// public CarStatus? CarStatus { get; set; } + + + /// + /// 温度故障数据 + /// + /// + public TemperatureDetectionMsg? TemperatureDetectionMsg { get; set; } } \ No newline at end of file diff --git a/Service/Execute/Model/Tbox/TemperatureDetectionMsg.cs b/Service/Execute/Model/Tbox/TemperatureDetectionMsg.cs new file mode 100644 index 0000000..5f0e53d --- /dev/null +++ b/Service/Execute/Model/Tbox/TemperatureDetectionMsg.cs @@ -0,0 +1,198 @@ +using HybirdFrameworkCore.Autofac.Attribute; + +namespace Service.Car.Msg.Car.Req; + +/// +/// 温度监测信息 +/// +public class TemperatureDetectionMsg +{ + /// + /// 故障等级 + /// /// 0:无故障 + /// 1:1 级故障 + /// 2:2 级故障 + /// 3:3 级故障 + /// + [Property(248, 8)] + public byte FaultLevel { get; set; } + + /// + /// 换电系统故障码 + /// 0:换电连接器未过温 + ///1:换电连接器温度检测 1 过温一级故障 + /// 注:暂不定义一级故障 + ///2:换电连接器温度检测 2 过温一级故障 + /// 注:暂不定义一级故障 + ///3:换电连接器温度检测 3 过温一级故障 + /// 注:暂不定义一级故障 + ///4:换电连接器温度检测 4 过温一级故障 + /// 注:暂不定义一级故障 + ///5:换电连接器温度检测 5 过温一级故障 + /// 注:暂不定义一级故障 + ///6:换电连接器温度检测 6 过温一级故障 + /// 注:暂不定义一级故障 + ///7:换电连接器温度检测 7 过温一级故障 + /// 注:暂不定义一级故障 + ///8:换电连接器温度检测 8 过温一级故障 + /// 注:暂不定义一级故障 + ///9:换电连接器温度检测 1 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解 + /// 除条件:Tmax<80℃, 持续 3s; + ///10:换电连接器温度检测 2 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///11:换电连接器温度检测 3 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///12:换电连接器温度检测 4 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///13:换电连接器温度检测 5 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///14:换电连接器温度检测 6 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///15:换电连接器温度检测 7 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + ///解除条件:Tmax<80℃, 持续 3s; + ///16:换电连接器温度检测 8 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 0:换电连接器未过温 + /// 1:换电连接器温度检测 1 过温一级故障 + /// 注:暂不定义一级故障 + /// 2:换电连接器温度检测 2 过温一级故障 + /// 注:暂不定义一级故障 + /// 3:换电连接器温度检测 3 过温一级故障 + /// 注:暂不定义一级故障 + /// 4:换电连接器温度检测 4 过温一级故障 + /// 注:暂不定义一级故障 + /// 5:换电连接器温度检测 5 过温一级故障 + /// 注:暂不定义一级故障 + /// 6:换电连接器温度检测 6 过温一级故障 + /// 注:暂不定义一级故障 + /// 7:换电连接器温度检测 7 过温一级故障 + /// 注:暂不定义一级故障 + /// 8:换电连接器温度检测 8 过温一级故障 + /// 注:暂不定义一级故障 + /// 9:换电连接器温度检测 1 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解 + /// 除条件:Tmax<80℃, 持续 3s; + /// 10:换电连接器温度检测 2 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 11:换电连接器温度检测 3 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 12:换电连接器温度检测 4 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 13:换电连接器温度检测 5 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 14:换电连接器温度检测 6 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 15:换电连接器温度检测 7 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 16:换电连接器温度检测 8 过温二级故障 + /// 判定条件:Tmax>90℃,持续 3s; + /// 解除条件:Tmax<80℃, 持续 3s; + /// 17:换电连接器温度检测 1 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 18:换电连接器温度检测 2 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 19:换电连接器温度检测 3 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 20:换电连接器温度检测 4 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 21:换电连接器温度检测 5 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 22:换电连接器温度检测 6 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 23:换电连接器温度检测 7 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 24:换电连接器温度检测 8 过温三级故障 + /// 判定条件:Tmax>100℃,持续 3s; + /// 解除条件:需重新上电且 Tmax<70℃, 持续 + /// 3s; + /// 25:换电连接器温度检测传感器 1 开路二级 + /// 故障 + /// 26:换电连接器温度检测传感器 2 开路二级 + /// 故障 + /// 27:换电连接器温度检测传感器 3 开路二级 + /// 故障 + /// 28:换电连接器温度检测传感器 4 开路二级 + /// 故障 + /// 29:换电连接器温度检测传感器 5 开路二级 + /// 故障 + /// 30:换电连接器温度检测传感器 6 开路二级 + /// 故障 + /// 31:换电连接器温度检测传感器 7 开路二级 + /// 故障 + /// 32:换电连接器温度检测传感器 8 开路二级 + /// 故障 + /// + [Property(248+8, 8)] + public byte FaultCode { get; set; } + + /// + /// 换电连接器温度检测 1(放电 1正) 有效值-40~210,单位℃ + /// + [Property(248+2*8, 8)] + public double ConnectorTemp1 { get; set; } + + /// + /// 换电连接器温度检 测 2(放电 1负) 有效值-40~210,单位℃ + /// + [Property(248+3*8, 8)] + public double ConnectorTemp2 { get; set; } + /// + /// 换电连接器温度检测3(放电2 正) 有效值-40~210,单位℃ + /// + [Property(248+4*8, 8)] + public double ConnectorTemp3 { get; set; } + /// + /// 换电连接器温度检测 4(放电 2负) 有效值-40~210,单位℃ + /// + [Property(248+5*8, 8)] + public double ConnectorTemp4 { get; set; } + /// + /// 换电连接器温度检测 5(充电 1正)有效值-40~210,单位℃ + /// + [Property(248+6*8, 8)] + public double ConnectorTemp5 { get; set; } + /// + /// 换电连接器温度检测 6(充电 1负) 有效值-40~210,单位℃ + /// + [Property(248+7*8, 8)] + public double ConnectorTemp6 { get; set; } + /// + /// 换电连接器温度检测 7(充电 2正) 有效值-40~210,单位℃ + /// + [Property(248+8*8, 8)] + public double ConnectorTemp7 { get; set; } + /// + ///换电连接器温度检测 8(充电 2负) 有效值-40~210,单位℃ + /// + [Property(248+9*8, 8)] + public double ConnectorTemp8 { get; set; } +} \ No newline at end of file diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 2503e3d..d1d64ff 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -20,6 +20,13 @@ public class CarCtrlState : IState public StateResult Handle(SwappingStateMachine machine) { + //拍照定位 + //查看通道状态 + StateResult checkChannelStatus = CheckChannelStatus(machine); + if (checkChannelStatus != null) + { + return checkChannelStatus; + } //解锁车辆 @@ -29,14 +36,40 @@ public class CarCtrlState : IState return SwappingStateMachine.ReturnWithInvokeErr(unLockCar, ExceptionReason.None); } - //下发选包 - /*InvokeStatus distributeSelectPack = DistributeSelectPack(machine); + //站控下发换电启动命令到VCU和TBOX //vcu反馈换电就绪 + InvokeStatus startSwapToTBox = StartSwapToTBox(machine); + if (startSwapToTBox != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(startSwapToTBox, ExceptionReason.None); + } + + + //TBOX收到抬起到位信号 + InvokeStatus tBoxHandUp = TBoxHandUp(machine); + if (tBoxHandUp != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(tBoxHandUp, ExceptionReason.None); + } + + + //TBOX收到车辆下电OK信号 + InvokeStatus tBoxEnergyDown = TBoxEnergyDown(machine); + if (tBoxEnergyDown != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(tBoxEnergyDown, ExceptionReason.None); + } + + //请操作换电启动按钮 + SoundApi.PlayOneSound((int) InfoEnum.SwapInfo.InfoManualStartSwap); + Thread.Sleep(2000); + + /*//下发选包 + InvokeStatus distributeSelectPack = DistributeSelectPack(machine); if (distributeSelectPack != InvokeStatus.Done) { return SwappingStateMachine.ReturnWithInvokeErr(distributeSelectPack, ExceptionReason.None); - } - */ + }*/ return new StateResult() { @@ -54,7 +87,7 @@ public class CarCtrlState : IState () => machine.VelUnlockFlag, () => { Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); - + bool unLock = result.Result; if (unLock) { @@ -72,12 +105,97 @@ public class CarCtrlState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar); }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } , 10, InvokeStatus.None); } + /// + ///收到抬起到位信号 + /// + /// + public InvokeStatus StartSwapToTBox(SwappingStateMachine machine) + { + return Invoker.Invoke("StartSwapToTBox", 500, 10, machine.IsCanceled, + () => machine.TboxHandUpFlag, () => + { + Task result = TBoxApi.StartSwap(machine.RfidReadModel.VelVin); + + byte res = result.Result; + //换电就绪 + if (res == 1) + { + //查询车辆锁止状态 + machine.TboxHandUpFlag = true; + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.TBoxSwapReadyFlag, + machine); + } + }, () => + { + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwapToTBox); + }, false, () => { machine.ExceptionReason = ExceptionReason.StartSwapToTBoxError; } + , 10, InvokeStatus.None); + } + + /// + ///收到抬起到位信号 + /// + /// + public InvokeStatus TBoxHandUp(SwappingStateMachine machine) + { + return Invoker.Invoke("TBoxHandUp", 500, 5, machine.IsCanceled, + () => machine.TboxHandUpFlag, () => + { + Task result = TBoxApi.StartSwap(machine.RfidReadModel.VelVin); + + byte res = result.Result; + //换电就绪 + if (res == 2) + { + //查询车辆锁止状态 + machine.TboxHandUpFlag = true; + // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.TBoxSwapReadyFlag, + // machine); + } + }, () => + { + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxHandUp); + }, false, () => { } + , 10, InvokeStatus.None); + } + + + /// + ///收到下电成功 + /// + /// + public InvokeStatus TBoxEnergyDown(SwappingStateMachine machine) + { + return Invoker.Invoke("TBoxEnergyDown", 500, 5, machine.IsCanceled, + () => machine.TboxEnergyDownFlag, () => + { + Task result = TBoxApi.StartSwap(machine.RfidReadModel.VelVin); + + byte res = result.Result; + //换电就绪 + if (res == 3) + { + //查询车辆锁止状态 + machine.TboxEnergyDownFlag = true; + // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.TBoxSwapReadyFlag, + // machine); + } + }, () => + { + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxEnergyDown); + }, false, () => { } + , 10, InvokeStatus.None); + } + /// /// 下发选包 @@ -99,8 +217,60 @@ public class CarCtrlState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrDistributeSelectPack.GetLed()); - + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrDistributeSelectPack.GetLed()); }); } + + + /// + /// 查看通道状态 + /// :0:无效值 + /// 1000;拍照OK + ///1010;拍照NG + ///1020;拍照超限,请移车 + /// + /// + public StateResult CheckChannelStatus(SwappingStateMachine machine) + { + int count = 0; + while (!machine.ChannelStatusOkFlag) + { + if (machine.CancelFlag) + { + _log.Info($" CheckChannelStatus canceled"); + return StateResult.Cancel; + } + + _log.Info("begin plc CheckChannelStatus"); + Thread.Sleep(2000); + var channelStatus = PlcApi.ChannelStatus(); + if (count % 10 == 0) + { + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo); + } + + count++; + + if (channelStatus == 1000) + { + machine.ChannelStatusOkFlag = true; + return null; + } + + else + { + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoErrRepeat); + //故障 不能继续换电,提示驶离,上报云平台,修改换电订单 + machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail; + machine.SwapFailReason = "拍照故障 plc故障码1010"; + //跳转到SwappDone + return new StateResult() + { + SwappingState = SwappingState.SwapDone + }; + } + } + + return null; + } } \ No newline at end of file diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index a41c948..31deac7 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -50,13 +50,7 @@ public class DoSwappingState : IState return SwappingStateMachine.ReturnWithInvokeErr(holdOn, ExceptionReason.None); } - - //查看通道状态 - StateResult checkChannelStatus = CheckChannelStatus(machine); - if (checkChannelStatus != null) - { - return checkChannelStatus; - } + //旧电池拆卸 InvokeStatus unPack = UnPack(machine); @@ -331,77 +325,7 @@ public class DoSwappingState : IState } - /// - /// 查看通道状态 - /// :0:无效值 - /// 1000;拍照OK - ///1010;拍照NG - ///1020;拍照超限,请移车 - /// - /// - public StateResult CheckChannelStatus(SwappingStateMachine machine) - { - int count = 0; - while (!machine.ChannelStatusOkFlag) - { - - if (machine.CancelFlag) - { - _log.Info($" CheckChannelStatus canceled"); - return StateResult.Cancel; - } - - _log.Info("begin plc CheckChannelStatus"); - Thread.Sleep(2000); - var channelStatus = PlcApi.ChannelStatus(); - if (count % 10 == 0) - { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo); - } - - count++; - - if (channelStatus == 1000) - { - machine.ChannelStatusOkFlag = true; - return null; - } - else if (channelStatus == 1020) - { - //需要移车 先解锁 提示移动车辆,等待3分钟 - var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); - if (lockCar.Result) - { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus); - //等待2分钟 - Thread.Sleep(3*60 *1000); - machine.VehiclesInPlace2Flag = false; - machine.StartSwappingFlag = false; - machine.PlcHoldFlag = false; - machine.ChannelStatusOkFlag = false; - //回归到本阶段的读锁止状态 - return new StateResult() - { - SwappingState = SwappingState.DoSwapping - }; - } - } - else if (channelStatus == 1010) - { - //故障 不能继续换电,提示驶离,上报云平台,修改换电订单 - machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail; - machine.SwapFailReason = "拍照故障 plc故障码1010"; - //跳转到SwappDone - return new StateResult() - { - SwappingState = SwappingState.SwapDone - }; - } - } - - return null; - } + /// diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index 580a8a1..a360a16 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -62,7 +62,8 @@ public class StationReadyState : IState { return SwappingStateMachine.ReturnWithInvokeErr(entranceRadar, ExceptionReason.None); } - + //语音播报车辆识别 + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.BeginReadRfid); //开始读rifd var beginRfid = BeginRead(machine); diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index 94f1f46..7d13777 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -63,6 +63,7 @@ public class SwapDoneState : IState machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.SwapDoneWithVel; // CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState); } + //TODO::缺少车辆自检 //云平台没有匹配的失败状态 //车辆上锁 ,提示请驶离 @@ -73,6 +74,21 @@ public class SwapDoneState : IState return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None); } + + //TBOX收到车辆上电OK信号 + InvokeStatus tBoxEnergyUp = TBoxEnergyUp(machine); + if (tBoxEnergyUp != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(tBoxEnergyUp, ExceptionReason.None); + } + + //TBOX收到货箱放下 + InvokeStatus tBoxDown = TBoxDown(machine); + if (tBoxDown != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(tBoxDown, ExceptionReason.None); + } + //出口雷达监测 InvokeStatus existRadar = ExistRadar(machine); if (existRadar != InvokeStatus.Done) @@ -107,26 +123,9 @@ public class SwapDoneState : IState { machine.ManualConfirmCarLockFlag = false; machine.BoxCarInfoModel = carInfo.Result; - //设置出口的是绿灯 - if (PlcApi.WriteExistLamp(1000)) - { - /*machine.LedTool?.WriteProgramContent( - machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success - ? InfoEnum.SwapInfo.InfoCarLeave.GetLed() - : InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed());*/ - SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success - ? (int)InfoEnum.SwapInfo.InfoCarLeave - : (int)InfoEnum.SwapInfo.ErrInfoCarLeave); - machine.VelLockFlag = true; - //断连Tbox - if (StaticStationInfo.TboxStateDisConnect) - { - TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo); - } - - _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, - machine); - } + machine.VelLockFlag = true; + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, + machine); } } }, () => @@ -178,4 +177,75 @@ public class SwapDoneState : IState : (int)InfoEnum.SwapInfo.ErrInfoCarLeave); }, false, () => { }, 10, InvokeStatus.None); } + + /// + ///收到货箱放下 + /// + /// + public InvokeStatus TBoxDown(SwappingStateMachine machine) + { + return Invoker.Invoke("TBoxDown", 500, 5, machine.IsCanceled, + () => machine.TboxDownFlag, () => + { + Task result = TBoxApi.StartSwap(machine.RfidReadModel.VelVin); + + byte res = result.Result; + //换电就绪 + if (res == 7) + { + //设置出口的是绿灯 + if (PlcApi.WriteExistLamp(1000)) + { + machine.TboxDownFlag = true; + /*machine.LedTool?.WriteProgramContent( + machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success + ? InfoEnum.SwapInfo.InfoCarLeave.GetLed() + : InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed());*/ + SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success + ? (int)InfoEnum.SwapInfo.InfoCarLeave + : (int)InfoEnum.SwapInfo.ErrInfoCarLeave); + + //断连Tbox + if (StaticStationInfo.TboxStateDisConnect) + { + TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo); + } + } + } + }, () => + { + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxDown); + }, false, () => { } + , 10, InvokeStatus.None); + } + + + /// + ///收到上电成功 + /// + /// + public InvokeStatus TBoxEnergyUp(SwappingStateMachine machine) + { + return Invoker.Invoke("TBoxEnergyUp", 500, 5, machine.IsCanceled, + () => machine.TboxEnergyUpFlag, () => + { + Task result = TBoxApi.StartSwap(machine.RfidReadModel.VelVin); + + byte res = result.Result; + //换电就绪 + if (res == 6) + { + //查询车辆锁止状态 + machine.TboxEnergyUpFlag = true; + // _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.TBoxSwapReadyFlag, + // machine); + } + }, () => + { + // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); + SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxEnergyUp); + }, false, () => { } + , 10, InvokeStatus.None); + } } \ No newline at end of file diff --git a/Service/Execute/SwapException/ExceptionReason.cs b/Service/Execute/SwapException/ExceptionReason.cs index 2da6f1d..9ae5a9b 100644 --- a/Service/Execute/SwapException/ExceptionReason.cs +++ b/Service/Execute/SwapException/ExceptionReason.cs @@ -21,5 +21,6 @@ namespace Service.Execute.SwapException; LockCarError, LvPwrOffError, SelfCheckError, - TimeOutError + TimeOutError, + StartSwapToTBoxError } diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs index 317496b..eb1f992 100644 --- a/Service/Execute/SwappingStateMachine.cs +++ b/Service/Execute/SwappingStateMachine.cs @@ -106,6 +106,15 @@ public class SwappingStateMachine : IDisposable //车辆解锁 public bool VelUnlockFlag = false; + //TODO::新加 + //给Tbox下发开始换电 + public bool StartSwapToTBoxFlag = false; + public bool TboxHandUpFlag = false; + public bool TboxEnergyDownFlag = false; + public bool TboxDownFlag = false; + + public bool TboxEnergyUpFlag = false; + //开始换电 public bool StartSwappingFlag = false; @@ -280,7 +289,7 @@ public class SwappingStateMachine : IDisposable Log.Info($"ManualSwapSuccFlag machine ok"); return true; } - + public bool ManualConfirmLockCar() { ManualConfirmCarLockFlag = true; @@ -288,7 +297,7 @@ public class SwappingStateMachine : IDisposable Log.Info($"ManualConfirmLockCar ok"); return true; } - + public bool ManualConfirmUnLockCar() { ManualConfirmCarUnlockFlag = true; @@ -298,7 +307,6 @@ public class SwappingStateMachine : IDisposable } - private void ResetData() { BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.Idle; @@ -401,6 +409,12 @@ public class SwappingStateMachine : IDisposable RadarOutFlag = false; + + StartSwapToTBoxFlag = false; + TboxHandUpFlag = false; + TboxEnergyDownFlag = false; + TboxDownFlag = false; + TboxEnergyUpFlag = false; } //关于仓库锁定相关重置