diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs index 5867831..4da8141 100644 --- a/Service/Execute/Api/RfidApi.cs +++ b/Service/Execute/Api/RfidApi.cs @@ -48,10 +48,56 @@ public class RfidApi Log.Error($"RfidApi StopRead err e={e}"); return false; } + + + } + + public static async Task DisConnect() + { + Log.Info("DisConnect"); + string url = BASE_URL + "/Api/Close"; + try + { + string s = await _httpClient.GetStringAsync(url); + Log.Info($"DisConnect resp={s}"); + return bool.Parse(s); + } + catch (Exception e) + { + Log.Error($"RfidApi DisConnect err e={e}"); + return false; + } + } + + public static async Task Connect() + { + var disConnect = await DisConnect(); + + Log.Info("Connect"); + string url = BASE_URL + "/Api/Open"; + try + { + string s = await _httpClient.GetStringAsync(url); + Log.Info($"Connect resp={s}"); + return bool.Parse(s); + } + catch (Exception e) + { + Log.Error($"RfidApi Connect err e={e}"); + return false; + } } public static async Task ReadRifd() { + //断连 + var connect = await Connect(); + if (!connect) + { + Log.Info("Rfid connect fail"); + return null; + } + Log.Info("ReadRifd"); string url = BASE_URL + "/Api/ReadRfidData"; try diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index b1d3191..4684259 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -39,6 +39,7 @@ public class StationReadyState : IState { return null; } + //plc是否是远程模式 var plcIsAuto = PlcIsAuto(machine); if (InvokeStatus.Done != plcIsAuto) @@ -229,7 +230,7 @@ public class StationReadyState : IState machine); RfidApi.StopRead(); _log.Info("stop read rfid"); - + RfidApi.DisConnect(); machine.RfidReadFlag = true; } }, () =>