Commit 871c943a LN

1

1 个父辈 5363c914
...@@ -18,9 +18,9 @@ using System.Windows.Forms; ...@@ -18,9 +18,9 @@ using System.Windows.Forms;
namespace OnlineStore.AssemblyLine namespace OnlineStore.AssemblyLine
{ {
internal partial class FrmRFIPEdit : FrmBase internal partial class FrmRFIPEdit : FrmBase
{ {
internal FrmRFIPEdit( ) internal FrmRFIPEdit()
{ {
InitializeComponent(); InitializeComponent();
} }
private Dictionary<string, string> rfMap = new Dictionary<string, string>(); private Dictionary<string, string> rfMap = new Dictionary<string, string>();
...@@ -47,16 +47,12 @@ namespace OnlineStore.AssemblyLine ...@@ -47,16 +47,12 @@ namespace OnlineStore.AssemblyLine
if (LineManager.Line.runStatus <= LineRunStatus.Wait) if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{ {
Task.Factory.StartNew(delegate RFIDManager.Open();
{
LogUtil.info(Name + "RFIDManager.Open");
RFIDManager.Open();
});
} }
string hostN = Dns.GetHostName(); string hostN = Dns.GetHostName();
} }
private void btnBack_Click(object sender, EventArgs e) private void btnBack_Click(object sender, EventArgs e)
{ {
...@@ -80,8 +76,8 @@ namespace OnlineStore.AssemblyLine ...@@ -80,8 +76,8 @@ namespace OnlineStore.AssemblyLine
} }
} }
lblResult.Text=("["+ip+"]读取到数据:" + resul); lblResult.Text = ("[" + ip + "]读取到数据:" + resul);
LogUtil.info("点击RFID[" + ip + "]读取数据测试,结果:" + resul); LogUtil.info("点击RFID[" + ip + "]读取数据测试,结果:" + resul);
} }
...@@ -93,14 +89,14 @@ namespace OnlineStore.AssemblyLine ...@@ -93,14 +89,14 @@ namespace OnlineStore.AssemblyLine
if (!txtIP.Text.Equals(V)) if (!txtIP.Text.Equals(V))
{ {
txtIP.Text = V; txtIP.Text = V;
} }
} }
} }
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 RFIDManager.Close();
{
LogUtil.info(Name + "RFIDManager.Close");
RFIDManager.Close();
});
} }
} }
} }
......
...@@ -260,18 +260,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -260,18 +260,16 @@ 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
{ RFIDManager.Open();
LogUtil.info(Name + "RFIDManager.Open");
RFIDManager.Open();
});
Thread.Sleep(5); Thread.Sleep(5);
//连接AGV调度 //连接AGV调度
if (!AgvClient.ISConnected()) if (!AgvClient.ISConnected())
{ {
AgvClient.Init(); AgvClient.Init();
} }
LineServer.StartServer(ConfigAppSettings.GetIntValue(Setting_Init.TCPServerPort)); LineServer.StartServer(ConfigAppSettings.GetIntValue(Setting_Init.TCPServerPort));
...@@ -401,11 +399,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -401,11 +399,11 @@ namespace OnlineStore.DeviceLibrary
equip.OpenStopCylinder(); equip.OpenStopCylinder();
} }
} }
public override void StopRun() public override void StopRun()
{ {
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
mainTimer.Enabled = false; mainTimer.Enabled = false;
ledProcessTimer.Enabled = false; ledProcessTimer.Enabled = false;
...@@ -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
{ RFIDManager.Close();
LogUtil.info(Name + "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()
{ {
RFIDReader.Open(ShelfIpList.ToArray()); Task.Factory.StartNew(delegate
// RFIDAutoReader.Open(null, new List<string>(rfidMap.Values).ToArray()); {
RFIDAutoReader.Open(null, TrayIpList.ToArray()); LogUtil.info( "RFIDManager.Open");
RFIDReader.Open(ShelfIpList.ToArray());
// RFIDAutoReader.Open(null, new List<string>(rfidMap.Values).ToArray());
RFIDAutoReader.Open(null, TrayIpList.ToArray());
});
} }
/// <summary> /// <summary>
...@@ -149,24 +153,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -149,24 +153,28 @@ namespace OnlineStore.DeviceLibrary
public static void Close() public static void Close()
{ {
try Task.Factory.StartNew(delegate
{
LogUtil.info("调用 RFIDAutoReader.CloseAll");
RFIDAutoReader.CloseAll();
}
catch (Exception ex)
{
LogUtil.error("RFIDAutoReader.CloseAll()出错:", ex);
}
try
{
LogUtil.info("调用 RFIDReader.CloseAll");
RFIDReader.CloseAll();
}
catch (Exception ex)
{ {
LogUtil.error("RFIDReader.CloseAll()出错:", ex); LogUtil.info( "RFIDManager.Close");
} try
{
LogUtil.info("调用 RFIDAutoReader.CloseAll");
RFIDAutoReader.CloseAll();
}
catch (Exception ex)
{
LogUtil.error("RFIDAutoReader.CloseAll()出错:", ex);
}
try
{
LogUtil.info("调用 RFIDReader.CloseAll");
RFIDReader.CloseAll();
}
catch (Exception 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++)
LOGGER.Info("Connect [" + IP + "] :" + ErrCode);
if (ErrCode == 0)
{ {
ErrCode = OpenAutoScanMode(addr); ErrCode = ReaderA.StaticClassReaderA.OpenNetPort(port, IP, ref addr, ref portIndex);
LOGGER.Info(" [" + IP + "] Open Auto Scan Mode:" + ErrCode); LOGGER.Info("Connect [" + IP + "] :" + ErrCode);
Task.Factory.StartNew(AutoScan); 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; return ErrCode;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!