ClientNode.cs
4.3 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
130
131
132
133
134
135
136
137
138
139
140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dolen.Agv
{
/// <summary>
/// 客户端节点
/// </summary>
public class ClientNode
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; private set; }
/// <summary>
/// IP地址
/// </summary>
public string IP { get; private set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; private set; }
/// <summary>
/// 别名
/// </summary>
public string AliceName { get; set; } = "";
/// <summary>
/// 料架号
/// </summary>
public string RFID { set; get; } = "";
/// <summary>
/// 备注
/// </summary>
public string Remark { set; get; } = "";
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get; private set; } = false;
/// <summary>
/// 是否开启
/// </summary>
public bool Enabled { private set; get; }
/// <summary>
/// 动作
/// </summary>
public ClientAction Action { set; get; } = ClientAction.None;
/// <summary>
/// 优先级
/// </summary>
public ClientLevel Level { set; get; } = ClientLevel.None;
/// <summary>
/// 客户端类型
/// </summary>
public ClientType Type {private set; get; } = ClientType.None;
/// <summary>
/// 料架类型
/// </summary>
public ClientShelf Shelf { private set; get; } = ClientShelf.None;
public ClientNode(int id,string ip,string name,bool enabled=false,ClientType clientType = ClientType.None)
{
ID = id;
IP = ip;
Name = name;
AliceName = name;
Enabled = enabled;
Type = clientType;
}
/// <summary>
/// 修改节点状态
/// </summary>
/// <param name="action">动作</param>
/// <param name="rfid">rfid</param>
/// <param name="clientShelf">料架类型</param>
/// <param name="level">紧急程度</param>
public void ChangeState(ClientAction action, string rfid = "",ClientShelf clientShelf = ClientShelf.None,ClientLevel level= ClientLevel.None)
{
Action = action;
RFID = rfid;
Level = level;
}
/// <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 ClientNode)
{
ClientNode node = (ClientNode)obj;
if (ID.Equals(node.ID) && RFID.Equals(node.RFID) && Remark.Equals(node.Remark) &&
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;
//}
/// <summary>
/// 节点离线
/// </summary>
public void Offline()
{
RFID = "";
Remark = "";
Action = ClientAction.None;
Level = ClientLevel.None;
Shelf = ClientShelf.None;
Online = false;
}
}
}