Commit 871c943a LN

1

1 个父辈 5363c914
...@@ -19,7 +19,7 @@ namespace OnlineStore.AssemblyLine ...@@ -19,7 +19,7 @@ namespace OnlineStore.AssemblyLine
{ {
internal partial class FrmRFIPEdit : FrmBase internal partial class FrmRFIPEdit : FrmBase
{ {
internal FrmRFIPEdit( ) internal FrmRFIPEdit()
{ {
InitializeComponent(); InitializeComponent();
} }
...@@ -47,11 +47,7 @@ namespace OnlineStore.AssemblyLine ...@@ -47,11 +47,7 @@ namespace OnlineStore.AssemblyLine
if (LineManager.Line.runStatus <= LineRunStatus.Wait) if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{ {
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Open");
RFIDManager.Open(); RFIDManager.Open();
});
} }
string hostN = Dns.GetHostName(); string hostN = Dns.GetHostName();
...@@ -81,7 +77,7 @@ namespace OnlineStore.AssemblyLine ...@@ -81,7 +77,7 @@ namespace OnlineStore.AssemblyLine
} }
lblResult.Text=("["+ip+"]读取到数据:" + resul); lblResult.Text = ("[" + ip + "]读取到数据:" + resul);
LogUtil.info("点击RFID[" + ip + "]读取数据测试,结果:" + resul); LogUtil.info("点击RFID[" + ip + "]读取数据测试,结果:" + resul);
} }
...@@ -100,7 +96,7 @@ namespace OnlineStore.AssemblyLine ...@@ -100,7 +96,7 @@ namespace OnlineStore.AssemblyLine
private void btnReadClear_Click(object sender, EventArgs e) private void btnReadClear_Click(object sender, EventArgs e)
{ {
string ip = txtIP.Text; string ip = txtIP.Text;
RFIDData data = RFIDManager.ReadRFID(ip,true); RFIDData data = RFIDManager.ReadRFID(ip, true);
string resul = ""; string resul = "";
if (data != null) if (data != null)
{ {
...@@ -121,11 +117,7 @@ namespace OnlineStore.AssemblyLine ...@@ -121,11 +117,7 @@ namespace OnlineStore.AssemblyLine
{ {
if (LineManager.Line.runStatus <= LineRunStatus.Wait) if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{ {
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Close");
RFIDManager.Close(); RFIDManager.Close();
});
} }
} }
} }
......
...@@ -260,11 +260,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -260,11 +260,9 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(Name + "开始启动,启动时间:" + StartTime.ToString()); LogUtil.info(Name + "开始启动,启动时间:" + StartTime.ToString());
// rfidList = new List<string>(); // rfidList = new List<string>();
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Open");
RFIDManager.Open(); RFIDManager.Open();
});
Thread.Sleep(5); Thread.Sleep(5);
//连接AGV调度 //连接AGV调度
...@@ -415,13 +413,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -415,13 +413,10 @@ namespace OnlineStore.DeviceLibrary
runStatus = LineRunStatus.Wait; runStatus = LineRunStatus.Wait;
LineServer.StopServer(); LineServer.StopServer();
Task.Factory.StartNew(delegate
{
LogUtil.info(Name + "RFIDManager.Close");
RFIDManager.Close(); RFIDManager.Close();
});
TimeSpan span = DateTime.Now - StartTime; TimeSpan span = DateTime.Now - StartTime;
LogUtil.info( Name + ",停止运行,总运行时间:" + span.ToString()); LogUtil.info(Name + ",停止运行,总运行时间:" + span.ToString());
} }
public override void Alarm(LineAlarmType alarmType ) public override void Alarm(LineAlarmType alarmType )
......
...@@ -36,9 +36,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -36,9 +36,13 @@ namespace OnlineStore.DeviceLibrary
public static void Open() public static void Open()
{ {
Task.Factory.StartNew(delegate
{
LogUtil.info( "RFIDManager.Open");
RFIDReader.Open(ShelfIpList.ToArray()); 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());
});
} }
/// <summary> /// <summary>
...@@ -149,6 +153,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -149,6 +153,9 @@ namespace OnlineStore.DeviceLibrary
public static void Close() public static void Close()
{ {
Task.Factory.StartNew(delegate
{
LogUtil.info( "RFIDManager.Close");
try try
{ {
LogUtil.info("调用 RFIDAutoReader.CloseAll"); LogUtil.info("调用 RFIDAutoReader.CloseAll");
...@@ -167,6 +174,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -167,6 +174,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error("RFIDReader.CloseAll()出错:", ex); LogUtil.error("RFIDReader.CloseAll()出错:", ex);
} }
});
} }
} }
public class RFIDData public class RFIDData
......
...@@ -4,6 +4,7 @@ using System; ...@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Asa.RFID namespace Asa.RFID
...@@ -58,14 +59,15 @@ namespace Asa.RFID ...@@ -58,14 +59,15 @@ namespace Asa.RFID
{ {
if (IsConnect) if (IsConnect)
{ {
LOGGER.Warn(" RFID [" + IP+"] is already connected, no need to start again"); LOGGER.Warn(" RFID [" + IP + "] is already connected, no need to start again");
return 0; return 0;
} }
this.Received = OnReceive; this.Received = OnReceive;
//IP合法 //IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"; string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(IP, pattern); bool rtn = System.Text.RegularExpressions.Regex.IsMatch(IP, pattern);
if (!rtn) { if (!rtn)
{
LOGGER.Error(IP + " is error"); LOGGER.Error(IP + " is error");
return -1; return -1;
} }
...@@ -79,14 +81,24 @@ namespace Asa.RFID ...@@ -79,14 +81,24 @@ namespace Asa.RFID
addr = Convert.ToByte(arr[3]); addr = Convert.ToByte(arr[3]);
int port = 6000 + Convert.ToInt32(arr[3]); int port = 6000 + Convert.ToInt32(arr[3]);
portIndex = 0; portIndex = 0;
int ErrCode = 0;
int ErrCode = ReaderA.StaticClassReaderA.OpenNetPort(port, IP, ref addr, ref portIndex); for (int i = 1; i <= 3; i++)
{
ErrCode = ReaderA.StaticClassReaderA.OpenNetPort(port, IP, ref addr, ref portIndex);
LOGGER.Info("Connect [" + IP + "] :" + ErrCode); LOGGER.Info("Connect [" + IP + "] :" + ErrCode);
if (ErrCode == 0) if (ErrCode == 0)
{ {
ErrCode = OpenAutoScanMode(addr); ErrCode = OpenAutoScanMode(addr);
LOGGER.Info(" [" + IP + "] Open Auto Scan Mode:" + ErrCode); LOGGER.Info(" [" + IP + "] Open Auto Scan Mode:" + ErrCode);
Task.Factory.StartNew(AutoScan); Task.Factory.StartNew(AutoScan);
break;
}
else if (i < 3)
{
LOGGER.Error("Connect [" + IP + "] " + ErrCode + ", StopAutoScan");
StopAutoScan();
}
Thread.Sleep(10);
} }
return ErrCode; return ErrCode;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!