master
赵宝玉 1 month ago
parent 4a468d137f
commit ac5c571dcf

@ -47,7 +47,7 @@ public class CarCtrlState : IState
/// <returns></returns> /// <returns></returns>
public InvokeStatus UnLockCar(SwappingStateMachine machine) public InvokeStatus UnLockCar(SwappingStateMachine machine)
{ {
return Invoker.Invoke("UnLockCar", 500, 7, machine.IsCanceled, return Invoker.Invoke("UnLockCar", 500, 4, machine.IsCanceled,
() => machine.VelUnlockFlag, () => () => machine.VelUnlockFlag, () =>
{ {
Task<bool> result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); Task<bool> result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin);
@ -88,6 +88,6 @@ public class CarCtrlState : IState
}, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; } }, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; }
, 5, InvokeStatus.None); , 3, InvokeStatus.None);
} }
} }

@ -228,8 +228,7 @@ public class CarPrepareState : IState
i = 1; i = 1;
} }
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); Thread.Sleep(1000);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed());
break; break;
case 5: case 5:
_log.Info("radar 车辆靠前"); _log.Info("radar 车辆靠前");
@ -242,8 +241,7 @@ public class CarPrepareState : IState
a = 1; a = 1;
} }
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); Thread.Sleep(1000);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed());
break; break;
} }
}); });

@ -30,7 +30,8 @@ public class DoSwappingState : IState
public static SoundClient? SoundClient { get; set; } public static SoundClient? SoundClient { get; set; }
private int a = 0;
private int b = 0;
public StateResult Handle(SwappingStateMachine machine) public StateResult Handle(SwappingStateMachine machine)
{ {
//上报云平台换电开始 //上报云平台换电开始
@ -142,8 +143,14 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine); machine);
if (a == 0)
{
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
a = 1;
}
Thread.Sleep(1000);
//LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); //LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
//查詢當前任務狀態是否被更改 //查詢當前任務狀態是否被更改
if (startSwapping) if (startSwapping)
@ -185,13 +192,13 @@ public class DoSwappingState : IState
int i = 0; int i = 0;
return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled,
() => machine.UnOldBatteryFlag, () => () => machine.UnOldBatteryFlag, () =>
{
if (b==0)
{ {
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); b = 1;
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed()); }
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.StartSwap.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>(); SoundClient = AppInfo.Container.Resolve<SoundClient>();
machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone; machine.UnOldBatteryFlag = ClientMgr.PlcClient.DisassembleDone;

