WaitResultInfo.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
105
106
107
108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLib.Model.AGV
{
public class WaitResultInfo
{
private WaitResultInfo()
{
}
public static WaitResultInfo WaitIO(string ioType, IO_VALUE ioValue, int targetP = 0)
{
//targetP=0表示默认,=1必须检测DI,=2必须检测DO
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = WaitEnum.W002_IOValue;
wait.IoType = ioType;
wait.IoValue = ioValue;
wait.TargetPosition = targetP;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitTime(int MScends)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = WaitEnum.W003_Time;
wait.TimeMSeconds = MScends;
wait.IsEnd = false;
return wait;
}
public string ToStr()
{
if (WaitType.Equals(WaitEnum.W001_RobotMission))
{
return $"等待机器人任务【{RobotMission}】完成";
}
else if (WaitType.Equals(WaitEnum.W002_IOValue))
{
return "等待IO【" + IoType + "】=【" + IoValue + "】";
}
else if (WaitType.Equals(WaitEnum.W003_Time))
{
return "等待时间【" + TimeMSeconds + "】毫秒";
}
else
{
return "Wait位置类型:WaitType=【" + WaitType + "】";
}
}
/// <summary>
/// 当未结束时可以重复运动的次数
/// </summary>
public int CanWhileMoveCount { get; set; }
/// <summary>
/// 等待结果
/// </summary>
public WaitEnum WaitType { get; set; }
/// <summary>
/// IO类型
/// </summary>
public string IoType { get; set; }
/// <summary>
/// IO值
/// </summary>
public IO_VALUE IoValue { get; set; }
/// <summary>
/// 等待的毫秒
/// </summary>
public int TimeMSeconds { get; set; }
/// <summary>
/// 是否已经结束
/// </summary>
public bool IsEnd { get; set; }
/// <summary>
/// 机器人任务名称
/// </summary>
public string RobotMission { get; set; }
public int TargetPosition { get; set; }
}
public enum WaitEnum
{
/// <summary>
/// 机器人任务完成
/// </summary>
W001_RobotMission = 0,
/// <summary>
/// 信号到达
/// </summary>
W002_IOValue,
/// <summary>
/// 时间等待
/// </summary>
W003_Time,
}
public enum IO_VALUE
{
High,
Low
}
}