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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.Common;
using Misc;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class BOLTMAP_OBJ_INTERFACE
{
#region Pack
public class Pack_Params : IPack
{
public int boltNo1st;
public Range[] bolts;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(boltNo1st));
int len = bolts.Count();
buf.AddRange(BitConverter.GetBytes(len));
for (int i = 0; i < len; i++)
{
buf.AddRange(bolts[i].ToBytes());
}
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 8)
return false;
int idx = 0;
boltNo1st = BitConverter.ToInt32(value, idx);
idx += 4;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
if (value.Length < (idx + len * 8))
return false;
bolts = new Range[len];
for (int i = 0; i < len; i++)
{
bolts[i] = new Range();
bolts[i].TryParse(value, idx);
idx += 8;
}
return true;
}
#endregion
}
public class Pack_BorderParams:IPack
{
public BORDER_TYPE bordertype;
public int borderboltno_b;
public int borderboltno_e;
public int smooth;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes((int)bordertype));
buf.AddRange(BitConverter.GetBytes(borderboltno_b));
buf.AddRange(BitConverter.GetBytes(borderboltno_e));
buf.AddRange(BitConverter.GetBytes(smooth));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 16)
return false;
int idx = 0;
bordertype = (BORDER_TYPE)BitConverter.ToInt32(value, idx);
idx += 4;
borderboltno_b = BitConverter.ToInt32(value, idx);
idx += 4;
borderboltno_e = BitConverter.ToInt32(value, idx);
idx += 4;
smooth = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
public class Pack_BoltsInfo : IPack
{
public int LastBoltNo;
public int BoltInterval;
public int BoltWidth;
public int PosBegin;
public int PosEnd;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(LastBoltNo));
buf.AddRange(BitConverter.GetBytes(BoltInterval));
buf.AddRange(BitConverter.GetBytes(BoltWidth));
buf.AddRange(BitConverter.GetBytes(PosBegin));
buf.AddRange(BitConverter.GetBytes(PosEnd));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < 20)
return false;
int idx = 0;
LastBoltNo = BitConverter.ToInt32(value, idx);
idx += 4;
BoltInterval = BitConverter.ToInt32(value, idx);
idx += 4;
BoltWidth = BitConverter.ToInt32(value, idx);
idx += 4;
PosBegin = BitConverter.ToInt32(value, idx);
idx += 4;
PosEnd = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
#endregion
#region GetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 GET_PARAMS = 0;
/// <summary>
/// Pack_BorderParams
/// </summary>
public const UInt16 GET_BORDERPARAMS = 1;
/// <summary>
/// Pack_BoltsInfo
/// </summary>
public const UInt16 GET_BOLTSINFO = 2;
#endregion
#region SetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 SET_PARAMS = 0;
/// <summary>
/// Pack_BorderParams
/// </summary>
public const UInt16 SET_BORDERPARAMS = 1;
#endregion
#region PushMsg
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 PUSH_PARAMS = 0;
/// <summary>
/// Pack_BorderParams
/// </summary>
public const UInt16 PUSH_BORDERPARAMS = 1;
/// <summary>
/// Pack_BoltsInfo
/// </summary>
public const UInt16 PUSH_BOLTSINFO = 2;
#endregion
}
}