Commit a8f58955 LN

1

1 个父辈 becdfb76
...@@ -96,7 +96,8 @@ ...@@ -96,7 +96,8 @@
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" /> <Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" /> <Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="assemblyLine\EquipBase.cs" /> <Compile Include="assemblyLine\EquipBase.cs" />
<Compile Include="deviceLibrary\RFID\RFID.cs" /> <Compile Include="deviceLibrary\RFID\RFIDAuto.cs" />
<Compile Include="deviceLibrary\RFID\RFIDReader.cs" />
<Compile Include="deviceLibrary\RFID\RFIDAutoReader.cs" /> <Compile Include="deviceLibrary\RFID\RFIDAutoReader.cs" />
<Compile Include="model\LineAlarm.cs"> <Compile Include="model\LineAlarm.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
......
...@@ -8,7 +8,7 @@ using System.Threading.Tasks; ...@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Asa.RFID namespace Asa.RFID
{ {
public class RFID public class RFIDAuto
{ {
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID"); public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
...@@ -29,7 +29,7 @@ namespace Asa.RFID ...@@ -29,7 +29,7 @@ namespace Asa.RFID
/// </summary> /// </summary>
public event Received_Event Received; public event Received_Event Received;
public RFID(string ip) public RFIDAuto(string ip)
{ {
this.IP = ip; this.IP = ip;
} }
......
...@@ -4,7 +4,7 @@ using System.Collections.Generic; ...@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Asa.RFID.RFID; using static Asa.RFID.RFIDAuto;
namespace Asa.RFID namespace Asa.RFID
{ {
...@@ -12,7 +12,7 @@ namespace Asa.RFID ...@@ -12,7 +12,7 @@ namespace Asa.RFID
{ {
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID"); public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
private static Dictionary<string, RFID> rfidMap = new Dictionary<string, RFID>(); private static Dictionary<string, RFIDAuto> rfidMap = new Dictionary<string, RFIDAuto>();
/// <summary> /// <summary>
/// 打开所有 /// 打开所有
...@@ -30,7 +30,7 @@ namespace Asa.RFID ...@@ -30,7 +30,7 @@ namespace Asa.RFID
} }
else else
{ {
RFID rfid = new RFID(ip); RFIDAuto rfid = new RFIDAuto(ip);
rfid.StartAutoScan(OnReceive); rfid.StartAutoScan(OnReceive);
rfidMap.Add(ip, rfid); rfidMap.Add(ip, rfid);
} }
......
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Asa.RFID.RFIDAuto;
namespace Asa.RFID
{
public class RFIDReader
{
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
private static Dictionary<string, RFIDAuto> rfidMap = new Dictionary<string, RFIDAuto>();
/// <summary>
/// 打开所有
/// </summary>
/// <param name="ipArr"></param>
/// <param name="OnReceive"></param>
/// <param name="ip"></param>
public static void Open(Received_Event OnReceive, params string[] ipArr)
{
foreach(var ip in ipArr)
{
if (rfidMap.ContainsKey(ip))
{
rfidMap[ip].StartAutoScan(OnReceive);
}
else
{
RFIDAuto rfid = new RFIDAuto(ip);
rfid.StartAutoScan(OnReceive);
rfidMap.Add(ip, rfid);
}
}
}
/// <summary>
/// 获取最后读到的标签并清理
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static byte[] ReadAndClear(string ip)
{
if (rfidMap.ContainsKey(ip))
{
return rfidMap[ip].ReadAndClear();
}
return null;
}
/// <summary>
/// 获取最后读到的标签
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static byte[] Read(string ip)
{
if (rfidMap.ContainsKey(ip))
{
return rfidMap[ip].Read();
}
return null;
}
/// <summary>
/// 关闭所有
/// </summary>
public static void CloseAll()
{
foreach(var rfid in rfidMap.Values)
{
rfid.StopAutoScan();
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!