|
|
@ -2,6 +2,7 @@
|
|
|
|
using Entity.Attr;
|
|
|
|
using Entity.Attr;
|
|
|
|
using Entity.Constant;
|
|
|
|
using Entity.Constant;
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
|
|
|
using HybirdFrameworkCore.Configuration;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
using Service.Charger.Client;
|
|
|
|
using Service.Charger.Client;
|
|
|
|
using Service.Execute.Api;
|
|
|
|
using Service.Execute.Api;
|
|
|
@ -10,6 +11,7 @@ using Service.Execute.SwapException;
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
using Service.Init;
|
|
|
|
using Service.Init;
|
|
|
|
using Service.Led;
|
|
|
|
using Service.Led;
|
|
|
|
|
|
|
|
using Service.Sound.SoundClient;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +20,11 @@ public class DoSwappingState : IState
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState));
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState));
|
|
|
|
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve<CommonMgr>();
|
|
|
|
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve<CommonMgr>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static SoundClient? SoundClient { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//上报云平台换电开始
|
|
|
|
//上报云平台换电开始
|
|
|
@ -33,13 +40,12 @@ public class DoSwappingState : IState
|
|
|
|
InvokeStatus startSwapping = StartSwapping(machine);
|
|
|
|
InvokeStatus startSwapping = StartSwapping(machine);
|
|
|
|
if (startSwapping != InvokeStatus.Done)
|
|
|
|
if (startSwapping != InvokeStatus.Done)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//旧电池拆卸
|
|
|
|
//旧电池拆卸
|
|
|
|
InvokeStatus unPack = UnPack(machine);
|
|
|
|
InvokeStatus unPack = UnPack(machine);
|
|
|
|
if (unPack != InvokeStatus.Done)
|
|
|
|
if (unPack != InvokeStatus.Done)
|
|
|
@ -100,7 +106,11 @@ public class DoSwappingState : IState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address30"));
|
|
|
|
|
|
|
|
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap);
|
|
|
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address01"));
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrStartSwap.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrStartSwap.GetLed());
|
|
|
|
},false, () => { },10,InvokeStatus.None);
|
|
|
|
},false, () => { },10,InvokeStatus.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -123,7 +133,9 @@ public class DoSwappingState : IState
|
|
|
|
bool holdOn = PlcApi.HoldOn();
|
|
|
|
bool holdOn = PlcApi.HoldOn();
|
|
|
|
if (holdOn)
|
|
|
|
if (holdOn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address28"));
|
|
|
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo);
|
|
|
|
machine.PlcHoldFlag = true;
|
|
|
|
machine.PlcHoldFlag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -147,7 +159,8 @@ public class DoSwappingState : IState
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
|
|
|
|
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoUnPack.GetLed());
|
|
|
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address11"));
|
|
|
|
machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone;
|
|
|
|
machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone;
|
|
|
|
|
|
|
|
|
|
|
|
if (machine.UnOldBatteryFlag)
|
|
|
|
if (machine.UnOldBatteryFlag)
|
|
|
@ -185,7 +198,9 @@ public class DoSwappingState : IState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address17"));
|
|
|
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
InvokeStatus.None);
|
|
|
|
InvokeStatus.None);
|
|
|
@ -215,7 +230,9 @@ public class DoSwappingState : IState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address18"));
|
|
|
|
|
|
|
|
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
InvokeStatus.None);
|
|
|
|
InvokeStatus.None);
|
|
|
@ -239,7 +256,9 @@ public class DoSwappingState : IState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
|
|
|
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address12"));
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPack.GetLed());
|
|
|
|
},false, () => { },
|
|
|
|
},false, () => { },
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
10,InvokeStatus.None);
|
|
|
@ -258,7 +277,9 @@ public class DoSwappingState : IState
|
|
|
|
InfoEnum.BusinessSwappingForCloudState.SwapFinish;
|
|
|
|
InfoEnum.BusinessSwappingForCloudState.SwapFinish;
|
|
|
|
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
|
|
|
|
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
|
|
|
|
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
|
|
|
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address13"));
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
|
|
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
@ -287,7 +308,9 @@ public class DoSwappingState : IState
|
|
|
|
|
|
|
|
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1007)
|
|
|
|
if (PlcApi.ReadPlcTaskStatus() == 1007)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address14"));
|
|
|
|
|
|
|
|
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
|
|
|
|
machine.ToSafePositionFlag = true;
|
|
|
|
machine.ToSafePositionFlag = true;
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
@ -322,7 +345,9 @@ public class DoSwappingState : IState
|
|
|
|
var channelStatus = PlcApi.ChannelStatus();
|
|
|
|
var channelStatus = PlcApi.ChannelStatus();
|
|
|
|
if (count % 10 == 0)
|
|
|
|
if (count % 10 == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address29"));
|
|
|
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
@ -338,8 +363,10 @@ public class DoSwappingState : IState
|
|
|
|
var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
if (lockCar.Result)
|
|
|
|
if (lockCar.Result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address10"));
|
|
|
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
//等待2分钟
|
|
|
|
//等待2分钟
|
|
|
|
Thread.Sleep(3*60 *1000);
|
|
|
|
Thread.Sleep(3*60 *1000);
|
|
|
|
machine.VehiclesInPlace2Flag = false;
|
|
|
|
machine.VehiclesInPlace2Flag = false;
|
|
|
@ -422,8 +449,10 @@ public class DoSwappingState : IState
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
machine.ExceptionReason = ExceptionReason.CarInPositionError;
|
|
|
|
machine.ExceptionReason = ExceptionReason.CarInPositionError;
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
|
|
|
|
machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
|
|
|
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address06"));
|
|
|
|
}, false, () => { }
|
|
|
|
}, false, () => { }
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|