Commit ed1d2e2f 张东亮

添加位置误差

1 个父辈 0c68e781
...@@ -472,6 +472,9 @@ namespace OnlineStore.AssemblyLine ...@@ -472,6 +472,9 @@ namespace OnlineStore.AssemblyLine
SetMenuS(复位RToolStripMenuItem, false); SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(停止TToolStripMenuItem, false); SetMenuS(停止TToolStripMenuItem, false);
} }
textBox1.Text = $"从AGV获取的信息:{LineManager.RobotInfo}\r\n" +
$"上报的信息:{LineManager.UploadInfo}\r\n" +
$"位置信息:{LineManager.posInfo}";
} }
catch { } catch { }
finally finally
......
...@@ -232,11 +232,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -232,11 +232,16 @@ namespace OnlineStore.DeviceLibrary
return false; return false;
} }
static Dictionary<string, List<Point>> AgvPoints = new Dictionary<string, List<Point>>(); static Dictionary<string, List<Point>> AgvPoints = new Dictionary<string, List<Point>>();
static string posInfo = ""; public static string posInfo = "";
public static string RobotInfo = "";
public static string UploadInfo = "";
public static void UploadAGVStatus(RobotStates robotStates) public static void UploadAGVStatus(RobotStates robotStates)
{ {
try try
{ {
RobotInfo = JsonHelper.SerializeObject(robotStates);
int errorX = ConfigHelper.Config.Get("errorPosX", 1000);
int errorY = ConfigHelper.Config.Get("errorPosY", 1000);
if (robotStates != null && robotStates.robots != null) if (robotStates != null && robotStates.robots != null)
{ {
List<AgvStatus> agvs = new List<AgvStatus>(); List<AgvStatus> agvs = new List<AgvStatus>();
...@@ -249,7 +254,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -249,7 +254,8 @@ namespace OnlineStore.DeviceLibrary
status.type = j + 1; status.type = j + 1;
foreach (var key in AgvPoints.Keys) foreach (var key in AgvPoints.Keys)
{ {
var find = AgvPoints[key].Find(s => s.X.Equals(item.positionX) && s.Y.Equals(item.positionY)); var find = AgvPoints[key].Find(s => (s.X - errorX <= item.positionX && s.X + errorX >= item.positionX)
&& (s.Y - errorY <= item.positionY && s.Y + errorY >= item.positionY));
if (find != null && find.X != 0 && find.Y != 0) if (find != null && find.X != 0 && find.Y != 0)
{ {
status.loc = key; status.loc = key;
...@@ -262,9 +268,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -262,9 +268,10 @@ namespace OnlineStore.DeviceLibrary
} }
agvs.Add(status); agvs.Add(status);
} }
UploadInfo = JsonHelper.SerializeObject(agvs);
SServerManager.UpdateAgvStatus(agvs); SServerManager.UpdateAgvStatus(agvs);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
robotStates.robots.ForEach(s => sb.Append($"{s.robotCode} 当前位置:{s.positionX},{s.positionY}")); robotStates.robots.ForEach(s => sb.Append($" {s.robotCode} [{s.energyLevel}]当前位置:{s.positionX},{s.positionY};"));
string curPosInfo = sb.ToString(); string curPosInfo = sb.ToString();
if (!posInfo.Equals(curPosInfo)) if (!posInfo.Equals(curPosInfo))
{ {
......
...@@ -424,7 +424,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -424,7 +424,7 @@ namespace OnlineStore.DeviceLibrary
/// <param name="status">状态</param> /// <param name="status">状态</param>
/// <param name="locInfo">位置</param> /// <param name="locInfo">位置</param>
/// <returns></returns> /// <returns></returns>
public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo ,out bool canRemove,out string msg) public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo, out bool canRemove, out string msg)
{ {
msg = ""; msg = "";
canRemove = false; canRemove = false;
...@@ -448,7 +448,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -448,7 +448,7 @@ namespace OnlineStore.DeviceLibrary
string server = GetAddr(Addr_UpdateLocInfo, paramMap); string server = GetAddr(Addr_UpdateLocInfo, paramMap);
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server); string resultStr = HttpHelper.Get(server);
msg=("UpdateTrayLoc " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】"); msg = ("UpdateTrayLoc " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
// 返回: { "code": 0, "msg":"ok", "data":""} // 返回: { "code": 0, "msg":"ok", "data":""}
ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr); ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
if (serverResult == null) if (serverResult == null)
...@@ -531,7 +531,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -531,7 +531,7 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
if(agvStatuses==null || agvStatuses.Count==0) if (agvStatuses == null || agvStatuses.Count == 0)
{ {
LogUtil.error($"UpdateAgvStatus 无信息"); LogUtil.error($"UpdateAgvStatus 无信息");
return false; return false;
...@@ -542,10 +542,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -542,10 +542,14 @@ namespace OnlineStore.DeviceLibrary
string content = JsonHelper.SerializeObject(agvStatuses); string content = JsonHelper.SerializeObject(agvStatuses);
string json = HttpHelper.Post(server, content); string json = HttpHelper.Post(server, content);
ServerData rtnData = JsonHelper.DeserializeJsonToObject<ServerData>(json); ServerData rtnData = JsonHelper.DeserializeJsonToObject<ServerData>(json);
if(!agvStr.Equals(json)) if (string.IsNullOrEmpty(json))
{
LogUtil.error($"UpdateAgvStatus【{content}】【{json}】");
}
else if (!agvStr.Equals(content))
{ {
LogUtil.info($"UpdateAgvStatus【{content}】【{json}】"); LogUtil.info($"UpdateAgvStatus【{content}】【{json}】");
agvStr = json; agvStr = content;
} }
if (rtnData != null && rtnData.code == 0) if (rtnData != null && rtnData.code == 0)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!