换电流程优化

master
lxw 4 months ago
parent e00d94e103
commit 1ab9746844

@ -245,6 +245,7 @@ public class CommonMgr
var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos;
if (carInfoBatteryInfos != null && carInfoBatteryInfos.Count > 0)
{
orderBatteryInfo.InBinInfo.BatteryNo = carInfoBatteryInfos[0].BatteryNo;
// orderBatteryInfo.InBinInfo.Soc = carInfoBatteryInfos[0].Soc;
orderBatteryInfo.InBinInfo.Soe = carInfoBatteryInfos[0].Soe;

@ -8,7 +8,6 @@ public class SwapOrderBatteryInfo
{
public bool isAmt;
public SwapAmtOrder swapAmtOrder;
public SwapOrderBattery SwapOrderBattery;
public InfoEnum.SelectBinStatusInfo CanSwap;

@ -230,7 +230,7 @@ public class CarCtrlState : IState
_log.Info("begin plc CheckChannelStatus");
Thread.Sleep(2000);
var channelStatus = PlcApi.ChannelStatus();
PlcRealTimeTask.cameraTask = true;//开始记录拍照偏移日志
PlcRealTimeTask.CameraTask = true;//开始记录拍照偏移日志
PlcRealTimeTask.VehicleParkingStatusTask = true;//开始下发车辆驻车状态
if (count % 10 == 0)
@ -281,6 +281,7 @@ public class CarCtrlState : IState
{
machine.PhysicalButtonState = true;
}
//TODO::是否自动实现拍下按钮功能
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoManualStartSwap);
}
@ -288,12 +289,7 @@ public class CarCtrlState : IState
{
machine.PhysicalButtonState = true;
}
if (machine.PhysicalButtonState)
{
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,machine);
}
}, () => { }, false, () => { }, 10,
InvokeStatus.None);
}

@ -41,12 +41,6 @@ public class CarPrepareState : IState
};
}
/*//云平台车辆认证
var cloudCheckVel = CloudCheckVel(machine);
if (cloudCheckVel != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None);
}*/
//TBox连接
if (StaticStationInfo.TboxStateConnect)
@ -73,13 +67,6 @@ public class CarPrepareState : IState
}
//云端数据上报
// InvokeStatus cloudTBox = CloudTBoxFlag(machine);
/*if (cloudTBox != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(cloudTBox, ExceptionReason.None);
}*/
machine.ExceptionReason = ExceptionReason.None;
//选包

