Commit f42804a9 张东亮

包装仓出库搬运逻辑更新(与服务器通讯判断出库任务是否完成)

1 个父辈 b0593d6e
{
"ExpandedNodes": [
""
"",
"\\AGVControl",
"\\AGVControl\\BLL"
],
"SelectedNode": "\\AGVControl.sln",
"PreviewInSolutionExplorer": false
......
此文件类型无法预览
......@@ -5,7 +5,7 @@
</startup>
<appSettings>
<!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" />
<add key="http.server" value="http://10.85.199.25/myproject/" />
<add key="LocalIP" value="192.168.103.12"/>
<add key="FLEET" value="10.85.199.3"/>
<add key="AutoCharge" value="false"/>
......
......@@ -4,14 +4,89 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AGVControl;
using System.Web.Script.Serialization;
namespace BLL
{
public class AGVManager
{
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
/// <summary>
/// 小车从B区域离开前检查出库任务是否完成
/// </summary>
/// <param name="rfid"></param>
/// <returns>true:可以离开</returns>
public static bool LeaveCheck(Agv_Info agv, out int taskCount)
{
taskCount = 0;
try
{
//Common.log.OutInfo("URL:" + Common.webService["URL"]);
string url = ConfigAppSettings.GetValue(Setting_Init.http_server) + "rest/api/qisda/device/getShelfLockInfo?rfid=" + agv.RFID;
Common.log.OutInfo("URL: " + url);
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.log.OutInfo("Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return true; //可以离开
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(json);
if (serverResult == null)
{
Common.log.OutInfo(" 没有收到服务器反馈");
return true;
}
if (serverResult.code != 0) return true;
if (serverResult.data.Count == 0) //该料架出库完成
{
Common.log.OutInfo(agv.Name+" 料架【" + agv.RFID + "】 无剩余出库任务,data.Count="+serverResult.data.Count.ToString());
return true;
}
else //该料架的出库任务未完成
{
// foreach (ShelfLockData item in serverResult.data)
// {
taskCount = serverResult.data[0].taskCount;
Common.log.OutInfo(agv.Name + " [RFID=" + serverResult.data[0].rfid + "] [taskCount=" + serverResult.data[0].taskCount + "]");
// }
return false;
}
//if (!obj.TryGetValue("data", out object value)) return true; //可以离开
//// {"code":0,"msg":"ok","data":["":]}
//if (value.Equals(null))
//{
// return true;
//}
//Dictionary<string, object> dic = (Dictionary<string, object>)value;
//if (dic.TryGetValue("taskCount", out object count))
//{
// if (count.ToString() == "0")
// {
// return true;
// }
// else
// {
// int.TryParse(count.ToString(), out taskCount);
// return false;
// }
//}
//else
//{
// return true;
//}
}
catch (Exception ex)
{
Common.log.OutError(ex);
return true;
}
}
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string rfid, out List<string> shelfLockNodeNames)
{
string msg = "";
......@@ -26,12 +101,12 @@ namespace BLL
string resultStr = HttpHelper.Post(server, "");
Common.log.OutInfo( "料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
Common.log.OutInfo("料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
if (serverResult == null)
{
msg = " 没有收到服务器反馈";
msg = " 没有收到服务器反馈";
Common.log.OutInfo(msg);
return false;
}
......@@ -46,8 +121,8 @@ namespace BLL
{
shelfLockNodeNames = new List<string>();
foreach (ShelfLockData item in serverResult.data)
{
if(!shelfLockNodeNames.Contains(Common.webService[item.cid]))
{
if (!shelfLockNodeNames.Contains(Common.webService[item.cid]))
{
shelfLockNodeNames.Add(Common.webService[item.cid]);
Common.log.OutInfo("锁定的CID=" + item.cid + ";节点名称=" + Common.webService[item.cid]);
......@@ -59,7 +134,7 @@ namespace BLL
}
catch (Exception ex)
{
Common.log.OutInfo( ex.Message);
Common.log.OutInfo(ex.Message);
}
return false;
}
......@@ -119,6 +194,10 @@ namespace BLL
/// 库位中料盘的锁定库位
/// </summary>
public string lockPos { get; set; }
/// <summary>
/// 料架出库的剩余数量
/// </summary>
public int taskCount { get; set; }
}
}
......@@ -37,10 +37,9 @@ namespace BLL
{
guid = null;
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
log.OutInfo("URL: " + url);
string json = HttpGet(url, info.IP, info.Authorization);
log.OutInfo("Return: " + json);
log.OutInfo("URL: " + url+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -78,10 +77,9 @@ namespace BLL
input = null;
output = null;
string url = "http://" + info.IP + "/api/v2.0.0/io_modules/" + info.IOID + "/status";
log.OutInfo("URL: " + url);
string json = HttpGet(url, info.IP, info.Authorization);
log.OutInfo("Return: " + json);
log.OutInfo("URL: " + url + "\n" + "Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -122,10 +120,9 @@ namespace BLL
{
regValue = -1;
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg + "?whitelist=value";
log.OutInfo("URL: " + url);
string json = HttpGet(url, info.IP, info.Authorization);
log.OutInfo("Return: " + json);
log.OutInfo("URL: " + url + "\n" + "Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -158,10 +155,9 @@ namespace BLL
{
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg;
string body = "{\"value\": " + regValue + "}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPost(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -197,10 +193,9 @@ namespace BLL
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
string body = "{\"mission_id\":\"" + mission_id + "\"}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPost(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -236,10 +231,9 @@ namespace BLL
string ip = AGVControl.Common.appConfig.AppSettings.Settings["FLEET"].Value;
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPost(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -272,10 +266,9 @@ namespace BLL
mission = null;
string url = "http://" + info.IP + "/api/v2.0.0/missions/search?whitelist=guid,name";
string body = "{\"filters\" :[]}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPost(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -311,10 +304,9 @@ namespace BLL
mission = null;
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue/search";
string body = "{\"filters\" : [{\"fieldname\": \"state\", \"operator\": \"IN\", \"value\": [\"Pending\", \"Executing\"]}]}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPost(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -357,9 +349,8 @@ namespace BLL
try
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
log.OutInfo(string.Format("URL: {0}", url));
HttpDel(url, info.IP, info.Authorization);
log.OutInfo("Return DEL");
log.OutInfo(string.Format("URL: {0}", url)+"\n"+"Return DEL");
}
catch (Exception ex)
{
......@@ -375,18 +366,18 @@ namespace BLL
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <returns></returns>
public bool Get_State(AGVControl.Agv_Info info, out int stateID, out string stateText, out int battery)
public bool Get_State(AGVControl.Agv_Info info, out int stateID, out string stateText, out int battery,out string mission_text)
{
try
{
stateID = -1;
stateText = "";
battery = 0;
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage";
log.OutInfo("URL: " + url);
mission_text = "";
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text";
string json = HttpGet(url, info.IP, info.Authorization);
log.OutInfo("Return: " + json);
log.OutInfo("URL: " + url+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -395,6 +386,7 @@ namespace BLL
stateID = Convert.ToInt32(dic["state_id"].ToString());
stateText = dic["state_text"].ToString();
mission_text = dic["mission_text"].ToString();
string s = dic["battery_percentage"].ToString();
float f = Convert.ToSingle(s);
battery = Convert.ToInt32(f);
......@@ -405,6 +397,7 @@ namespace BLL
stateID = -1;
stateText = "";
battery = 0;
mission_text = "";
log.OutError(ex);
return false;
}
......@@ -421,10 +414,9 @@ namespace BLL
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 3}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPut(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -455,10 +447,9 @@ namespace BLL
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 4}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPut(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
......@@ -489,10 +480,9 @@ namespace BLL
{
string url = "http://" + info.IP + "/api/v2.0.0/status";
string body = "{\"clear_error\": true}";
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body));
string json = HttpPut(url, info.IP, info.Authorization, body);
log.OutInfo("Return: " + json);
log.OutInfo(string.Format("URL: {0}; Body: {1}", url, body)+"\n"+"Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
return true;
......@@ -549,6 +539,7 @@ namespace BLL
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
//int n = 0;
......
......@@ -317,6 +317,10 @@ namespace AGVControl
/// </summary>
public int Battery { set; get; }
/// <summary>
/// 任务文本
/// </summary>
public string Mission_text { set; get; }
/// <summary>
/// 任务的状态
/// </summary>
public Mission_Status MissionStatus { set; get; }
......@@ -378,6 +382,16 @@ namespace AGVControl
return s;
}
public string[] ToMission()
{
//AGV名称,IP,AGV状态,任务状态,地点,后续任务,在线,电量,调用,清除缓存
string[] s = new string[2];
s[0] = Name;
s[1] = Mission_text;
return s;
}
/// <summary>
/// 脱机
/// </summary>
......@@ -417,9 +431,9 @@ namespace AGVControl
/// </summary>
public int chargeMin;
/// <summary>
/// 两车充电间隔时间(ms)
/// 两车充电间隔时间(ms)
/// </summary>
public int chargeInterval;
public long chargeInterval;
private bool _autoCharge;
......
......@@ -29,6 +29,7 @@ namespace AGVControl
for (int i = 0; i < Common.agvInfo.Count; i++)
{
n = DgvAgv.Rows.Add(Common.agvInfo[i].ToRow());
dgvMission.Rows.Add(Common.agvInfo[i].ToMission());
DgvAgv.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (!Common.agvInfo[i].IsCon)
DgvAgv.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
......@@ -49,7 +50,32 @@ namespace AGVControl
private void Server_NodeChanged(int nodeIndex)
{
Invoke(new Action(() => { DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow()); }));
Invoke(new Action(() =>
{
List<string> markLst = new List<string>();
foreach (var mark in Common.control.Marks)
{
int count = 0;
foreach (var node in Common.nodeInfo)
{
if (mark.Equals(node.Mark))
count++;
}
if(count ==0)//mark存在标记,但节点任务没有,删除该mark
{
markLst.Add(mark);
}
}
if(markLst.Count!=0)
{
for (int i = 0; i < markLst.Count; i++)
{
Common.control.Marks.Remove(markLst[i]);
}
}
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
}
private void Server_NodeOnline(int nodeIndex)
......@@ -59,7 +85,11 @@ namespace AGVControl
private void Control_AgvChanged(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow()); }));
Invoke(new Action(() =>
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
dgvMission.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToMission());
}));
}
private void Control_AgvOnline(int agvIndex)
......@@ -191,9 +221,7 @@ namespace AGVControl
//添加Init任务
Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission["Init"]);
Common.mir.State_Ready(Common.agvInfo[idx]);
}
}
}
}
......
......@@ -174,6 +174,12 @@
<metadata name="Column15.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column20.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column21.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" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
......
......@@ -5,7 +5,7 @@
</startup>
<appSettings>
<!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" />
<add key="http.server" value="http://10.85.199.25/myproject/" />
<add key="LocalIP" value="192.168.103.12"/>
<add key="FLEET" value="10.85.199.3"/>
<add key="AutoCharge" value="false"/>
......
......@@ -29,12 +29,12 @@ MoveC5,34ec2f1f-2ae8-11ea-a6cf-94c691a734f1
MoveC6,52f37677-2f96-11ea-9ee4-94c691a734f1
MoveC7,bcd0e389-2ab7-11ea-a6cf-94c691a734f1
MoveC8,8a48301d-2624-11ea-a30e-94c691a73861
MoveD1,
MoveD2,
MoveD1,931f7c6c-a97d-11ea-b91f-94c691a7387d
MoveD2,ae09ca1e-a97f-11ea-b91f-94c691a7387d
Enter,2eadcb87-239a-11ea-8343-94c691a73861
Leave,80943220-239a-11ea-8343-94c691a73861
MoveStandby,4eb9641a-3439-11ea-984a-94c691a734f1
MoveStandbyTemp,25a2aea4-9e5f-11ea-b91f-94c691a7387d
Init,cd51e039-34eb-11ea-b4fe-94c691a734f1
AutoCharge1,9e1b33c0-2886-11ea-a0d6-94c691a734f1
AutoCharge2,d756f63d-2886-11ea-a0d6-94c691a734f1
\ No newline at end of file
AutoCharge2,d756f63d-2886-11ea-a0d6-94c691a734f1
URL,http://10.85.160.25/myproject/rest/api/qisda/device/emptyStoragePosCount
packing-19,B1
packing-20,B2
packing-21,B3
packing-22,B4
packing-24,B5
packing-23,B6
\ No newline at end of file
packing-23,B6
......@@ -76,3 +76,18 @@ C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\A
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.CopyComplete
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.exe
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.pdb
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.exe.config
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.exe
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.pdb
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\Newtonsoft.Json.dll
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\RestSharp.dll
C:\ZDL\Gitee\AGVControl\AGVControl\bin\Debug\RestSharp.xml
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\Interop.IWshRuntimeLibrary.dll
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.ResolveComReference.cache
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.FrmMain.resources
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.Properties.Resources.resources
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.GenerateResource.cache
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.CopyComplete
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.exe
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.pdb
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csprojAssemblyReference.cache
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!