Rfid修改 增加连接和断开连接

master
lxw 7 months ago
parent 4a5ab90bb5
commit 00cf40a1f3

@ -48,10 +48,56 @@ public class RfidApi
Log.Error($"RfidApi StopRead err e={e}");
return false;
}
}
public static async Task<bool> 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<bool> 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<RfidReadModel?> ReadRifd()
{
//断连
var connect = await Connect();
if (!connect)
{
Log.Info("Rfid connect fail");
return null;
}
Log.Info("ReadRifd");
string url = BASE_URL + "/Api/ReadRfidData";
try

@ -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;
}
}, () =>

Loading…
Cancel
Save