Blame view

C5/xpadprotocal/src/main/java/com/sunvote/cmd/push/DownloadSingletonPkgResponse.java 3.21 KB
fac86401   孙向锦   初始化C5 Vote
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
  package com.sunvote.cmd.push;
  
  import com.sunvote.cmd.ICmd;
  
  import java.io.ByteArrayOutputStream;
  import java.util.Arrays;
  
  /**
   * Created by Elvis on 2017/8/23.
   * Email:Eluis@psunsky.com
   * 版权所有:长沙中天电子设计开发有限公司
   * Description:平板模块键盘投票功能模块
   *
   * 字节	标识符	描述
   1	KEYCMD	0xB0 表决器遥控指令应答
   2-3	KEYID	表决器编号,2字节,高位在前
   4	KCMD	1 表决器配置信息
   5-6	KEYID	表决器编号
   7	OFFTIME	表决器自动关机时间
   8	LOCKBASE	固定配对模式还是自由配对模式
   9-24		参数无意义
  
   */
  public class DownloadSingletonPkgResponse extends PushBaseCmd {
  
      public static final byte CMD = (byte) 0xB0;
  
      /**
       * KEYCMD	0xB0 表决器遥控指令应答
       */
      private byte keyCmd = CMD ;
  
      /**
       * KEYID	表决器编号,2字节,高位在前
       */
      private byte[] keyId = new byte[2];
  
      /**
       * KCMD	1 表决器配置信息
       */
      private byte kcmd ;
  
      /**
       * KEYID	表决器编号
       */
      private byte[] keyId2 = new byte[2];
  
      private byte offtime ;
  
      /**
       * LOCKBASE	固定配对模式还是自由配对模式
       */
      private byte lockBase;
  
      /**
       * 9-24		参数无意义
       */
      private byte[] datas = new byte[16];
  
  
      @Override
      public byte[] toBytes() {
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          try {
              outputStream.write(getKeyCmd());
              outputStream.write(getKeyId());
              outputStream.write(getKcmd());
              outputStream.write(getKeyId2());
              outputStream.write(getOfftime());
              outputStream.write(getLockBase());
              outputStream.write(getDatas());
              return outputStream.toByteArray();
          }catch (Exception ex){
              return new byte[0];
          }
      }
  
      @Override
      public ICmd parseCmd(byte[] source, int start) {
          setKeyCmd(source[start]);
          setKeyId(new byte[]{source[start+1],source[start+2]});
          setKcmd(source[start+3]);
          setKeyId2(new byte[]{source[start+4],source[start+5]});
          setOfftime(source[6]);
          setLockBase(source[start+7]);
          setDatas(Arrays.copyOfRange(source, start+8, start+24));
          return this;
      }
  
      public void setOfftime(byte offtime) {
          this.offtime = offtime;
      }
  
      public byte getOfftime() {
          return offtime;
      }
  
      public byte getKeyCmd() {
          return keyCmd;
      }
  
      public void setKeyCmd(byte keyCmd) {
          this.keyCmd = keyCmd;
      }
  
      public byte[] getKeyId() {
          return keyId;
      }
  
      public void setKeyId(byte[] keyId) {
          this.keyId = keyId;
      }
  
      public byte getKcmd() {
          return kcmd;
      }
  
      public void setKcmd(byte kcmd) {
          this.kcmd = kcmd;
      }
  
      public byte[] getKeyId2() {
          return keyId2;
      }
  
      public void setKeyId2(byte[] keyId2) {
          this.keyId2 = keyId2;
      }
  
      public byte getLockBase() {
          return lockBase;
      }
  
      public void setLockBase(byte lockBase) {
          this.lockBase = lockBase;
      }
  
      public byte[] getDatas() {
          return datas;
      }
  
      public void setDatas(byte[] datas) {
          this.datas = datas;
      }
  }