#
whycq
2025-01-08 00fd3eb5037f07763d4e8d3e5729066d3dc097ea
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package com.example.agvcontroller.protocol;
 
 
import com.example.agvcontroller.action.CommonConstant;
import com.example.agvcontroller.socket.RadixTools;
 
import java.io.Serializable;
import java.nio.ByteBuffer;
 
/**
 * 实时数据包1
 * Created by vincent on 2023/3/16
 */
public class AGV_12_UP implements IMessageBody, Serializable {
 
    private static final long serialVersionUID = 7485846034848121068L;
 
    @Override
    public byte[] writeToBytes() {
        return new byte[0];
    }
 
    @Override
    public void readFromBytes(byte[] bytes) {
        //地面码ID
        this.qrCode =  Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 0, 4))), CommonConstant.QR_CODE_LEN);;
        //地面码偏移x
        this.offsetX = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 4 , 2));
        //地面码偏移y
        this.offsetY = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 6, 2));
        //地面码偏移θ
        this.groundCodeOffset0 = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 8, 4));
        //当前状态
        this.status = Utils.slice(bytes, 12, 1)[0];
        //直行方向坐标
        this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 13, 4));
        //AGV当前角度
//        this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4));
        this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, 17, 4)).getFloat();
        //陀螺仪角度
        this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 21, 4));
        //编码器角度
        this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 25, 4));
        //当前高度
        this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 29, 2));
        //货叉伸出距离
        this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 31, 2));
        //载货台旋转角度
        this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 33, 2));
        //传感器状态标志
//        this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 35, 4));
 
//        byte[] sensorStatusBytes = Utils.slice(bytes, 35, 4);
//        parseSensorStatue(sensorStatusBytes);
    }
 
    @Override
    public String getSerialNo() {
        return "";
    }
 
    //地面码ID
    private String qrCode;
 
    //地面码偏移x
    private int offsetX;
 
    //地面码偏移y
    private int offsetY;
 
    //地面码偏移θ
    private int groundCodeOffset0;
 
    //当前状态
    private int status;
 
    //直行方向坐标-单位:mm
    private int straightDirectionPosition;
 
    //AGV当前角度-单位:°
    private float AGVCurrentAngle;
 
    //陀螺仪角度-单位:°
    private int gyroAngle;
 
    //编码器角度-单位:°
    private int encoderAngle;
 
    //当前高度
    private int currentAltitude;
 
    // 货叉伸出距离
    private int forkLength;
 
    // 载货台旋转角度
    private int loaderTheta;
 
    //传感器状态标志
    private int sensorStatusFlags;
 
    // 取放货状态
    private byte inOutFlag;
 
    private void parseSensorStatue(byte[] bytes) {
        this.tempLoc1 = Utils.getBit(bytes[0], 0);
        this.tempLoc2 = Utils.getBit(bytes[0], 1);
        this.tempLoc3 = Utils.getBit(bytes[0], 2);
        this.tempLoc4 = Utils.getBit(bytes[0], 3);
        this.tempLoc5 = Utils.getBit(bytes[0], 4);
        this.tempLoc6 = Utils.getBit(bytes[0], 5);
        this.tempLoc7 = Utils.getBit(bytes[0], 6);
        this.tempLoc8 = Utils.getBit(bytes[0], 7);
 
        this.inOutFlag = bytes[1];
 
//        this.tempLoc9 = Utils.getBit(bytes[1], 0);
//        this.tempLoc10 = Utils.getBit(bytes[1], 1);
//        this.tempLoc11 = Utils.getBit(bytes[1], 2);
//        this.tempLoc12 = Utils.getBit(bytes[1], 3);
//        this.tempLoc13 = Utils.getBit(bytes[1], 4);
//        this.tempLoc14 = Utils.getBit(bytes[1], 5);
//        this.tempLoc15 = Utils.getBit(bytes[1], 6);
//        this.tempLoc16 = Utils.getBit(bytes[1], 7);
 
        this.expandFront = Utils.getBit(bytes[2], 0);
        this.expandBack = Utils.getBit(bytes[2], 1);
        this.expandLeft = Utils.getBit(bytes[2], 2);
        this.expandRight = Utils.getBit(bytes[2], 3);
        this.finger1 = Utils.getBit(bytes[2], 4);
        this.finger2 = Utils.getBit(bytes[2], 5);
        this.finger3 = Utils.getBit(bytes[2], 6);
        this.finger4 = Utils.getBit(bytes[2], 7);
 
        this.rotaLeft = Utils.getBit(bytes[3], 0);
        this.rotaRight = Utils.getBit(bytes[3], 1);
        this.loaderFront = Utils.getBit(bytes[3], 2);
        this.loaderBack = Utils.getBit(bytes[3], 3);
        this.loaderMid = Utils.getBit(bytes[3], 4);
        this.liftMid = Utils.getBit(bytes[3], 5);
        this.liftUp = Utils.getBit(bytes[3], 6);
        this.liftBottom = Utils.getBit(bytes[3], 7);
    }
 
 
    // 暂存货位1检测
    private boolean tempLoc1;
 
    // 暂存货位2检测
    private boolean tempLoc2;
 
    // 暂存货位3检测
    private boolean tempLoc3;
 
    // 暂存货位4检测
    private boolean tempLoc4;
 
    // 暂存货位5检测
    private boolean tempLoc5;
 
    // 暂存货位6检测
    private boolean tempLoc6;
 
    // 暂存货位7检测
    private boolean tempLoc7;
 
    // 暂存货位8检测
    private boolean tempLoc8;
 
    // 暂存货位9检测
    private boolean tempLoc9;
 
    // 暂存货位10检测
    private boolean tempLoc10;
 
    // 暂存货位11检测
    private boolean tempLoc11;
 
    // 暂存货位12检测
    private boolean tempLoc12;
 
    // 暂存货位13检测
    private boolean tempLoc13;
 
    // 暂存货位14检测
    private boolean tempLoc14;
 
    // 暂存货位15检测
    private boolean tempLoc15;
 
    // 暂存货位16检测
    private boolean tempLoc16;
 
    // 伸缩前限位
    private boolean expandFront;
 
    // 伸缩后限位
    private boolean expandBack;
 
    // 伸缩左零位
    private boolean expandLeft;
 
    // 伸缩右零位
    private boolean expandRight;
 
    // 拨指1位置
    private boolean finger1;
 
    // 拨指2位置
    private boolean finger2;
 
    // 拨指3位置
    private boolean finger3;
 
    // 拨指4位置
    private boolean finger4;
 
    // 回转左到位
    private boolean rotaLeft;
 
    // 回转右到位
    private boolean rotaRight;
 
    // 载货台前探货
    private boolean loaderFront;
 
    // 载货台后探货
    private boolean loaderBack;
 
    // 载货台货物检测
    private boolean loaderMid;
 
    // 升降零位
    private boolean liftMid;
 
    // 升降上限位
    private boolean liftUp;
 
    // 升降下限位
    private boolean liftBottom;
 
}