Commit b91dc470 顾剑亮

添加异常看板

1 个父辈 f571fc94
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using Model;
......@@ -8,6 +10,8 @@ namespace BLL
public class Control
{
private Timer timerCall;
private PointF[] position;
private DateTime[] timeout;
public delegate void AgvChangedEvent(int agvIndex);
public event AgvChangedEvent AgvChanged;
......@@ -20,6 +24,12 @@ namespace BLL
public void Start()
{
position = new PointF[Common.agvInfos.Count];
for (int i = 0; i < position.Length; i++)
position[i] = new PointF();
timeout = new DateTime[Common.agvInfos.Count];
for (int i = 0; i < timeout.Length; i++)
timeout[i] = DateTime.Now;
timerCall = new Timer(CallProcess, null, 0, 2000);
}
......@@ -48,6 +58,7 @@ namespace BLL
if (info.StateID == (int)StateID.Pause)
Common.mir.State_Ready(info.IP, info.Authorization);
position[i] = new PointF(Common.agvInfos[i].Position.X, Common.agvInfos[i].Position.Y);
if (info.CurrentJob == null)
info.CurrentJob = new StandbyJob();
......@@ -63,6 +74,7 @@ namespace BLL
info.IsCall = false;
}
}
UpdateBoard();
}
private void GetAgvState(ref AgvInfo info)
......@@ -115,6 +127,42 @@ namespace BLL
}
}
private void UpdateBoard()
{
for (int i = 0; i < Common.agvInfos.Count; i++)
{
if (Common.agvInfos[i].CurrentJob == null
|| Common.agvInfos[i].CurrentJob is ChargeJob
|| Common.agvInfos[i].CurrentJob is StandbyJob)
{
timeout[i] = DateTime.Now;
continue;
}
if (Math.Abs(Common.agvInfos[i].Position.X - position[i].X) < 2
&& Math.Abs(Common.agvInfos[i].Position.Y - position[i].Y) < 2)
{
TimeSpan span = DateTime.Now - timeout[i];
if (span.TotalMinutes >= 2)
{
string name = "";
if (Common.agvInfos[i].Name.IndexOf("11") >= 0)
name = "11号车";
else if (Common.agvInfos[i].Name.IndexOf("13") >= 0)
name = "13号车";
string value = string.Format("{0}在{1}停留超时2分钟以上", name, Common.agvInfos[i].Place);
DisplayBoard.Add(name, "lineAgv." + name + ".StandTimeOut", value);
}
}
else
{
timeout[i] = DateTime.Now;
}
}
DisplayBoard.UpdateAlarmMsg();
}
private enum StateID : int
{
None,
......
......@@ -21,6 +21,7 @@ namespace Model
//public static string[] PLACE_NAME;
public static bool FLEET_SEND;
public static string BoardURL;
public static bool StorageDockFinish = false; //停靠完成
public static bool StorageDockAlway = false; //指定停靠状态,一直不改变
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Script.Serialization;
using RestSharp;
namespace Model
{
public static class DisplayBoard
{
private static List<AlarmMsg> msgList = new List<AlarmMsg>();
public static void Add(string name, string key, string value, int type = 0)
{
msgList.Add(new AlarmMsg(name, key, value, type));
}
public static string UpdateAlarmMsg()
{
if (msgList.Count == 0) return "";
string s = UpdateDeviceAlarmMsg();
msgList.Clear();
return s;
}
private static string UpdateDeviceAlarmMsg()
{
string msg = "OK";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(msgList);
paramMap.Add("deviceAlarmList", json);
string server = GetUrl(paramMap);
RestClient client = new RestClient(server) { Timeout = 2000 };
RestRequest request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json;charset=UTF-8");
IRestResponse response = client.Execute(request);
json = response.Content;
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
msg = "updateDeviceAlarmMsg 没有收到服务器反馈";
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
private static string GetUrl(Dictionary<string, string> paramsMap)
{
string path = Common.BoardURL;
List<string> value = new List<string>();
foreach (string key in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[key], Encoding.UTF8);
value.Add(key + "=" + par);
}
path += "?" + string.Join("&", value);
return path;
}
}
internal class AlarmMsg
{
public string name = "";
public string msgKey = "";
public string msgValue = "";
public int type;
public AlarmMsg(string name, string key, string value, int type = 0)
{
this.name = name;
msgKey = key;
msgValue = value;
this.type = type;
}
}
}
......@@ -57,6 +57,7 @@
<ItemGroup>
<Compile Include="AgvInfo.cs" />
<Compile Include="Common.cs" />
<Compile Include="DisplayBoard.cs" />
<Compile Include="IJob.cs" />
<Compile Include="Log.cs" />
<Compile Include="MiR_API.cs" />
......
067396c83b7f2774c2cefca8b57e624dd8067a35
55762488e9ab378cb6871978329ebc986d9d5dd2
......@@ -8,6 +8,7 @@
<add key="FLEET_Send" value="true"/>
<add key="WebService" value="http://10.85.196.40:8089/"/>
<!--<add key="WebService" value="http://127.0.0.1:8089/"/>-->
<add key="Board" value="http://10.85.199.25/myproject/rest/api/qisda/device/updateDeviceAlarmMsg"/>
<add key="AGV_BATTERY_MAX" value="100"/>
<add key="AGV_BATTERY_MIN" value="40"/>
<add key="11号_4C" value="false"/>
......
......@@ -44,6 +44,7 @@ namespace AGVControl_Steel
{
Common.appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
Common.FLEET_SEND = Convert.ToBoolean(Common.appConfig.AppSettings.Settings["FLEET_Send"].Value);
Common.BoardURL = Common.appConfig.AppSettings.Settings["Board"].Value;
Common.mir = new MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value }; //asa
ReadAgvInfo();
ReadAgvMission();
......
......@@ -8,6 +8,7 @@
<add key="FLEET_Send" value="true"/>
<add key="WebService" value="http://10.85.196.40:8089/"/>
<!--<add key="WebService" value="http://127.0.0.1:8089/"/>-->
<add key="Board" value="http://10.85.199.25/myproject/rest/api/qisda/device/updateDeviceAlarmMsg"/>
<add key="AGV_BATTERY_MAX" value="100"/>
<add key="AGV_BATTERY_MIN" value="40"/>
<add key="11号_4C" value="false"/>
......
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!