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
using FLY.Thick.Blowing.IService;
using FObjBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Thick.Blowing.OBJ_INTERFACE
{
public class BLOWING_DETECT_OBJ_INTERFACE
{
#region Pack
public class Pack_Params : IPack
{
/// <summary>
/// 旋转架转动角度 °
/// </summary>
public double rangle;
/// <summary>
/// 人字架周期 设置值
/// </summary>
public TimeSpan period;
/// <summary>
/// 加减速时间
/// </summary>
public TimeSpan accDecTime;
/// <summary>
/// 信号0 需要撞2次
/// </summary>
public bool isSign0Double;
/// <summary>
/// 信号1 需要撞2次
/// </summary>
public bool isSign1Double;
/// <summary>
/// 信号模式
/// </summary>
public BlowingSignType signType;
/// <summary>
/// 转向信号时间
/// </summary>
public TimeSpan limitSignTime;
/// <summary>
/// 人字架到测厚仪长度 m
/// </summary>
public double filmLength;
/// <summary>
/// 辊周长 mm
/// </summary>
public double rollPerimeter;
/// <summary>
/// 转向信号100ms 滤波
/// </summary>
public bool isSignFilter;
/// <summary>
/// 缺少信号模式
/// </summary>
public bool isLackSignMode;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(rangle));
buf.AddRange(BitConverter.GetBytes(period.Ticks));
buf.AddRange(BitConverter.GetBytes(rollPerimeter));
buf.AddRange(BitConverter.GetBytes(filmLength));
buf.AddRange(BitConverter.GetBytes(accDecTime.Ticks));
buf.AddRange(BitConverter.GetBytes(limitSignTime.Ticks));
buf.AddRange(BitConverter.GetBytes(isSign0Double));
buf.AddRange(BitConverter.GetBytes(isSign1Double));
buf.AddRange(BitConverter.GetBytes((int)signType));
buf.AddRange(BitConverter.GetBytes(isSignFilter));
buf.AddRange(BitConverter.GetBytes(isLackSignMode));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 8 * 6 + 1 * 2 + 4 + 1+1)
return false;
int idx = 0;
rangle = BitConverter.ToDouble(value, idx);
idx += 8;
period = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
rollPerimeter = BitConverter.ToDouble(value, idx);
idx += 8;
filmLength = BitConverter.ToDouble(value, idx);
idx += 8;
accDecTime = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
limitSignTime = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
isSign0Double = BitConverter.ToBoolean(value, idx);
idx++;
isSign1Double = BitConverter.ToBoolean(value, idx);
idx++;
signType = (BlowingSignType)BitConverter.ToInt32(value, idx);
idx += 4;
isSignFilter = BitConverter.ToBoolean(value, idx);
idx++;
isLackSignMode = BitConverter.ToBoolean(value, idx);
idx++;
return true;
}
#endregion
}
public class Pack_CurrState : IPack
{
public int limitno;
public TimeSpan pasttime;
public int rotationCnt;
public double filmvelocity;
public Misc.DIRECTION direction;
public double angle;
/// <summary>
/// 人字架周期 当前值
/// </summary>
public TimeSpan period;
public TimeSpan swapCoolTime;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(limitno));
buf.AddRange(BitConverter.GetBytes(pasttime.Ticks));
buf.AddRange(BitConverter.GetBytes(rotationCnt));
buf.AddRange(BitConverter.GetBytes(filmvelocity));
buf.Add((byte)direction);
buf.AddRange(BitConverter.GetBytes(angle));
buf.AddRange(BitConverter.GetBytes(period.Ticks));
buf.AddRange(BitConverter.GetBytes(swapCoolTime.Ticks));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 4 + 8 + 4 + 8 + 1 + 8 + 8 + 8)
return false;
int idx = 0;
limitno = BitConverter.ToInt32(value, idx);
idx += 4;
pasttime = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
rotationCnt = BitConverter.ToInt32(value, idx);
idx += 4;
filmvelocity = BitConverter.ToDouble(value, idx);
idx += 8;
direction = (Misc.DIRECTION)value[idx];
idx += 1;
angle = BitConverter.ToDouble(value, idx);
idx += 8;
period = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
swapCoolTime = new TimeSpan(BitConverter.ToInt64(value, idx));
idx += 8;
return true;
}
#endregion
}
public class Pack_BM : IPack
{
public int firstbm;
public int lastbm;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(firstbm));
buf.AddRange(BitConverter.GetBytes(lastbm));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 4 + 4)
return false;
int idx = 0;
firstbm = BitConverter.ToInt32(value, idx);
idx += 4;
lastbm = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
#endregion
#region GetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 GET_PARAMS = 1;
/// <summary>
/// Pack_CurrState
/// </summary>
public const UInt16 GET_STATE = 5;
/// <summary>
/// Pack_BM
/// </summary>
public const UInt16 GET_SIGNBM = 9;
#endregion
#region SetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 SET_PARAMS = 1;
#endregion
#region CallFunction
/// <summary>
/// request:null
/// reponse:GetBufListReponse
/// </summary>
public const UInt16 CALL_GETSIGNLIST = 4;
#endregion
#region PushInfo
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 PUSH_PARAMS = 1;
/// <summary>
/// Pack_CurrState
/// </summary>
public const UInt16 PUSH_STATE = 5;
/// <summary>
/// Pack_BM
/// </summary>
public const UInt16 PUSH_SIGNBM = 9;
#endregion
}
}