ConfigItemBase.cs
6.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
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
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class ConfigBase
{
/// <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; }
/// <summary>
/// 目标速度
/// </summary>
[CSVAttribute("目标速度")]
public int TargetSpeed { get; set; }
/// <summary>
/// 目标速度
/// </summary>
[CSVAttribute("加速时间")]
public int AddSpeed { get; set; }
/// <summary>
/// 目标速度
/// </summary>
[CSVAttribute("减速时间")]
public int DelSpeed { 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 + "】必须配置值!");
}
}
}
/// <summary>
/// 运动轴配置
/// </summary>
public class ConfigMoveAxis : ConfigBase
{
/// <summary>
/// 伺服ON的Do信号
/// </summary>
public string ServerOnDO = "";
/// <summary>
/// 伺服刹车信号
/// </summary>
public string BreakOnDO = "";
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
[CSVAttribute("目标速度")]
public new int TargetSpeed { 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 (slv.Equals(GetAxisValue()))
{
return true;
}
return false;
}
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 ConfigIO : ConfigBase
{
public ConfigIO()
{
SlaveID = 0;
}
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
[CSVAttribute("电器定义")]
public string ElectricalDefinition { get; set; }
[CSVAttribute("SlaveID")]
public byte SlaveID { get; set; }
public string DisplayStr
{
get
{
return ElectricalDefinition + "-" + Explain;// + "-" + ProName + "";
}
}
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 void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型: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";
}
}