Commit dfd0a30a 张东亮

更新端口9500

1 个父辈 dac976ba
正在显示 51 个修改的文件 包含 1019 行增加80 行删除
此文件类型无法预览
......@@ -40,6 +40,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
......@@ -63,9 +67,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BLL\AGVManager.cs" />
<Compile Include="BLL\AgvServer.cs" />
<Compile Include="BLL\Common.cs" />
<Compile Include="BLL\ConfigAppSettings.cs" />
<Compile Include="BLL\Control.cs" />
<Compile Include="BLL\HttpHelper.cs" />
<Compile Include="BLL\JsonHelper.cs" />
<Compile Include="BLL\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
......
......@@ -24,7 +24,8 @@
</log4net>
<appSettings>
<add key="ITS" value="http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIGetBoxDestInfo?boxRFID=" />
<add key="WebService" value="http://127.0.0.1/Webservice/AGVService/"/>
<add key="WebService" value="http://10.85.199.1/Webservice/AGVService/"/>
<add key="http.server" value="http://10.85.199.25/myproject/" />
<add key="FLEET" value="10.85.199.3"/>
<!--<add key="LocalIP" value="192.168.103.12"/>
<add key="AutoCharge" value="false"/>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AGVControl;
namespace BLL
{
public class AGVManager
{
/// <summary>
/// 小车从B区域离开前检查出库任务是否完成
/// </summary>
/// <param name="rfid"></param>
/// <returns>true:可以离开</returns>
//public static bool LeaveCheck(Agv_Info agv, out int taskCount)
//{
// taskCount = 0;
// try
// {
// //Common.LogInfo("URL:" + Common.webService["URL"]);
// string url = ConfigAppSettings.GetValue(Setting_Init.http_server) + "rest/api/qisda/device/shelfTaskCount? rfid =" + agv.RFID;
// var client = new RestSharp.RestClient(url) { Timeout = -1 };
// var request = new RestSharp.RestRequest(RestSharp.Method.GET);
// RestSharp.IRestResponse response = client.Execute(request);
// string json = response.Content;
// Common.LogInfo(agv.Name + " [URL: " + url+"] [Return: " + json+"]");
// if (string.IsNullOrWhiteSpace(json)) return true; //可以离开
// ShelfTaskCount serverResult = JsonHelper.DeserializeJsonToObject<ShelfTaskCount>(json);
// if (serverResult == null)
// {
// Common.LogInfo(" 没有收到服务器反馈");
// return true;
// }
// if (serverResult.code != 0) return true;
// if (serverResult.shelfTaskData.taskCount == 0) //该料架出库完成
// {
// Common.LogInfo(agv.Name+" 料架【" + agv.RFID + "】 无剩余出库任务,serverResult.shelfTaskData.taskCount=" + serverResult.shelfTaskData.taskCount.ToString());
// return true;
// }
// else //该料架的出库任务未完成
// {
// // foreach (ShelfLockData item in serverResult.data)
// // {
// taskCount = serverResult.shelfTaskData.taskCount;
// Common.LogInfo(agv.Name + " [RFID=" + serverResult.shelfTaskData.rfid + "] [taskCount=" + serverResult.shelfTaskData.taskCount + "]");
// // }
// return false;
// }
// }
// catch (Exception ex)
// {
// Common.log.OutError(ex);
// return true;
// }
//}
//private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
//public static bool GetShelfLockInfo(string name,string rfid, List<string> shelfLockNodeNames)
//{
// string msg = "";
// try
// {
// Dictionary<string, string> paramMap = new Dictionary<string, string>();
// paramMap.Add("rfid", rfid);
// string server = GetAddr(Addr_getShelfLockInfo, paramMap);
// DateTime startTime = DateTime.Now;
// string resultStr = HttpHelper.Post(server, "");
// Common.LogInfo("节点【"+name+ "】 料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
// ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
// if (serverResult == null)
// {
// msg = "节点【" + name + "】没有收到服务器反馈";
// Common.LogInfo(msg);
// return false;
// }
// if (serverResult.data.Count == 0) //该料架未锁定
// {
// msg = "节点【" + name + "】 料架【" + rfid + "】 没有锁定库位的料";
// Common.LogInfo(msg);
// return false;
// }
// else //该料架存在锁定库位的料
// {
// foreach (ShelfLockData item in serverResult.data)
// {
// if (!shelfLockNodeNames.Contains(Common.webService[item.cid]))
// {
// shelfLockNodeNames.Add(Common.webService[item.cid]);
// Common.LogInfo("锁定的CID=" + item.cid + ";节点名称=" + Common.webService[item.cid]);
// }
// }
// Common.LogInfo("节点【" + name + "】"+rfid+"获取料架上的锁定料仓信息完成");
// return true;
// }
// }
// catch (Exception ex)
// {
// Common.LogInfo(ex.Message);
// }
// return false;
//}
private static string Addr_updateDeviceAlarmMsg = "/updateDeviceAlarmMsg";
/// <summary>
/// 异常看板
/// </summary>
/// <param name="msgList"></param>
/// <returns></returns>
public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
string msgListStr = JsonHelper.SerializeObject(msgList);
paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
Common.LogInfo("updateDeviceAlarmMsg " + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (data == null)
{
return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " updateDeviceAlarmMsg 【" + server + "】【" + resultStr + "】" + data.msg;
}
return "";
}
catch (Exception ex)
{
Common.log.Error(ex);
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = ConfigAppSettings.GetValue("http.server");
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
}
string path = server + addr.Trim() + "?";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
}
public class ShelfLockInfo
{
//返回: {"code":0,"msg":"ok","data":
//[{"barcode":"S20052301213","cid":"packing-20","rfid":"A12","rfidLoc":"3","lockPos":"4D2001AA0006","lockPosId":"1231"}]}
/// <summary>
/// 返回码,0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public List<ShelfLockData> data { get; set; }
}
public class ShelfLockData
{
/// <summary>
/// 库位中料盘的条码
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 库位中料盘的锁定库位对应的料仓编
/// </summary>
public string cid { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
/// <summary>
/// 料架的库位
/// </summary>
public int rfidLoc { get; set; }
/// <summary>
/// 库位中料盘的锁定库位
/// </summary>
public string lockPos { get; set; }
/// <summary>
/// 料架出库的剩余数量
/// </summary>
public int taskCount { get; set; }
}
/// <summary>
/// 获取料架中的任务数
/// </summary>
public class ShelfTaskCount
{
// {"code":0,"msg":"ok","data":{"taskCount":0,"rfid":"A2"}}
/// <summary>
/// 0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public ShelfTaskData shelfTaskData { get; set; }
}
public struct ShelfTaskData
{
/// <summary>
/// 当前料架剩余任务数(即还有几盘料没放上去)
/// </summary>
public int taskCount { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
}
public class AlarmMsg
{
//>>>name : 异常位置名称
public string name = "";
//>>>msgKey : 异常信息唯一标识
public string msgKey = "";
//>>>msgValue : 异常信息
public string msgValue = "";
/// <summary>
/// 异常信息
/// </summary>
/// <param name="name">异常位置名称</param>
/// <param name="key">异常信息唯一标识</param>
/// <param name="value">异常信息</param>
public AlarmMsg(string name, string key, string value)
{
this.name = name;
this.msgKey = key;
this.msgValue = value;
}
}
public class RfidData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
}
......@@ -16,7 +16,8 @@ namespace BLL
private Socket _server; //服务端
private List<Client> _client; //所有客户端
private Thread tListenClient; //监听客户端连接
private const int PORT = 12001; //端口
private const int PORT = 9500; //端口
private Thread tPingClient; //ping
/// <summary>
/// 节点改变事件
......@@ -37,7 +38,7 @@ namespace BLL
/// </summary>
public AgvServer()
{
}
/// <summary>
......@@ -57,6 +58,8 @@ namespace BLL
_client = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
tPingClient = new Thread(new ThreadStart(PingClient));
tPingClient.Start();
}
catch (Exception ex)
{
......@@ -115,6 +118,60 @@ namespace BLL
}
private void PingClient()
{
while (_loop)
{
Thread.Sleep(3000);
for (int i = 0; i < Common.nodeInfo.Count; i++)
{
try
{
if (!Common.nodeInfo[i].IP.Equals(""))
Common.nodeInfo[i].Online = CheckIP(Common.nodeInfo[i].Name, Common.nodeInfo[i].IP);
NodeOnline?.Invoke(i);
NodeChanged?.Invoke(i);
}
catch (Exception e)
{
Common.log.Error("PingClient", e);
}
}
}
}
private bool CheckIP(string name, string 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?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
Common.LogInfo("非法的IP地址" + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
Common.LogInfo(name + " Ping " + ip + " 请求没有响应",false);
return false;
}
return true;
}
catch (Exception ex)
{
Common.log.Error("CheckIP", ex);
return false;
}
}
/// <summary>
/// 监听客户端
......@@ -210,10 +267,10 @@ namespace BLL
else
{
time += sleep;
if (time > 5000)
if (time > 30000)
{
Offline(client);
Common.LogInfo("[" + client.IP + "] 超过5s没有收到数据,关闭连接");
Common.LogInfo("[" + client.IP + "] 超过30s没有收到数据,关闭连接");
}
}
}
......
......@@ -33,20 +33,29 @@ namespace AGVControl
public static Dictionary<string, string> agvProductionLine;
public static System.Configuration.Configuration appConfig;
public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\";
public static int logCnt = 0;
public static void LogInfo(string text)
private static string msg="";
private static int logCnt = 0;
public static void LogInfo(string text, bool isShow = true)
{
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);
if (msg.Equals(text))//连续重复的日志只打印一次
return;
logCnt++;
if(logCnt>100)
{
logCnt = 0;
msg = "";
}
log.Info(msg);
if (isShow)
msg+= string.Format("[{0}] {1}\r\n", DateTime.Now.ToString("HH:mm:ss"), text);
logTextBox.Text = msg;
}
public static void ReadLinePlace()
{
......@@ -57,7 +66,7 @@ namespace AGVControl
linePlace.AddRange(s);
}
public static bool AddLinePlace(string nodeName)
{
int idx = Common.nodeInfo.FindIndex(s => s.Name == nodeName);
......@@ -73,7 +82,7 @@ namespace AGVControl
return true;
}
else
{
{
log.Error("AddLinePlace 失败 节点" + nodeName + "不存在");
return false;
}
......@@ -332,7 +341,7 @@ namespace AGVControl
/// <summary>
/// 当前任务文本,(从小车获取)
/// </summary>
public string MissionText { private set; get; }
public string MissionText { set; get; }
/// <summary>
/// 下一个地点
/// </summary>
......@@ -355,6 +364,15 @@ namespace AGVControl
/// 临时待机位,用于执行一次
/// </summary>
//public bool StandbyTemp { set; get; }
public struct DockingStru
{
public DateTime startTime;
public bool IsDocking;
}
/// <summary>
/// 停靠信息
/// </summary>
public DockingStru DockingInfo;
public Agv_Info(string id, string name, string ip, string authorization, bool isUse)
{
......@@ -368,11 +386,13 @@ namespace AGVControl
Place = "";
TaskSend = "";
NextPlace = "";
DockingInfo.IsDocking = false;
DockingInfo.startTime = DateTime.Now;
}
public bool SetState(int stateID, string stateText, int battery, string missionText)
{
bool isChange=false;
bool isChange = false;
if (!StateID.Equals(stateID) || !StateText.Equals(stateText) || !Battery.Equals(battery) || !MissionText.Equals(missionText))
isChange = true;
StateID = stateID;
......@@ -417,7 +437,7 @@ namespace AGVControl
}
else
{
s.AddRange(new List<string> { "" ,"","",""});
s.AddRange(new List<string> { "", "", "", "" });
}
s.Add(IsCon.ToString());
s.Add(Battery + "%");
......@@ -426,7 +446,7 @@ namespace AGVControl
return s.ToArray();
}
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
using AGVControl;
namespace BLL
{
public class ConfigAppSettings
{
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.LogInfo("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.log.Error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.log.Info("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
Common.log.Error( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
Common.log.Error( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
Common.log.Error( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
......@@ -60,6 +60,38 @@ namespace BLL
bool change = false;
if (rtn) change = Common.agvInfo[i].SetState(stateID, stateText, battery, mission_text);
//上报异常
if (Common.agvInfo[i].MissionText != mission_text)
{
Common.agvInfo[i].MissionText = mission_text;
if (mission_text.Equals("停靠") || mission_text.ToLower().Equals("DOCKING"))
{
Common.agvInfo[i].DockingInfo.startTime = DateTime.Now;
Common.agvInfo[i].DockingInfo.IsDocking = true;
}
}
bool isAlarm = false;
List<AlarmMsg> msglist = new List<AlarmMsg>();
if (Common.agvInfo[i].DockingInfo.IsDocking && (DateTime.Now - Common.agvInfo[i].DockingInfo.startTime).TotalMinutes.Equals(2))
{
isAlarm = true;
Common.agvInfo[i].DockingInfo.IsDocking = false;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv.Docking", mission_text));
}
if (battery <= 10)
{
isAlarm = true;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv.battery", battery.ToString()));
}
if (stateText.Equals("Error") || stateText.Equals("EmergencyStop"))
{
isAlarm = true;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv.Error.EmergencyStop", "agv状态" + stateText));
}
if (isAlarm)
BLL.AGVManager.updateDeviceAlarmMsg(msglist);
//获取地点任务状态
Thread.Sleep(50);
rtn = Common.mir.Get_Register(Common.agvInfo[i], REG_STATUS, out int regValue);
......@@ -99,8 +131,7 @@ namespace BLL
{
while (loop)
{
Thread.Sleep(1000);
Thread.Sleep(1000);
for (int i = 0; i < Common.agvInfo.Count; i++)
{
if (!loop) break;
......@@ -238,7 +269,7 @@ namespace BLL
for (int i = 0; i < Common.linePlace.Count; i++)
{
string name = Common.linePlace[i];
index = Common.nodeInfo.FindIndex(s => s.Name.Equals(name) && s.Action == ClientAction.NeedLeave && s.IsUse);
index = Common.nodeInfo.FindIndex(s => s.Name.Equals(name) && s.IsUse);
if (index > -1)
{
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Move" + name]);
......@@ -470,10 +501,10 @@ namespace BLL
if (idx == -1) return false;
bool rtn = true;//FindA6Destination(Common.nodeInfo[idx].RFID, out string dest);
string dest = "E1";
string dest = "E2";
if (!rtn) return false;
idx = Common.nodeInfo.FindIndex(s => s.Name.Equals(dest) && s.Action == ClientAction.NeedEnter && s.IsUse);
idx = Common.nodeInfo.FindIndex(s => s.Name.Equals(dest)&& s.IsUse);
if (idx == -1)
{
return false;
......
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
using BLL;
using AGVControl;
namespace BLL
{
public class HttpHelper
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
//public static bool PingURLIP(string url, int ms=100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
//public static Operation Post(string url, Operation operation, bool simulate)
//{
// try
// {
// ////如果Op=0或者Op=5,先拼Ip,不通不发送
// //if (operation.op < 0 || operation.op.Equals(5))
// //{
// // if (PingURLIP(url, 100).Equals(false))
// // {
// // return null;
// // }
// //}
// if (simulate)
// {//模拟服务器返回
// operation.status = 200;
// operation.data.Clear();
// operation.data.Add("posId", "A001");
// string pos = "D100-111#D102-222#D104-333";
// operation.data.Add("pos", pos);
// if (operation.op == 1 || operation.op == 2)
// {//入库或出库
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error("模拟HTTP服务器返回出库入库信息:" + json);
// return operation;
// }
// }
// else
// {
// string json = "";
// try
// {
// json = JsonHelper.SerializeObject(operation);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.SerializeObject(operation) 出错【operation.op=" + operation.op + "】" + ex);
// }
// string result = Post(url, json);
// if (!string.IsNullOrEmpty(result))
// {
// try
// {
// return JsonHelper.DeserializeJsonToObject<Operation>(result);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.DeserializeJsonToObject 出错【result=" + result + "】" + ex);
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
// }
// return null;
//}
public static string LastServerMsg = "";
public static string Post(string url, string paramData, Encoding encoding)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new MyWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
Common.log.Error("POST ERROR:" + e.ToString());
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
LastServerMsg = DateTime.Now.ToLongTimeString() + " URL:" + url + "\r\n"
+ "发送:" + paramData + "\r\n"
+ "接收:" + result + "\r\n"
;
Common.LogInfo(LastServerMsg);
return result;
}
//public static string Get(string url)
//{
// return Get(url, Encoding.UTF8);
//}
//public static string Get(string url, Encoding encoding)
//{
// try
// {
// LogUtil.info("HTTP GET FROM: " + url);
// var wc = new WebClient { Encoding = encoding };
// var readStream = wc.OpenRead(url);
// using (var sr = new StreamReader(readStream, encoding))
// {
// var result = sr.ReadToEnd();
// LogUtil.info("receive << " + result);
// return result;
// }
// }
// catch (Exception e)
// {
// LogUtil.error("HTTP GET ERROR:" + e.Message, 2);
// }
// return "";
//}
}
}
\ No newline at end of file
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace BLL
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
......@@ -28,7 +28,7 @@ namespace BLL
// string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
// string json = HttpGet(url, info.IP, info.Authorization);
// //log.OutInfo("URL: " + url+"\n"+"Return: " + json);
// //LogInfo("URL: " + url+"\n"+"Return: " + json);
// if (string.IsNullOrWhiteSpace(json)) return false;
// JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -68,7 +68,7 @@ namespace BLL
// string url = "http://" + info.IP + "/api/v2.0.0/io_modules/" + info.IOID + "/status";
// string json = HttpGet(url, info.IP, info.Authorization);
// //log.OutInfo("URL: " + url + "\n" + "Return: " + json);
// //LogInfo("URL: " + url + "\n" + "Return: " + json);
// if (string.IsNullOrWhiteSpace(json)) return false;
// JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -482,7 +482,7 @@ namespace BLL
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
Common.LogInfo("Ping " + ip + " 请求没有响应");
Common.LogInfo("Ping " + ip + " 请求没有响应",false);
return false;
}
return true;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace BLL
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
......@@ -54,11 +54,13 @@ namespace AGVControl
{
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Server_NodeOnline(int nodeIndex)
{
Invoke(new Action(() => { DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = Common.nodeInfo[nodeIndex].Online ? Color.Black : Color.Red; }));
System.GC.Collect();
}
private void Control_AgvChanged(int agvIndex)
......@@ -67,11 +69,13 @@ namespace AGVControl
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
}));
System.GC.Collect();
}
private void Control_AgvOnline(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].IsCon ? Color.Black : Color.Red; }));
System.GC.Collect();
}
private void ItemShow_Click(object sender, EventArgs e)
......
......@@ -24,7 +24,8 @@
</log4net>
<appSettings>
<add key="ITS" value="http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIGetBoxDestInfo?boxRFID=" />
<add key="WebService" value="http://127.0.0.1/Webservice/AGVService/"/>
<add key="WebService" value="http://10.85.199.1/Webservice/AGVService/"/>
<add key="http.server" value="http://10.85.199.25/myproject/" />
<add key="FLEET" value="10.85.199.3"/>
<!--<add key="LocalIP" value="192.168.103.12"/>
<add key="AutoCharge" value="false"/>
......
[2020-06-24 15:50:36,271][1]INFO =====程序开始=====
[2020-06-24 15:50:41,870][1]DEBUG HttpGet URL: http://192.168.12.20/api/v2.0.0/registers/20?whitelist=value Return:
[2020-06-24 15:50:41,871][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-06-24 15:50:46,943][1]DEBUG HttpGet URL: http://10.85.199.56/api/v2.0.0/registers/20?whitelist=value Return:
[2020-06-24 15:50:46,943][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-06-24 15:50:52,015][1]DEBUG HttpGet URL: http://10.85.199.57/api/v2.0.0/registers/20?whitelist=value Return:
[2020-06-24 15:50:52,015][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-06-24 15:50:57,088][1]DEBUG HttpGet URL: http://10.85.199.58/api/v2.0.0/registers/20?whitelist=value Return:
[2020-06-24 15:50:57,088][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-06-24 15:50:57,102][1]INFO Server Start
[2020-06-24 15:50:58,155][1]ERROR Open
System.ServiceModel.AddressAccessDeniedException: HTTP 无法注册 URL http://+:80/Webservice/AGVService/。进程不具有此命名空间的访问权限(有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkId=70353)。 ---> System.Net.HttpListenerException: 拒绝访问。
在 System.Net.HttpListener.AddAllPrefixes()
在 System.Net.HttpListener.Start()
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- 内部异常堆栈跟踪的结尾 ---
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
在 System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
在 System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
在 System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open()
在 BLL.WebService.Open(String url) 位置 C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\BLL\WebService.cs:行号 81
[2020-06-24 15:51:00,061][7]INFO Ping 192.168.12.20 请求没有响应
[2020-06-24 15:51:02,062][7]INFO Ping 10.85.199.56 请求没有响应
[2020-06-24 15:51:04,061][7]INFO Ping 10.85.199.57 请求没有响应
[2020-06-24 15:51:06,062][7]INFO Ping 10.85.199.58 请求没有响应
[2020-07-01 15:17:57,270][1]INFO =====程序开始=====
[2020-07-01 15:18:02,937][1]DEBUG HttpGet URL: http://10.85.199.71/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:18:02,937][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:18:08,008][1]DEBUG HttpGet URL: http://10.85.199.72/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:18:08,008][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:18:13,080][1]DEBUG HttpGet URL: http://10.85.199.73/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:18:13,081][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:18:18,152][1]DEBUG HttpGet URL: http://10.85.199.74/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:18:18,152][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:18:18,166][1]INFO Server Start
[2020-07-01 15:18:27,967][1]ERROR Open
System.ServiceModel.AddressAccessDeniedException: HTTP 无法注册 URL http://+:80/Webservice/AGVService/。进程不具有此命名空间的访问权限(有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkId=70353)。 ---> System.Net.HttpListenerException: 拒绝访问。
在 System.Net.HttpListener.AddAllPrefixes()
在 System.Net.HttpListener.Start()
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- 内部异常堆栈跟踪的结尾 ---
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
在 System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
在 System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
在 System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open()
在 BLL.WebService.Open(String url) 位置 C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\BLL\WebService.cs:行号 85
[2020-07-01 15:18:28,454][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:18:52,567][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:18:53,730][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:18:55,898][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:18:59,901][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:19:04,477][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:19:05,366][1]INFO 非法的IP地址
[2020-07-01 15:19:06,185][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:19:07,796][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:20:21,519][1]INFO =====程序开始=====
[2020-07-01 15:20:26,898][1]DEBUG HttpGet URL: http://10.85.199.71/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:20:26,899][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:20:31,971][1]DEBUG HttpGet URL: http://10.85.199.72/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:20:31,971][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:20:37,043][1]DEBUG HttpGet URL: http://10.85.199.73/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:20:37,043][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:20:42,114][1]DEBUG HttpGet URL: http://10.85.199.74/api/v2.0.0/registers/20?whitelist=value Return:
[2020-07-01 15:20:42,114][1]ERROR CheckAGVMissionState 获取PLC20失败
[2020-07-01 15:20:42,130][1]INFO Server Start
[2020-07-01 15:20:43,518][1]ERROR Open
System.ServiceModel.AddressAccessDeniedException: HTTP 无法注册 URL http://+:80/Webservice/AGVService/。进程不具有此命名空间的访问权限(有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkId=70353)。 ---> System.Net.HttpListenerException: 拒绝访问。
在 System.Net.HttpListener.AddAllPrefixes()
在 System.Net.HttpListener.Start()
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- 内部异常堆栈跟踪的结尾 ---
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
在 System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
在 System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
在 System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open()
在 BLL.WebService.Open(String url) 位置 C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\BLL\WebService.cs:行号 85
[2020-07-01 15:20:44,062][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:20:57,156][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:21:08,635][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:21:10,070][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:21:17,748][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:21:23,544][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:21:26,315][1]INFO E1 Ping 10.85.199.42 请求没有响应
[2020-07-01 15:21:27,872][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:21:34,744][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:21:36,669][1]INFO E2 Ping 10.85.199.90 请求没有响应
[2020-07-01 15:21:37,670][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:21:37,749][1]INFO E3 Ping 10.85.199.91 请求没有响应
[2020-07-01 15:21:37,749][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:21:39,671][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:21:39,696][1]INFO E4 Ping 10.85.199.92 请求没有响应
[2020-07-01 15:21:40,748][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:21:40,754][1]INFO E5 Ping 10.85.199.93 请求没有响应
[2020-07-01 15:21:42,670][1]INFO E6 Ping 10.85.199.94 请求没有响应
[2020-07-01 15:21:43,669][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:21:43,758][1]INFO E8 Ping 10.85.199.95 请求没有响应
[2020-07-01 15:21:43,763][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:21:45,670][1]INFO E9 Ping 10.85.199.180 请求没有响应
[2020-07-01 15:21:45,677][1]INFO Ping 10.85.199.73 请求没有响应
[2020-07-01 15:21:46,767][1]INFO E10 Ping 10.85.199.181 请求没有响应
[2020-07-01 15:21:46,773][1]INFO Ping 10.85.199.74 请求没有响应
[2020-07-01 15:21:48,669][1]INFO E11 Ping 10.85.199.182 请求没有响应
[2020-07-01 15:21:49,670][1]INFO Ping 10.85.199.71 请求没有响应
[2020-07-01 15:21:49,783][1]INFO E12 Ping 10.85.199.183 请求没有响应
[2020-07-01 15:21:49,794][1]INFO Ping 10.85.199.72 请求没有响应
[2020-07-01 15:34:39,078][1]INFO =====程序开始=====
[2020-07-01 15:34:44,529][1]ERROR CheckAGVMissionState 获取PLC20失败
......@@ -25,10 +25,11 @@ C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\bin\Debug
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\bin\Debug\AGVControl-ProductionLine.pdb
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\bin\Debug\RestSharp.dll
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\bin\Debug\RestSharp.xml
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csprojAssemblyReference.cache
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl.FrmMain.resources
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl.Properties.Resources.resources
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csproj.GenerateResource.cache
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csproj.CopyComplete
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.exe
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.pdb
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csprojAssemblyReference.cache
C:\ZDL\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\bin\Debug\Newtonsoft.Json.dll
......@@ -22,7 +22,7 @@ namespace AsaPL
private readonly log4net.ILog LOG;
private readonly string IP; //远程IP地址
private const int PORT = 12001; //端口
private const int PORT = 9500; //端口
private const int SEND_INTERVAL = 2000; //客户端发送所有节点后的间隔
/// <summary>
......@@ -77,7 +77,7 @@ namespace AsaPL
tRecon.Start();
tListen.Start();
tSend.Start();
LogInfo("Connect");
LOG.Info("Connect");
}
/// <summary>
......@@ -93,7 +93,7 @@ namespace AsaPL
_client.Close();
_client = null;
}
LogInfo("Close");
LOG.Info("Close");
}
/// <summary>
......@@ -118,7 +118,7 @@ namespace AsaPL
_node[idx].Action = action;
_node[idx].Level = level;
}
LogInfo("SetStatus " + _node[idx].ToText());
LOG.Info("SetStatus " + _node[idx].ToText());
}
/// <summary>
......@@ -127,7 +127,7 @@ namespace AsaPL
/// <param name="name"></param>
public void MayEnter(string name)
{
LogInfo(name + " MayEnter");
LOG.Info(name + " MayEnter");
ClientNode node = new ClientNode(name, "", ClientAction.MayEnter, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
......@@ -139,7 +139,7 @@ namespace AsaPL
/// <param name="name"></param>
public void MayLeave(string name)
{
LogInfo(name + " MayLeave");
LOG.Info(name + " MayLeave");
ClientNode node = new ClientNode(name, "", ClientAction.MayLeave, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
......@@ -151,7 +151,7 @@ namespace AsaPL
/// <param name="name"></param>
public void FinishEnter(string name)
{
LogInfo(name + " FinishEnter");
LOG.Info(name + " FinishEnter");
ClientNode node = new ClientNode(name, "", ClientAction.FinishEnter, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
......@@ -163,7 +163,7 @@ namespace AsaPL
/// <param name="name"></param>
public void FinishLeave(string name)
{
LogInfo(name + " FinishLeave");
LOG.Info(name + " FinishLeave");
ClientNode node = new ClientNode(name, "", ClientAction.FinishLeave, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
......@@ -184,11 +184,11 @@ namespace AsaPL
if (IsConn)
{
countRecon = 0;
LogInfo("Server connection successful");
LOG.Info("Server connection successful");
}
else
{
LogInfo("Server connection failed " + ++countRecon + " times");
LOG.Info("Server connection failed " + ++countRecon + " times");
}
}
Thread.Sleep(1000);
......@@ -202,7 +202,7 @@ namespace AsaPL
{
try
{
LogInfo("Connect " + IP + ":" + PORT);
LOG.Info("Connect " + IP + ":" + PORT);
if (CheckIP(IP))
{
_client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
......@@ -212,7 +212,7 @@ namespace AsaPL
_client.Connect(IPAddress.Parse(IP), PORT);
if (!_loop) return;
IsConn = true;
LogInfo("Connect OK");
LOG.Info("Connect OK");
}
}
catch (Exception ex)
......@@ -246,11 +246,11 @@ namespace AsaPL
ClientNode node = Decode(_buffer);
if (node == null)
{
LogInfo("Command decoding failed: " + HexBuff(_buffer));
LOG.Info("Command decoding failed: " + HexBuff(_buffer));
}
else
{
LogInfo("From server: " + node.ToText());
LOG.Info("From server: " + node.ToText());
Resolve(node);
}
}
......@@ -273,12 +273,12 @@ namespace AsaPL
{
if (result.Action == ClientAction.ReadyEnter)
{
LogInfo("Trigger ReadyEnter Event");
LOG.Info("Trigger ReadyEnter Event");
ReadyEnter?.Invoke(result.Name);
}
else if (result.Action == ClientAction.ReadyLeave)
{
LogInfo("Trigger ReadyLeave Event");
LOG.Info("Trigger ReadyLeave Event");
ReadyLeave?.Invoke(result.Name);
}
}
......@@ -324,7 +324,7 @@ namespace AsaPL
{
if (!IsConn)
{
LogInfo("服务器没有连接");
LOG.Info("服务器没有连接");
return false;
}
......@@ -418,7 +418,7 @@ namespace AsaPL
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
LogInfo("Illegal IP address " + ip);
LOG.Info("Illegal IP address " + ip);
return false;
}
......@@ -430,7 +430,7 @@ namespace AsaPL
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
LogInfo("Ping " + ip + " request timeout");
LOG.Info("Ping " + ip + " request timeout");
return false;
}
return true;
......
......@@ -25,7 +25,7 @@ namespace AgvClientTest
comboBox1.Items.Add((AsaPL.ClientAction)i);
comboBox1.SelectedIndex = 0;
comboBox2.SelectedIndex = 0;
client = new AsaPL.AgvClient("127.0.0.1");
client = new AsaPL.AgvClient("10.85.199.1");
client.SetStatus("E1", "C6", AsaPL.ClientAction.None);
client.Connect();
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!