Node.cs
3.2 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Agv
{
public class Node
{
/// <summary>
/// 节点名称
/// </summary>
public string Name { set; get; } = "";
/// <summary>
/// 料架号
/// </summary>
public string RFID { set; get; } = "";
/// <summary>
/// 标记
/// </summary>
public string Mark { set; get; } = "";
/// <summary>
/// 动作
/// </summary>
public ClientAction Action { set; get; } = ClientAction.None;
/// <summary>
/// 优先级
/// </summary>
public ClientLevel Level { set; get; } = ClientLevel.Low;
/// <summary>
/// 客户端类型
/// </summary>
public ClientType Type { set; get; } = ClientType.None;
/// <summary>
/// 料架类型
/// </summary>
public ClientShelf Shelf { set; get; } = ClientShelf.None;
public Node(string name,string rfid="",string mark="",ClientAction action = ClientAction.None,
ClientLevel level = ClientLevel.Low,ClientShelf shelfType = ClientShelf.None,ClientType clientType = ClientType.None)
{
Name = name;
RFID = rfid;
Mark = mark;
Action = action;
Level = level;
Type = clientType;
Shelf = shelfType;
}
public Node(string name, string rfid = "", ClientAction action = ClientAction.None)
{
Name = name;
RFID = rfid;
Action = action;
}
public Node(string name)
{
Name = name;
}
public Node() { }
/// <summary>
/// 所有属性的文本形式
/// </summary>
/// <returns></returns>
public string ToText()
{
System.Reflection.PropertyInfo[] info = this.GetType().GetProperties();
string[] arr = new string[info.Length];
for (int i = 0; i < info.Length; i++)
arr[i] = info[i].Name + "=" + info[i].GetValue(this).ToString();
return string.Join(",", arr);
}
public override bool Equals(object obj)
{
if (obj is Node)
{
Node node = (Node)obj;
if (Name.Equals(node.Name) && RFID.Equals(node.RFID) && Mark.Equals(node.Mark) &&
Action.Equals(node.Action) && Level.Equals(node.Level) && Type.Equals(node.Type) &&
Shelf.Equals(node.Shelf))
return true;
else
return false;
}
return false;
}
/// <summary>
/// 拷贝一个新的实例
/// </summary>
/// <returns></returns>
public Node ToCopy()
{
Node node = new Node();
System.Reflection.PropertyInfo[] info1 = node.GetType().GetProperties();
System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
for (int i = 0; i < info1.Length; i++)
info1[i].SetValue(node, info2[i].GetValue(this));
return node;
}
}
}