修改前端上报

master
zby 3 months ago
parent 83e337f97a
commit cacf63a312

@ -109,16 +109,16 @@ public class InfoEnum
[Const("空闲")] Idel,
[Const("车辆到站(入口雷达检测到车辆驶入)")] RadarInFlag,
[Const("rfid扫描完成")] RfidReadFlag,
//[Const("云平台车辆认证")] CloudVelCheckFlag,
[Const("云平台车辆认证")] CloudVelCheckFlag,
[Const("车辆到位")] CarInPositionFlag,
// [Const("云平台下发换电指令")] CloudCarCanStartFlag,
[Const("云平台下发换电指令")] CloudCarCanStartFlag,
[Const("车辆解锁")] VelUnlockFlag,
// [Const("下发plc选包")] DistributeSelectPackFlag,
[Const("下发plc选包")] DistributeSelectPackFlag,
[Const("开始换电")] StartSwappingFlag,
[Const("拆旧电池完成")] UnOldBatteryFlag,
//[Const("入库旧电池完成")] StorageOldBatteryFlag,
//[Const("搬运新电池完成")] OutNewBatteryFlag,
[Const("入库旧电池完成")] StorageOldBatteryFlag,
[Const("搬运新电池完成")] OutNewBatteryFlag,
[Const("安装新电池完成")] InstallNewBatteryFlag,
[Const("安装完成")] FinishNewBatteryFlag,
[Const("车辆上锁")] VelLockFlag,

@ -45,8 +45,11 @@ public class CommonMgr
StartTime = DateTime.Now,
Status = 1
};
machine.StepModel[stepModel.StepNo.ToString()] = stepModel;
if (machine.SwapOrder != null)
{
if (!string.IsNullOrEmpty(machine.SwapOrder.Sn))

@ -8,7 +8,8 @@ public class BeginState: IState
return new StateResult()
{
SwappingState = SwappingState.StationReady
SwappingState = SwappingState.StationReady
//SwappingState = SwappingState.DoSwapping
};
}
}

@ -71,6 +71,8 @@ public class CarCtrlState : IState
machine.ManualConfirmCarUnlockFlag = false;
machine.BoxCarInfoModel = carInfo.Result;
machine.VelUnlockFlag = true;
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,
machine);
if (a==0)

@ -219,7 +219,7 @@ public class CarPrepareState : IState
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03"));
SoundClient.SoundPlay(SoundEnum.music43);
// SoundClient.SoundPlay(SoundEnum.music43);
//machine.ExceptionReason = ExceptionReason.ConnTBoxError;
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
}, false, () =>

@ -33,11 +33,72 @@ public class DoSwappingState : IState
public StateResult Handle(SwappingStateMachine machine)
{
//上报云平台换电开始
// machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.BeginSwap;
// machine.BusinessSwappingStateUpdateTime = DateTime.Now;
// _log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}");
// machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.BeginSwap;
// machine.BusinessSwappingStateUpdateTime = DateTime.Now;
// _log.Info($"BusinessSwappingForCloudState={machine.BusinessSwappingForCloudState}");
// CloudApi.SendStateLog(machine.SwapOrder, InfoEnum.BusinessSwappingForCloudState.BeginSwap);
//while (true)
//{
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.Idel,
// machine);
// Thread.Sleep(1000);
// //_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
// //machine);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
// machine);
// Thread.Sleep(1000);
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
// machine);
// Thread.Sleep(1000);
// //_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
// // machine);
// Thread.Sleep(10000);
// machine.Reset();
//}
@ -86,12 +147,13 @@ public class DoSwappingState : IState
return SwappingStateMachine.ReturnWithInvokeErr(beginRadar, ExceptionReason.None);
}
// 车辆离开
//var adjustCarByRadar = AdjustCarByRadar(machine);
//if (InvokeStatus.Done != adjustCarByRadar)
//{
// return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None);
//}
//车辆离开
var adjustCarByRadar = AdjustCarByRadar(machine);
machine.Reset();
if (InvokeStatus.Done != adjustCarByRadar)
{
return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None);
}
@ -187,6 +249,10 @@ public class DoSwappingState : IState
machine.SwapOrderBatteryInfo.UpBinInfo.No);
if (c==0)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag,
machine);
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music91);
Thread.Sleep(3000);
@ -200,8 +266,7 @@ public class DoSwappingState : IState
_CommonMgr.UpdateSwapOrder(machine);
machine.SwapStatus = 0;
machine.StartSwappingFlag = true;
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine);
}
}
@ -279,7 +344,9 @@ public class DoSwappingState : IState
if (machine.InstallNewBatteryFlag)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
machine);
}
}, () =>
@ -316,14 +383,19 @@ public class DoSwappingState : IState
SoundClient = AppInfo.Container.Resolve<SoundClient>();
if (b==0)
{
SoundClient.SoundPlay(SoundEnum.music77);
// SoundClient.SoundPlay(SoundEnum.music77);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
b = 1;
}
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
machine);
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
machine.ToSafePositionFlag = true;
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
@ -369,9 +441,16 @@ public class DoSwappingState : IState
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19"));
if (v == 0)
{
SoundClient.SoundPlay(SoundEnum.music76);
Thread.Sleep(3000);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
machine);
SoundClient.SoundPlay(SoundEnum.music77);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music76);
v = 1;
}
//断连Tbox
@ -381,8 +460,6 @@ public class DoSwappingState : IState
}
//新增小步
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
machine);
}
}
}, () =>

