换电流程

zw
lxw 4 months ago
parent 83683acf08
commit 95e73fcbe1

@ -8,26 +8,23 @@ public class InfoEnum
{ {
public enum SwapInfo : ushort public enum SwapInfo : ushort
{ {
[Info("欢迎光临换电站!(正在营业)", "欢迎光临换电站!,本站正在营业中")]
WelcomeInfo = 1,
[Info("欢迎光临换电站!(正在营业)","欢迎光临换电站!,本站正在营业中")]WelcomeInfo=1,
[Info("标签读写失败", "标签读写失败")] ErrorReadRfid, [Info("标签读写失败", "标签读写失败")] ErrorReadRfid,
[Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn, [Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn,
[Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck, [Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck,
[Info("车辆已到位", "车辆已到位")] InfoCarInPosition, [Info("车辆已到位", "车辆已到位")] InfoCarInPosition,
//TODO:: 录音内容已改 //TODO:: 录音内容已改
[Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout, [Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout,
[Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError, [Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError,
[Info("解锁车辆失败", "解锁车辆失败")] ErrUnLockCar , [Info("解锁车辆失败,请人工解锁", "解锁车辆失败,请人工解锁")] ErrUnLockCar,
[Info("选包失败,请驶离", "选包失败,请驶离")] ErrorSelectPack, [Info("选包失败,请驶离", "选包失败,请驶离")] ErrorSelectPack,
[Info("通道拍照定位失败,请在三分钟内重新调整车辆位置", "通道拍照定位失败,请在三分钟内重新调整车辆位置")]ErrChannelStatus, [Info("停车超限,请使出重新进入", "停车超限,请使出重新进入")] ErrChannelStatus,
[Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack, [Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack,
[Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack, [Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack,
[Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish, [Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish,
[Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition, [Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition,
@ -36,23 +33,36 @@ public class InfoEnum
[Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn, [Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn,
[Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut, [Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut,
[Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar, [Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar,
[Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr,
[Info("通道的电池仓无可用换电电池", "通道的电池仓无可用换电电池")]
NoBatteryErr,
[Info("结束充电电池数量不足", "通道的电池仓无可用换电电池")] LessOfFinishChargingErr, [Info("结束充电电池数量不足", "通道的电池仓无可用换电电池")] LessOfFinishChargingErr,
[Info("空仓数量不足", "通道的电池仓无可用换电电池")] LessOfEmptyBinErr, [Info("空仓数量不足", "通道的电池仓无可用换电电池")] LessOfEmptyBinErr,
[Info("符合soc限制数量不足", "通道的电池仓无可用换电电池")] LessOfSocErr, [Info("符合soc限制数量不足", "通道的电池仓无可用换电电池")] LessOfSocErr,
[Info("结束充电大于3分钟的数量不足","通道的电池仓无可用换电电池")] LessOf3MinuteErr,
[Info("换电站处于手动模式,不能自动换电","换电站处于手动模式,不能自动换电")] InfoStationModel,
[Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr, [Info("结束充电大于3分钟的数量不足", "通道的电池仓无可用换电电池")]
LessOf3MinuteErr,
[Info("换电站处于手动模式,不能自动换电", "换电站处于手动模式,不能自动换电")]
InfoStationModel,
[Info("换电站处于本地模式,不能远程换电", "换电站处于本地模式,不能远程换电")]
InfoStationModelRemoteErr,
[Info("车辆驶入", "车辆驶入")] CarInInfo, [Info("车辆驶入", "车辆驶入")] CarInInfo,
[Info("换电任务启动", "换电任务启动")] StartSwapInfo, [Info("换电任务启动", "换电任务启动")] StartSwapInfo,
[Info("航车拍照中,请稍后", "航车拍照中,请稍后")] CarTakePhotoInfo, [Info("航车拍照中,请稍后", "航车拍照中,请稍后")] CarTakePhotoInfo,
[Info("启动换电失败,请联系站务人员","启动换电失败,请联系站务人员")] ErrStartSwap,
[Info("即将进行消防移仓,请车辆驶离","即将进行消防移仓,请车辆驶离")] InfoFireRemoveLabel, [Info("启动换电失败,请联系站务人员", "启动换电失败,请联系站务人员")]
ErrStartSwap,
[Info("即将进行消防移仓,请车辆驶离", "即将进行消防移仓,请车辆驶离")]
InfoFireRemoveLabel,
[Info("电池移仓中", "电池移仓中")] InfoBatteryMove, [Info("电池移仓中", "电池移仓中")] InfoBatteryMove,
[Info("消防移仓中", "消防移仓中")] InfoFireRemove, [Info("消防移仓中", "消防移仓中")] InfoFireRemove,
[Info("拍照失败,请在三分钟内挪车","拍照失败,请在三分钟内挪车")] ErrChannel1020,
[Info("拍照失败,请在三分钟内挪车", "拍照失败,请在三分钟内挪车")]
ErrChannel1020,
} }
@ -105,6 +115,7 @@ public class InfoEnum
[Const("rfid扫描完成")] RfidReadFlag, [Const("rfid扫描完成")] RfidReadFlag,
[Const("云平台车辆认证")] CloudVelCheckFlag, [Const("云平台车辆认证")] CloudVelCheckFlag,
[Const("车辆到位")] CarInPositionFlag, [Const("车辆到位")] CarInPositionFlag,
// [Const("云平台下发换电指令")] CloudCarCanStartFlag, // [Const("云平台下发换电指令")] CloudCarCanStartFlag,
[Const("车辆解锁")] VelUnlockFlag, [Const("车辆解锁")] VelUnlockFlag,
// [Const("下发plc选包")] DistributeSelectPackFlag, // [Const("下发plc选包")] DistributeSelectPackFlag,
@ -121,9 +132,6 @@ public class InfoEnum
} }
public enum AmtBatLockStatus public enum AmtBatLockStatus
{ {
UnLock = 0, UnLock = 0,

@ -9,22 +9,18 @@ public class PlcApi
private static readonly ILog Log = LogManager.GetLogger("PlcApi"); private static readonly ILog Log = LogManager.GetLogger("PlcApi");
/// <summary> /// <summary>
/// 数据有效时间。单位秒 /// 数据有效时间。单位秒
/// </summary> /// </summary>
static int DataTimeSeconds = 2; static int DataTimeSeconds = 2;
/// <summary> /// <summary>
/// 是否远程模式 /// 是否远程模式
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static bool IsRemote() public static bool IsRemote()
{ {
var isRemote = PlcMgr.IsRemote(); var isRemote = PlcMgr.IsRemote();
Log.Info($"PlcApi IsRemove resp={isRemote}"); Log.Info($"PlcApi IsRemove resp={isRemote}");
return isRemote; return isRemote;
@ -89,6 +85,13 @@ public class PlcApi
return writeExistLamp; return writeExistLamp;
} }
//z轴上升
public static bool ZPushUp()
{
return PlcMgr.ZPushUp();
}
/// <summary> /// <summary>
/// 下发选包 /// 下发选包
/// </summary> /// </summary>
@ -108,7 +111,6 @@ public class PlcApi
/// <returns></returns> /// <returns></returns>
public static bool StartSwapping(string inBinNo, string outBinNo) public static bool StartSwapping(string inBinNo, string outBinNo)
{ {
Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}"); Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}");
var distributeTask = PlcMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo), 1); var distributeTask = PlcMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo), 1);
@ -130,6 +132,17 @@ public class PlcApi
return readTaskStatus; return readTaskStatus;
} }
/// <summary>
/// 查看换电允许
/// </summary>
/// <returns></returns>
public static bool ReadSwapReady()
{
PlcMgr.ResetPlc();
Log.Info($"PlcApi ReadSwapReady ");
return PlcMgr.ReadSwapReady();
}
/// <summary> /// <summary>
/// plc上使能 1换电2移仓3消防 /// plc上使能 1换电2移仓3消防
/// </summary> /// </summary>
@ -142,6 +155,17 @@ public class PlcApi
return holdOn; return holdOn;
} }
/// <summary>
/// 行车回归初始位置
/// </summary>
/// <returns></returns>
public static bool PlcCarInit()
{
Log.Info($"PlcApi Init ");
return PlcMgr.PlcCarInit();
}
/// <summary> /// <summary>
/// 查看拍照状态 /// 查看拍照状态
/// </summary> /// </summary>
@ -209,5 +233,24 @@ public class PlcApi
return readPlcTaskStatus; return readPlcTaskStatus;
} }
//拍照准备
public static bool ReadyPlcPhoto()
{
Log.Info($"PlcApi start ReadyPlcPhoto ");
return PlcMgr.PhotoPreparation();
}
//行车在拍照位
public static bool CarInPhotoPosition()
{
Log.Info($"PlcApi start CarInPhotoPosition ");
return PlcMgr.CarInPhotoPosition();
} }
//拍照
public static bool TakPhoto()
{
Log.Info($"PlcApi start TakPhoto ");
return PlcMgr.TakePhoto();
}
}

@ -287,4 +287,5 @@ public enum InvokeStatus
Exception, Exception,
None, None,
ManualSucc, ManualSucc,
Fail,
} }

@ -9,6 +9,7 @@ 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;
using Service.Plc.Client;
using Service.Station; using Service.Station;
namespace Service.Execute.Step; namespace Service.Execute.Step;
@ -22,6 +23,14 @@ public class CarCtrlState : IState
{ {
//写选包 --判断是否允许换电
InvokeStatus issuedPlcPack = IssuedPlcPack(machine);
if (issuedPlcPack != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(issuedPlcPack, ExceptionReason.None);
}
//解锁车辆 //解锁车辆
InvokeStatus unLockCar = UnLockCar(machine); InvokeStatus unLockCar = UnLockCar(machine);
if (unLockCar != InvokeStatus.Done) if (unLockCar != InvokeStatus.Done)
@ -29,14 +38,6 @@ public class CarCtrlState : IState
return SwappingStateMachine.ReturnWithInvokeErr(unLockCar, ExceptionReason.None); return SwappingStateMachine.ReturnWithInvokeErr(unLockCar, ExceptionReason.None);
} }
//下发选包
/*InvokeStatus distributeSelectPack = DistributeSelectPack(machine);
if (distributeSelectPack != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(distributeSelectPack, ExceptionReason.None);
}
*/
return new StateResult() return new StateResult()
{ {
@ -44,6 +45,43 @@ public class CarCtrlState : IState
}; };
} }
/// <summary>
/// 下发plc選報
/// </summary>
/// <returns></returns>
public InvokeStatus IssuedPlcPack(SwappingStateMachine machine)
{
return Invoker.Invoke("IssuedPlcPack", 1000, 5, machine.IsCanceled,
() => machine.StartSwappingFlag, () =>
{
//查询当前是否有任务执行
var readTaskNo = PlcMgr.PlcClient?.ReadTaskNo();
if (readTaskNo == 0 || readTaskNo == 1)
{
PlcMgr.PlcClient?.ExChangeTaskNo(1);
//查询车辆锁止状态
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
machine.SwapOrderBatteryInfo.UpBinInfo.No);
//当前允许换电
var readPlcTaskStatus = PlcApi.ReadSwapReady();
if (startSwapping && readPlcTaskStatus)
{
machine.SwapOrder.SwapBeginTime = DateTime.Now;
_CommonMgr.UpdateSwapOrder(machine);
machine.SwapStatus = 0;
machine.StartSwappingFlag = true;
}
}
else
{
_log.Info("当前有任务在执行");
}
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); }, false, () => { }, 10,
InvokeStatus.None);
}
/// <summary> /// <summary>
/// 车辆解锁 /// 车辆解锁
/// </summary> /// </summary>
@ -69,9 +107,12 @@ public class CarCtrlState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,
machine); machine);
} }
} }
}, () => }, () =>
{ {
//z轴上升
PlcApi.ZPushUp();
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar);
}, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; }
@ -100,7 +141,6 @@ public class CarCtrlState : IState
}, () => }, () =>
{ {
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrDistributeSelectPack.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrDistributeSelectPack.GetLed());
}); });
} }
} }

