zuoxiao
2024-03-06 1cbb505922e010cace51020773a2dc1529713322
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
package com.dayu.rechargeqh.socketBean;
 
import com.dayu.rechargeqh.tools.ArraysUtil;
import com.dayu.rechargeqh.tools.BcdUtil;
import com.dayu.rechargeqh.utils.CRC8;
 
/**
 * Copyright (C), 2022,
 * Author: zuo
 * Date: 2022/2/7 11:20
 * Description:确认收到注册报文 ——————请求
 */
public class ConfirmMachineRequestBean extends BaseSocketBean {
    String control;//控制域C表示报文传输方向和所提供的传输服务类型的信息,0x00代表此帧报文是由中心端发出的下行报文;// 0x01 表示此帧报文是由终端发出的上行报文;
    String address;//BCD十位为乡最后一位,个位为村第一位
    String xuLie;
    String AFN = "91";
    String initCode;//设备注册号
 
    @Override
    public byte[] toByte() {
        byte[] data = new byte[27];
        data[0] = CRC8.hexStrToBinaryStr(control)[0];
        byte[] addressByte = BcdUtil.strToBcd(address);
        ArraysUtil.copyof(data, addressByte, 1);
        byte[] xulieByte = CRC8.hexStrToBinaryStr(xuLie);
        ArraysUtil.copyof(data, xulieByte, 7);
        ArraysUtil.copyof(data, CRC8.hexStrToBinaryStr(AFN)[0], 10);
        byte[] initCodeByte = CRC8.hexStrToBinaryStr(initCode);
        ArraysUtil.copyof(data, initCodeByte, 11);
        return data;
    }
 
    @Override
    public String toString() {
        return
                control +
                        address +
                        xuLie +
                        AFN +
                        initCode;
    }
 
    public String getControl() {
        return control;
    }
 
    public void setControl(String control) {
        this.control = control;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    public String getXuLie() {
        return xuLie;
    }
 
    public void setXuLie(String xuLie) {
        this.xuLie = xuLie;
    }
 
    public String getAFN() {
        return AFN;
    }
 
    public void setAFN(String AFN) {
        this.AFN = AFN;
    }
 
    public String getInitCode() {
        return initCode;
    }
 
    public void setInitCode(String initCode) {
        this.initCode = initCode;
    }
 
 
}