@ -27,16 +27,6 @@ public class DoSwappingState : IState
machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.BeginSwap;
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
_log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}");
// 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);
@ -51,7 +41,6 @@ public class DoSwappingState : IState
return SwappingStateMachine.ReturnWithInvokeErr(holdOn, ExceptionReason.None);
}
//旧电池拆卸
InvokeStatus unPack = UnPack(machine);
@ -132,10 +121,8 @@ public class DoSwappingState : IState
machine);
}
}
}, () =>
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap);
},false, () => { },10,InvokeStatus.None);
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrStartSwap); }, false, () => { }, 10,
InvokeStatus.None);
}
@ -174,20 +161,13 @@ public class DoSwappingState : IState
/// <returns></returns>
public InvokeStatus UnPack(SwappingStateMachine machine)
{
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, ReadTaskErr,
() => machine.UnOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
//plc任务异常结束流程
if (PlcApi.ReadTaskStatus(1))
{
machine.PLCAbnormalFlag = true;
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "PLC任务异常结束";
}
int status = PlcApi.ReadPlcTaskStatus();
//处理程序太快plc还没有初始值的状态
if (status == 1002 || status != 1003)
@ -209,18 +189,11 @@ public class DoSwappingState : IState
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
{
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled,ReadTaskErr,
() => machine.StorageOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
//plc任务异常结束流程
if (PlcApi.ReadTaskStatus(1))
{
machine.PLCAbnormalFlag = true;
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "PLC任务异常结束";
}
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (readPlcTaskStatus == 1003 || readPlcTaskStatus != 1004)
@ -244,21 +217,13 @@ public class DoSwappingState : IState
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
{
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled,ReadTaskErr,
() => machine.OutNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
//plc任务异常结束流程
if (PlcApi.ReadTaskStatus(1))
{
machine.PLCAbnormalFlag = true;
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "PLC任务异常结束";
}
if (PlcApi.ReadPlcTaskStatus() == 1004)
{
}
else
{
@ -270,28 +235,21 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine);
}
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, 10,
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut); }, false, 10,
InvokeStatus.None);
}
public InvokeStatus Pack(SwappingStateMachine machine)
{
return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, ReadTaskErr,
() => machine.InstallNewBatteryFlag, () =>
{
//plc任务异常结束流程
if (PlcApi.ReadTaskStatus(1))
{
machine.PLCAbnormalFlag = true;
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "PLC任务异常结束";
}
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
if (PlcApi.ReadPlcTaskStatus() == 1005)
{
}
else
{
@ -303,27 +261,16 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
machine);
}
}, () =>
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
},false,
10,InvokeStatus.None);
}, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack); }, false,
10, InvokeStatus.None);
}
public InvokeStatus PackFinish(SwappingStateMachine machine)
{
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,ReadTaskErr,
() => machine.FinishNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
//plc任务异常结束流程
if (PlcApi.ReadTaskStatus(1))
{
machine.PLCAbnormalFlag = true;
machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
machine.SwapFailReason = "PLC任务异常结束";
}
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (readPlcTaskStatus == 1006 || readPlcTaskStatus == 1007)
{
@ -337,8 +284,8 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
machine);
}
}, () => { },false,
10,InvokeStatus.None);
}, () => { }, false,
10, InvokeStatus.None);
}
/// <summary>
@ -352,7 +299,7 @@ public class DoSwappingState : IState
() => machine.ToSafePositionFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
if (PlcApi.ReadPlcTaskStatus() == 1007)
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
@ -362,19 +309,16 @@ public class DoSwappingState : IState
machine.SwapStatus = 1;
{
PlcRealTimeTask.cameraTask = false;//结束记录拍照偏移日志
PlcRealTimeTask.LockStatusTask = false;//结束下发电池包锁状态
PlcRealTimeTask.VehicleParkingStatusTask = false;//结束下发车辆驻车状态
PlcRealTimeTask.RollerShutterTask= false;
PlcRealTimeTask.CameraTask = false; //结束记录拍照偏移日志
PlcRealTimeTask.LockStatusTask = false; //结束下发电池包锁状态
PlcRealTimeTask.VehicleParkingStatusTask = false; //结束下发车辆驻车状态
PlcRealTimeTask.RollerShutterTask = false;
}
}
}, () => { });
}
/// <summary>
/// 车辆到位
/// </summary>
@ -419,8 +363,8 @@ public class DoSwappingState : IState
succCount++;
}
}
if (succCount==successCount)
if (succCount == successCount)
{
machine.VehiclesInPlace2Flag = true;
}
@ -432,4 +376,19 @@ public class DoSwappingState : IState
}, false, () => { }
, 20, InvokeStatus.None);
}
public bool ReadTaskErr()
{
if (PlcApi.ReadTaskStatus(1))
{
StationSoftMgr.SwappingStateMachine.PLCAbnormalFlag = true;
StationSoftMgr.SwappingStateMachine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
StationSoftMgr.SwappingStateMachine.SwapFailReason = "PLC任务异常结束";
return true;
}
return false;
}
}

@ -63,6 +63,8 @@ public class StationReadyState : IState
{
return SwappingStateMachine.ReturnWithInvokeErr(entranceRadar, ExceptionReason.None);
}
//语音播报车辆识别
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.BeginReadRfid);

@ -254,11 +254,7 @@ public class SwappingStateMachine : IDisposable
{
return CancelFlag;
}
public bool IsPLCAbnormal()
{
return PLCAbnormalFlag;
}
public bool IsManualSwapSucc()
{
return ManualSwapSuccFlag;

@ -27,7 +27,7 @@ public class PlcRealTimeTask : ITask
private volatile bool _stop;
public static bool cameraTask=false;//相机偏移记录任务(查看通道状态开始,行车回归安全位置结束)
public static bool CameraTask=false;//相机偏移记录任务(查看通道状态开始,行车回归安全位置结束)
public static bool VehicleParkingStatusTask= false;//车辆驻车状态下发任务
public static bool LockStatusTask = false;//电池包锁状态下发任务
@ -48,7 +48,7 @@ public class PlcRealTimeTask : ITask
{
try
{
if (cameraTask)
if (CameraTask)
{
if (PlcMgr.PlcToHostData != null)
{

Loading…
Cancel
Save