Commit 871c943a LN

1

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