ConfigItemBase.cs
9.5 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
/// <summary>
/// 基础的属性配置
/// </summary>
public class ConfigBase
{
//protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// DI=输入IO,DO=输出IO,PRO=属性,AXIS=轴
/// </summary>
[CSVAttribute("类型")]
public string ProType { get; set; }
/// <summary>
/// 说明
/// </summary>
[CSVAttribute("说明")]
public string Explain { get; set; }
/// <summary>
/// 名称
/// </summary>
[CSVAttribute("名称")]
public string ProName { get; set; }
/// <summary>
/// 属性值
/// </summary>
[CSVAttribute("属性值")]
public string ProValue { get; set; }
/// <summary>
/// 分类编号
/// </summary>
[CSVAttribute("分类编号")]
public int SubType { get; set; }
public string ConfigStr { get; set; }
public override string ToString()
{
// return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale;
return ConfigStr;
}
public virtual void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:" + ProType + "】【名称:" + ProName + "】【属性值:" + ProValue + "】必须配置值!");
}
}
}
public class ConfigMoveAxis : ConfigBase
{
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
[CSVAttribute("目标速度")]
public int TargetSpeed { get; set; }
[CSVAttribute("加速度")]
public int AddSpeed { get; set; }
[CSVAttribute("减速度")]
public int DelSpeed { get; set; }
[CSVAttribute("回零低速")]
public int HomeLowSpeed { get; set; }
[CSVAttribute("回零高速")]
public int HomeHighSpeed { get; set; }
[CSVAttribute("回零加速度")]
public int HomeAddSpeed { get; set; }
[CSVAttribute("脉冲最小误差")]
public int CanErrorCountMin { get; set; }
[CSVAttribute("脉冲最大误差")]
public int CanErrorCountMax { get; set; }
[CSVAttribute("脉冲最小限位")]
public int PositionMin { get; set; }
[CSVAttribute("脉冲最大限位")]
public int PositionMax { get; set; }
public int TargetPosition { get; set; }
public string GetNameStr()
{
return DeviceName + "_" + GetAxisValue();
}
public bool IsSameAxis(string portName, int slv)
{
if (DeviceName.Equals(portName) && slv.Equals(GetAxisValue()))
{
return true;
}
return false;
}
public bool PositionIsHasLimit()
{
if (PositionMin.Equals(PositionMax))
{
return false;
}
return true;
}
public string DisplayStr
{
get
{
return Explain + "(" + ProName + ")";
}
set
{
}
}
public short GetAxisValue()
{
if (ProValue.Equals("") || ProValue.Equals("-1"))
{
return -1;
}
return (short)Convert.ToInt32(ProValue);
}
public override void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!");
}
}
}
public class ConfigClampJaw : ConfigBase
{
[CSVAttribute("设备名称")]
public string PortName { get; set; }
[CSVAttribute("目标速度")]
public float Velocity { get; set; }
[CSVAttribute("加速度")]
public float AddSpeed { get; set; }
[CSVAttribute("减速度")]
public float DelSpeed { get; set; }
[CSVAttribute("出力")]
public float Force { get; set; }
[CSVAttribute("距离")]
public float Distance { get; set; }
[CSVAttribute("推压速度")]
public float PushVelocity { get; set; }
[CSVAttribute("脆盘目标速度")]
public float CrispVelocity { get; set; }
[CSVAttribute("脆盘加速度")]
public float CrispAddSpeed { get; set; }
[CSVAttribute("脆盘减速度")]
public float CrispDelSpeed { get; set; }
[CSVAttribute("脆盘出力")]
public float CrispForce { get; set; }
[CSVAttribute("脆盘距离")]
public float CrispDistance { get; set; }
[CSVAttribute("脆盘推压速度")]
public float CrispPushVelocity { get; set; }
public string GetNameStr()
{
return PortName + "_" + AxisNo;
}
public bool IsSameAxis(string portName, ushort slv)
{
if (PortName.Equals(portName) && slv.Equals(AxisNo))
{
return true;
}
return false;
}
public string DisplayStr
{
get
{
return Explain + "(" + ProName + ")";
}
set
{
}
}
private ushort axisNo=999;
public ushort AxisNo
{
get
{
if (axisNo.Equals(999)){
if (ProValue.Equals("") || ProValue.Equals("-1"))
{
axisNo = 0;
}
axisNo = (ushort)Convert.ToInt32(ProValue);
}
return axisNo;
}
}
public override void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(PortName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + "【类型】【名称】【属性值】【设备名称】必须配置值!");
}
}
}
/// <summary>
/// io配置
/// </summary>
public class ConfigIO : ConfigBase
{
public ConfigIO()
{
SlaveID = 0;
}
private string IP = "";
/// <summary>
/// 设备IP
/// </summary>
public string IO_IP
{
get
{
if (String.IsNullOrEmpty(IP))
{
if (DeviceConfig.ProIOIpMap != null && DeviceConfig.ProIOIpMap.ContainsKey(DeviceName))
{
IP = DeviceConfig.ProIOIpMap[DeviceName];
}
else
{
return DeviceName;
}
}
return IP;
}
}
/// <summary>
/// 设备名称
/// </summary>
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
/// <summary>
/// 电器定义
/// </summary>
[CSVAttribute("电器定义")]
public string ElectricalDefinition { get; set; }
public byte SlaveID = 0;
public string DisplayStr
{
get
{
return ElectricalDefinition + "-" + Explain + "-" + ProName + "";
}
set
{
}
}
ushort value = 0;
public ushort GetIOAddr()
{
if (value > 0)
{
return value;
}
try
{
value = (ushort)Convert.ToInt32(ProValue);
}
catch (Exception ex)
{
LogUtil.error("出错:", ex);
}
return value;
}
//public override string ToString()
//{
// return "[" + ProType + "]" + Explain + "," + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName + ",描述:" + Describe + ",电器定义:" + ElectricalDefinition + ",代码定义:" + CodeDefinition + "";
//}
public override void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ToString() + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!");
}
}
}
public static class ConfigItemType
{
public static string DI = "DI";
public static string DO = "DO";
public static string AXIS = "AXIS";
public static string PRO = "PRO";
public static string CLAW = "CLAW";
}
}