JobManager.cs
1.7 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
using DeviceLib.Model.AGV;
using System.Collections.Generic;
namespace DeviceLib.BLL
{
public class JobManager
{
static List<JobType> jobTypes = new List<JobType>()
{
new ToShelfJobType(),
new ToStoreJobType(),
new ChargeStandJobType()
};
/// <summary>
/// 获取运输任务
/// </summary>
/// <param name="robot"></param>
/// <returns></returns>
public static bool CheckNewJob(Robot robot)
{
bool rtn= jobTypes[0].CheckNewJob(robot);
if(!rtn)
rtn = jobTypes[1].CheckNewJob(robot);
return rtn;
}
public static void GetNewJob(Robot robot)
{
Job job = robot.job;
if (job == null)
job = getJob(robot);
robot.job = job;
}
public static void Execute(Robot robot)
{
robot?.operation?.Check_Mission_InQueue();
if (!robot.auto) return;
if (robot.job != null)
robot.job = robot.job.Execute(robot);
}
public static void CheckResend(Robot robot)
{
if (!robot.auto) return;
if (robot?.mission_state?.run_id == -1)
{
if (robot.job != null)
{
robot.job.ReSendMission(robot);
}
}
}
static Job getJob(Robot robot)
{
foreach (var item in jobTypes)
{
Job job = item.GetNewJob(robot);
if (job != null) return job;
}
return null;
}
}
}