XPadApiInterface.java
21 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
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
package com.sunvote.xpadcomm;
import java.util.Arrays;
public interface XPadApiInterface {
//事件类型
public enum BaseEventType{
BaseEventWorkMode,
BaseEventBaseInfo
}
//状态类型
/*
* 下送类
* */
public static final int CMD_BASE_STATUS_CHANGE = 0x71;//基础信标变化
public static final int CMD_VOTE_STATUS_CHANGE = 0x72;//投票信标变化
public static final int CMD_KEY_MANAGE = 0x30; //表决器管理类指令,自定义透传指令
/*
*上传类
*/
public static final int CMD_VOTE_RESULT_SEND_RESPONSE = 0xF3;//投票结果上传应答
public static final int CMD_VOTE_SEND_SUCCESS_RESPONSE = 0x73;//传输入成功通知
/*
* 状态类
*/
public static final int CMD_CHECK_BASE_STATUS_RESPONSE = 0xF0;//查询和设置各类应答
//下载多包
public static final int CMD_MULTI_PCKAGE_DOWNLOAD = 0x40;//
public static final int CMD_FIRM_UPDATE_RESPONSE = 0xF8;//固件升级应答
public static final int CMD_COM_COMMUNICATION_TEST_RESPONSE = 0xB0; //串口测试应答
public static final int CMD_UPLOAD_DATA_RESPONSE = 0x20; //上传指令
/*******************************************************************************
******************************************************************************/
public static final int VoteType_Stop = 0 ;
public static final int VoteType_Signin = 1;
public static final int VoteType_Vote = 2;
public static final int VoteType_Evaluate = 3;//评议
public static final int VoteType_SingleItemEvalue = 4;//单项评分
public static final int VoteType_KeypadTest = 9;
public static final int VoteType_Choice = 10;
public static final int VoteType_BatchVote = 20;//批次
public static final int VoteType_BatchElect = 22;//选举
public static final int VoteType_BatchEvalue = 30; //带名称二维表评测模式 综合测评
public static final int VoteType_BatchIDEvalue = 31; //编号式二维表评测模式 综合测评
public static final int AnsType_Single = 1;//单值
public static final int AnsType_Select = 2;//选择
public static final int AnsType_Number = 3;//数字
public static final int AnsType_LoginIn = 16;//登录信息
public static final int AnsType_BatchSingle = 21;//批次单值结果
public static final int AnsType_BatchNumber = 23;//批次评分值结果
public static final int AnsType_SelectOther = 26;//
public static final int AnsType_Service = 33; //服务申请
/*
* 状态类
*/
public void getWorkMode();//查询模块工作模式
public void setWorkMode(int iMode);//设置模块工作模式
public void getBaseStatus();//查询基础信标
public void getVoteStatus();//查询投票信标
public void getKeypadParam(); //查询键盘参数
public void setKeypadParam(int keyId, byte[] KEYSN); //设置键盘参数
public void checkOnLine(int volt, int keyinStatus);//查询在线状态
public void execKeypadMatch(int iMode, int channal);//执行配对
public void configMode();//进入配置模式
public void comCommunicationTest(int sendn, int okn);//串口测试
/*
* 上传类
*/
public void submitVote(int ansType, String info);//ID模式结果
public void submitVoteBySn(byte[] keySn, String info); //SN模式结果
public void submitVoteAllOK(); //确认提交
public void submitVoteAllOKWithValue(int ansType, String info);//确认提交带某项结果
public void cancelSubmitVoteAllOK();
public void submitSelectOther(String info);
/*
* 固件升级
*/
public void startFirmUpdate(byte[] fileBuffer);
/*
* 透传
*/
public void sendCmdData(int cmdId, byte[] data);
/*
* 设置串口监听
*/
public void setComListener(ComListener cl);
public class BaseInfo{
public int baseId;//基站编号
public int idMode;//基站识别模式,1编号、2序列号
public int confId;//会议资料UID编号,1-65535,高位字节在前
public int billId;//议题编号
public int pageNo; //议案页码
public int authCode;//授权号,2字节,高位在前,0-0xFFFF
public int login;//登录申请模式(后台签到模式),是否需要IC卡、登录码(
public int report;//表决器报告状态模式和指定语言
public int offTime;//自动关机时间
public int attrib;//表决器特性:背光模式+蜂鸣器模式等等
public String baseName; //基站名称,最多12字节
}
public class ModelInfo{
public int mode;//模块当前主从模式 1 基站模式(主) 2 键盘模式(从)
public int hModel;//硬件型号,数字
public String sVer;//固件版本,3位数字,例如 0.1.0
}
public class KeypadInfo{
public int cmd1;//8:match 9:config
public int ok;
public int chan;
public int keyId;//键盘编号,高位在前
public String keySn;//6字节键盘序列号
public String matchCode;//4字节配对码
}
public class OnLineInfo{
public int onLine; //键盘是否在线 1 在线 2 离线
public int idMode;//基站的识别模式
public int chan; //当前频点号
public int rssi; //接收到基站的信号强度RSSI值,负数,越小表示信号越大
public int tx; //1表示刚才1秒内有提交数据过 0 表示没有
public int rx; //1 表示刚才1秒内收到过基站的投票指令(特指投票中) 0 表示没有
public int baseId;
public int keyId;
public String keySn;
public int comError=0;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OnLineInfo that = (OnLineInfo) o;
return onLine == that.onLine &&
idMode == that.idMode &&
chan == that.chan &&
rssi == that.rssi &&
tx == that.tx &&
rx == that.rx &&
baseId == that.baseId &&
keyId == that.keyId &&
comError == that.comError &&
(keySn == that.keySn || (keySn != null && keySn.equals(that.keySn)));
}
@Override
public int hashCode() {
return Arrays.hashCode(new Object[]{onLine, idMode, chan, rssi, tx, rx, baseId, keyId, keySn, comError});
}
@Override
public Object clone(){
OnLineInfo lineInfo = new OnLineInfo();
lineInfo.onLine = onLine;
lineInfo.idMode = idMode;
lineInfo.chan = chan;
lineInfo.rssi = rssi;
lineInfo.tx = tx;
lineInfo.rx = rx;
lineInfo.baseId = baseId;
lineInfo.keyId = keyId;
lineInfo.keySn = new String(keySn);
lineInfo.comError = comError;
return lineInfo;
}
}
public class SigninInfo{
public int signinMode; //1 按键签到模式, 2 Uid签到 , 3 SN
public int showUserInfo;
}
public class VoteInfo{
public int baseId;//[1]基站编号
public int nowT;//[2,3]
public int dataPos;//[4]
public int mode;// [5] 表决模式
public int mode1_msgType;// [6] mode=0时,就是MSGTYPE 2为投票结果显示
public int mode2_modify; // [7]投票参数 0不可修改 1可修改
public int mode3_secret;//[8]投票参数 保密
public int mode4;//[9]投票参数
public int mode5;//
public int mode6;
public int mode7;
/**
* 是否带票数限定,,对批次表决、批次评议、批次自定义评议有效
0 不限定
1 带票数限定
*/
public int fixballot;
/**
* 赞成限制 0 限制
*/
public int limitFavor ;
/**
* 反对限制(0 不限制)
*/
public int limitOppo;
/**
* 弃权限制(0 不限制)
*/
public int limitWaiver ;
public int voteid; //[11] >1 指定议案编号 0,不指定,相当于快速表决
public int file; //[12]是否允许切换标题和内容 0 不允许 1允许
public int init; //[13]初始是标题还是内容 0 标题 1内容
public int less;//[11]
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VoteInfo voteInfo = (VoteInfo) o;
if (baseId != voteInfo.baseId) return false;
if (nowT != voteInfo.nowT) return false;
if (dataPos != voteInfo.dataPos) return false;
if (mode != voteInfo.mode) return false;
if (mode1_msgType != voteInfo.mode1_msgType) return false;
if (mode2_modify != voteInfo.mode2_modify) return false;
if (mode3_secret != voteInfo.mode3_secret) return false;
if (mode4 != voteInfo.mode4) return false;
if (mode5 != voteInfo.mode5) return false;
if (mode6 != voteInfo.mode6) return false;
if (mode7 != voteInfo.mode7) return false;
if (fixballot != voteInfo.fixballot) return false;
if (limitFavor != voteInfo.limitFavor) return false;
if (limitOppo != voteInfo.limitOppo) return false;
if (limitWaiver != voteInfo.limitWaiver) return false;
if (voteid != voteInfo.voteid) return false;
if (file != voteInfo.file) return false;
if (init != voteInfo.init) return false;
if (less != voteInfo.less) return false;
if (!resultInfo.equals(voteInfo.resultInfo)) return false;
if (!electInfo.equals(voteInfo.electInfo)) return false;
if (!singleEvalueInfo.equals(voteInfo.singleEvalueInfo)) return false;
return batchEvalueInfo.equals(voteInfo.batchEvalueInfo);
}
@Override
public int hashCode() {
int result = baseId;
result = 31 * result + nowT;
result = 31 * result + dataPos;
result = 31 * result + mode;
result = 31 * result + mode1_msgType;
result = 31 * result + mode2_modify;
result = 31 * result + mode3_secret;
result = 31 * result + mode4;
result = 31 * result + mode5;
result = 31 * result + mode6;
result = 31 * result + mode7;
result = 31 * result + fixballot;
result = 31 * result + limitFavor;
result = 31 * result + limitOppo;
result = 31 * result + limitWaiver;
result = 31 * result + voteid;
result = 31 * result + file;
result = 31 * result + init;
result = 31 * result + less;
result = 31 * result + resultInfo.hashCode();
result = 31 * result + electInfo.hashCode();
result = 31 * result + singleEvalueInfo.hashCode();
result = 31 * result + batchEvalueInfo.hashCode();
return result;
}
public ResultInfo resultInfo = new ResultInfo();
public class ResultInfo{//结果
public int resultType;//[7] 结果显示类型 。 如 0为 签到 1为表决
public int bits;// [8]
public int num0;//[9-10]
public int num1;//[11,12]
public int num2;//[13,14]
public int num3;//[15,16]
public int num4;//[17,18]
public int num5;//[19,20]
public int num6;//[21,22]
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ResultInfo that = (ResultInfo) o;
if (resultType != that.resultType) return false;
if (bits != that.bits) return false;
if (num0 != that.num0) return false;
if (num1 != that.num1) return false;
if (num2 != that.num2) return false;
if (num3 != that.num3) return false;
if (num4 != that.num4) return false;
if (num5 != that.num5) return false;
return num6 == that.num6;
}
@Override
public int hashCode() {
int result = resultType;
result = 31 * result + bits;
result = 31 * result + num0;
result = 31 * result + num1;
result = 31 * result + num2;
result = 31 * result + num3;
result = 31 * result + num4;
result = 31 * result + num5;
result = 31 * result + num6;
return result;
}
}
public ElectInfo electInfo = new ElectInfo();
public class ElectInfo{
public int type;//[6];
public int random;//[7];
public int select;//[8];
public int other;//[9];
public int less;//[10]
public int secrecy;//[11]
public int modify;//[12]
public int start;//[13]
public int end;//[14]
public int equityMode;//[15]
public int minSelect;//[16]
public int voteid;//[21]
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ElectInfo electInfo = (ElectInfo) o;
if (type != electInfo.type) return false;
if (random != electInfo.random) return false;
if (select != electInfo.select) return false;
if (other != electInfo.other) return false;
if (less != electInfo.less) return false;
if (secrecy != electInfo.secrecy) return false;
if (modify != electInfo.modify) return false;
if (start != electInfo.start) return false;
if (end != electInfo.end) return false;
if (equityMode != electInfo.equityMode) return false;
if (minSelect != electInfo.minSelect) return false;
return voteid == electInfo.voteid;
}
@Override
public int hashCode() {
int result = type;
result = 31 * result + random;
result = 31 * result + select;
result = 31 * result + other;
result = 31 * result + less;
result = 31 * result + secrecy;
result = 31 * result + modify;
result = 31 * result + start;
result = 31 * result + end;
result = 31 * result + equityMode;
result = 31 * result + minSelect;
result = 31 * result + voteid;
return result;
}
}
public SingleItemEvalueInfo singleEvalueInfo = new SingleItemEvalueInfo();
public class SingleItemEvalueInfo{
public int mode1;//[6];
public int mode2;//[7];
public int mode3;//[8];
public int mode4;//[9];
public int mode5;
public int mode6;
public int mode7;
public int mode8;
public int mode9;
public int mode10;
public int mode11;
public int mode12;
public byte[] title;
public int number;//[24]
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SingleItemEvalueInfo that = (SingleItemEvalueInfo) o;
if (mode1 != that.mode1) return false;
if (mode2 != that.mode2) return false;
if (mode3 != that.mode3) return false;
if (mode4 != that.mode4) return false;
if (mode5 != that.mode5) return false;
if (mode6 != that.mode6) return false;
if (mode7 != that.mode7) return false;
if (mode8 != that.mode8) return false;
if (mode9 != that.mode9) return false;
if (mode10 != that.mode10) return false;
if (mode11 != that.mode11) return false;
if (mode12 != that.mode12) return false;
if (number != that.number) return false;
return Arrays.equals(title, that.title);
}
@Override
public int hashCode() {
int result = mode1;
result = 31 * result + mode2;
result = 31 * result + mode3;
result = 31 * result + mode4;
result = 31 * result + mode5;
result = 31 * result + mode6;
result = 31 * result + mode7;
result = 31 * result + mode8;
result = 31 * result + mode9;
result = 31 * result + mode10;
result = 31 * result + mode11;
result = 31 * result + mode12;
result = 31 * result + Arrays.hashCode(title);
result = 31 * result + number;
return result;
}
}
public BatchEvalueInfo batchEvalueInfo = new BatchEvalueInfo();
public class BatchEvalueInfo{
public int mode1;//[6];
public int startVal;//[7];
public int endVal;//[7];
public int autoMove;//[7];
public int width1;//[7];
public int width2;//[7];
public int less;//[7];
public int secrecy;//[7];
public int modify;//[7];
public int ruleStart;//[7];
public int ruleEnd;//[7];
public int sliderover;//[7];
public int billNo; // 议案编号
public int billSubNo ; // 议案子编号
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BatchEvalueInfo that = (BatchEvalueInfo) o;
if (mode1 != that.mode1) return false;
if (startVal != that.startVal) return false;
if (endVal != that.endVal) return false;
if (autoMove != that.autoMove) return false;
if (width1 != that.width1) return false;
if (width2 != that.width2) return false;
if (less != that.less) return false;
if (secrecy != that.secrecy) return false;
if (modify != that.modify) return false;
if (ruleStart != that.ruleStart) return false;
if (ruleEnd != that.ruleEnd) return false;
if (sliderover != that.sliderover) return false;
if (billNo != that.billNo) return false;
return billSubNo == that.billSubNo;
}
@Override
public int hashCode() {
int result = mode1;
result = 31 * result + startVal;
result = 31 * result + endVal;
result = 31 * result + autoMove;
result = 31 * result + width1;
result = 31 * result + width2;
result = 31 * result + less;
result = 31 * result + secrecy;
result = 31 * result + modify;
result = 31 * result + ruleStart;
result = 31 * result + ruleEnd;
result = 31 * result + sliderover;
result = 31 * result + billNo;
result = 31 * result + billSubNo;
return result;
}
}
//Deprecated blow
// public int voteMode;// 表决模式
// public int modifyMode;//修改模式
// public int secretMode;//保密模式
// public int quickTitleMode;//在Mode1=3的时候,是使用哪种标准
// public String title; //在Mode1=3的时候,是表决项目的标题,14字节字符,可支持7个汉字
// public int voteNo;//议案号(0-255),0表示不启用键盘记录表决结果,1到255表示启用键盘记录表决结果(但具体最大值看键盘)
}
public class BatchVoteInfo{
public int start; //6-7 开始项目编号,2字节,高位在前,从1开始,小于项目表最大项目数
public int end; //8-9 结束项目编号,2字节,高位在前,一般比START值大,和START值相同时候表示仅选一项目
public int mode1; //10特殊模式,脱机调研模式或快速批次投票
public int less; //迫先模式 0 不迫选 1 迫选,所有议题必需做出选择 2 调研模式
public int secret; //
public int fixballot;//是否带票数限定,,对批次表决、批次评议、批次自定义评议有效 0 不限定 1 带票数限定
public byte[] limit = new byte[8]; //如果是票数限定,8字节依次是每个等级限定的票数
public int rule; //无项目名称表的批次表决、批次评议、批次评分时候使用规则 批次表决时候,1=3键表决,2=2键表决 批次评议时候,是评议规则表的规则号,从1开始
//批次评分时候,是评分规则表中的规则好,从1开始
public int modify; //0 不允许修改 1 允许修改,
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BatchVoteInfo that = (BatchVoteInfo) o;
if (start != that.start) return false;
if (end != that.end) return false;
if (mode1 != that.mode1) return false;
if (less != that.less) return false;
if (secret != that.secret) return false;
if (fixballot != that.fixballot) return false;
if (rule != that.rule) return false;
if (modify != that.modify) return false;
return Arrays.equals(limit, that.limit);
}
@Override
public int hashCode() {
int result = start;
result = 31 * result + end;
result = 31 * result + mode1;
result = 31 * result + less;
result = 31 * result + secret;
result = 31 * result + fixballot;
result = 31 * result + Arrays.hashCode(limit);
result = 31 * result + rule;
result = 31 * result + modify;
return result;
}
}
/*
* 选举投票信标
*/
public class BatchSelectInfo{
public int type ;// 人机界面模式,不同型号可能不同 0缺省,使用打勾模式 1 使用赞成、反对模式 2 使用累计投票制
public int random; //
public int select;//要选出的人数(赞成票数)
public int other; //是否允许另选他人 0 不允许 1 允许(在名称表中选) 2 允许,另外输入
public int less; //迫选,是否允许少选 0 允许 1 不允许,必须要选出SELECT个人员 2 允许少选,但限定最少必选人数(InfoWyse M52Li定制),参数在第16字节
public int secrecy;
public int modify;
public int start;
public int end;
public int equityMode;
public int minSelect;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BatchSelectInfo that = (BatchSelectInfo) o;
if (type != that.type) return false;
if (random != that.random) return false;
if (select != that.select) return false;
if (other != that.other) return false;
if (less != that.less) return false;
if (secrecy != that.secrecy) return false;
if (modify != that.modify) return false;
if (start != that.start) return false;
if (end != that.end) return false;
if (equityMode != that.equityMode) return false;
return minSelect == that.minSelect;
}
@Override
public int hashCode() {
int result = type;
result = 31 * result + random;
result = 31 * result + select;
result = 31 * result + other;
result = 31 * result + less;
result = 31 * result + secrecy;
result = 31 * result + modify;
result = 31 * result + start;
result = 31 * result + end;
result = 31 * result + equityMode;
result = 31 * result + minSelect;
return result;
}
}
/*
* 评议投票信标
*/
public class EvaluateInfo{
public int mode1;
public int modify;
public int secrecy;
public int mode4;
}
public class KeypadTestInfo{
public int mode1;
public int mode2;
public int mode3;
}
public class CmdDataInfo{
public int cmd;
public byte[] data;
}
}