#
vincentlu
7 天以前 2743d98b983b7ecd049093931749db749b4b2fe4
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/AGV_13_UP.java
@@ -1,7 +1,7 @@
package com.zy.acs.common.domain.protocol;
import com.zy.acs.framework.common.RadixTools;
import com.zy.acs.common.constant.CommonConstant;
import com.zy.acs.common.utils.QrCodeCodecSupport;
import com.zy.acs.common.utils.Utils;
import lombok.Data;
@@ -24,29 +24,39 @@
    @Override
    public void readFromBytes(byte[] bytes) {
        int qrCodeBytes = QrCodeCodecSupport.qrCodeBytes();
        int statusPos = qrCodeBytes;
        int straightDirectionPos = statusPos + 1;
        int currentAnglePos = straightDirectionPos + 4;
        int gyroAnglePos = currentAnglePos + 4;
        int encoderAnglePos = gyroAnglePos + 4;
        int currentAltitudePos = encoderAnglePos + 4;
        int forkLengthPos = currentAltitudePos + 2;
        int loaderThetaPos = forkLengthPos + 2;
        int sensorStatusPos = loaderThetaPos + 2;
        //地面码ID
        this.qrCode =  Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 0, 4))), CommonConstant.QR_CODE_LEN);;
        this.qrCode = QrCodeCodecSupport.decode(bytes, 0);
        //当前状态
        this.status = Utils.slice(bytes, 4, 1)[0];
        this.status = Utils.slice(bytes, statusPos, 1)[0];
        //直行方向坐标
        this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 5, 4));
        this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, straightDirectionPos, 4));
        //AGV当前角度
//        this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 9, 4));
        this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, 9, 4)).getFloat();
//        this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, currentAnglePos, 4));
        this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, currentAnglePos, 4)).getFloat();
        //陀螺仪角度
        this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 13, 4));
        this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, gyroAnglePos, 4));
        //编码器角度
        this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4));
        this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, encoderAnglePos, 4));
        //当前高度
        this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 21, 2));
        this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, currentAltitudePos, 2));
        //货叉伸出距离
        this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 23, 2));
        this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, forkLengthPos, 2));
        //载货台旋转角度
        this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 25, 2));
        this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, loaderThetaPos, 2));
        //传感器状态标志
//        this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 27, 4));
//        this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, sensorStatusPos, 4));
        byte[] sensorStatusBytes = Utils.slice(bytes, 27, 4);
        byte[] sensorStatusBytes = Utils.slice(bytes, sensorStatusPos, 4);
        parseSensorStatue(sensorStatusBytes);
    }