Commit b8514908 张东亮

lineplace

1 个父辈 a29760e4
此文件类型无法预览
...@@ -51,7 +51,7 @@ namespace BLL ...@@ -51,7 +51,7 @@ namespace BLL
_server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_server.Bind(localEP); _server.Bind(localEP);
_server.Listen(100); _server.Listen(100);
Common.log.Info("Server Start"); Common.LogInfo("Server Start");
_loop = true; _loop = true;
_client = new List<Client>(); _client = new List<Client>();
...@@ -79,7 +79,7 @@ namespace BLL ...@@ -79,7 +79,7 @@ namespace BLL
_server.Close(); _server.Close();
_client = null; _client = null;
Thread.Sleep(50); Thread.Sleep(50);
Common.log.Info("Server Stop"); Common.LogInfo("Server Stop");
} }
public bool ReadyEnter(string nodeName, string rfid = "") public bool ReadyEnter(string nodeName, string rfid = "")
...@@ -87,7 +87,7 @@ namespace BLL ...@@ -87,7 +87,7 @@ namespace BLL
int idx = FindClient(nodeName); int idx = FindClient(nodeName);
if (idx == -1) if (idx == -1)
{ {
Common.log.Info("ReadyEnter 没有找到" + nodeName); Common.LogInfo("ReadyEnter 没有找到" + nodeName);
return false; return false;
} }
else else
...@@ -103,7 +103,7 @@ namespace BLL ...@@ -103,7 +103,7 @@ namespace BLL
int idx = FindClient(nodeName); int idx = FindClient(nodeName);
if (idx == -1) if (idx == -1)
{ {
Common.log.Info("ReadyLeave 没有找到" + nodeName); Common.LogInfo("ReadyLeave 没有找到" + nodeName);
return false; return false;
} }
else else
...@@ -156,12 +156,12 @@ namespace BLL ...@@ -156,12 +156,12 @@ namespace BLL
_client.Add(client); _client.Add(client);
listen.Start(_client.Count - 1); listen.Start(_client.Count - 1);
Common.log.Info(string.Format("[{0}] 已连接", client.IP)); Common.LogInfo(string.Format("[{0}] 已连接", client.IP));
} }
catch (SocketException) catch (SocketException)
{ {
//关闭连接,退出阻塞Accept //关闭连接,退出阻塞Accept
Common.log.Info("服务端关闭连接,退出阻塞Accept"); Common.LogInfo("服务端关闭连接,退出阻塞Accept");
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -197,7 +197,7 @@ namespace BLL ...@@ -197,7 +197,7 @@ namespace BLL
ClientNode node = Decode(buff); ClientNode node = Decode(buff);
if (node == null) if (node == null)
{ {
Common.log.Info("解码失败:" + HexBuff(buff)); Common.LogInfo("解码失败:" + HexBuff(buff));
} }
else else
{ {
...@@ -213,7 +213,7 @@ namespace BLL ...@@ -213,7 +213,7 @@ namespace BLL
if (time > 5000) if (time > 5000)
{ {
Offline(client); Offline(client);
Common.log.Info("[" + client.IP + "] 超过5s没有收到数据,关闭连接"); Common.LogInfo("[" + client.IP + "] 超过5s没有收到数据,关闭连接");
} }
} }
} }
...@@ -273,7 +273,7 @@ namespace BLL ...@@ -273,7 +273,7 @@ namespace BLL
int idx = Common.nodeInfo.FindIndex(s => s.Name == node.Name); int idx = Common.nodeInfo.FindIndex(s => s.Name == node.Name);
if (idx == -1) if (idx == -1)
{ {
Common.log.Info("UpdateNode " + node.Name + " 不存在"); Common.LogInfo("UpdateNode " + node.Name + " 不存在");
return; return;
} }
...@@ -288,7 +288,7 @@ namespace BLL ...@@ -288,7 +288,7 @@ namespace BLL
{ {
Common.nodeInfo[idx].Action = node.Action; Common.nodeInfo[idx].Action = node.Action;
Common.nodeInfo[idx].RFID = node.RFID; Common.nodeInfo[idx].RFID = node.RFID;
Common.log.Info(node.Name + "更新 " + node.ToText()); Common.LogInfo(node.Name + "更新 " + node.ToText());
NodeChanged?.Invoke(idx); NodeChanged?.Invoke(idx);
} }
} }
...@@ -363,7 +363,7 @@ namespace BLL ...@@ -363,7 +363,7 @@ namespace BLL
if (!_client[idx].IsConn) if (!_client[idx].IsConn)
{ {
Common.log.Info(ip + " 没有连接"); Common.LogInfo(ip + " 没有连接");
return false; return false;
} }
......
...@@ -20,7 +20,7 @@ namespace AGVControl ...@@ -20,7 +20,7 @@ namespace AGVControl
/// </summary> /// </summary>
public static List<Agv_Info> agvInfo; public static List<Agv_Info> agvInfo;
public static List<string> linePlace; public static List<string> linePlace;
public static System.Windows.Forms.TextBox logTextBox;
public static BLL.AgvServer server; public static BLL.AgvServer server;
public static BLL.Control control; public static BLL.Control control;
...@@ -33,42 +33,57 @@ namespace AGVControl ...@@ -33,42 +33,57 @@ namespace AGVControl
public static Dictionary<string, string> agvProductionLine; public static Dictionary<string, string> agvProductionLine;
public static System.Configuration.Configuration appConfig; public static System.Configuration.Configuration appConfig;
public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\"; public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\";
public static int logCnt = 0;
public static void LogInfo(string text)
{
if (logTextBox.InvokeRequired)
{
logTextBox.Invoke(new Action(() => LogInfo(text)));
return;
}
logCnt++;
if (logCnt > 200)
logTextBox.Text = "";
logTextBox.Text += string.Format("[{0}] {1}\r\n",DateTime.Now.ToString("HH:mm:ss") ,text);
}
public static void ReadLinePlace() public static void ReadLinePlace()
{ {
if (!System.IO.File.Exists(CONFIG_PATH + "LinePlace.txt"))
return;
string[] s = System.IO.File.ReadAllLines(CONFIG_PATH + "LinePlace.txt"); string[] s = System.IO.File.ReadAllLines(CONFIG_PATH + "LinePlace.txt");
linePlace = new List<string>(); linePlace = new List<string>();
linePlace.AddRange(s); linePlace.AddRange(s);
} }
//public static void AddLinePlace(string nodeName)
//{ public static bool AddLinePlace(string nodeName)
// int idx = Common.nodeInfo.FindIndex(s => s.Name == nodeName); {
// if(idx>-1) int idx = Common.nodeInfo.FindIndex(s => s.Name == nodeName);
// { if (idx > -1)
// if(Common.linePlace.ContainsKey(nodeName)) {
// { if (Common.linePlace.Contains(nodeName))
// log.Info("AddLinePlace 节点" + nodeName + "已存在任务队列,无需重复添加"); {
// return; LogInfo("AddLinePlace 节点" + nodeName + "已存在任务队列,无需重复添加");
// } return false;
// Common.linePlace.Add(nodeName,Common.nodeInfo[idx].Level); }
// Common.appConfig.AppSettings.Settings["nodesLevel"].Value = string.Join(",",linePlace.Values); Common.linePlace.Add(nodeName);
// Common.appConfig.AppSettings.Settings["nodesMission"].Value =string.Join(",",linePlace.Keys); System.IO.File.WriteAllLines(CONFIG_PATH + "LinePlace.txt", linePlace);
// Common.appConfig.Save(); return true;
// } }
// else else
// { {
// log.Error("AddLinePlace 失败 节点"+ nodeName+"不存在"); log.Error("AddLinePlace 失败 节点" + nodeName + "不存在");
// } return false;
}
//}
//public static void RemoveLinePlace(string nodeName) }
//{ public static void RemoveLinePlace(string nodeName)
// Common.linePlace.Remove(nodeName); {
// Common.appConfig.AppSettings.Settings["nodesLevel"].Value = string.Join(",", linePlace.Values); Common.linePlace.Remove(nodeName);
// Common.appConfig.AppSettings.Settings["nodesMission"].Value = string.Join(",", linePlace.Keys); System.IO.File.WriteAllLines(CONFIG_PATH + "LinePlace.txt", linePlace);
// Common.appConfig.Save(); }
//}
public static void CheckAGVMissionState() public static void CheckAGVMissionState()
{ {
...@@ -79,7 +94,7 @@ namespace AGVControl ...@@ -79,7 +94,7 @@ namespace AGVControl
if (rtn) if (rtn)
{ {
agv.GetPlace(regValue); agv.GetPlace(regValue);
Common.log.Info(string.Format("软件开启:{0} Get_Register PLC{1}={2} Place={3} PlaceState={4}", agv.Name, 20, regValue, agv.Place, agv.PlaceState)); Common.LogInfo(string.Format("软件开启:{0} Get_Register PLC{1}={2} Place={3} PlaceState={4}", agv.Name, 20, regValue, agv.Place, agv.PlaceState));
if (!agv.Place.Equals("")) if (!agv.Place.Equals(""))
{ {
int idx = nodeInfo.FindIndex(s => s.Name == agv.Place); int idx = nodeInfo.FindIndex(s => s.Name == agv.Place);
......
...@@ -470,7 +470,7 @@ namespace BLL ...@@ -470,7 +470,7 @@ namespace BLL
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern); bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn) if (!rtn)
{ {
Common.log.Info("非法的IP地址" + ip); Common.LogInfo("非法的IP地址" + ip);
return false; return false;
} }
...@@ -482,7 +482,7 @@ namespace BLL ...@@ -482,7 +482,7 @@ namespace BLL
ping.Dispose(); ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success) if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{ {
Common.log.Info("Ping " + ip + " 请求没有响应"); Common.LogInfo("Ping " + ip + " 请求没有响应");
return false; return false;
} }
return true; return true;
......
...@@ -3,6 +3,7 @@ using System.ServiceModel.Web; ...@@ -3,6 +3,7 @@ using System.ServiceModel.Web;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.ServiceModel.Activation; using System.ServiceModel.Activation;
using System; using System;
using AGVControl;
namespace BLL namespace BLL
{ {
...@@ -39,25 +40,32 @@ namespace BLL ...@@ -39,25 +40,32 @@ namespace BLL
public Result CreateEmptyRecycleTask(string line) public Result CreateEmptyRecycleTask(string line)
{ {
AGVControl.Common.log.Info("WebService Request emptyStation=" + line); AGVControl.Common.LogInfo("WebService Request emptyStation=" + line);
Result res; Result res;
if (AGVControl.Common.agvProductionLine.TryGetValue(line, out string value)) if (AGVControl.Common.agvProductionLine.TryGetValue(line, out string value))
{ {
res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" }; res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" };
AGVControl.Common.log.Info("WebService Response OK"); AGVControl.Common.LogInfo("WebService Response OK");
//加到任务 //加到任务
int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value); //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
if (idx > -1) //if (idx > -1)
AGVControl.Common.linePlace.Add(value); // AGVControl.Common.linePlace.Add(value);
//else
// AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
if(!Common.AddLinePlace(value))
AGVControl.Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
else else
AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在"); {
AGVControl.Common.LogInfo("CreateEmptyRecycleTask 节点【" + value + "】收到出空料架任务");
}
//System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
} }
else else
{ {
res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line }; res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line };
AGVControl.Common.log.Info("WebService Response false"); AGVControl.Common.LogInfo("WebService Response false");
} }
return res; return res;
...@@ -75,7 +83,7 @@ namespace BLL ...@@ -75,7 +83,7 @@ namespace BLL
ClsWebService service = new ClsWebService(); ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(service, new Uri(url)); _serviceHost = new WebServiceHost(service, new Uri(url));
_serviceHost.Open(); _serviceHost.Open();
AGVControl.Common.log.Info("Web服务已开启"); AGVControl.Common.LogInfo("Web服务已开启");
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -88,7 +96,7 @@ namespace BLL ...@@ -88,7 +96,7 @@ namespace BLL
try try
{ {
_serviceHost.Close(); _serviceHost.Close();
AGVControl.Common.log.Info("Web服务已关闭"); AGVControl.Common.LogInfo("Web服务已关闭");
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -19,6 +19,7 @@ namespace AGVControl ...@@ -19,6 +19,7 @@ namespace AGVControl
public FrmMain() public FrmMain()
{ {
InitializeComponent(); InitializeComponent();
Common.logTextBox = TxtLog;
} }
private void ShowConfig() private void ShowConfig()
...@@ -37,6 +38,7 @@ namespace AGVControl ...@@ -37,6 +38,7 @@ namespace AGVControl
{ {
n = DgvNode.Rows.Add(Common.nodeInfo[i].ToRow()); n = DgvNode.Rows.Add(Common.nodeInfo[i].ToRow());
DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString(); DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString();
comboBox1.Items.Add(Common.nodeInfo[i].Name);
if (!Common.nodeInfo[i].Online) if (!Common.nodeInfo[i].Online)
DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red; DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
} }
...@@ -138,7 +140,7 @@ namespace AGVControl ...@@ -138,7 +140,7 @@ namespace AGVControl
else if (e.ColumnIndex == 9) //清除缓存 else if (e.ColumnIndex == 9) //清除缓存
{ {
//清除小车缓存 //清除小车缓存
Common.log.Info(string.Format("手动清除缓存,{0} {1}", Common.agvInfo[e.RowIndex].Name, Common.agvInfo[e.RowIndex].Place)); Common.LogInfo(string.Format("手动清除缓存,{0} {1}", Common.agvInfo[e.RowIndex].Name, Common.agvInfo[e.RowIndex].Place));
string place = Common.agvInfo[e.RowIndex].Place; string place = Common.agvInfo[e.RowIndex].Place;
Common.agvInfo[e.RowIndex].Place = ""; Common.agvInfo[e.RowIndex].Place = "";
Common.agvInfo[e.RowIndex].RFID = ""; Common.agvInfo[e.RowIndex].RFID = "";
...@@ -176,7 +178,7 @@ namespace AGVControl ...@@ -176,7 +178,7 @@ namespace AGVControl
else if (e.ColumnIndex == 7) //清除缓存 else if (e.ColumnIndex == 7) //清除缓存
{ {
//清除节点缓存 //清除节点缓存
Common.log.Info(string.Format("手动清除缓存,{0} {1}", Common.nodeInfo[e.RowIndex].AgvName, Common.nodeInfo[e.RowIndex].Name)); Common.LogInfo(string.Format("手动清除缓存,{0} {1}", Common.nodeInfo[e.RowIndex].AgvName, Common.nodeInfo[e.RowIndex].Name));
string name = Common.nodeInfo[e.RowIndex].AgvName; string name = Common.nodeInfo[e.RowIndex].AgvName;
Common.nodeInfo[e.RowIndex].AgvName = ""; Common.nodeInfo[e.RowIndex].AgvName = "";
DgvNode.Rows[e.RowIndex].Cells[4].Value = ""; DgvNode.Rows[e.RowIndex].Cells[4].Value = "";
...@@ -237,41 +239,42 @@ namespace AGVControl ...@@ -237,41 +239,42 @@ namespace AGVControl
private void btnAddlinePlace_Click(object sender, EventArgs e) private void btnAddlinePlace_Click(object sender, EventArgs e)
{ {
//if (TxtPlace.Text == "") if (comboBox1.SelectedItem == null)
//{ {
// MessageBox.Show("请输入节点名"); MessageBox.Show("请先选择任务节点!");
// return; return;
//} }
//Common.AddLinePlace(TxtPlace.Text.ToUpper()); Common.AddLinePlace(comboBox1.SelectedItem.ToString());
//dgvLinePlace.Rows.Clear(); Common.LogInfo("手动添加【"+ comboBox1.SelectedItem.ToString() + "】出空料架任务");
//foreach (var item in Common.linePlace) dgvLinePlace.Rows.Clear();
//{ foreach (var item in Common.linePlace)
// dgvLinePlace.Rows.Add(item.Key, item.Value); {
//} dgvLinePlace.Rows.Add(item);
}
} }
private void btnDeletelinePlace_Click(object sender, EventArgs e) private void btnDeletelinePlace_Click(object sender, EventArgs e)
{ {
//if (TxtPlace.Text == "") if (comboBox1.SelectedItem == null)
//{ {
// MessageBox.Show("请输入节点名"); MessageBox.Show("请先选择任务节点!");
// return; return;
//} }
//Common.RemoveLinePlace(TxtPlace.Text.ToUpper()); Common.RemoveLinePlace(comboBox1.SelectedItem.ToString());
//dgvLinePlace.Rows.Clear(); dgvLinePlace.Rows.Clear();
//foreach (var item in Common.linePlace) foreach (var item in Common.linePlace)
//{ {
// dgvLinePlace.Rows.Add(item.Key, item.Value); dgvLinePlace.Rows.Add(item);
//} }
} }
private void btnReadlinePlace_Click(object sender, EventArgs e) private void btnReadlinePlace_Click(object sender, EventArgs e)
{ {
//dgvLinePlace.Rows.Clear(); dgvLinePlace.Rows.Clear();
//foreach (var item in Common.linePlace) foreach (var item in Common.linePlace)
//{ {
// dgvLinePlace.Rows.Add(item.Key, item.Value); dgvLinePlace.Rows.Add(item);
//} }
} }
} }
} }
...@@ -174,9 +174,6 @@ ...@@ -174,9 +174,6 @@
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column20.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
......
...@@ -38,9 +38,9 @@ namespace AGVControl ...@@ -38,9 +38,9 @@ namespace AGVControl
return; return;
} }
} }
Common.logTextBox = new TextBox();
Common.log = log4net.LogManager.GetLogger("AgvServer"); Common.log = log4net.LogManager.GetLogger("AgvServer");
Common.log.Info("=====程序开始====="); Common.LogInfo("=====程序开始=====");
ReadConfig(); ReadConfig();
Common.ReadLinePlace(); Common.ReadLinePlace();
...@@ -59,7 +59,7 @@ namespace AGVControl ...@@ -59,7 +59,7 @@ namespace AGVControl
Common.control.Stop(); Common.control.Stop();
Common.server.Stop(); Common.server.Stop();
Common.web.Close(); Common.web.Close();
Common.log.Info("=====程序结束=====\r\n"); Common.LogInfo("=====程序结束=====\r\n");
} }
private static void ReadConfig() private static void ReadConfig()
......
...@@ -77,7 +77,7 @@ namespace AsaPL ...@@ -77,7 +77,7 @@ namespace AsaPL
tRecon.Start(); tRecon.Start();
tListen.Start(); tListen.Start();
tSend.Start(); tSend.Start();
LOG.Info("Connect"); LogInfo("Connect");
} }
/// <summary> /// <summary>
...@@ -93,7 +93,7 @@ namespace AsaPL ...@@ -93,7 +93,7 @@ namespace AsaPL
_client.Close(); _client.Close();
_client = null; _client = null;
} }
LOG.Info("Close"); LogInfo("Close");
} }
/// <summary> /// <summary>
...@@ -118,7 +118,7 @@ namespace AsaPL ...@@ -118,7 +118,7 @@ namespace AsaPL
_node[idx].Action = action; _node[idx].Action = action;
_node[idx].Level = level; _node[idx].Level = level;
} }
LOG.Info("SetStatus " + _node[idx].ToText()); LogInfo("SetStatus " + _node[idx].ToText());
} }
/// <summary> /// <summary>
...@@ -127,7 +127,7 @@ namespace AsaPL ...@@ -127,7 +127,7 @@ namespace AsaPL
/// <param name="name"></param> /// <param name="name"></param>
public void MayEnter(string name) public void MayEnter(string name)
{ {
LOG.Info(name + " MayEnter"); LogInfo(name + " MayEnter");
ClientNode node = new ClientNode(name, "", ClientAction.MayEnter, ClientLevel.High); ClientNode node = new ClientNode(name, "", ClientAction.MayEnter, ClientLevel.High);
byte[] buff = Encode(node); byte[] buff = Encode(node);
bool bln = Send(buff); bool bln = Send(buff);
...@@ -139,7 +139,7 @@ namespace AsaPL ...@@ -139,7 +139,7 @@ namespace AsaPL
/// <param name="name"></param> /// <param name="name"></param>
public void MayLeave(string name) public void MayLeave(string name)
{ {
LOG.Info(name + " MayLeave"); LogInfo(name + " MayLeave");
ClientNode node = new ClientNode(name, "", ClientAction.MayLeave, ClientLevel.High); ClientNode node = new ClientNode(name, "", ClientAction.MayLeave, ClientLevel.High);
byte[] buff = Encode(node); byte[] buff = Encode(node);
bool bln = Send(buff); bool bln = Send(buff);
...@@ -151,7 +151,7 @@ namespace AsaPL ...@@ -151,7 +151,7 @@ namespace AsaPL
/// <param name="name"></param> /// <param name="name"></param>
public void FinishEnter(string name) public void FinishEnter(string name)
{ {
LOG.Info(name + " FinishEnter"); LogInfo(name + " FinishEnter");
ClientNode node = new ClientNode(name, "", ClientAction.FinishEnter, ClientLevel.High); ClientNode node = new ClientNode(name, "", ClientAction.FinishEnter, ClientLevel.High);
byte[] buff = Encode(node); byte[] buff = Encode(node);
bool bln = Send(buff); bool bln = Send(buff);
...@@ -163,7 +163,7 @@ namespace AsaPL ...@@ -163,7 +163,7 @@ namespace AsaPL
/// <param name="name"></param> /// <param name="name"></param>
public void FinishLeave(string name) public void FinishLeave(string name)
{ {
LOG.Info(name + " FinishLeave"); LogInfo(name + " FinishLeave");
ClientNode node = new ClientNode(name, "", ClientAction.FinishLeave, ClientLevel.High); ClientNode node = new ClientNode(name, "", ClientAction.FinishLeave, ClientLevel.High);
byte[] buff = Encode(node); byte[] buff = Encode(node);
bool bln = Send(buff); bool bln = Send(buff);
...@@ -184,11 +184,11 @@ namespace AsaPL ...@@ -184,11 +184,11 @@ namespace AsaPL
if (IsConn) if (IsConn)
{ {
countRecon = 0; countRecon = 0;
LOG.Info("Server connection successful"); LogInfo("Server connection successful");
} }
else else
{ {
LOG.Info("Server connection failed " + ++countRecon + " times"); LogInfo("Server connection failed " + ++countRecon + " times");
} }
} }
Thread.Sleep(1000); Thread.Sleep(1000);
...@@ -202,7 +202,7 @@ namespace AsaPL ...@@ -202,7 +202,7 @@ namespace AsaPL
{ {
try try
{ {
LOG.Info("Connect " + IP + ":" + PORT); LogInfo("Connect " + IP + ":" + PORT);
if (CheckIP(IP)) if (CheckIP(IP))
{ {
_client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
...@@ -212,7 +212,7 @@ namespace AsaPL ...@@ -212,7 +212,7 @@ namespace AsaPL
_client.Connect(IPAddress.Parse(IP), PORT); _client.Connect(IPAddress.Parse(IP), PORT);
if (!_loop) return; if (!_loop) return;
IsConn = true; IsConn = true;
LOG.Info("Connect OK"); LogInfo("Connect OK");
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -246,11 +246,11 @@ namespace AsaPL ...@@ -246,11 +246,11 @@ namespace AsaPL
ClientNode node = Decode(_buffer); ClientNode node = Decode(_buffer);
if (node == null) if (node == null)
{ {
LOG.Info("Command decoding failed: " + HexBuff(_buffer)); LogInfo("Command decoding failed: " + HexBuff(_buffer));
} }
else else
{ {
LOG.Info("From server: " + node.ToText()); LogInfo("From server: " + node.ToText());
Resolve(node); Resolve(node);
} }
} }
...@@ -273,12 +273,12 @@ namespace AsaPL ...@@ -273,12 +273,12 @@ namespace AsaPL
{ {
if (result.Action == ClientAction.ReadyEnter) if (result.Action == ClientAction.ReadyEnter)
{ {
LOG.Info("Trigger ReadyEnter Event"); LogInfo("Trigger ReadyEnter Event");
ReadyEnter?.Invoke(result.Name); ReadyEnter?.Invoke(result.Name);
} }
else if (result.Action == ClientAction.ReadyLeave) else if (result.Action == ClientAction.ReadyLeave)
{ {
LOG.Info("Trigger ReadyLeave Event"); LogInfo("Trigger ReadyLeave Event");
ReadyLeave?.Invoke(result.Name); ReadyLeave?.Invoke(result.Name);
} }
} }
...@@ -324,7 +324,7 @@ namespace AsaPL ...@@ -324,7 +324,7 @@ namespace AsaPL
{ {
if (!IsConn) if (!IsConn)
{ {
LOG.Info("服务器没有连接"); LogInfo("服务器没有连接");
return false; return false;
} }
...@@ -418,7 +418,7 @@ namespace AsaPL ...@@ -418,7 +418,7 @@ namespace AsaPL
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern); bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn) if (!rtn)
{ {
LOG.Info("Illegal IP address " + ip); LogInfo("Illegal IP address " + ip);
return false; return false;
} }
...@@ -430,7 +430,7 @@ namespace AsaPL ...@@ -430,7 +430,7 @@ namespace AsaPL
ping.Dispose(); ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success) if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{ {
LOG.Info("Ping " + ip + " request timeout"); LogInfo("Ping " + ip + " request timeout");
return false; return false;
} }
return true; return true;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!