@ -32,11 +32,14 @@ public class StationReadyState : IState
public StateResult Handle(SwappingStateMachine machine)
{
_log.Info($"'goto stationReady");
machine.Reset();
machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.Idle;
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
//machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.Idle;
//machine.BusinessSwappingStateUpdateTime = DateTime.Now;
//判断换电站是否具备换电条件 前端页面
if (!IsAutoSwapping())
@ -98,6 +101,9 @@ public class StationReadyState : IState
public InvokeStatus PlcIsAuto(SwappingStateMachine machine)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.Idel,
machine);
int a = 0;
bool isAuto = false;
return Invoker.Invoke("check plc auto", 1000, 5, machine.IsCanceled, () => isAuto,
@ -171,6 +177,9 @@ public class StationReadyState : IState
/// <returns></returns>
public InvokeStatus ControlRadar(SwappingStateMachine machine, byte flag)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine);
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => PadarMgr._PadarClient?.CarState > 0,
() => { PadarMgr._PadarClient?.PadarControl(flag); });
}
@ -185,9 +194,7 @@ public class StationReadyState : IState
() =>
{
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarInPosition.GetLed());
//新增小步
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
machine);
if (PadarMgr._PadarClient?.CarState==6)
{
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Backoff.GetLed());
@ -230,10 +237,12 @@ public class StationReadyState : IState
beginRead.Wait();
if (!beginRead.Result)
{
_log.Info("begin read rfid error");
}
else
{
machine.ExceptionReason = ExceptionReason.None;
_log.Info("begin read done");
machine.BeginRfidReadFlag = true;
@ -243,7 +252,7 @@ public class StationReadyState : IState
machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address02"));
SoundClient.SoundPlay(SoundEnum.music74);
// SoundClient.SoundPlay(SoundEnum.music74);
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid);
//LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
@ -304,12 +313,12 @@ public class StationReadyState : IState
//新增换电订单
machine.SwapOrder = _CommonMgr.SaveOrder(BuildOrder(machine.RfidReadModel));
//新增小步
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.Idel,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
machine);
// 前端页面
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,

@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.Reflection.PortableExecutable;
using Autofac;
using Entity.Attr;
using Entity.Constant;
@ -73,16 +74,16 @@ public class SwappingStateMachine : IDisposable
["0"] = new StepModel { StepNo = 0, Status = 0, StepName = "空闲" },
["1"] = new StepModel { StepNo = 1, Status = 0, StepName = "车辆到站(入口雷达检测到车辆驶入)" },
["2"] = new StepModel { StepNo = 2, Status = 0, StepName = "rfid扫描完成" },
//["3"] = new StepModel { StepNo = 3, Status = 0, StepName = "云平台车辆认证" },
["3"] = new StepModel { StepNo = 3, Status = 0, StepName = "云平台车辆认证" },
["4"] = new StepModel { StepNo = 4, Status = 0, StepName = "车辆到位" },
// ["5"] = new StepModel { StepNo = 5, Status = 0, StepName = "云平台下发换电指令" },
["5"] = new StepModel { StepNo = 5, Status = 0, StepName = "云平台下发换电指令" },
["5"] = new StepModel { StepNo = 5, Status = 0, StepName = "车辆解锁" },
//["6"] = new StepModel { StepNo = 6, Status = 0, StepName = "下发plc选包" },
["6"] = new StepModel { StepNo = 6, Status = 0, StepName = "下发plc选包" },
["6"] = new StepModel { StepNo = 6, Status = 0, StepName = "开始换电" },
["7"] = new StepModel { StepNo = 7, Status = 0, StepName = "拆旧电池完成" },
//["8"] = new StepModel { StepNo = 8, Status = 0, StepName = "入库旧电池完成" },
//["9"] = new StepModel { StepNo = 9, Status = 0, StepName = "搬运新电池完成" },
["8"] = new StepModel { StepNo = 8, Status = 0, StepName = "入库旧电池完成" },
["9"] = new StepModel { StepNo = 9, Status = 0, StepName = "搬运新电池完成" },
["10"] = new StepModel { StepNo = 10, Status = 0, StepName = "安装新电池完成" },
["11"] = new StepModel { StepNo = 11, Status = 0, StepName = "安装完成" },
["12"] = new StepModel { StepNo = 12, Status = 0, StepName = "车辆上锁" },
@ -270,6 +271,8 @@ public class SwappingStateMachine : IDisposable
public void Reset()
{
Log.Info("reset data");
/*if (PlcMgr.PlcClient?.ReadTaskNo() == 1)
@ -441,7 +444,9 @@ public class SwappingStateMachine : IDisposable
private void ResetOrderAmtStatus()
{
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.WelcomeInfo.GetLed());

@ -115,7 +115,7 @@ public class LedClient
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_socket.NoDelay = true;
_socket.Connect("192.168.3.79", 10000);
Log.Info($"end connect {"192.168.3.79"}:{10000} {_socket.Connected}");
Log.Info($"end connect {"192.168.3.79"}:{10000} {_socket.Connected}");
}
public static bool InnerSend(byte[] bytes)

Loading…
Cancel
Save