master
赵宝玉 3 weeks ago
commit e8f2ac182b

@ -47,6 +47,7 @@ public class StationReadyState : IState
machine);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.WelcomeInfo.GetLed());
Thread.Sleep(2000);
////开启雷达
var beginRadar = ControlRadar(machine, 1);
if (InvokeStatus.Done != beginRadar)
@ -346,8 +347,20 @@ public class StationReadyState : IState
Task<RfidReadModel?> rfidReadModel = RfidApi.ReadRfid();
rfidReadModel.Wait();
var machineRfidReadModel = rfidReadModel.Result;
Thread.Sleep(1000);
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;
}
Thread.Sleep(1000);
if (rfidReadModel.IsCompletedSuccessfully && machineRfidReadModel != null
&& machineRfidReadModel.Result == 1
&& !string.IsNullOrEmpty(machineRfidReadModel.VelVin))
@ -365,11 +378,11 @@ public class StationReadyState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag,
machine,param:JsonConvert.SerializeObject(machine.RfidReadModel));
//RfidApi.StopRead();
// _log.Info("stop read rfid");
// RfidApi.DisConnect();
machine.RfidConnectFlag = false;
machine.RfidReadFlag = true;
}
Thread.Sleep(1000);
Task<bool> beginRead = RfidApi.BeginRead();

@ -180,9 +180,10 @@ public class LedClient
private static string _ip = "192.168.3.79";
// private static string _ip = "127.0.0.1";
private static int _port = 10000;
private static DateTime LastestSendTime;
private static string LastestKey=InfoEnum.SwapInfo.WelcomeInfo.GetLed();
private static bool HeartBegin = false;
private static byte[] Heart = new byte[]
{
@ -226,7 +227,7 @@ public class LedClient
}
}*/
Thread.Sleep(3000);
Thread.Sleep(4500);
}
}
@ -242,20 +243,30 @@ public class LedClient
_socket.NoDelay = true;
_socket.Connect(_ip, _port);
Log.Info($"end connect {_ip}:{_port} {_socket.Connected}");
Task.Run(ListenHeart);
if (_socket.Connected)
{
if (!HeartBegin)
{
HeartBegin = true;
Task.Run(ListenHeart);
}
}
}
catch (SocketException ex)
{
Log.Error($"Failed to connect to {_ip}:{_port}. Reason: {ex.Message}");
_socket?.Close();
_socket = null;
}
}
private static bool InnerSend(byte[] bytes)
{
if (_socket?.Connected ?? false)
if ( _socket?.Connected ?? false )
{
try
{
@ -295,19 +306,8 @@ public class LedClient
int count = 0;
if (Dictionary.TryGetValue(key, out var bytes))
{
LastestKey = key;
LastestSendTime=DateTime.Now;
while (!InnerSend(bytes))
{
Thread.Sleep(100);
count++;
if (count > 10)
{
return false;
}
}
return true;
return InnerSend(bytes);
}
return false;

@ -82,7 +82,7 @@ public class UpdateDownBatteryInfoTask : ITask
battery.DownBatterySoc = info.Soc;
battery.DownBatterySoe = info.Soe;
battery.DownNominalEnergy = info.NominalEnergy;
Log.Info($"add battery battery ={JsonConvert.SerializeObject(battery)}");
updateDbBattery.Add(battery);

Loading…
Cancel
Save