|
|
|
@ -41,13 +41,14 @@ public class DoSwappingState : IState
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InvokeStatus holdOn = HoldOn(machine);
|
|
|
|
|
if (holdOn != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(holdOn, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查看通道状态
|
|
|
|
|
StateResult checkChannelStatus = CheckChannelStatus(machine);
|
|
|
|
|
if (checkChannelStatus != null)
|
|
|
|
@ -89,8 +90,8 @@ public class DoSwappingState : IState
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(packFinish, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//航车回归安全位置
|
|
|
|
|
InvokeStatus toInvokeStatus = ToSafePosition(machine);
|
|
|
|
|
if (toInvokeStatus != InvokeStatus.Done)
|
|
|
|
@ -121,7 +122,7 @@ public class DoSwappingState : IState
|
|
|
|
|
//查询车辆锁止状态
|
|
|
|
|
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
|
|
|
|
|
machine.SwapOrderBatteryInfo.UpBinInfo.No);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查詢當前任務狀態是否被更改
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
|
|
|
|
|
if (startSwapping && readPlcTaskStatus)
|
|
|
|
@ -155,7 +156,7 @@ public class DoSwappingState : IState
|
|
|
|
|
bool holdOn = PlcApi.HoldOn();
|
|
|
|
|
if (holdOn)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo);
|
|
|
|
|
machine.PlcHoldFlag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -177,13 +178,12 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.UnOldBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int status = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
//处理程序太快,plc还没有初始值的状态
|
|
|
|
|
if (status==1002 || status!=1003)
|
|
|
|
|
if (status == 1002 || status != 1003)
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -195,7 +195,8 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, () => { }, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
|
|
|
|
@ -204,25 +205,25 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.StorageOldBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1003)
|
|
|
|
|
if (readPlcTaskStatus == 1003 || readPlcTaskStatus != 1004)
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machine.StorageOldBatteryFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
machine.StorageOldBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1004;
|
|
|
|
|
machine.StorageOldBatteryFlag = readPlcTaskStatus == 1004;
|
|
|
|
|
|
|
|
|
|
if (machine.StorageOldBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, () => { }, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
|
|
|
|
@ -231,22 +232,23 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.OutNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1004)
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machine.OutNewBatteryFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (machine.OutNewBatteryFlag)
|
|
|
|
|
{
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, () => { }, 10,
|
|
|
|
|
InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -256,10 +258,9 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.InstallNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1005)
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -271,7 +272,11 @@ public class DoSwappingState : IState
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
},false, () => { },
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus PackFinish(SwappingStateMachine machine)
|
|
|
|
@ -280,22 +285,23 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.FinishNewBatteryFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
|
|
|
|
|
if (readPlcTaskStatus == 1006 || readPlcTaskStatus==1007 )
|
|
|
|
|
if (readPlcTaskStatus == 1006 || readPlcTaskStatus == 1007)
|
|
|
|
|
{
|
|
|
|
|
machine.FinishNewBatteryFlag = true;
|
|
|
|
|
machine.BusinessSwappingForCloudState =
|
|
|
|
|
InfoEnum.BusinessSwappingForCloudState.SwapFinish;
|
|
|
|
|
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
|
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}, () => { },false, () => { },
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 行车回归安全位置
|
|
|
|
|
/// </summary>
|
|
|
|
@ -307,19 +313,19 @@ public class DoSwappingState : IState
|
|
|
|
|
() => machine.ToSafePositionFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1007)
|
|
|
|
|
{
|
|
|
|
|
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
|
machine.ToSafePositionFlag = true;
|
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
machine.SwapStatus = 1;
|
|
|
|
|
}
|
|
|
|
|
}, () => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查看通道状态
|
|
|
|
|
/// :0:无效值
|
|
|
|
|