Commit bf10fc86 LN

料架读取rfid改为查找方式

1 个父辈 f1de5b9b
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<add key ="OpenRFIDWrite" value ="1"/> <add key ="OpenRFIDWrite" value ="1"/>
<add key="DefaultPWD" value ="123456"/> <add key="DefaultPWD" value ="123456"/>
<!--当前调试的设备ID,分号分割--> <!--当前调试的设备ID,分号分割-->
<add key ="DebugDeviceId" value ="0"/> <add key ="DebugDeviceId" value ="301"/>
<add key ="Server_Log_Open" value ="0"/> <add key ="Server_Log_Open" value ="0"/>
<add key ="CodeCount" value ="3"/> <add key ="CodeCount" value ="3"/>
<add key ="DefaultTrayNum" value ="0"/> <add key ="DefaultTrayNum" value ="0"/>
......
...@@ -221,6 +221,7 @@ ...@@ -221,6 +221,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmRFIPEdit"; this.Name = "FrmRFIPEdit";
this.Text = "托盘编码"; this.Text = "托盘编码";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmRFIPEdit_FormClosed);
this.Load += new System.EventHandler(this.FrmPwd_Load); this.Load += new System.EventHandler(this.FrmPwd_Load);
((System.ComponentModel.ISupportInitialize)(this.numNum)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numNum)).EndInit();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
......
...@@ -45,6 +45,14 @@ namespace OnlineStore.AssemblyLine ...@@ -45,6 +45,14 @@ namespace OnlineStore.AssemblyLine
comboxType.SelectedIndex = 0; comboxType.SelectedIndex = 0;
comType.SelectedIndex = 0; comType.SelectedIndex = 0;
if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Open");
RFIDManager.Open();
});
}
string hostN = Dns.GetHostName(); string hostN = Dns.GetHostName();
} }
...@@ -108,5 +116,17 @@ namespace OnlineStore.AssemblyLine ...@@ -108,5 +116,17 @@ namespace OnlineStore.AssemblyLine
lblResult.Text = ("[" + ip + "]读取到数据:" + resul); lblResult.Text = ("[" + ip + "]读取到数据:" + resul);
LogUtil.info("点击RFID[" + ip + "]读取数据并清理测试,结果:" + resul); LogUtil.info("点击RFID[" + ip + "]读取数据并清理测试,结果:" + resul);
} }
private void FrmRFIPEdit_FormClosed(object sender, FormClosedEventArgs e)
{
if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Close");
RFIDManager.Close();
});
}
}
} }
} }
...@@ -112,19 +112,19 @@ namespace OnlineStore.AssemblyLine ...@@ -112,19 +112,19 @@ namespace OnlineStore.AssemblyLine
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
LogUnhandledException("CurrentDomain_UnhandledException", e); LogUnhandledException("CurrentDomain_UnhandledException", e.ToString() +""+e.ExceptionObject.ToString()+" ");
} }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{ {
LogUnhandledException("Application_ThreadException", e); LogUnhandledException("Application_ThreadException", e.ToString() + "" + e.Exception.ToString() + " ");
} }
static void LogUnhandledException(string type, object exceptionobj) static void LogUnhandledException(string type, string exceptionobj)
{ {
//这里可以进一步地写日志 //这里可以进一步地写日志
LOGGER.Error("【" + type + "】" + exceptionobj.ToString()); LOGGER.Error("【" + type + "】" + exceptionobj);
MessageBox.Show(exceptionobj.ToString(), type); MessageBox.Show(exceptionobj, type);
} }
} }
} }
...@@ -97,8 +97,8 @@ ...@@ -97,8 +97,8 @@
<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\RFIDAuto.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="deviceLibrary\RFID\RFIDReader.cs" />
<Compile Include="model\LineAlarm.cs"> <Compile Include="model\LineAlarm.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
......
...@@ -35,10 +35,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -35,10 +35,10 @@ namespace OnlineStore.DeviceLibrary
} }
public static void Open() public static void Open()
{ {
RFIDReader.Open(ShelfIpList.ToArray());
// RFIDAutoReader.Open(null, new List<string>(rfidMap.Values).ToArray()); // RFIDAutoReader.Open(null, new List<string>(rfidMap.Values).ToArray());
RFIDAutoReader.Open(null, TrayIpList.ToArray()); RFIDAutoReader.Open(null, TrayIpList.ToArray());
RFIDReader.Open(ShelfIpList.ToArray());
} }
/// <summary> /// <summary>
...@@ -94,7 +94,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -94,7 +94,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (String.IsNullOrEmpty(ip).Equals(false) && ShelfIpList.Contains(ip)) if (String.IsNullOrEmpty(ip).Equals(false) && ShelfIpList.Contains(ip))
{ {
byte[] bdata = RFIDReader.Read(ip, true); byte[] bdata = RFIDReader.Read(ip, isClear);
if (bdata == null) if (bdata == null)
{ {
...@@ -207,7 +207,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -207,7 +207,7 @@ namespace OnlineStore.DeviceLibrary
RFType = (char)data[1]; RFType = (char)data[1];
} }
Num = (int)(data[2]); Num = (int)(data[2]);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -12,8 +12,6 @@ namespace Asa.RFID ...@@ -12,8 +12,6 @@ namespace Asa.RFID
{ {
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID"); public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
private System.Threading.Thread tScan;
private bool loop;
private string IP = ""; private string IP = "";
private byte addr; private byte addr;
private int portIndex; private int portIndex;
...@@ -22,18 +20,8 @@ namespace Asa.RFID ...@@ -22,18 +20,8 @@ namespace Asa.RFID
internal byte[] _buff; //8字节缓存 internal byte[] _buff; //8字节缓存
private byte[] _uid; //卡片ID private byte[] _uid; //卡片ID
public bool IsExist = false; public bool IsExist = false;
public int ErrCode = 0;
/// <summary> public int ErrCode = 0;
/// 接收事件
/// </summary>
/// <param name="ip"></param>
/// <param name="buff"></param>
public delegate void Received_Event(string ip, byte[] buff);
/// <summary>
/// 接收数据
/// </summary>
public event Received_Event Received;
public RFID(string ip) public RFID(string ip)
{ {
...@@ -44,7 +32,6 @@ namespace Asa.RFID ...@@ -44,7 +32,6 @@ namespace Asa.RFID
{ {
try try
{ {
loop = false;
IsConnect = false; IsConnect = false;
int ErrCode = ReaderA.StaticClassReaderA.CloseNetPort(portIndex); int ErrCode = ReaderA.StaticClassReaderA.CloseNetPort(portIndex);
LOGGER.Info("Close RFID [" + IP + "]:" + ErrCode); LOGGER.Info("Close RFID [" + IP + "]:" + ErrCode);
...@@ -57,6 +44,7 @@ namespace Asa.RFID ...@@ -57,6 +44,7 @@ namespace Asa.RFID
return -1; return -1;
} }
public int Open() public int Open()
{ {
if (IsConnect) if (IsConnect)
...@@ -92,29 +80,6 @@ namespace Asa.RFID ...@@ -92,29 +80,6 @@ namespace Asa.RFID
OpenCloseRF(true); OpenCloseRF(true);
return ErrCode; return ErrCode;
} }
public void FindMode()
{
loop = true;
tScan = new System.Threading.Thread(new System.Threading.ThreadStart(Scan));
tScan.Start();
}
private void Scan()
{
while (loop)
{
bool rtn = FindRFID();
if (rtn)
{
ReadRFID();
byte[] bb = new byte[] { _buff[1], _buff[2] };
Received?.Invoke(IP, bb);
}
System.Threading.Thread.Sleep(100);
}
}
private void OpenCloseRF(bool rtn) private void OpenCloseRF(bool rtn)
{ {
if (rtn) if (rtn)
...@@ -123,6 +88,7 @@ namespace Asa.RFID ...@@ -123,6 +88,7 @@ namespace Asa.RFID
ErrCode = ReaderA.StaticClassReaderA.CloseRf(ref addr, portIndex); ErrCode = ReaderA.StaticClassReaderA.CloseRf(ref addr, portIndex);
} }
/// <summary> /// <summary>
/// 查找电子标签,扫描模式不能使用 /// 查找电子标签,扫描模式不能使用
/// </summary> /// </summary>
...@@ -181,7 +147,6 @@ namespace Asa.RFID ...@@ -181,7 +147,6 @@ namespace Asa.RFID
} }
return null; return null;
} }
private void ReadRFID() private void ReadRFID()
{ {
//0 不带AFI //0 不带AFI
...@@ -227,13 +192,13 @@ namespace Asa.RFID ...@@ -227,13 +192,13 @@ namespace Asa.RFID
return s; return s;
} }
} }
public class RFIDReader public class RFIDReader
{ {
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, RFID> rfidMap = new Dictionary<string, RFID>();
public static void Open(params string[] ipArr) public static void Open(params string[] ipArr)
{ {
foreach (var ip in ipArr) foreach (var ip in ipArr)
...@@ -250,7 +215,6 @@ namespace Asa.RFID ...@@ -250,7 +215,6 @@ namespace Asa.RFID
} }
} }
} }
public static bool FindRFID(string ip) public static bool FindRFID(string ip)
{ {
if (rfidMap.ContainsKey(ip)) if (rfidMap.ContainsKey(ip))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!