Commit 9e138c47 张东亮

添加异常看板

1 个父辈 dbafb8f6
...@@ -61,10 +61,9 @@ namespace BLL ...@@ -61,10 +61,9 @@ namespace BLL
} }
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址 private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string rfid, out List<string> shelfLockNodeNames) public static bool GetShelfLockInfo(string name,string rfid, List<string> shelfLockNodeNames)
{ {
string msg = ""; string msg = "";
shelfLockNodeNames = null;
try try
{ {
Dictionary<string, string> paramMap = new Dictionary<string, string>(); Dictionary<string, string> paramMap = new Dictionary<string, string>();
...@@ -75,25 +74,24 @@ namespace BLL ...@@ -75,25 +74,24 @@ namespace BLL
string resultStr = HttpHelper.Post(server, ""); string resultStr = HttpHelper.Post(server, "");
Common.log.OutInfo("料架锁定状态 " + " 【" + server + "】【" + resultStr + "】"); Common.log.OutInfo("节点【"+name+ "】 料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr); ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
if (serverResult == null) if (serverResult == null)
{ {
msg = " 没有收到服务器反馈"; msg = "节点【" + name + "】没有收到服务器反馈";
Common.log.OutInfo(msg); Common.log.OutInfo(msg);
return false; return false;
} }
if (serverResult.data.Count == 0) //该料架未锁定 if (serverResult.data.Count == 0) //该料架未锁定
{ {
msg = " 料架【" + rfid + "】 没有锁定库位的料"; msg = "节点【" + name + "】 料架【" + rfid + "】 没有锁定库位的料";
Common.log.OutInfo(msg); Common.log.OutInfo(msg);
return false; return false;
} }
else //该料架存在锁定库位的料 else //该料架存在锁定库位的料
{ {
shelfLockNodeNames = new List<string>();
foreach (ShelfLockData item in serverResult.data) foreach (ShelfLockData item in serverResult.data)
{ {
if (!shelfLockNodeNames.Contains(Common.webService[item.cid])) if (!shelfLockNodeNames.Contains(Common.webService[item.cid]))
...@@ -102,7 +100,7 @@ namespace BLL ...@@ -102,7 +100,7 @@ namespace BLL
Common.log.OutInfo("锁定的CID=" + item.cid + ";节点名称=" + Common.webService[item.cid]); Common.log.OutInfo("锁定的CID=" + item.cid + ";节点名称=" + Common.webService[item.cid]);
} }
} }
Common.log.OutInfo("获取料架上的料仓信息完成"); Common.log.OutInfo("节点【" + name + "】"+rfid+"获取料架上的锁定料仓信息完成");
return true; return true;
} }
} }
...@@ -112,7 +110,43 @@ namespace BLL ...@@ -112,7 +110,43 @@ namespace BLL
} }
return false; return false;
} }
private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/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.log.OutInfo("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.OutError(ex);
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap) private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{ {
string server = ConfigAppSettings.GetValue(Setting_Init.http_server); string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
...@@ -204,4 +238,37 @@ namespace BLL ...@@ -204,4 +238,37 @@ namespace BLL
/// </summary> /// </summary>
public string rfid { get; set; } 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; }
}
} }
...@@ -26,6 +26,7 @@ namespace BLL ...@@ -26,6 +26,7 @@ namespace BLL
{ {
areaC_Index = 0; areaC_Index = 0;
Marks = new List<string>(); Marks = new List<string>();
shelfLockedNodeNames = new List<string>();
} }
public void Start() public void Start()
...@@ -232,8 +233,35 @@ namespace BLL ...@@ -232,8 +233,35 @@ namespace BLL
{ {
Common.agvInfo[i].Mission_text = mission_text; Common.agvInfo[i].Mission_text = mission_text;
change = true; change = true;
if (mission_text.Equals("停靠") || mission_text.ToLower().Equals("DOCKING"))
{
Common.agvInfo[i].DockingInfo.startTime = DateTime.Now;
Common.agvInfo[i].DockingInfo.IsDocking = true;
}
}
log += " " + stateText + " " + mission_text + " " + battery + "%";
//上报异常
bool isAlarm = false;
List<AlarmMsg> msglist = new List<AlarmMsg>();
if (Common.agvInfo[i].DockingInfo.IsDocking && (DateTime.Now - Common.agvInfo[i].DockingInfo.startTime).TotalMinutes.Equals(1))
{
isAlarm = true;
Common.agvInfo[i].DockingInfo.IsDocking = false;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv." + Common.agvInfo[i].Name + ".Docking", mission_text));
}
if (battery <= 10)
{
isAlarm = true;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv." + Common.agvInfo[i].Name + ".battery", "电量 " + battery.ToString() + "%"));
} }
log += " " + stateText +" "+ mission_text+" " + battery + "%"; if (stateText.Equals("Error") || stateText.Equals("EmergencyStop")|| stateText.Equals("Pause"))
{
isAlarm = true;
msglist.Add(new AlarmMsg(Common.agvInfo[i].Name, "agv." + Common.agvInfo[i].Name + ".Error.EmergencyStop", "agv状态 "+stateText));
}
if (isAlarm)
BLL.AGVManager.updateDeviceAlarmMsg(msglist);
} }
else else
{ {
...@@ -411,7 +439,8 @@ namespace BLL ...@@ -411,7 +439,8 @@ namespace BLL
MarkAdd(Common.nodeInfo[nodeIdx].Mark); MarkAdd(Common.nodeInfo[nodeIdx].Mark);
Common.log.OutString("Mark缓存 " + string.Join(",", Marks.ToArray())); Common.log.OutString("Mark缓存 " + string.Join(",", Marks.ToArray()));
log = string.Format("{0} Move {1} {2}", agv.Name, agv.Place, Common.nodeInfo[nodeIdx].Action.ToString()); log = string.Format("{0} Move To {1}[{2}] [{3}]", agv.Name, agv.Place,
Common.nodeInfo[nodeIdx].Action.ToString(), Common.nodeInfo[nodeIdx].Mark);
Common.log.OutInfo(log); Common.log.OutInfo(log);
Common.log.OutTextBox(log); Common.log.OutTextBox(log);
Common.mir.State_Ready(agv); Common.mir.State_Ready(agv);
...@@ -420,7 +449,7 @@ namespace BLL ...@@ -420,7 +449,7 @@ namespace BLL
else else
{ {
agv.TaskSend = false; agv.TaskSend = false;
log = string.Format("{0} Move {1} 失败", agv.Name, agv.Place); log = string.Format("{0} Move To {1} 失败", agv.Name, agv.Place);
//防止上一个任务已执行但返回失败时,删除任务 //防止上一个任务已执行但返回失败时,删除任务
//Common.mir.Del_Mission(agv); //Common.mir.Del_Mission(agv);
Common.log.OutInfo(log); Common.log.OutInfo(log);
...@@ -506,7 +535,7 @@ namespace BLL ...@@ -506,7 +535,7 @@ namespace BLL
if (Common.nodeInfo[node[i]].Mark == "0") if (Common.nodeInfo[node[i]].Mark == "0")
{ {
//获取料架锁定信息 //获取料架锁定信息
AGVManager.GetShelfLockInfo(Common.nodeInfo[node[i]].RFID, out shelfLockedNodeNames); AGVManager.GetShelfLockInfo(Common.nodeInfo[node[i]].Name, Common.nodeInfo[node[i]].RFID,shelfLockedNodeNames);
nodeIdx = node[i]; nodeIdx = node[i];
break; break;
} }
...@@ -694,7 +723,7 @@ namespace BLL ...@@ -694,7 +723,7 @@ namespace BLL
case "C6": case "C6":
case "C8": case "C8":
case "D2": case "D2":
log = string.Format("{0} Ready {1}", agv.Name, agv.Place); log = string.Format("{0} Ready In {1}", agv.Name, agv.Place);
Common.log.OutInfo(log); Common.log.OutInfo(log);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]); //对于小车,料架进入 rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]); //对于小车,料架进入
if (rtn) if (rtn)
...@@ -727,7 +756,7 @@ namespace BLL ...@@ -727,7 +756,7 @@ namespace BLL
case "C5": case "C5":
case "C7": case "C7":
case "D1": case "D1":
log = string.Format("{0} Ready {1}", agv.Name, agv.Place); log = string.Format("{0} Ready In {1}", agv.Name, agv.Place);
Common.log.OutInfo(log); Common.log.OutInfo(log);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]); //对于小车,料架出去 rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]); //对于小车,料架出去
if (rtn) if (rtn)
...@@ -816,7 +845,7 @@ namespace BLL ...@@ -816,7 +845,7 @@ namespace BLL
{ {
if (input[3]) if (input[3])
{ {
log = string.Format("{0} Ready {1}", agv.Name, agv.Place); log = string.Format("{0} Ready In {1}", agv.Name, agv.Place);
Common.log.OutInfo(log); Common.log.OutInfo(log);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]); //对于小车,料架出去 rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]); //对于小车,料架出去
if (rtn) if (rtn)
...@@ -841,7 +870,7 @@ namespace BLL ...@@ -841,7 +870,7 @@ namespace BLL
} }
else else
{ {
log = string.Format("{0} Ready {1}", agv.Name, agv.Place); log = string.Format("{0} Ready In {1}", agv.Name, agv.Place);
Common.log.OutInfo(log); Common.log.OutInfo(log);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]); //对于小车,料架进入 rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]); //对于小车,料架进入
if (rtn) if (rtn)
...@@ -1098,6 +1127,11 @@ namespace BLL ...@@ -1098,6 +1127,11 @@ namespace BLL
} }
} }
/// <summary>
/// 小车进入A1
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
private bool A1Enter(Agv_Info agv) private bool A1Enter(Agv_Info agv)
{ {
string log; string log;
...@@ -1213,6 +1247,11 @@ namespace BLL ...@@ -1213,6 +1247,11 @@ namespace BLL
return rtn; return rtn;
} }
/// <summary>
/// 小车进入A2
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
private bool A2Leave(Agv_Info agv) private bool A2Leave(Agv_Info agv)
{ {
bool rtn = false; bool rtn = false;
...@@ -1306,21 +1345,30 @@ namespace BLL ...@@ -1306,21 +1345,30 @@ namespace BLL
} }
else else
{ {
if(shelfLockedNodeNames !=null) if(shelfLockedNodeNames !=null && shelfLockedNodeNames.Count>0)
{ {
foreach (string item in shelfLockedNodeNames) foreach (string item in shelfLockedNodeNames)
{ {
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name == item && s.Action == ClientAction.NeedEnter && s.AgvName == "" && s.IsUse); nodeIdx = Common.nodeInfo.FindIndex(s => s.Name == item && s.Action == ClientAction.NeedEnter && s.AgvName == "" && s.IsUse);
if (nodeIdx > -1) if (nodeIdx > -1)
{ {
agv.NextMission = "";
shelfLockedNodeNames.Remove(item);
return MoveNode(agv, nodeIdx); return MoveNode(agv, nodeIdx);
} }
else else
{ {
log = item+ " 不等于NeedEnter 或Use为False,不能搬运锁定的料架"; int idx = Common.nodeInfo.FindIndex(s => s.Name == item);
log = string.Format("[{0}] [ClientAction={1}] [IsUse={2}],不能搬运锁定的料架,到待机位等待"
,item,Common.nodeInfo[idx].Action,Common.nodeInfo[idx].IsUse);
Common.log.OutInfo(log); Common.log.OutInfo(log);
//Common.log.OutTextBox(log); if (!agv.StandbyTemp)
//return false; {
agv.StandbyTemp = true;
agv.NextMission = item;
Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
return false;
} }
} }
} }
......
...@@ -345,6 +345,15 @@ namespace AGVControl ...@@ -345,6 +345,15 @@ namespace AGVControl
/// </summary> /// </summary>
public bool StandbyTemp { set; get; } 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, string ioId, bool isUse) public Agv_Info(string id, string name, string ip, string authorization, string ioId, bool isUse)
{ {
ID = id; ID = id;
...@@ -359,6 +368,8 @@ namespace AGVControl ...@@ -359,6 +368,8 @@ namespace AGVControl
Place = ""; Place = "";
StateText = ""; StateText = "";
WaitTime = 0; WaitTime = 0;
DockingInfo.IsDocking = false;
DockingInfo.startTime = DateTime.Now;
} }
public string[] ToRow() public string[] ToRow()
......
...@@ -90,4 +90,3 @@ C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.GenerateResource. ...@@ -90,4 +90,3 @@ C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.GenerateResource.
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.CopyComplete 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.exe
C:\ZDL\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.pdb 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!