|
|
|
|
using Autofac;
|
|
|
|
|
using Entity.Attr;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Configuration;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
|
using Service.Execute.Model;
|
|
|
|
|
using Service.Execute.Model.Tbox;
|
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
|
using Service.Led;
|
|
|
|
|
using Service.Sound.SoundClient;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
|
|
|
|
|
|
public class CarCtrlState : IState
|
|
|
|
|
{
|
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(CarCtrlState));
|
|
|
|
|
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve<CommonMgr>();
|
|
|
|
|
public static SoundClient? SoundClient { get; set; }
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//解锁车辆
|
|
|
|
|
InvokeStatus unLockCar = UnLockCar(machine);
|
|
|
|
|
if (unLockCar != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(unLockCar, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//下发选包
|
|
|
|
|
/*InvokeStatus distributeSelectPack = DistributeSelectPack(machine);
|
|
|
|
|
|
|
|
|
|
if (distributeSelectPack != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(distributeSelectPack, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
return new StateResult()
|
|
|
|
|
{
|
|
|
|
|
SwappingState = SwappingState.DoSwapping
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆解锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus UnLockCar(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled,
|
|
|
|
|
() => machine.VelUnlockFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
Task<bool> result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
|
|
|
|
|
|
bool unLock = result.Result;
|
|
|
|
|
if (unLock)
|
|
|
|
|
{
|
|
|
|
|
//查询车辆锁止状态
|
|
|
|
|
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
var resultHeartBeatMsg = carInfo.Result.CarStatus;
|
|
|
|
|
if (resultHeartBeatMsg?.LockStatus == 1 || machine.ManualConfirmCarUnlockFlag)
|
|
|
|
|
{
|
|
|
|
|
machine.ManualConfirmCarUnlockFlag = false;
|
|
|
|
|
machine.BoxCarInfoModel = carInfo.Result;
|
|
|
|
|
machine.VelUnlockFlag = true;
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed());
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar);
|
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed());
|
|
|
|
|
SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
SoundClient.SoundPlay(SoundEnum.music48);
|
|
|
|
|
}, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; }
|
|
|
|
|
, 10, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
}
|