@ -96,6 +96,26 @@ public class CarPrepareState : IState
{ {
return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None); return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None);
} }
//读取车辆在拍照位置
InvokeStatus plcPhotoReady = CarInPhotoPosition(machine);
if (plcPhotoReady != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(plcPhotoReady, ExceptionReason.None);
}
//拍照
InvokeStatus takePhoto = TakePhoto(machine);
if (takePhoto != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(takePhoto, ExceptionReason.None);
}
//查看通道状态
StateResult checkChannelStatus = CheckChannelStatus(machine);
if (checkChannelStatus != null)
{
return checkChannelStatus;
}
return new StateResult() return new StateResult()
{ {
@ -103,6 +123,110 @@ public class CarPrepareState : IState
}; };
} }
/// <summary>
/// 查看通道状态
/// :0无效值
/// 1000;拍照OK
///1010;拍照NG
///1020;拍照超限,请移车
/// </summary>
/// <returns></returns>
public StateResult CheckChannelStatus(SwappingStateMachine machine)
{
int count = 0;
while (!machine.ChannelStatusOkFlag)
{
if (machine.CancelFlag)
{
_log.Info($" CheckChannelStatus canceled");
return StateResult.Cancel;
}
_log.Info("begin plc CheckChannelStatus");
Thread.Sleep(2000);
var channelStatus = PlcApi.ChannelStatus();
if (count % 10 == 0)
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo);
}
count++;
if (channelStatus == 1000)
{
machine.ChannelStatusOkFlag = true;
return null;
}
else if (channelStatus == 1020)
{
//需要移车 先解锁 提示移动车辆,等待3分钟
if (PlcApi.PlcCarInit())
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
//等待2分钟
Thread.Sleep(3 * 60 * 1000);
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "拍照故障 plc故障码1020";
//回归到本阶段的读锁止状态
return new StateResult()
{
SwappingState = SwappingState.SwapDone
};
}
}
else if (channelStatus == 1010)
{
//故障 不能继续换电,提示驶离,上报云平台,修改换电订单
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "拍照故障 plc故障码1010";
//跳转到SwappDone
return new StateResult()
{
SwappingState = SwappingState.SwapDone
};
}
}
return null;
}
/// <summary>
/// 拍照准备
/// </summary
/// <returns></returns>
public InvokeStatus CarInPhotoPosition(SwappingStateMachine machine)
{
return Invoker.Invoke("Car In Photo Position", 500, 10, machine.IsCanceled,
() => machine.CarInPhotoPositionFlag, () =>
{
machine.CarInPhotoPositionFlag = PlcApi.CarInPhotoPosition();
}, () =>
{
machine.ExceptionReason = ExceptionReason.CarInPhotoPositionError;
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
}, false, () =>
{
machine.ExceptionReason = ExceptionReason.CarInPhotoPositionError;
}
, 20, InvokeStatus.None);
}
/// <summary>
/// 启动拍照
/// </summary
/// <returns></returns>
public InvokeStatus TakePhoto(SwappingStateMachine machine)
{
bool takePhotoFlag = false;
return Invoker.Invoke("Take Photo", 500, 10, machine.IsCanceled,
() => takePhotoFlag, () =>
{
takePhotoFlag = PlcApi.TakPhoto();
});
}
/// <summary> /// <summary>
/// 车辆到位 /// 车辆到位
@ -123,7 +247,7 @@ public class CarPrepareState : IState
TboxCarInfoModel tboxCarInfoModel = result.Result; TboxCarInfoModel tboxCarInfoModel = result.Result;
var status = tboxCarInfoModel?.CarStatus; var status = tboxCarInfoModel?.CarStatus;
PlcApi.ReadyPlcPhoto();
if (StaticStationInfo.TboxStateFlameout) if (StaticStationInfo.TboxStateFlameout)
{ {
if (status?.Keys == 0) if (status?.Keys == 0)
@ -151,6 +275,7 @@ public class CarPrepareState : IState
if (succCount == successCount) if (succCount == successCount)
{ {
machine.VehiclesInPlaceFlag = true; machine.VehiclesInPlaceFlag = true;
//写入口等 :红灯 //写入口等 :红灯
if (PlcApi.WriteEntranceLamp(1020)) if (PlcApi.WriteEntranceLamp(1020))

@ -30,21 +30,6 @@ public class DoSwappingState : IState
// CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap); // CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap);
//再次读锁止状态防止plc需要挪车
InvokeStatus carInPosition2 = CarInPosition2(machine);
if (carInPosition2 != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(carInPosition2, ExceptionReason.None);
}
//下发启动换电
InvokeStatus startSwapping = StartSwapping(machine);
if (startSwapping != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
}
InvokeStatus holdOn = HoldOn(machine); InvokeStatus holdOn = HoldOn(machine);
if (holdOn != InvokeStatus.Done) if (holdOn != InvokeStatus.Done)
{ {
@ -52,13 +37,6 @@ public class DoSwappingState : IState
} }
//查看通道状态
StateResult checkChannelStatus = CheckChannelStatus(machine);
if (checkChannelStatus != null)
{
return checkChannelStatus;
}
//旧电池拆卸 //旧电池拆卸
InvokeStatus unPack = UnPack(machine); InvokeStatus unPack = UnPack(machine);
if (unPack != InvokeStatus.Done) if (unPack != InvokeStatus.Done)
@ -166,16 +144,15 @@ public class DoSwappingState : IState
() => machine.PlcHoldFlag, () => () => machine.PlcHoldFlag, () =>
{ {
//查询换电任务状态 //查询换电任务状态
var taskPrepare = PlcApi.ReadTaskStatus(1);
if (taskPrepare)
{
bool holdOn = PlcApi.HoldOn(1); bool holdOn = PlcApi.HoldOn(1);
if (holdOn) if (holdOn)
{ {
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine);
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo);
machine.PlcHoldFlag = true; machine.PlcHoldFlag = true;
} }
}
}, () => { }); }, () => { });
} }
@ -262,7 +239,8 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine); machine);
} }
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); }, false, () => { }, 10, }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); }, false, () => { },
10,
InvokeStatus.None); InvokeStatus.None);
} }
@ -337,78 +315,6 @@ public class DoSwappingState : IState
} }
/// <summary>
/// 查看通道状态
/// :0无效值
/// 1000;拍照OK
///1010;拍照NG
///1020;拍照超限,请移车
/// </summary>
/// <returns></returns>
public StateResult CheckChannelStatus(SwappingStateMachine machine)
{
int count = 0;
while (!machine.ChannelStatusOkFlag)
{
if (machine.CancelFlag)
{
_log.Info($" CheckChannelStatus canceled");
return StateResult.Cancel;
}
_log.Info("begin plc CheckChannelStatus");
Thread.Sleep(2000);
var channelStatus = PlcApi.ChannelStatus();
if (count % 10 == 0)
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CarTakePhotoInfo);
}
count++;
if (channelStatus == 1000)
{
machine.ChannelStatusOkFlag = true;
return null;
}
else if (channelStatus == 1020)
{
//需要移车 先解锁 提示移动车辆,等待3分钟
var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
if (lockCar.Result)
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrChannelStatus);
//等待2分钟
Thread.Sleep(3 * 60 * 1000);
machine.VehiclesInPlace2Flag = false;
machine.StartSwappingFlag = false;
machine.PlcHoldFlag = false;
machine.ChannelStatusOkFlag = false;
//回归到本阶段的读锁止状态
return new StateResult()
{
SwappingState = SwappingState.DoSwapping
};
}
}
else if (channelStatus == 1010)
{
//故障 不能继续换电,提示驶离,上报云平台,修改换电订单
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "拍照故障 plc故障码1010";
//跳转到SwappDone
return new StateResult()
{
SwappingState = SwappingState.SwapDone
};
}
}
return null;
}
/// <summary> /// <summary>
/// 车辆到位 /// 车辆到位
/// </summary> /// </summary>
@ -424,7 +330,8 @@ public class DoSwappingState : IState
int succCount = 0; int succCount = 0;
List<bool> succL = new List<bool>() List<bool> succL = new List<bool>()
{ {
StaticStationInfo.TboxStateFlameout, StaticStationInfo.TboxStateBreak, StaticStationInfo.TboxStateN StaticStationInfo.TboxStateFlameout, StaticStationInfo.TboxStateBreak,
StaticStationInfo.TboxStateN
}; };
var successCount = succL.Where(i => i).Count(); var successCount = succL.Where(i => i).Count();

