20c0108c
wutaian
xx
|
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using GeneralLib;
namespace SunVoteARSPPT
{
public class Demo : IResponse
{
/// <summary>
/// 演示模式类
/// </summary>
public Imitation DemoMode = null;
/// <summary>
/// 要演示的键盘编号
/// </summary>
public static string[] Keypads { get; set; }
public static Dictionary<string, string> PollList { get; set; }
/// <summary>
/// 签到码列表
/// 2012-06-18
/// </summary>
public static Dictionary<string, string> SignCodeList { get; set; }
/// <summary>
/// 构造函数
/// </summary>
public Demo()
{
DemoMode = new Imitation();
DemoMode.KeyIDList = new List<string>();
DemoMode.Interval = 500;//杨斌 2012-06-27 模拟太快了按键音效太密
DemoMode.DemoCreat += new DemoCreatEvt(DemoMode_DemoCreat);
}
/// <summary>
/// 演示模式收取数据
/// </summary>
/// <param name="Result"></param>
void DemoMode_DemoCreat(DemoResult Result)
{
if (DemoMode.DemoType.GetType().Name == "ChoiceDemo")
{
Result.Value = Result.Value.Replace("10", "0");
Result.Value = Result.Value.Replace(",", "");
}
Result.Value = ConvertOper.DoNumberString(Result.Value);//杨斌 2013-08-29
ResponsePar ObjResponseValue = new ResponsePar();
ObjResponseValue.BaseTag = "1";
ObjResponseValue.KeyID = Result.KeyID.ToString();
ObjResponseValue.KeyValue = Result.Value;
if (ResponseType == ResponseType.Poll)
{
if (PollList.ContainsKey(Result.Value))
{
//if (GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll)
//杨斌 2017-02-13
if (PanelPoll.IsUseMultiPoll(Globals.SunVoteARSAddIn.PPTShow.SlideShow))
{
//杨斌 2018-11-22。SDK分段式选举与数字选举不兼容,数字选举模式4值为"1=4",而分段式模式7值为"01-4"
int UseModeLimitNumber = TagSet.GetValue(TagKey.Poll_UseModeLimitNumber).ToInt;
if (UseModeLimitNumber == 1)
ObjResponseValue.KeyValue = Result.Value + "-" + PollList[Result.Value];
else
ObjResponseValue.KeyValue = Result.Value + "=" + PollList[Result.Value];
}
else
ObjResponseValue.KeyValue = PollList[Result.Value];
}
}
//2012-06-19 添加签到码签到的演示模式
if ((ResponseType == ResponseType.SignIn) && (TagSet.GetValue(TagKey.SignIn_Mode).ToInt > 0))//杨斌 2017-03-30
{
//if (SignCodeList.ContainsKey(Result.Value))
// ObjResponseValue.KeyValue = SignCodeList[Result.Value];
}
ObjResponseValue.Speed = Result.Speed;
//多选收到的按键进行排序,与硬件一致,如21转为12。杨斌 2012-11-07
//注意choice.OptionsMode = 1才有效,否则0要放到最后
int n0 = ObjResponseValue.KeyValue.IndexOf('0');
switch (ResponseType)
{
case ResponseType.Choice:
if (n0 >= 0)
{
ObjResponseValue.KeyValue = ObjResponseValue.KeyValue.Replace('0', 'J');
}
char[] ary = ObjResponseValue.KeyValue.ToCharArray();
Array.Sort(ary);
ObjResponseValue.KeyValue = new string(ary);
if (n0 >= 0)
{
ObjResponseValue.KeyValue = ObjResponseValue.KeyValue.Replace('J', '0');
}
break;
default:
break;
}
ResponseEventHander(ObjResponseValue);
}
/// <summary>
/// 初始化键盘范围
/// 修改:杨斌 2012-06-27 模拟太快了按键音效太密
/// </summary>
/// <returns></returns>
private bool IniKeypadArea()
{
//if (Keypads == null)
// throw (new ApplicationException(l.LPT.ReadString("DemoSDK", "initialize", "没有初始化演示的键盘范围")));
//if (Keypads.Length < 1)
// throw (new ApplicationException(GlobalInfo.LPT.ReadString("DemoSDK", "setting", "没有设置演示的键盘范围")));
DemoMode.KeyIDList.Clear();
DemoMode.ResultList.Clear();//重新反馈或清空结果时调用
for (int i = 0; i < Keypads.Length; i++)
{
DemoMode.KeyIDList.Add(Keypads[i]);
}
//根据设置的键盘数动态设置反馈事件的触发时间间隔
int interval = 500;
//2012-06-14 赵丽 键盘个数为0时报错
if (DemoMode.KeyIDList.Count != 0)
{
interval = 10 * 1000 / DemoMode.KeyIDList.Count;
//杨斌 2014-04-22
int max = 200;
if (interval > max)
interval = max;
}
//interval = interval > 500 ? 500 : interval;//杨斌 2012-10-15,去掉此行
DemoMode.Interval = interval;
return true;
}
#region IResponse 成员
public event ResponseEventHander ResponseEventHander;
/// <summary>
/// 开始演示投票
/// </summary>
public void Start()
{
IniKeypadArea();
switch (ResponseType)
{
case ResponseType.Choice:
IniChoice();
break;
case ResponseType.Grade:
IniGrade();
break;
case ResponseType.Group:
IniGroup();
break;
case ResponseType.Vote:
IniVote();
break;
case ResponseType.Judge:
IniJudge();
break;
case ResponseType.Number:
IniNumber();
break;
case ResponseType.Order:
IniOrder();
break;
case ResponseType.Poll:
IniPoll();
break;
case ResponseType.Score:
IniScore();
break;
case ResponseType.SignIn:
IniSigIn();
break;
default:
break;
}
DemoMode.Start();
}
/// <summary>
/// 选择题初始化参数
/// </summary>
private void IniChoice()
{
ChoiceDemo choice = new ChoiceDemo();
choice.IsForced = TagSet.GetValue(TagKey.Choice_IisN).ToBoolean;//杨斌 2012-06-27 演示模式时应判断是否迫选
choice.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt;//杨斌 2012-06-27
choice.OptionCount = TagSet.GetValue(TagKey.Choice_OptionCount).ToInt;
choice.LimitCount = TagSet.GetValue(TagKey.Choice_OptionLimit).ToInt;
choice.IsOrderly = true;
DemoMode.DemoType = choice;
}
/// <summary>
/// 等级初始化参数
/// </summary>
private void IniGrade()
{
ChoiceDemo grade = new ChoiceDemo();
grade.IsForced = false;//杨斌 2012-06-27
grade.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt;//杨斌 2012-06-27
grade.LimitCount = 1;
grade.OptionCount = TagSet.GetValue(TagKey.Grade_OptionCount).ToInt;
DemoMode.DemoType = grade;
}
/// <summary>
/// 分组初始化参数
/// </summary>
private void IniGroup()
{
ChoiceDemo gruop = new ChoiceDemo();
gruop.IsForced = false;//杨斌 2012-06-27
gruop.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1 ? 0 : 1;//杨斌 2012-06-27
gruop.LimitCount = 1;
gruop.OptionCount = TagSet.GetValue(TagKey.Group_OptionCount).ToInt;
DemoMode.DemoType = gruop;
}
/// <summary>
/// 判断初始化参数
/// </summary>
private void IniJudge()
{
ChoiceDemo judge = new ChoiceDemo();
judge.IsForced = false;//杨斌 2012-06-27
judge.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1 ? 0 : 1;//杨斌 2012-06-27
judge.LimitCount = 1;
judge.OptionCount = 2;
DemoMode.DemoType = judge;
}
//初始化表决
private void IniVote()
{
ChoiceDemo vote = new ChoiceDemo();
vote.IsForced = false;//杨斌 2012-06-27
vote.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1 ? 0 : 1;//杨斌 2012-06-27
vote.LimitCount = 1;
vote.OptionCount = TagSet.GetValue(TagKey.Vote_OptionCount).ToInt;
DemoMode.DemoType = vote;
}
/// <summary>
/// 数值初始化
/// </summary>
private void IniNumber()
{
NumberDemo number = new NumberDemo();
//number.MaxLength = 10;
string lowRange = TagSet.GetValue(TagKey.Number_LowRange).Value;
string highRange = TagSet.GetValue(TagKey.Number_HighRange).Value;
string dec = TagSet.GetValue(TagKey.Number_DecimalFormat).Value;
number.Decimal = (dec.Trim() == "") ? 0 : (ConvertOper.Convert(dec).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
//最小值
number.MinVal = (lowRange.Trim() == "") ? -9999999 : (ConvertOper.Convert(lowRange).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
//最大值
number.MaxVal = (highRange.Trim() == "") ? 9999999 : (ConvertOper.Convert(highRange).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
DemoMode.DemoType = number;
}
/// <summary>
/// 初始化排序
/// </summary>
private void IniOrder()
{
ChoiceDemo order = new ChoiceDemo();
order.IsForced = TagSet.GetValue(TagKey.Order_IisN).ToBoolean;//杨斌 2012-06-27 演示模式时应判断是否迫选
order.IsABC = true;//TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1 ? 0 : 1;//杨斌 2012-06-27
order.OptionCount = TagSet.GetValue(TagKey.Order_OptionCount).ToInt;
order.LimitCount = TagSet.GetValue(TagKey.Order_OptionLimit).ToInt;
order.IsOrderly = false;
DemoMode.DemoType = order;
}
/// <summary>
/// 初始化选举
/// </summary>
private void IniPoll()
{
NumberDemo poll = new NumberDemo();
poll.Decimal = 0;
//poll.MaxLength = 10;
if (PollList.Count > 0)
{
//最小值
poll.MinVal = 0;
//最大值
poll.MaxVal = PollList.Count - 1;
}
else//杨斌 2014-10-24
{
//最小值
poll.MinVal = 8801;
//最大值
poll.MaxVal = 8820;
}
DemoMode.DemoType = poll;
}
/// <summary>
/// 初始化分数
/// </summary>
private void IniScore()
{
NumberDemo score = new NumberDemo();
string lowRange = TagSet.GetValue(TagKey.Score_LowRange).Value;
string highRange = TagSet.GetValue(TagKey.Score_HighRange).Value;
string dec = TagSet.GetValue(TagKey.Score_DecimalFormat).Value;
//score.MaxLength = 10;
score.Decimal = (dec.Trim() == "") ? 0 : (ConvertOper.Convert(dec).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
//最小值
score.MinVal = (lowRange.Trim() == "") ? 0 : (ConvertOper.Convert(lowRange).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
//最大值
score.MaxVal = (highRange.Trim() == "") ? 99999 : (ConvertOper.Convert(highRange).ToInt);//Convert.ToInt32有问题。杨斌 2012-11-15
DemoMode.DemoType = score;
}
/// <summary>
/// 初始化签到
/// </summary>
private void IniSigIn()
{
BaseDemo signIn = new BaseDemo();
signIn.ResultValue = "1";
DemoMode.DemoType = signIn;
}
/// <summary>
/// 键盘测试
/// </summary>
public void KeyTestStart()
{
ChoiceDemo vote = new ChoiceDemo();
vote.OptionCount = 3;
vote.LimitCount = 1;
DemoMode.DemoType = vote;
DemoMode.Start();
}
public void Stop()
{
DemoMode.Stop();
}
/// <summary>
/// 基站连接类,演示模式不需要
/// </summary>
public SunVote.BaseConnection BaseConnection { get; set; }
/// <summary>
/// 幻灯片容器
/// </summary>
public TagSet TagSet { get; set; }
/// <summary>
/// 反馈类型
/// </summary>
public ResponseType ResponseType { get; set; }
#endregion
}
}
|