JobStep.cs
1.9 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
using AGVControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
public class JobStep<T> where T : Enum
{
private T step;
private string msg = "";
public string Msg
{
get { return msg; }
set
{
if (!string.IsNullOrEmpty(value))
{
//不为空,且与上一个消息不一样才打印
if (!value.Equals(msg))
{
Common.LogInfo(value);
}
}
msg = value;
}
}
private DateTime startTime = DateTime.Now;
public JobStep(T initStep)
{
this.step = initStep;
this.msg = "";
}
/// <summary>
/// 当前步骤是否是某个步骤
/// </summary>
/// <param name="step"></param>
/// <returns></returns>
public bool IsStep(T step)
{
return this.step.Equals(step);
}
/// <summary>
/// 是否超时
/// </summary>
/// <param name="timeOutMilliseconds"></param>
/// <returns></returns>
public bool IsTimeOut(int timeOutMilliseconds)
{
TimeSpan span = DateTime.Now - startTime;
if (span.TotalMilliseconds > timeOutMilliseconds)
{
return true;
}
return false;
}
/// <summary>
/// 进入下一个步骤
/// </summary>
/// <param name="nextStep"></param>
public void ToNextStep(T nextStep)
{
step = nextStep;
startTime = DateTime.Now;
}
public string StatusStr()
{
return step.ToString();
}
}
}