@ -65,6 +65,7 @@ public class StationReadyState : IState
} }
//开始读rifd //开始读rifd
var beginRfid = BeginRead(machine); var beginRfid = BeginRead(machine);
if (InvokeStatus.Done != beginRfid) if (InvokeStatus.Done != beginRfid)

@ -21,5 +21,6 @@ namespace Service.Execute.SwapException;
LockCarError, LockCarError,
LvPwrOffError, LvPwrOffError,
SelfCheckError, SelfCheckError,
TimeOutError TimeOutError,
CarInPhotoPositionError,
} }

@ -89,6 +89,7 @@ public class SwappingStateMachine : IDisposable
["13"] = new StepModel { StepNo = 13, Status = 0, StepName = "换电完成(车辆驶离)" }, ["13"] = new StepModel { StepNo = 13, Status = 0, StepName = "换电完成(车辆驶离)" },
["14"] = new StepModel { StepNo = 14, Status = 0, StepName = "换电失败(车辆驶离)" }, ["14"] = new StepModel { StepNo = 14, Status = 0, StepName = "换电失败(车辆驶离)" },
}; };
#region 小步状态 #region 小步状态
//雷达检测/车辆进入 //雷达检测/车辆进入
@ -106,6 +107,8 @@ public class SwappingStateMachine : IDisposable
//Tbox连接 //Tbox连接
public bool BoxConnectFlag = false; public bool BoxConnectFlag = false;
public bool CarInPhotoPositionFlag = false;
//车辆lock //车辆lock
public bool BoxLocalCheckFlag = false; public bool BoxLocalCheckFlag = false;
@ -374,7 +377,7 @@ public class SwappingStateMachine : IDisposable
BoxConnectFlag = false; BoxConnectFlag = false;
CarInPhotoPositionFlag = false;
BoxLocalCheckFlag = false; BoxLocalCheckFlag = false;
@ -441,7 +444,8 @@ public class SwappingStateMachine : IDisposable
{ {
if (SwapOrderBatteryInfo?.UpBinInfo != null) ; if (SwapOrderBatteryInfo?.UpBinInfo != null) ;
{ {
BinInfoRepository.Update(i=>i.AmtLock==(int)InfoEnum.AmtBatLockStatus.UnLock,i=>i.Id==SwapOrderBatteryInfo.UpBinInfo.Id); BinInfoRepository.Update(i => i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock,
i => i.Id == SwapOrderBatteryInfo.UpBinInfo.Id);
} }
} }

