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