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