@ -216,18 +216,9 @@ public class StationReadyState : IState
PlcApi.Traffic(0); PlcApi.Traffic(0);
i = 0; i = 0;
a = 0; a = 0;
LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed());
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine,type: machine.ManualSkipRadar? (int)SwapConstant.StepType.MANUAL :(int)SwapConstant.StepType.AUTO); machine,type: machine.ManualSkipRadar? (int)SwapConstant.StepType.MANUAL :(int)SwapConstant.StepType.AUTO);
} }
return PadarMgr._PadarClient?.CarState == 6 || machine.ManualSkipRadar; return PadarMgr._PadarClient?.CarState == 6 || machine.ManualSkipRadar;
@ -247,15 +238,12 @@ public class StationReadyState : IState
che++; che++;
if (che == 10) if (che == 10)
{ {
LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed());
SoundClient.SoundPlay(SoundEnum.music100); SoundClient.SoundPlay(SoundEnum.music100);
Thread.Sleep(6000); Thread.Sleep(6000);
SoundClient.SoundPlay(SoundEnum.music101); SoundClient.SoundPlay(SoundEnum.music101);
che = 1; che = 1;
} }
break; break;
case 4: case 4:
_log.Info("radar 车辆靠后"); _log.Info("radar 车辆靠后");
@ -268,8 +256,7 @@ public class StationReadyState : IState
i = 1; i = 1;
} }
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed()); Thread.Sleep(1000);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Muka.GetLed());
break; break;
case 5: case 5:
_log.Info("radar 车辆靠前"); _log.Info("radar 车辆靠前");
@ -281,9 +268,9 @@ public class StationReadyState : IState
SoundClient.SoundPlay(SoundEnum.music101); SoundClient.SoundPlay(SoundEnum.music101);
a = 0; a = 0;
} }
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed()); Thread.Sleep(1000);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Mundur.GetLed());
break; break;
} }
}); });
@ -296,7 +283,6 @@ public class StationReadyState : IState
{ {
// Task<bool> open = RfidApi.Connect(); // Task<bool> open = RfidApi.Connect();
machine.RfidConnectFlag = true; machine.RfidConnectFlag = true;
Task<bool> beginRead = RfidApi.BeginRead(); Task<bool> beginRead = RfidApi.BeginRead();
beginRead.Wait(); beginRead.Wait();
@ -311,8 +297,6 @@ public class StationReadyState : IState
machine.BeginRfidReadFlag = true; machine.BeginRfidReadFlag = true;
} }
}, () => }, () =>
{ {
// machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); // machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
@ -390,6 +374,21 @@ public class StationReadyState : IState
// machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); // machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>(); SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music42); SoundClient.SoundPlay(SoundEnum.music42);
Task<bool> beginRead = RfidApi.BeginRead();
beginRead.Wait();
if (!beginRead.Result)
{
_log.Info("begin read rfid error");
}
else
{
machine.ExceptionReason = ExceptionReason.None;
_log.Info("begin read done");
machine.BeginRfidReadFlag = true;
}
}, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30, }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30,
InvokeStatus.None); InvokeStatus.None);
} }
@ -427,6 +426,7 @@ public class StationReadyState : IState
SoundClient = AppInfo.Container.Resolve<SoundClient>(); SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music42); SoundClient.SoundPlay(SoundEnum.music42);
}, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30, }, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 30,
InvokeStatus.None); InvokeStatus.None);
} }

@ -216,9 +216,9 @@ public class SwapDoneState : IState
// machine); // machine);
var SoundClient = AppInfo.Container.Resolve<SoundClient>(); var SoundClient = AppInfo.Container.Resolve<SoundClient>();
// LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeave.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeaveflushed.GetLed());
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeaveflushed.GetLed());
Thread.Sleep(1000);
SoundClient.SoundPlay(SoundEnum.music76); SoundClient.SoundPlay(SoundEnum.music76);
Thread.Sleep(7000); Thread.Sleep(7000);
SoundClient.SoundPlay(SoundEnum.music77); SoundClient.SoundPlay(SoundEnum.music77);

@ -176,6 +176,7 @@ public class LedClient
private static readonly ILog Log = LogManager.GetLogger(typeof(LedClient)); private static readonly ILog Log = LogManager.GetLogger(typeof(LedClient));
private static Socket? _socket; private static Socket? _socket;
private static string _ip = "192.168.3.79"; private static string _ip = "192.168.3.79";
//private static string _ip = "127.0.0.1";
private static int _port = 10000; private static int _port = 10000;
public static bool Init(string ip, int port) public static bool Init(string ip, int port)

@ -30,10 +30,10 @@ public static class ClientMgr
{ {
EquipNetInfo netInfo = new EquipNetInfo() EquipNetInfo netInfo = new EquipNetInfo()
{ {
// NetAddr = "192.168.251.199", //NetAddr = "127.0.0.1",
NetAddr = "192.168.3.20", NetAddr = "192.168.3.20",
NetPort = "2000", NetPort = "2000",
//NetPort = "1689", //NetPort = "10000",
Code = PlcConst.ChargeEqpCode, Code = PlcConst.ChargeEqpCode,
DestAddr = "132,208,208,224" DestAddr = "132,208,208,224"
}; };

Loading…
Cancel
Save