@ -17,7 +17,6 @@ public class PlcMgr
public public
/// <summary> /// <summary>
/// 数据有效时间。单位秒 /// 数据有效时间。单位秒
/// </summary> /// </summary>
@ -56,6 +55,49 @@ public class PlcMgr
return false; return false;
} }
/// <summary>
/// 拍照准备
/// </summary>
/// <returns></returns>
public static bool PhotoPreparation()
{
if (PlcClient != null)
{
HostToPlcData.PhotoPreparation.Value = 1000;
return PlcClient.WriteValue(HostToPlcData.PhotoPreparation);
}
return false;
}
/// <summary>
/// 车辆在拍照位
/// </summary>
/// <returns></returns>
public static bool TakePhoto()
{
if (PlcClient != null)
{
HostToPlcData.StartPhoto.Value = 1000;
return PlcClient.WriteValue(HostToPlcData.StartPhoto);
}
return false;
}
/// <summary>
/// 拍照
/// </summary>
/// <returns></returns>
public static bool CarInPhotoPosition()
{
if (PlcClient != null)
{
return PlcToHostData.CarInPhotoPosition.Value == 1000;
}
return false;
}
public static bool AirBlowerControl(ushort value) public static bool AirBlowerControl(ushort value)
{ {
@ -199,6 +241,7 @@ public class PlcMgr
{ {
return true; return true;
} }
return false; return false;
case 2: case 2:
return PlcToHostData.MovingCondition.Value == 1001; return PlcToHostData.MovingCondition.Value == 1001;
@ -212,6 +255,11 @@ public class PlcMgr
return false; return false;
} }
public static bool ReadSwapReady()
{
return PlcToHostData.WhetherAllowPowerChange.Value == 1010;
}
/// <summary> /// <summary>
/// plc上使能 1换电2移仓3消防 /// plc上使能 1换电2移仓3消防
/// </summary> /// </summary>
@ -278,6 +326,22 @@ public class PlcMgr
return 0; return 0;
} }
/// <summary>
/// 行车回归安全位置
/// </summary>
/// <returns></returns>
public static bool PlcCarInit()
{
if (PlcClient != null)
{
HostToPlcData.Regression.Value = 1000;
return PlcClient.WriteValue(HostToPlcData.Regression);
}
return false;
}
/// <summary> /// <summary>
/// 重新读 /// 重新读
/// </summary> /// </summary>
@ -345,6 +409,17 @@ public class PlcMgr
return bResult; return bResult;
} }
public static bool ZPushUp()
{
if (PlcClient != null)
{
HostToPlcData.BatteryUnlockedState.Value = 1000;
return PlcClient.WriteValue(HostToPlcData.BatteryUnlockedState);
}
return false;
}
/// <summary> /// <summary>
/// 获取当前灯光状态 /// 获取当前灯光状态
/// </summary> /// </summary>
@ -375,6 +450,4 @@ public class PlcMgr
return bResult; return bResult;
} }
} }

@ -106,6 +106,14 @@ namespace Service.Plc.Msg
/// 1000:已拍按钮 /// 1000:已拍按钮
/// </summary> /// </summary>
public ModbusProperty<ushort> PhysicalButtonState { get; set; } = new(40112); public ModbusProperty<ushort> PhysicalButtonState { get; set; } = new(40112);
/// <summary>
/// 在拍照位
/// 0:无状态
/// 1000:已拍按钮
/// </summary>
public ModbusProperty<ushort> CarInPhotoPosition { get; set; } = new(40113);
/// <summary> /// <summary>
/// 三色灯控制通道状态(入口) /// 三色灯控制通道状态(入口)
/// <para>0无颜色</para> /// <para>0无颜色</para>

Loading…
Cancel
Save