|
|
|
@ -5,6 +5,7 @@ using Service.Execute.Enum;
|
|
|
|
|
using Service.Execute.Model;
|
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
using Swapping.Business.Tech;
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
@ -13,6 +14,7 @@ public class DoSwappingState : IState
|
|
|
|
|
{
|
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState));
|
|
|
|
|
private SwapOrderRepository SwapOrderRepository { get; set; }
|
|
|
|
|
public SwapOrderStepService SwapOrderStepService { get; set; }
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
@ -22,6 +24,7 @@ public class DoSwappingState : IState
|
|
|
|
|
_log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}");
|
|
|
|
|
CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//再次读锁止状态,防止plc需要挪车
|
|
|
|
|
InvokeStatus carInPosition2 = CarInPosition2(machine);
|
|
|
|
|
if (carInPosition2 != InvokeStatus.Done)
|
|
|
|
@ -29,6 +32,7 @@ public class DoSwappingState : IState
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(carInPosition2, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//下发启动换电
|
|
|
|
|
InvokeStatus startSwapping = StartSwapping(machine);
|
|
|
|
|
if (startSwapping != InvokeStatus.Done)
|
|
|
|
@ -106,6 +110,8 @@ public class DoSwappingState : IState
|
|
|
|
|
SwapOrderRepository.Update(machine.SwapOrder);
|
|
|
|
|
machine.SwapStatus = 0;
|
|
|
|
|
machine.StartSwappingFlag = true;
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
@ -129,6 +135,12 @@ public class DoSwappingState : IState
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
|
|
|
|
|
|
|
|
|
|
machine.UnOldBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1002;
|
|
|
|
|
|
|
|
|
|
if (machine.UnOldBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -141,6 +153,12 @@ public class DoSwappingState : IState
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
|
|
|
|
|
|
|
|
|
|
machine.StorageOldBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1003;
|
|
|
|
|
|
|
|
|
|
if (machine.StorageOldBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -153,6 +171,11 @@ public class DoSwappingState : IState
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
|
|
|
|
|
|
|
|
|
|
machine.OutNewBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1004;
|
|
|
|
|
if (machine.OutNewBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,6 +189,12 @@ public class DoSwappingState : IState
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
|
|
|
|
|
machine.InstallNewBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1005;
|
|
|
|
|
|
|
|
|
|
if (machine.InstallNewBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -185,6 +214,9 @@ public class DoSwappingState : IState
|
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
//上报云平台换电完成
|
|
|
|
|
machine.SwapStatus = 1;
|
|
|
|
|
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|