自动化立体仓库 - WCS系统
Junjie
2023-07-27 84a9e3a9a624526116b42ab15e27ec852eaa7c21
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
package com.zy.core.model.protocol;
 
import com.alibaba.fastjson.JSON;
import com.core.common.SpringUtils;
import com.zy.asrs.service.BasShuttleService;
import com.zy.common.utils.NavigatePositionConvert;
import com.zy.core.News;
import com.zy.core.enums.ShuttleErrorCodeType;
import com.zy.core.enums.ShuttleProtocolStatusType;
import com.zy.core.enums.ShuttleStatusType;
import com.zy.core.model.command.ShuttleAssignCommand;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
 
import java.util.List;
 
/**
 * 牛眼四向穿梭车
 */
@Slf4j
@Data
public class NyShuttleProtocol {
 
    /**
     * 四向穿梭车号
     */
    private Short shuttleNo;
 
    /**
     * 任务号
     */
    private Integer taskNo = 0;
 
    /**
     * 任务指令
     */
    private ShuttleAssignCommand assignCommand;
 
    /**
     * 当前小车状态(内部自我维护)
     */
    private Integer protocolStatus;
 
    /**
     * 当前小车状态枚举
     */
    private ShuttleProtocolStatusType protocolStatusType;
 
    /**
     * 源库位
     */
    private String sourceLocNo;
 
    /**
     * 目标库位
     */
    private String locNo;
 
    /**
     * 作业标记
     */
    private Boolean pakMk = false;
 
    /**
     * 手动状态/自动状态
     * 0/1
     */
    private Integer workingMode;
 
    /**
     * 0:运行中1:空闲。(车自动模式下,在
     * 静止状态下,且没有其他任务且满足发送
     * 新任务的状态)
     */
    private Integer free;
 
    /**
     * 当前速度,单位mm/s
     */
    private Integer speed;
 
    /**
     * 负载状态无/有负载
     * 0/1
     */
    private Integer loadState;
 
    /**
     * 管制状态不在管制下/被管制中
     * 0/1
     */
    private Integer suspendState;
 
    /**
     * 顶升位置0-未知1-下降位置2-托举位置
     */
    private Integer liftPosition;
 
    /**
     * 运行方向0-未知1-X向2-Y向
     */
    private Integer runDir;
 
    /**
     * 运行方向0-未知(静止)1-X+向2-X向3-Y+向4-Y-向
     */
    private Integer runDir2;
 
    /**
     * 充电状态0不在充电状态1充电中
     */
    private Integer chargState;
 
    /**
     * 电池电量0%-100%
     */
    private Integer powerPercent;
 
    /**
     * 最高电芯电压(mV)
     */
    private Integer maxCellVoltage;
 
    /**
     * 最低电芯电压(mV),低于2900mv需要立即充电
     */
    private Integer minCellVoltage;
 
    /**
     * 电池电压(mV)
     */
    private Integer voltage;
 
    /**
     * 充放电循环次数
     */
    private Integer chargeCycleTimes;
 
    /**
     * 剩余电量/10(A)
     */
    private Integer surplusQuantity;
 
    /**
     * 总电量/10(A)
     */
    private Integer countQuantity;
 
    /**
     * 实际库位xyz
     */
    private NyShuttlePointClass point;
 
    /**
     * 实际坐标xyz单位mm
     */
    private NyShuttlePointClass coord;
 
    /**
     * 任务目的库位xyztaskId(正在动作的任务ID)lastTaskId(最后一个完成的任务ID)recentTaskId(收到的最后一个任务ID)
     */
    private TaskClass task;
 
    /**
     * 任务状态0无任务1有任务
     */
    private Integer taskState;
 
    /**
     * 故障状态0无故障1故障中
     */
    private Integer errState;
 
    /**
     * 故障码
     */
    private List<Integer> errCode;
 
    /**
     * mileage总里程数(米),liftNumber顶升总数dropNumber下降总数reversingX换X总数reversingY换Y总数
     */
    private StatusSumClass statusSum;
 
    /**
     * 非自动状态时间计时(S)
     */
    private Integer errTime;
 
    //总里程数
    @Data
    public static class StatusSumClass {
        private Integer mileage;//总里程数(米)
        private Integer liftNumber;//顶升总数
        private Integer dropNumber;//下降总数
        private Integer reversingX;//换X总数
        private Integer reversingY;//换Y总数
    }
 
    @Data
    public static class NyShuttlePointClass{
        private Integer x;
        private Integer y;
        private Integer z;
    }
 
    //任务目的库位
    @Data
    public static class TaskClass extends NyShuttlePointClass{
        private Integer taskState;
        private Integer taskId;//当前任务ID
        private Integer lastTaskId;//上一次完成的任务ID
        private Integer recentTaskId;//最后一次接收到的任务ID
    }
 
    public String getFree$() {
        if (this.getFree() == null) {
            return "";
        }
        return this.getFree() == 1 ? "空闲" : "运行中";
    }
 
