|
|
@ -10,6 +10,7 @@ using Repository.Station;
|
|
|
|
using Service.Cloud.Msg.Cloud.Resp;
|
|
|
|
using Service.Cloud.Msg.Cloud.Resp;
|
|
|
|
using Service.Execute.Api;
|
|
|
|
using Service.Execute.Api;
|
|
|
|
using Service.Execute.Model;
|
|
|
|
using Service.Execute.Model;
|
|
|
|
|
|
|
|
using Service.Execute.Model.Tbox;
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
using Service.Execute.Utils;
|
|
|
@ -47,6 +48,16 @@ public class CarPrepareState : IState
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None);
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TBox连接
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateConnect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InvokeStatus tboxConnect = TboxConnect(machine);
|
|
|
|
|
|
|
|
if (tboxConnect != InvokeStatus.Done)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(tboxConnect, ExceptionReason.None);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//检查tbox链接状态
|
|
|
|
//检查tbox链接状态
|
|
|
|
InvokeStatus checkTBoxConnect = CheckTBoxConnectFlag(machine);
|
|
|
|
InvokeStatus checkTBoxConnect = CheckTBoxConnectFlag(machine);
|
|
|
|
if (checkTBoxConnect != InvokeStatus.Done)
|
|
|
|
if (checkTBoxConnect != InvokeStatus.Done)
|
|
|
@ -78,6 +89,7 @@ public class CarPrepareState : IState
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.None);
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//车辆到位
|
|
|
|
//车辆到位
|
|
|
|
InvokeStatus carInPosition = CarInPosition(machine);
|
|
|
|
InvokeStatus carInPosition = CarInPosition(machine);
|
|
|
|
if (carInPosition != InvokeStatus.Done)
|
|
|
|
if (carInPosition != InvokeStatus.Done)
|
|
|
@ -98,13 +110,46 @@ public class CarPrepareState : IState
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public InvokeStatus CarInPosition(SwappingStateMachine machine)
|
|
|
|
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, () =>
|
|
|
|
() => machine.VehiclesInPlaceFlag, () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
|
|
|
int succCount = 0;
|
|
|
|
|
|
|
|
List<bool> succL = new List<bool>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
StaticStationInfo.TboxStateFlameout, StaticStationInfo.TboxStateBreak, StaticStationInfo.TboxStateN
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var successCount = succL.Where(i => i).Count();
|
|
|
|
TboxCarInfoModel tboxCarInfoModel = result.Result;
|
|
|
|
TboxCarInfoModel tboxCarInfoModel = result.Result;
|
|
|
|
|
|
|
|
|
|
|
|
if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0)
|
|
|
|
var status = tboxCarInfoModel?.CarStatus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateFlameout)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (status?.Keys == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
succCount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateBreak)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (status?.Break == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
succCount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.TboxStateN)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (status?.Gear == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
succCount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (succCount == successCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
machine.VehiclesInPlaceFlag = true;
|
|
|
|
machine.VehiclesInPlaceFlag = true;
|
|
|
|
//写入口等 :红灯
|
|
|
|
//写入口等 :红灯
|
|
|
@ -123,6 +168,7 @@ public class CarPrepareState : IState
|
|
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
|
|
|
|
machine);
|
|
|
|
machine);
|
|
|
|
|
|
|
|
machine.BoxCarInfoModel = tboxCarInfoModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
}, () =>
|
|
|
@ -131,7 +177,7 @@ public class CarPrepareState : IState
|
|
|
|
// 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);
|
|
|
|
}, false, () => { }
|
|
|
|
}, false, () => { }
|
|
|
|
, 20, InvokeStatus.None);
|
|
|
|
, 10, InvokeStatus.None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -148,9 +194,10 @@ public class CarPrepareState : IState
|
|
|
|
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
|
|
|
|
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
|
|
|
|
StaticStationInfo.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");
|
|
|
|
_log.Info("cloud check vehicle error");
|
|
|
|
// machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
|
|
|
|
// machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
|
|
|
@ -208,6 +255,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>
|
|
|
|
/// 车辆本地验证:车牌校验
|
|
|
|
/// 车辆本地验证:车牌校验
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -285,11 +370,11 @@ public class CarPrepareState : IState
|
|
|
|
SwapOrderBatteryInfo orderBatteryInfo = null;
|
|
|
|
SwapOrderBatteryInfo orderBatteryInfo = null;
|
|
|
|
if (swapAmtOrder != null)
|
|
|
|
if (swapAmtOrder != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder);
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder, machine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackNotArm();
|
|
|
|
orderBatteryInfo = _CommonMgr.SelectPackNotArm(machine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success)
|
|
|
|
if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success)
|
|
|
|