LineNode.cs
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Acc.AgvManager.demo
{
/// <summary>
/// 产线
/// </summary>
public class LineNode : Node
{
private string _place;
/// <summary>
/// 解绑的RFID列表
/// </summary>
private List<String> unBindRfidList = new List<string>();
/// <summary>
/// 正在执行此任务的AGV,拉上料架后从列表中清除,同时ShelfTakeCount + 1
/// </summary>
private List<String> taskAgvList = new List<string>();
/// <summary>
/// 添加解绑料架
/// </summary>
/// <param name="rfid"></param>
public void AddUnBindRfid(string rfid)
{
if (!unBindRfidList.Contains(rfid))
{
Common.LogUtil.info("添加解绑料架["+rfid+"]");
unBindRfidList.Add(rfid);
}
else
{
Common.LogUtil.info("添加解绑料架[" + rfid + "]失败,该料架已经解绑过");
}
}
/// <summary>
/// 已经拉走了几个空料架
/// </summary>
public int AlreadyTakeCount { get; set; }
public LineNode(string place)
{
this._place = place;
}
public override string GetNodeName()
{
return _place;
}
/// <summary>
/// AGV已经拉上料架
/// </summary>
/// <returns></returns>
public void FinishedOneShelfTask(string agvName)
{
if (taskAgvList.Contains(agvName))
{
Common.LogUtil.info("AGV[" + agvName + "]已将[" + _place + "]的一个空料架拉上车,解除任务锁定");
taskAgvList.Remove(agvName);
AlreadyTakeCount = AlreadyTakeCount + 1;
if (AlreadyTakeCount == unBindRfidList.Count)
{
Common.LogUtil.info("[" + _place + "]的解绑的空料架已全部拉走");
AlreadyTakeCount = 0;
unBindRfidList = new List<string>();
}
}
}
/// <summary>
/// 是否有空料架需要回收
/// </summary>
/// <returns></returns>
public bool HasShelfToTake()
{
int remainUnBindShelf = unBindRfidList.Count - taskAgvList.Count - AlreadyTakeCount;
return remainUnBindShelf > 0;
}
/// <summary>
/// 开始一辆车去拉料架
/// </summary>
public bool StartOneTask(string agvName)
{
if(HasShelfToTask())
{
if (!taskAgvList.Contains(agvName))
{
taskAgvList.Add(agvName);
Common.LogUtil.info("AGV["+ agvName + "]锁定["+ _place + "]一个空料架任务");
}
}
return false;
}
}
}