|
|
|
@ -27,16 +27,6 @@ public class DoSwappingState : IState
|
|
|
|
|
machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.BeginSwap;
|
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
_log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}");
|
|
|
|
|
// CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*//再次读锁止状态,防止plc需要挪车
|
|
|
|
|
InvokeStatus carInPosition2 = CarInPosition2(machine);
|
|
|
|
|
if (carInPosition2 != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(carInPosition2, ExceptionReason.None);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//下发启动换电
|
|
|
|
|
InvokeStatus startSwapping = StartSwapping(machine);
|
|
|
|
@ -51,7 +41,6 @@ public class DoSwappingState : IState
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(holdOn, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//旧电池拆卸
|
|
|
|
|
InvokeStatus unPack = UnPack(machine);
|
|
|
|
@ -132,10 +121,8 @@ public class DoSwappingState : IState
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap);
|
|
|
|
|
},false, () => { },10,InvokeStatus.None);
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); }, false, () => { }, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -174,20 +161,13 @@ public class DoSwappingState : IState
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus UnPack(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, ReadTaskErr,
|
|
|
|
|
() => machine.UnOldBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
|
|
|
|
|
|
//plc任务异常结束流程
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
machine.PLCAbnormalFlag = true;
|
|
|
|
|
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
machine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int status = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
//处理程序太快,plc还没有初始值的状态
|
|
|
|
|
if (status == 1002 || status != 1003)
|
|
|
|
@ -209,18 +189,11 @@ public class DoSwappingState : IState
|
|
|
|
|
|
|
|
|
|
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled,ReadTaskErr,
|
|
|
|
|
() => machine.StorageOldBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
|
|
|
|
|
//plc任务异常结束流程
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
machine.PLCAbnormalFlag = true;
|
|
|
|
|
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
machine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
|
|
|
|
|
if (readPlcTaskStatus == 1003 || readPlcTaskStatus != 1004)
|
|
|
|
@ -244,21 +217,13 @@ public class DoSwappingState : IState
|
|
|
|
|
|
|
|
|
|
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled,ReadTaskErr,
|
|
|
|
|
() => machine.OutNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
|
|
|
|
|
//plc任务异常结束流程
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
machine.PLCAbnormalFlag = true;
|
|
|
|
|
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
machine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1004)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -270,28 +235,21 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, 10,
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); }, false, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InvokeStatus Pack(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, ReadTaskErr,
|
|
|
|
|
() => machine.InstallNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
//plc任务异常结束流程
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
machine.PLCAbnormalFlag = true;
|
|
|
|
|
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
machine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1005)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -303,27 +261,16 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
},false,
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack); }, false,
|
|
|
|
|
10, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus PackFinish(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,ReadTaskErr,
|
|
|
|
|
() => machine.FinishNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
|
//plc任务异常结束流程
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
machine.PLCAbnormalFlag = true;
|
|
|
|
|
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
machine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
if (readPlcTaskStatus == 1006 || readPlcTaskStatus == 1007)
|
|
|
|
|
{
|
|
|
|
@ -337,8 +284,8 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { },false,
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}, () => { }, false,
|
|
|
|
|
10, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -352,7 +299,7 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.ToSafePositionFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1007)
|
|
|
|
|
{
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
@ -362,19 +309,16 @@ public class DoSwappingState : IState
|
|
|
|
|
machine.SwapStatus = 1;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
PlcRealTimeTask.cameraTask = false;//结束记录拍照偏移日志
|
|
|
|
|
PlcRealTimeTask.LockStatusTask = false;//结束下发电池包锁状态
|
|
|
|
|
PlcRealTimeTask.VehicleParkingStatusTask = false;//结束下发车辆驻车状态
|
|
|
|
|
PlcRealTimeTask.RollerShutterTask= false;
|
|
|
|
|
PlcRealTimeTask.CameraTask = false; //结束记录拍照偏移日志
|
|
|
|
|
PlcRealTimeTask.LockStatusTask = false; //结束下发电池包锁状态
|
|
|
|
|
PlcRealTimeTask.VehicleParkingStatusTask = false; //结束下发车辆驻车状态
|
|
|
|
|
PlcRealTimeTask.RollerShutterTask = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆到位
|
|
|
|
|
/// </summary>
|
|
|
|
@ -419,8 +363,8 @@ public class DoSwappingState : IState
|
|
|
|
|
succCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (succCount==successCount)
|
|
|
|
|
|
|
|
|
|
if (succCount == successCount)
|
|
|
|
|
{
|
|
|
|
|
machine.VehiclesInPlace2Flag = true;
|
|
|
|
|
}
|
|
|
|
@ -432,4 +376,19 @@ public class DoSwappingState : IState
|
|
|
|
|
}, false, () => { }
|
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool ReadTaskErr()
|
|
|
|
|
{
|
|
|
|
|
if (PlcApi.ReadTaskStatus(1))
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.PLCAbnormalFlag = true;
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.SwapFailReason = "PLC任务异常结束";
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|