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

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

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

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

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

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

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

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

Loading…
Cancel
Save