|
|
@ -11,6 +11,7 @@ using Service.Execute.StaticTools;
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
using Service.Init;
|
|
|
|
using Service.Init;
|
|
|
|
|
|
|
|
using Service.Plc.Client;
|
|
|
|
using Service.Station;
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
namespace Service.Execute.Step;
|
|
|
@ -100,6 +101,7 @@ public class DoSwappingState : IState
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(toInvokeStatus, ExceptionReason.None);
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(toInvokeStatus, ExceptionReason.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询换电任务是否结束
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new StateResult()
|
|
|
|
return new StateResult()
|
|
|
@ -121,26 +123,36 @@ public class DoSwappingState : IState
|
|
|
|
bool unLock = result.Result;
|
|
|
|
bool unLock = result.Result;
|
|
|
|
if (unLock)
|
|
|
|
if (unLock)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//查询车辆锁止状态
|
|
|
|
//查询当前是否有任务执行
|
|
|
|
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
|
|
|
|
|
|
|
|
machine.SwapOrderBatteryInfo.UpBinInfo.No);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查詢當前任務狀態是否被更改
|
|
|
|
var readTaskNo = PlcMgr.PlcClient?.ReadTaskNo();
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
|
|
|
|
if (readTaskNo == 0 || readTaskNo==1)
|
|
|
|
if (startSwapping && readPlcTaskStatus)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
machine.SwapOrder.SwapBeginTime = DateTime.Now;
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(1);
|
|
|
|
_CommonMgr.UpdateSwapOrder(machine);
|
|
|
|
//查询车辆锁止状态
|
|
|
|
machine.SwapStatus = 0;
|
|
|
|
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
|
|
|
|
machine.StartSwappingFlag = true;
|
|
|
|
machine.SwapOrderBatteryInfo.UpBinInfo.No);
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
|
|
|
|
|
|
|
|
machine);
|
|
|
|
//查詢當前任務狀態是否被更改
|
|
|
|
|
|
|
|
var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
|
|
|
|
|
|
|
|
if (startSwapping && readPlcTaskStatus)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
machine.SwapOrder.SwapBeginTime = DateTime.Now;
|
|
|
|
|
|
|
|
_CommonMgr.UpdateSwapOrder(machine);
|
|
|
|
|
|
|
|
machine.SwapStatus = 0;
|
|
|
|
|
|
|
|
machine.StartSwappingFlag = true;
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
|
|
|
|
|
|
|
|
machine);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_log.Info("当前有任务在执行");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); }, false, () => { }, 10,
|
|
|
|
{
|
|
|
|
InvokeStatus.None);
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap);
|
|
|
|
|
|
|
|
},false, () => { },10,InvokeStatus.None);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -240,7 +252,6 @@ public class DoSwappingState : IState
|
|
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1004)
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1004)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -252,7 +263,7 @@ 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -265,7 +276,6 @@ public class DoSwappingState : IState
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1005)
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1005)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -277,11 +287,8 @@ 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)
|
|
|
@ -303,8 +310,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>
|
|
|
@ -318,14 +325,18 @@ 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);
|
|
|
|
if (PlcApi.ReadTaskStatusReset())
|
|
|
|
machine.ToSafePositionFlag = true;
|
|
|
|
{
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
PlcMgr.PlcClient?.ResetTaskNo();
|
|
|
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
|
|
|
|
machine.ToSafePositionFlag = true;
|
|
|
|
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
machine.SwapStatus = 1;
|
|
|
|
machine.SwapStatus = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () => { });
|
|
|
|
}, () => { });
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -344,13 +355,12 @@ public class DoSwappingState : IState
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
while (!machine.ChannelStatusOkFlag)
|
|
|
|
while (!machine.ChannelStatusOkFlag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (machine.CancelFlag)
|
|
|
|
if (machine.CancelFlag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_log.Info($" CheckChannelStatus canceled");
|
|
|
|
_log.Info($" CheckChannelStatus canceled");
|
|
|
|
return StateResult.Cancel;
|
|
|
|
return StateResult.Cancel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_log.Info("begin plc CheckChannelStatus");
|
|
|
|
_log.Info("begin plc CheckChannelStatus");
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
var channelStatus = PlcApi.ChannelStatus();
|
|
|
|
var channelStatus = PlcApi.ChannelStatus();
|
|
|
@ -375,7 +385,7 @@ public class DoSwappingState : IState
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
//等待2分钟
|
|
|
|
//等待2分钟
|
|
|
|
Thread.Sleep(3*60 *1000);
|
|
|
|
Thread.Sleep(3 * 60 * 1000);
|
|
|
|
machine.VehiclesInPlace2Flag = false;
|
|
|
|
machine.VehiclesInPlace2Flag = false;
|
|
|
|
machine.StartSwappingFlag = false;
|
|
|
|
machine.StartSwappingFlag = false;
|
|
|
|
machine.PlcHoldFlag = false;
|
|
|
|
machine.PlcHoldFlag = false;
|
|
|
@ -448,8 +458,8 @@ public class DoSwappingState : IState
|
|
|
|
succCount++;
|
|
|
|
succCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (succCount==successCount)
|
|
|
|
if (succCount == successCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
machine.VehiclesInPlace2Flag = true;
|
|
|
|
machine.VehiclesInPlace2Flag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -461,4 +471,4 @@ public class DoSwappingState : IState
|
|
|
|
}, false, () => { }
|
|
|
|
}, false, () => { }
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|