#
vincentlu
7 天以前 2743d98b983b7ecd049093931749db749b4b2fe4
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/AGV_12_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,35 +24,48 @@
    @Override
    public void readFromBytes(byte[] bytes) {
        int qrCodeBytes = QrCodeCodecSupport.qrCodeBytes();
        int offsetXPos = qrCodeBytes;
        int offsetYPos = offsetXPos + 2;
        int groundCodeOffsetPos = offsetYPos + 2;
        int statusPos = groundCodeOffsetPos + 4;
        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);
        //地面码偏移x
        this.offsetX = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 4 , 2));
        this.offsetX = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, offsetXPos , 2));
        //地面码偏移y
        this.offsetY = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 6, 2));
        this.offsetY = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, offsetYPos, 2));
        //地面码偏移θ
        this.groundCodeOffset0 = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 8, 4));
        this.groundCodeOffset0 = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, groundCodeOffsetPos, 4));
        //当前状态
        this.status = Utils.slice(bytes, 12, 1)[0];
        this.status = Utils.slice(bytes, statusPos, 1)[0];
        //直行方向坐标
        this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 13, 4));
        this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, straightDirectionPos, 4));
        //AGV当前角度
//        this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4));
        this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, 17, 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, 21, 4));
        this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, gyroAnglePos, 4));
        //编码器角度
        this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 25, 4));
        this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, encoderAnglePos, 4));
        //当前高度
        this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 29, 2));
        this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, currentAltitudePos, 2));
        //货叉伸出距离
        this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 31, 2));
        this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, forkLengthPos, 2));
        //载货台旋转角度
        this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 33, 2));
        this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, loaderThetaPos, 2));
        //传感器状态标志
//        this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 35, 4));
//        this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, sensorStatusPos, 4));
        byte[] sensorStatusBytes = Utils.slice(bytes, 35, 4);
        byte[] sensorStatusBytes = Utils.slice(bytes, sensorStatusPos, 4);
        parseSensorStatue(sensorStatusBytes);
    }