    public String getLoadState$() {
        if (this.getLoadState() == null) {
            return "";
        }
        return this.getLoadState() == 1 ? "有" : "无";
    }
 
    public String getSuspendState$() {
        if (this.getSuspendState() == null) {
            return "";
        }
        return this.getSuspendState() == 1 ? "是" : "否";
    }
 
    public String getPowerPercent$() {
        if (this.getPowerPercent() == null) {
            return "";
        }
        return this.getPowerPercent() + "%";
    }
 
    public String getLiftPosition$() {
        if (this.getLiftPosition() == null) {
            return "";
        }
 
        switch (this.getRunDir()) {
            case 0:
                return "未知";
            case 1:
                return "下降位置";
            case 2:
                return "托举位置";
            default:
                return this.getLiftPosition().toString();
        }
    }
 
    public String getChargState$() {
        if (this.getChargState() == null) {
            return "";
        }
        return this.getChargState() == 1 ? "充电中" : "未充电";
    }
 
    public String getMaxCellVoltage$() {
        if (this.getMaxCellVoltage() == null) {
            return "";
        }
        return this.getMaxCellVoltage() + "mV";
    }
 
    public String getMinCellVoltage$() {
        if (this.getMinCellVoltage() == null) {
            return "";
        }
        return this.getMinCellVoltage() + "mV";
    }
 
    public String getVoltage$() {
        if (this.getVoltage() == null) {
            return "";
        }
        return this.getVoltage() + "mV";
    }
 
    public String getTaskState$() {
        if (this.getTaskState() == null) {
            return "";
        }
        return this.getTaskState() == 1 ? "有任务" : "无任务";
    }
 
    public String getErrState$() {
        if (this.getErrState() == null) {
            return "";
        }
        return this.getErrState() == 1 ? "故障中" : "无故障";
    }
 
    public String getRunDir$() {
        if (this.getRunDir() == null) {
            return "";
        }
 
        switch (this.getRunDir()) {
            case 0:
                return "未知";
            case 1:
                return "X向";
            case 2:
                return "Y向";
            default:
                return "未知";
        }
    }
 
    public String getRunDir2$() {
        if (this.getRunDir2() == null) {
            return "";
        }
 
        switch (this.getRunDir2()) {
            case 0:
                return "未知";
            case 1:
                return "X+向";
            case 2:
                return "X-向";
            case 3:
                return "Y+向";
            case 4:
                return "Y-向";
            default:
                return "未知";
        }
    }
 
    /**
     * 设置小车状态
     */
    public void setProtocolStatus(Integer status) {
        this.protocolStatus = status;
        this.protocolStatusType = ShuttleProtocolStatusType.get(status);
    }
 
    /**
     * 设置小车状态
     */
    public void setProtocolStatus(ShuttleProtocolStatusType status) {
        this.protocolStatus = status.id;
        this.protocolStatusType = status;
    }
 
    public String getProtocolStatus$() {
        if (this.getProtocolStatus() == null) {
            return "";
        }
        return ShuttleProtocolStatusType.get(this.getProtocolStatus()).desc;
    }
 
    public String getPakMk$() {
        if (this.getPakMk() == null) {
            return "";
        }
        return this.getPakMk() ? "Y" : "N";
    }
 
    public String getPoint$() {
        if (this.getPoint() == null) {
            return "";
        }
        return NavigatePositionConvert.xyzToLocNo(this.getPoint().getX(), this.getPoint().getY(), this.getPoint().getZ());
    }
 
    public String getCoord$() {
        if (this.getCoord() == null) {
            return "";
        }
        return JSON.toJSONString(this.getCoord());
    }
 
    // 是否处于空闲待命状态
    public Boolean isIdle() {
        boolean res = this.free == ShuttleStatusType.IDLE.id
                && this.pakMk.equals(true)
                && this.errState == 0
                && this.taskNo == 0
                && this.protocolStatus == ShuttleProtocolStatusType.IDLE.id
                ;
        if (!res) {
            return res;
        } else {
            // 电量
            try {
                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
                if (chargeLine == null) {
                    return false;
                }
                return this.getPowerPercent() >= chargeLine;
            } catch (Exception e) {
                News.error("fail", e);
                return false;
            }
        }
    }
 
    // 是否处于空闲待命状态,传入的taskNo和当前taskNo相同时允许放行
    public Boolean isIdle(int taskNo) {
        boolean res = this.free == ShuttleStatusType.IDLE.id
                && this.pakMk.equals(true)
                && this.errState == 0
                && (this.taskNo == 0 || this.taskNo == taskNo)
                && this.protocolStatus.intValue() == ShuttleProtocolStatusType.IDLE.id
                ;
        if (!res) {
            return res;
        } else {
            // 电量
            try {
                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
                return this.getPowerPercent() > chargeLine;
            } catch (Exception e) {
                News.error("fail", e);
                return false;
            }
        }
    }
 
}