|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Entity.Attr;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Configuration;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Service.Charger.Client;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
@ -10,6 +11,7 @@ using Service.Execute.SwapException;
|
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
using Service.Led;
|
|
|
|
|
using Service.Sound.SoundClient;
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
|
|
|
|
|
@ -18,6 +20,11 @@ public class DoSwappingState : IState
|
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState));
|
|
|
|
|
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve<CommonMgr>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static SoundClient? SoundClient { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
//上报云平台换电开始
|
|
|
|
@ -33,13 +40,12 @@ public class DoSwappingState : IState
|
|
|
|
|
InvokeStatus startSwapping = StartSwapping(machine);
|
|
|
|
|
if (startSwapping != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//旧电池拆卸
|
|
|
|
|
InvokeStatus unPack = UnPack(machine);
|
|
|
|
|
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());
|
|
|
|
|
},false, () => { },10,InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
@ -123,7 +133,9 @@ public class DoSwappingState : IState
|
|
|
|
|
bool holdOn = PlcApi.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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -147,7 +159,8 @@ public class DoSwappingState : IState
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(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;
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
|
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());
|
|
|
|
|
}, false, () => { }, 10,
|
|
|
|
|
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());
|
|
|
|
|
},false, () => { },
|
|
|
|
|
10,InvokeStatus.None);
|
|
|
|
@ -258,7 +277,9 @@ public class DoSwappingState : IState
|
|
|
|
|
InfoEnum.BusinessSwappingForCloudState.SwapFinish;
|
|
|
|
|
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
|
|
|
|
@ -287,7 +308,9 @@ public class DoSwappingState : IState
|
|
|
|
|
|
|
|
|
|
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.BusinessSwappingStateUpdateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
@ -322,7 +345,9 @@ public class DoSwappingState : IState
|
|
|
|
|
var channelStatus = PlcApi.ChannelStatus();
|
|
|
|
|
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++;
|
|
|
|
@ -338,8 +363,10 @@ public class DoSwappingState : IState
|
|
|
|
|
var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
|
if (lockCar.Result)
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
|
machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address10"));
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
|
|
|
|
|
//等待2分钟
|
|
|
|
|
Thread.Sleep(3*60 *1000);
|
|
|
|
|
machine.VehiclesInPlace2Flag = false;
|
|
|
|
@ -422,8 +449,10 @@ public class DoSwappingState : IState
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
machine.ExceptionReason = ExceptionReason.CarInPositionError;
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
|
|
|
|
|
machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address06"));
|
|
|
|
|
}, false, () => { }
|
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|