DoubleLineNodeFor4D.cs
5.1 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using BLL;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
///
/// </summary>
public class DoubleLineNodeFor4D : ClientNode
{
public DoubleLineNodeFor4D(string name, string ip, string aliceName, string lineName, string pos_name, string pos_guid, bool isUse, int emptyCnt) : base(name, ip, aliceName, lineName, pos_name, pos_guid, isUse, emptyCnt)
{
}
/// <summary>
/// 双层线任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
return null;
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
//执行空料架任务的小车数量
int emptyJobCnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (SettingString.C4_AGV_IPs.Contains(agv.IP))
continue;
if (agv.CurJob is GoEmptyShelfLineJob || agv.CurJob is EmptyShelfBackJob)
{
emptyJobCnt++;
}
}
if ((SettingString.AGVCNT / 2 - emptyJobCnt).Equals(1))//保留1辆小车出满料架
{
return null;
}
//出工单料的目的地是否有空料架
if (Common.FindEmptyShelfBeforeSendFullShelf(out string nodeName))
{
if (nodeName.StartsWith("E") && !SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
ClientNode clientNode = Common.nodeInfo.Find(s => s.Name.Equals(nodeName));
int cnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (SettingString.C4_AGV_IPs.Contains(agv.IP))
continue;
if (agv.CurJob is GoEmptyShelfLineJob)
{
if (((GoEmptyShelfLineJob)agv.CurJob).EmptyShelfPlace.Equals(nodeName))
cnt++;
}
}
if (cnt < clientNode.EmptyShelfCnt)
{
return new GoEmptyShelfLineJob(currentAgv.Place, nodeName);
}
}
}
//回收空料架
if (Common.FindEmptyShelfNode(currentAgv, out string emptyNodeName))
{
if (!SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)s.CurJob).EmptyShelfPlace.Equals(emptyNodeName));
if (i > -1)
return null;
//foreach (Agv_Info agv in Common.agvInfo)
//{
// if (SettingString.C4_AGV_IPs.Contains(agv.IP))
// continue;
// if (agv.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)agv.CurJob).EmptyShelfPlace.Equals(emptyNodeName))
// {
// return null;
// }
//}
return new GoEmptyShelfLineJob(currentAgv.Place, emptyNodeName);
}
}
//出满料
if (Common.FindFullShelfTask(currentAgv))
{
if (!SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoFullShelfStationJob && !s.IP.Equals(currentAgv.IP));
if (i > -1)
{
return null;
}
ClientNode node = Common.nodeInfo.Find(s => s.Name.Equals(SettingString.A6)
&& (s.StateEquals(eNodeStatus.NeedLeave) || s.StateEquals(eNodeStatus.NeedEnterLeave)) && !s.RFID.Equals("00"));
if (node != null && node.Name.Equals(SettingString.A6))
{
if (AGVManager.FindFullShelfTarget(node.RFID, out AGVManager.BoxDestInfo boxDestInfo))
{
if (boxDestInfo != null)
{
i = Common.agvInfo.FindIndex(s => s.CurJob is SendFullShelfToLineJob && !s.IP.Equals(currentAgv.IP)
&& ((SendFullShelfToLineJob)s.CurJob).FullShelfPlace.Equals(boxDestInfo.location));
if (i > -1)
return null;
}
}
}
return new GoFullShelfStationJob(currentAgv.Place);
}
}
return null;
}
}
}