|
|
|
@ -121,7 +121,7 @@ public class DoSwappingState : IState
|
|
|
|
|
machine.SwapOrderBatteryInfo.UpBinInfo.No);
|
|
|
|
|
|
|
|
|
|
//查詢當前任務狀態是否被更改
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadTaskStatus(2);
|
|
|
|
|
if (startSwapping && readPlcTaskStatus)
|
|
|
|
|
{
|
|
|
|
|
machine.SwapOrder.SwapBeginTime = DateTime.Now;
|
|
|
|
@ -150,7 +150,7 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.PlcHoldFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
//查询车辆锁止状态
|
|
|
|
|
var taskPrepare = PlcApi.ReadTaskStatus(1);
|
|
|
|
|
var taskPrepare = PlcApi.ReadTaskStatus(2);
|
|
|
|
|
if (taskPrepare)
|
|
|
|
|
{
|
|
|
|
|
bool holdOn = PlcApi.HoldOn();
|
|
|
|
@ -174,12 +174,20 @@ public class DoSwappingState : IState
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus UnPack(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled,
|
|
|
|
|
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
() => 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)
|
|
|
|
@ -195,16 +203,24 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, () => { }, 10,
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled,
|
|
|
|
|
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
() => 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)
|
|
|
|
@ -222,17 +238,24 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, () => { }, 10,
|
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled,
|
|
|
|
|
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
() => 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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -247,16 +270,24 @@ 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,
|
|
|
|
|
return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
() => 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)
|
|
|
|
|
{
|
|
|
|
@ -275,16 +306,24 @@ public class DoSwappingState : IState
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
},false, () => { },
|
|
|
|
|
},false,
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus PackFinish(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,
|
|
|
|
|
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
|
|
|
|
|
() => 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)
|
|
|
|
|
{
|
|
|
|
@ -298,7 +337,7 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { },false, () => { },
|
|
|
|
|
}, () => { },false,
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|