|
|
|
@ -10,6 +10,7 @@ using Repository.Station;
|
|
|
|
|
using Service.Cloud.Msg.Cloud.Resp;
|
|
|
|
|
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;
|
|
|
|
@ -47,6 +48,16 @@ public class CarPrepareState : IState
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TBox连接
|
|
|
|
|
if (StaticStationInfo.TboxStateConnect)
|
|
|
|
|
{
|
|
|
|
|
InvokeStatus tboxConnect = CheckTBoxConnectFlag(machine);
|
|
|
|
|
if (tboxConnect != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(tboxConnect, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//检查tbox链接状态
|
|
|
|
|
InvokeStatus checkTBoxConnect = CheckTBoxConnectFlag(machine);
|
|
|
|
|
if (checkTBoxConnect != InvokeStatus.Done)
|
|
|
|
@ -78,6 +89,7 @@ public class CarPrepareState : IState
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//车辆到位
|
|
|
|
|
InvokeStatus carInPosition = CarInPosition(machine);
|
|
|
|
|
if (carInPosition != InvokeStatus.Done)
|
|
|
|
@ -98,13 +110,52 @@ public class CarPrepareState : IState
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus CarInPosition(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("check CarInPosition", 500, 50, machine.IsCanceled,
|
|
|
|
|
return Invoker.Invoke("check CarInPosition", 500, 5, machine.IsCanceled,
|
|
|
|
|
() => machine.VehiclesInPlaceFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
bool keyStatus = false;
|
|
|
|
|
bool breakStatus = false;
|
|
|
|
|
bool nStatus = false;
|
|
|
|
|
TboxCarInfoModel tboxCarInfoModel = result.Result;
|
|
|
|
|
if (StaticStationInfo.TboxStateFlameout ||
|
|
|
|
|
StaticStationInfo.TboxStateBreak ||
|
|
|
|
|
StaticStationInfo.TboxStateN)
|
|
|
|
|
{
|
|
|
|
|
var status = tboxCarInfoModel?.CarStatus;
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateFlameout)
|
|
|
|
|
{
|
|
|
|
|
if (status?.Keys == 0)
|
|
|
|
|
{
|
|
|
|
|
keyStatus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateBreak)
|
|
|
|
|
{
|
|
|
|
|
if (status?.Break == 1)
|
|
|
|
|
{
|
|
|
|
|
breakStatus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateN)
|
|
|
|
|
{
|
|
|
|
|
if (status?.Gear == 0)
|
|
|
|
|
{
|
|
|
|
|
nStatus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
keyStatus = true;
|
|
|
|
|
breakStatus = true;
|
|
|
|
|
nStatus = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0)
|
|
|
|
|
if (keyStatus && breakStatus && nStatus)
|
|
|
|
|
{
|
|
|
|
|
machine.VehiclesInPlaceFlag = true;
|
|
|
|
|
//写入口等 :红灯
|
|
|
|
@ -123,6 +174,7 @@ public class CarPrepareState : IState
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
|
|
|
|
|
machine);
|
|
|
|
|
machine.BoxCarInfoModel = tboxCarInfoModel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
@ -131,7 +183,7 @@ public class CarPrepareState : IState
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
|
|
|
|
|
}, false, () => { }
|
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
|
, 10, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -148,9 +200,10 @@ public class CarPrepareState : IState
|
|
|
|
|
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
|
|
|
|
|
StaticStationInfo.StationModel))
|
|
|
|
|
{
|
|
|
|
|
VehicleCertificationResp? vehicleCertificationResp = CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
|
|
|
|
|
VehicleCertificationResp? vehicleCertificationResp =
|
|
|
|
|
CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
|
|
|
|
|
|
|
|
|
|
if (vehicleCertificationResp==null || vehicleCertificationResp.re!=0)
|
|
|
|
|
if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0)
|
|
|
|
|
{
|
|
|
|
|
_log.Info("cloud check vehicle error");
|
|
|
|
|
// machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
|
|
|
|
@ -208,6 +261,44 @@ public class CarPrepareState : IState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 连接TBox
|
|
|
|
|
/// </summary
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus TboxConnect(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("TBox connect", 1000, 10, machine.IsCanceled,
|
|
|
|
|
() => machine.BoxConnectFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
Task<bool> result = TBoxApi.Connect(machine.RfidReadModel.VelVin);
|
|
|
|
|
bool isConnect = result.Result;
|
|
|
|
|
if (isConnect)
|
|
|
|
|
{
|
|
|
|
|
//读取车辆carNo=carVin
|
|
|
|
|
Task<TboxCarInfoModel> carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
var tboxCarInfoModel = carInfoResult.Result;
|
|
|
|
|
var carInfo = tboxCarInfoModel?.CarInfo;
|
|
|
|
|
if (carInfo != null)
|
|
|
|
|
{
|
|
|
|
|
if (carInfo.CarNo.Equals(carInfo.CarVin))
|
|
|
|
|
{
|
|
|
|
|
machine.BoxConnectFlag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
machine.ExceptionReason = ExceptionReason.ConnTBoxError;
|
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
|
|
|
|
|
}, false, () =>
|
|
|
|
|
{
|
|
|
|
|
machine.ExceptionReason = ExceptionReason.ConnTBoxError;
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed());
|
|
|
|
|
}
|
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆本地验证:车牌校验
|
|
|
|
|
/// </summary>
|
|
|
|
@ -285,11 +376,11 @@ public class CarPrepareState : IState
|
|
|
|
|
SwapOrderBatteryInfo orderBatteryInfo = null;
|
|
|
|
|
if (swapAmtOrder != null)
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder);
|
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder,machine);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackNotArm();
|
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackNotArm(machine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success)
|
|
|
|
|