Commit 9ea1b3d5 张东亮

1

1 个父辈 9194db74
......@@ -83,6 +83,7 @@
<Compile Include="bean\node\ClientNode.cs" />
<Compile Include="bean\node\DoubleLineNodeFor4D.cs" />
<Compile Include="bean\node\DoubleLineNodeFor4C.cs" />
<Compile Include="bean\UnlockedShelf.cs" />
<Compile Include="BLL\AGVManager.cs" />
<Compile Include="BLL\AgvServer.cs" />
<Compile Include="BLL\Common.cs" />
......@@ -96,6 +97,7 @@
</Compile>
<Compile Include="BLL\LineWebService.cs" />
<Compile Include="BLL\StationRFIDManager.cs" />
<Compile Include="BLL\UnlockMissionManager.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
......
......@@ -1073,102 +1073,6 @@ namespace AGVControl
}
}
/// <summary>
/// 添加空料架解绑
/// </summary>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool AddEmptyShelfTask(string nodeName,string rfid)
{
int idx = Common.nodeInfo.FindIndex(s => s.Name == nodeName);
if (idx > -1)
{
Common.missionManager.AddMission(new MissionStru(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), nodeName,rfid));
Common.nodeInfo[idx].IncreEmptyShelfCnt(rfid);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(CONFIG_PATH + "LinePlace.txt"))
{
foreach (var item in Common.missionManager.missionList)
{
file.WriteLine(string.Format("{0},{1},{2}", item.CreateTime, item.NodeName,rfid));
}
}
return true;
}
else
{
log.Error("AddLinePlace 失败 节点" + nodeName + "不存在");
return false;
}
}
/// <summary>
/// 删除空架任务
/// </summary>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool DelEmptyShelfTask(string nodeName,string rfid)
{
int idx = Common.nodeInfo.FindIndex(s => s.Name == nodeName);
if (idx > -1)
{
idx = Common.missionManager.missionList.FindIndex(s => s.NodeName == nodeName);
if (idx > -1)
{
Common.nodeInfo[idx].DecreEmptyShelfCnt(rfid);
LogInfo("删除一个空料架任务:" + nodeName + "[RFID=" + rfid + "]");
Common.missionManager.DelMission(idx);
//Common.missionManager.missionList.RemoveAt(idx);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(CONFIG_PATH + "LinePlace.txt"))
{
foreach (var item in Common.missionManager.missionList)
{
file.WriteLine(string.Format("{0},{1},{2}", item.CreateTime, item.NodeName,rfid));
}
}
return true;
}
log.Error("DelLinePlace 失败 节点任务" + nodeName + "不存在");
return false;
}
else
{
log.Error("DelLinePlace 失败 节点" + nodeName + "不存在");
return false;
}
}
//public static void CheckAGVMissionState()
//{
// foreach (Agv_Info agv in agvInfo)
// {
// Thread.Sleep(50);
// bool rtn = Common.mir.Get_Register(agv, 20, out int regValue);
// if (rtn)
// {
// agv.GetPlace(regValue);
// Common.log.Debug(string.Format("软件开启:{0} Get_Register PLC{1}={2} Place={3} PlaceState={4}", agv.Name, 20, regValue, agv.Place, agv.PlaceState));
// if (!agv.Place.Equals(""))
// {
// int idx = nodeInfo.FindIndex(s => s.Name == agv.Place);
// if (idx > -1)
// {
// nodeInfo[idx].AgvName = agv.Name;
// }
// agv.TaskSend = "Move" + agv.Place;
// }
// }
// else
// {
// Common.log.Debug("CheckAGVMissionState 获取PLC20失败");
// }
// }
//}
public static void GetNodesPosition()
{
Agv_Info agv = agvInfo[0];
......@@ -1452,65 +1356,5 @@ namespace AGVControl
public string C4_Station1;
public string C4_Station2;
}
/// <summary>
/// 任务信息结构
/// </summary>
public struct MissionStru
{
public string NodeName;
public string CreateTime;
public string Rfid;
/// <summary>
/// 任务结构
/// </summary>
/// <param name="dateTime">创建时间</param>
/// <param name="name">节点名称</param>
public MissionStru(string dateTime, string name,string rfid)
{
NodeName = name;
CreateTime = dateTime;
Rfid = rfid;
}
}
/// <summary>
/// 任务管理
/// </summary>
public class MissionManager
{
public delegate void MissionChangedHandler();
public event MissionChangedHandler MissionChanged;
/// <summary>
/// 任务列表
/// </summary>
public List<MissionStru> missionList;
/// <summary>
/// 空料架解绑总数
/// </summary>
public Int32 EmptyMissionCount
{
get { return missionList.Count; }
}
public void AddMission(MissionStru missionStru)
{
missionList.Add(missionStru);
MissionChanged?.Invoke();
}
public void DelMission(int idx)
{
if (idx == -1)
return;
Common.missionManager.missionList.RemoveAt(idx);
MissionChanged?.Invoke();
}
public MissionManager()
{
missionList = new List<MissionStru>();
}
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using AGVControl;
using BLL;
using log4net.Util;
using RestSharp;
......@@ -77,7 +78,7 @@ namespace AGVControl.BLL
msglist.Add(new AlarmMsg(Common.nodeInfo[j].AliceName, "lineAgv." + Common.nodeInfo[j].Name + ".OffLine", "离线"));
}
}
BLL.AGVManager.updateDeviceAlarmMsg(msglist);
AGVManager.updateDeviceAlarmMsg(msglist);
for (int i = 0; i < Common.agvInfo.Count; i++)
{
......@@ -139,7 +140,7 @@ namespace AGVControl.BLL
Common.log.Error(Common.agvInfo[i].Name + "上报小车运行步骤失败" + ex.Message + ex.StackTrace);
}
}
BLL.AGVManager.updateDeviceAlarmMsg(msglist);
AGVManager.updateDeviceAlarmMsg(msglist);
}
catch (Exception ex)
{
......
......@@ -73,12 +73,12 @@ namespace BLL
if (rfid == null)
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "rfid=null" };
Log.Error(string.Format("WebService Request(POST) Failed emptyStation={0},rfid=null", emptyStation));
Log.Error(string.Format("Unlock Request(POST) Failed [emptyStation={0},rfid=null]", emptyStation));
}
else
{
res = new Result() { Succeed = true, ResultData = rfid, ErrorMessage = "" };
Log.Info(string.Format("WebService Request(POST) emptyStation={0},rfid={1}", emptyStation, rfid.ToUpper()));
Log.Info(string.Format("Unlock Request(POST) [emptyStation={0},rfid={1}]", emptyStation, rfid.ToUpper()));
if (!Common.AddEmptyShelfTask(value, rfid.ToUpper()))
{
Common.log.Error("CreateEmptyRecycleTask(POST) 节点[" + value + "]不存在");
......@@ -92,7 +92,7 @@ namespace BLL
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + emptyStation };
AGVControl.Common.log.Error("WebService POST Response false " + "Not find " + emptyStation);
AGVControl.Common.log.Error("Unlock POST Response false " + "Not find " + emptyStation);
}
}
return JsonHelper.SerializeObject(res);
......@@ -120,14 +120,14 @@ namespace BLL
else
{
res = new Result() { Succeed = true, ResultData = RFID, ErrorMessage = "" };
Log.Info(string.Format("WebService Request(GET) emptyStation={0},rfid={1}", line, RFID));
Log.Info(string.Format("Unlock Request(GET) [emptyStation={0},rfid={1}]", line, RFID));
Common.LogInfo("任务[GET]:" + value + " 出空料架 [emptyStation=" + line + ",rfid=" + RFID.ToUpper() + "]");
}
}
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + line };
AGVControl.Common.LogInfo("WebService GET Response false " + "Not find " + line);
AGVControl.Common.LogInfo("Unlock GET Response false " + "Not find " + line);
}
//Log.Info(string.Format("WebService GET Request emptyStation={0},rfid={1}", line, RFID));
return JsonHelper.SerializeObject(res);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.BLL
{
/// <summary>
///解绑料架任务管理
/// </summary>
public class UnlockMissionManager
{
public delegate void MissionChangedHandler();
public event MissionChangedHandler MissionChanged;
/// <summary>
/// 任务列表
/// </summary>
public Dictionary<string, UnlockedShelf> NodeUnlockMissions { get; private set; }
public UnlockMissionManager()
{
NodeUnlockMissions = new Dictionary<string, UnlockedShelf>();
}
public UnlockedShelf GetUnlockInfo(string nodeName)
{
if (NodeUnlockMissions.ContainsKey(nodeName))
{
return NodeUnlockMissions[nodeName];
}
return null;
}
public void AddMission(string nodeName,string rfid)
{
NodeUnlockMissions[nodeName].Add(rfid);
MissionChanged?.Invoke();
}
public void DelMission(string nodeName,string rfid)
{
NodeUnlockMissions[nodeName].Delete(rfid);
MissionChanged?.Invoke();
}
}
}
......@@ -115,10 +115,6 @@ namespace AGVControl
}));
System.GC.Collect();
}
private void MissionManager_MissionChanged()
{
ShowEmptyTask();
}
private void Control_AgvOnline(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].IsCon ? Color.Black : Color.Red; }));
......@@ -177,7 +173,6 @@ namespace AGVControl
Common.control.AgvOnline += Control_AgvOnline;
Common.server.NodeChanged += Server_NodeChanged;
Common.server.NodeOnline += Server_NodeOnline;
Common.missionManager.MissionChanged += MissionManager_MissionChanged;
//foreach (var item in Common.agvInfo)
//{
// cmbBoxAGVName.Items.Add(item.Name);
......@@ -269,23 +264,11 @@ namespace AGVControl
else if (e.ColumnIndex == 8) //清除缓存
{
//清除节点缓存
Common.LogInfo(string.Format("手动清除缓存,{0} {1}", Common.nodeInfo[e.RowIndex].AgvName, Common.nodeInfo[e.RowIndex].Name));
string name = Common.nodeInfo[e.RowIndex].AgvName;
Common.LogInfo(string.Format("手动清除缓存,{0}",Common.nodeInfo[e.RowIndex].Name));
Common.nodeInfo[e.RowIndex].AgvName = "";
DgvNode.Rows[e.RowIndex].Cells[5].Value = "";
Common.nodeInfo[e.RowIndex].RFID = "";
DgvNode.Rows[e.RowIndex].Cells[4].Value = "";
//清除小车缓存
int idx = Common.agvInfo.FindIndex(s => s.Name == name);
if (idx > -1)
{
Common.agvInfo[idx].Place = "";
Common.agvInfo[idx].RFID = "";
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
//添加Init任务
Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission["Init"]);
Common.mir.State_Ready(Common.agvInfo[idx]);
}
DgvNode.Rows[e.RowIndex].SetValues(Common.nodeInfo[e.RowIndex].ToRow());
}
}
......@@ -394,32 +377,6 @@ namespace AGVControl
InShhow = false;
}
private void ShowEmptyTask()
{
if (dgvLineMission.InvokeRequired)
{
dgvLineMission.Invoke(new Action(() => ShowEmptyTask()));
return;
}
try
{
if (dgvLineMission.Rows.Count != 0)
dgvLineMission.Rows.Clear();
foreach (var item in Common.missionManager.missionList)
{
var key = Common.nodeInfo.Where(q => q.Name == item.NodeName).Select(q => q.AliceName);
if (key.ToList().Count > 0)
dgvLineMission.Rows.Add(item.CreateTime, key.ToList()[0]);
}
groupBox4.Text = "产线解绑信息:共" + Common.missionManager.EmptyMissionCount.ToString() + "个";
}
catch (Exception ex)
{
Common.log.Error(ex);
}
}
private void ChkAutoCharge_CheckedChanged(object sender, EventArgs e)
{
......@@ -438,21 +395,23 @@ namespace AGVControl
}
if (MessageBox.Show("确定删除产线任务[" + cmbBoxLineName.SelectedItem.ToString() + "]", "手动删除解绑任务", MessageBoxButtons.YesNo) == DialogResult.No)
return;
//int idx=Common.missionList.FindIndex(s => s.NodeName == Common.agvProductionLine[txtBoxMission.Text]);
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
if (txtRfid.Text.ToUpper().StartsWith("D") || txtRfid.Text.ToUpper().StartsWith("C"))
{
if (Common.DelEmptyShelfTask(Common.nodeInfo[idx].Name))
{
Common.LogInfo("手动删除任务成功:" + cmbBoxLineName.SelectedItem.ToString());
}
else
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
{
Common.LogInfo("手动删除任务失败");
if (Common.nodeInfo[idx].UnlockedShelf.Delete(txtRfid.Text.ToUpper()))
{
Common.LogInfo(string.Format("手动删除任务成功:{0} {1}",cmbBoxLineName.SelectedItem.ToString(),txtRfid.Text.ToUpper()));
}
else
{
Common.LogInfo("手动删除任务失败");
}
}
}
}
catch (Exception ex)
{
......@@ -465,32 +424,35 @@ namespace AGVControl
{
try
{
if (cmbBoxLineName.SelectedItem == null || cmbBoxLineName.SelectedIndex == 0)
if (cmbBoxLineName.SelectedItem == null || cmbBoxLineName.SelectedIndex == 0 || txtRfid.Text.Equals(""))
{
return;
}
if (cmbBoxLineName.SelectedItem.ToString().StartsWith("A"))
return;
if (MessageBox.Show("确定添加产线任务[" + cmbBoxLineName.SelectedItem.ToString() + "]", "手动1添加解绑", MessageBoxButtons.YesNo) == DialogResult.No)
if (MessageBox.Show("确定添加产线任务[" + cmbBoxLineName.SelectedItem.ToString() + "]", "手动添加解绑", MessageBoxButtons.YesNo) == DialogResult.No)
return;
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
if (txtRfid.Text.ToUpper().StartsWith("D") || txtRfid.Text.ToUpper().StartsWith("C"))
{
if (Common.AddEmptyShelfTask(Common.nodeInfo[idx].Name))
{
Common.LogInfo("手动添加任务成功:" + cmbBoxLineName.SelectedItem.ToString());
}
else
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
{
Common.LogInfo("手动添加任务失败");
}
if (Common.nodeInfo[idx].UnlockedShelf.Add(txtRfid.Text.ToUpper()))
{
Common.LogInfo(string.Format("手动添加任务成功:{0} {1}", cmbBoxLineName.SelectedItem.ToString(),txtRfid.Text.ToUpper()));
}
else
{
Common.LogInfo("手动添加任务失败");
}
}
}
}
catch (Exception ex)
{
ShowEmptyTask();
Common.log.Error("手动添加任务失败:" + ex.Message);
}
}
......@@ -617,11 +579,6 @@ namespace AGVControl
}
}
private void dgvLineMission_Click(object sender, EventArgs e)
{
ShowEmptyTask();
}
private void btnClearC4StandyInfo_Click(object sender, EventArgs e)
{
Common.StandbyStation.C4_Station1 = "";
......
......@@ -174,12 +174,6 @@
<metadata name="Column16.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column24.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column8.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>
......
......@@ -41,7 +41,11 @@ namespace AGVControl
{
Name = name;
}
/// <summary>
/// 状态比较
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public bool StateEquals(eNodeStatus obj)
{
return nodeStatus.Equals(obj);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
public class UnlockedShelf
{
/// <summary>
/// 已解绑料架信息
/// </summary>
/// <param name="nodeName"></param>
public UnlockedShelf(string nodeName)
{
NodeName = nodeName;
}
/// <summary>
/// 空料架数量
/// </summary>
public int EmptyCnt
{
get { return emptyCnt; }
set
{
EmptyCnt = emptyCnt;
}
}
/// <summary>
/// 节点名
/// </summary>
public string NodeName { get; private set; }
private int emptyCnt = 0;
/// <summary>
/// 解绑的所有RFID
/// </summary>
private Dictionary<string,string> Rfids;
/// <summary>
///添加解绑的空料架,如果RFID相同,不增加数量
/// </summary>
public bool Add(string rfid)
{
if (!rfid.Equals("") && !Rfids.Keys.Contains(rfid))
{
System.Threading.Interlocked.Increment(ref emptyCnt);
Rfids.Add(rfid,DateTime.Now.ToString("yyyy/MM/dd/HH:mm:ss,fff"));
Common.WriteIni(NodeName, SettingString.EmptyShelfRFIDs, string.Join(",", Rfids.Keys.ToArray()));
Common.WriteIni(NodeName, SettingString.EmptyShelfCnt, emptyCnt.ToString());
Common.LogInfo(string.Format("{0}解绑任务添加成功:RFID={1}", NodeName, rfid));
return true;
}
Common.LogInfo(string.Format("{0}解绑任务添加失败:RFID={1}", NodeName, rfid));
return false;
}
/// <summary>
/// 删除一个解绑任务
/// </summary>
public bool Delete(string rfid)
{
if (emptyCnt > 0)
{
if (!rfid.Equals("") && Rfids.Keys.Contains(rfid))
{
System.Threading.Interlocked.Decrement(ref emptyCnt);
Rfids.Remove(rfid);
Common.WriteIni(NodeName, SettingString.EmptyShelfCnt, emptyCnt.ToString());
Common.WriteIni(NodeName, SettingString.EmptyShelfRFIDs, string.Join(",", Rfids.Keys.ToArray()));
using ()
{
}
Common.LogInfo(string.Format("{0}解绑任务删除成功:RFID={1}", NodeName, rfid));
return true;
}
}
else if (Rfids.Count > 0)
{
Rfids.Clear();
return true;
}
Common.LogInfo(string.Format("{0}解绑任务删除失败:RFID={1}", NodeName, rfid));
return false;
}
}
}
......@@ -32,11 +32,6 @@ namespace AGVControl
}
/// <summary>
/// 小车名称
/// </summary>
public string AgvName { set; get; }
/// <summary>
/// 线体名(佳世达)
/// </summary>
public string LineName { set; get; }
......@@ -54,24 +49,10 @@ namespace AGVControl
/// 节点位置坐标
/// </summary>
public PositionStru position;
/// <summary>
/// 空料架数量
/// </summary>
public int EmptyShelfCnt
{
get { return _EmptyShelfCnt; }
set
{
EmptyShelfCnt = _EmptyShelfCnt;
}
}
/// <summary>
/// 空架子的RFID
/// 料架解绑信息
/// </summary>
public List<string> EmptyShelfRFIDs;
private int _EmptyShelfCnt = 0;
public UnlockedShelf UnlockedShelf { get; set; }
public string AliceName { get; set; }
/// <summary>
/// 客户端节点
......@@ -84,14 +65,12 @@ namespace AGVControl
AliceName = aliceName;
RFID = rfid;
AgvName = "";
Online = false;
IsUse = isUse;
_EmptyShelfCnt = emptyCnt;
this.Pos_name = pos_name;
this.Pos_guid = pos_guid;
LineName = lineName;
EmptyShelfRFIDs = new List<string>();
UnlockedShelf = new UnlockedShelf(name);
}
/// <summary>
......@@ -106,48 +85,8 @@ namespace AGVControl
RFID = rfid;
nodeStatus = status;
AgvName = "";
}
/// <summary>
///空料架数量增加,如果RFID相同,不增加数量
/// </summary>
public void IncreEmptyShelfCnt(string rfid)
{
if (!rfid.Equals("") && !EmptyShelfRFIDs.Contains(rfid))
{
System.Threading.Interlocked.Increment(ref _EmptyShelfCnt);
EmptyShelfRFIDs.Add(rfid);
Common.WriteIni(Name, SettingString.EmptyShelfRFIDs, string.Join(",", EmptyShelfRFIDs.ToArray()));
Common.WriteIni(Name, SettingString.EmptyShelfCnt, _EmptyShelfCnt.ToString());
Common.LogInfo(string.Format("{0}解绑任务添加成功:RFID={1}", Name, rfid));
}
//else if(rfid.Equals(""))
//{
// System.Threading.Interlocked.Increment(ref _EmptyShelfCnt);
// Common.WriteIni(Name, SettingString.EmptyShelfCnt, _EmptyShelfCnt.ToString());
//}
}
/// <summary>
/// 空料架数量减少1
/// </summary>
public void DecreEmptyShelfCnt(string rfid)
{
if (_EmptyShelfCnt > 0)
{
if (!rfid.Equals("") && EmptyShelfRFIDs.Contains(rfid))
{
System.Threading.Interlocked.Decrement(ref _EmptyShelfCnt);
Common.WriteIni(Name, SettingString.EmptyShelfCnt, _EmptyShelfCnt.ToString());
EmptyShelfRFIDs.Remove(rfid);
Common.WriteIni(Name, SettingString.EmptyShelfRFIDs, string.Join(",", EmptyShelfRFIDs.ToArray()));
Common.LogInfo(string.Format("{0}解绑任务删除成功:RFID={1}", Name, rfid));
}
}
else if (_EmptyShelfCnt.Equals(0) && EmptyShelfRFIDs.Count > 0)
{
EmptyShelfRFIDs.Clear();
}
}
/// <summary>
/// 节点状态的文本形式
/// </summary>
......@@ -185,7 +124,6 @@ namespace AGVControl
{
RFID = "00";
nodeStatus = eNodeStatus.None;
AgvName = "";
Online = false;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!