| | |
| | | package com.zy.acs.common.domain.protocol; |
| | | |
| | | import com.zy.acs.common.constant.CommonConstant; |
| | | import com.zy.acs.common.utils.QrCodeCodecSupport; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.RadixTools; |
| | | import lombok.Data; |
| | |
| | | |
| | | @Override |
| | | public void readFromBytes(byte[] bytes) { |
| | | int qrCodeBytes = QrCodeCodecSupport.qrCodeBytes(); |
| | | int qrCodePos = 16; |
| | | int actionCodePos = qrCodePos + qrCodeBytes; |
| | | // 流水号 |
| | | this.serialNo = new String(Utils.sliceWithReverse(bytes, 0, 16)); |
| | | // 地面码ID |
| | | this.qrCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 16, 4))), CommonConstant.QR_CODE_LEN); |
| | | this.qrCode = QrCodeCodecSupport.decode(bytes, qrCodePos); |
| | | // 动作码 |
| | | this.actionCode = Utils.slice(bytes, 20, 1)[0]; |
| | | this.actionCode = Utils.slice(bytes, actionCodePos, 1)[0]; |
| | | // 属性值 |
| | | this.val = Utils.slice(bytes, 21, 1)[0]; |
| | | this.val = Utils.slice(bytes, actionCodePos + 1, 1)[0]; |
| | | // 动作参数 |
| | | byte[] actionBodyBytes = Utils.sliceWithReverse(bytes, 22, 2); |
| | | byte[] actionBodyBytes = Utils.sliceWithReverse(bytes, actionCodePos + 2, 2); |
| | | this.actionBody = RadixTools.byteToShort(actionBodyBytes); |
| | | //预留字段 |
| | | this.reservedField = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 24, 4)); |
| | | this.reservedField = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, actionCodePos + 4, 4)); |
| | | } |
| | | |
| | | // 流水号 - 16 |