Commit bf10fc86 LN

料架读取rfid改为查找方式

1 个父辈 f1de5b9b
......@@ -50,7 +50,7 @@
<add key ="OpenRFIDWrite" value ="1"/>
<add key="DefaultPWD" value ="123456"/>
<!--当前调试的设备ID,分号分割-->
<add key ="DebugDeviceId" value ="0"/>
<add key ="DebugDeviceId" value ="301"/>
<add key ="Server_Log_Open" value ="0"/>
<add key ="CodeCount" value ="3"/>
<add key ="DefaultTrayNum" value ="0"/>
......
......@@ -221,6 +221,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmRFIPEdit";
this.Text = "托盘编码";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmRFIPEdit_FormClosed);
this.Load += new System.EventHandler(this.FrmPwd_Load);
((System.ComponentModel.ISupportInitialize)(this.numNum)).EndInit();
this.groupBox2.ResumeLayout(false);
......
......@@ -45,6 +45,14 @@ namespace OnlineStore.AssemblyLine
comboxType.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();
}
......@@ -108,5 +116,17 @@ namespace OnlineStore.AssemblyLine
lblResult.Text = ("[" + 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
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)
{
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());
MessageBox.Show(exceptionobj.ToString(), type);
LOGGER.Error("【" + type + "】" + exceptionobj);
MessageBox.Show(exceptionobj, type);
}
}
}
......@@ -97,8 +97,8 @@
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="assemblyLine\EquipBase.cs" />
<Compile Include="deviceLibrary\RFID\RFIDAuto.cs" />
<Compile Include="deviceLibrary\RFID\RFIDReader.cs" />
<Compile Include="deviceLibrary\RFID\RFIDAutoReader.cs" />
<Compile Include="deviceLibrary\RFID\RFIDReader.cs" />
<Compile Include="model\LineAlarm.cs">
<SubType>Code</SubType>
</Compile>
......
......@@ -35,10 +35,10 @@ namespace OnlineStore.DeviceLibrary
}
public static void Open()
{
RFIDReader.Open(ShelfIpList.ToArray());
// RFIDAutoReader.Open(null, new List<string>(rfidMap.Values).ToArray());
RFIDAutoReader.Open(null, TrayIpList.ToArray());
RFIDReader.Open(ShelfIpList.ToArray());
}
/// <summary>
......@@ -94,7 +94,7 @@ namespace OnlineStore.DeviceLibrary
{
if (String.IsNullOrEmpty(ip).Equals(false) && ShelfIpList.Contains(ip))
{
byte[] bdata = RFIDReader.Read(ip, true);
byte[] bdata = RFIDReader.Read(ip, isClear);
if (bdata == null)
{
......@@ -207,7 +207,7 @@ namespace OnlineStore.DeviceLibrary
RFType = (char)data[1];
}
Num = (int)(data[2]);
}
}
}
catch (Exception ex)
{
......
......@@ -12,8 +12,6 @@ namespace Asa.RFID
{
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
private System.Threading.Thread tScan;
private bool loop;
private string IP = "";
private byte addr;
private int portIndex;
......@@ -22,18 +20,8 @@ namespace Asa.RFID
internal byte[] _buff; //8字节缓存
private byte[] _uid; //卡片ID
public bool IsExist = false;
public int ErrCode = 0;
/// <summary>
/// 接收事件
/// </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 int ErrCode = 0;
public RFID(string ip)
{
......@@ -44,7 +32,6 @@ namespace Asa.RFID
{
try
{
loop = false;
IsConnect = false;
int ErrCode = ReaderA.StaticClassReaderA.CloseNetPort(portIndex);
LOGGER.Info("Close RFID [" + IP + "]:" + ErrCode);
......@@ -57,6 +44,7 @@ namespace Asa.RFID
return -1;
}
public int Open()
{
if (IsConnect)
......@@ -92,29 +80,6 @@ namespace Asa.RFID
OpenCloseRF(true);
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)
{
if (rtn)
......@@ -123,6 +88,7 @@ namespace Asa.RFID
ErrCode = ReaderA.StaticClassReaderA.CloseRf(ref addr, portIndex);
}
/// <summary>
/// 查找电子标签,扫描模式不能使用
/// </summary>
......@@ -181,7 +147,6 @@ namespace Asa.RFID
}
return null;
}
private void ReadRFID()
{
//0 不带AFI
......@@ -227,13 +192,13 @@ namespace Asa.RFID
return s;
}
}
public class RFIDReader
{
public static readonly ILog LOGGER = LogManager.GetLogger("TheRFID");
private static Dictionary<string, RFID> rfidMap = new Dictionary<string, RFID>();
public static void Open(params string[] ipArr)
{
foreach (var ip in ipArr)
......@@ -250,7 +215,6 @@ namespace Asa.RFID
}
}
}
public static bool FindRFID(string ip)
{
if (rfidMap.ContainsKey(ip))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!