自动化立体仓库 - WCS系统
#
Junjie
2023-12-15 fd69e79dd9861681e31893d7941b39571f49dca4
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
package com.zy.common.model;
 
import com.core.exception.CoolException;
import com.zy.core.model.protocol.StaProtocol;
import lombok.Data;
 
/**
 * Created by vincent on 2020/10/19
 */
@Data
public class LocTypeDto {
 
    // 高低类型{0:未知,1:较低库位,2:低库位,3:高库位,4: 特高库位}
    private Short locType1;
 
    // 宽窄类型{0:未知,1:窄库位,2:宽库位}
    private Short locType2;
 
    // 轻重类型{0:未知,1:轻库位,2:重库位}
    private Short locType3;
 
    public LocTypeDto() {
    }
 
    public LocTypeDto(Short locType1, Short locType2, Short locType3) {
        this.locType1 = locType1;
        this.locType2 = locType2;
        this.locType3 = locType3;
    }
 
    public LocTypeDto(StaProtocol staProtocol) {
        int trueLen = 0;
        if (staProtocol.isHigh()) {
            trueLen++;
        }
        if (staProtocol.isHigh1()) {
            trueLen++;
        }
        if (staProtocol.isLow()) {
            trueLen++;
        }
        if (staProtocol.isLow1()) {
            trueLen++;
        }
        if (trueLen != 1) {
            throw new CoolException("plc高低检测异常");
        }
 
        if (staProtocol.isLow()) {
            this.locType1 = 1; // 较低库位
        } else if (staProtocol.isLow1()){
            this.locType1 = 2; // 低库位
        } else if (staProtocol.isHigh()){
            this.locType1 = 3; // 高库位
        } else if (staProtocol.isHigh1()){
            this.locType1 = 4; // 特高库位
        }
    }
 
    /**
     * 库位类型解析
     */
    public static LocTypeDto process(StaProtocol staProtocol) {
        LocTypeDto dto = new LocTypeDto();
//        if (staProtocol.isHigh() == staProtocol.isLow()) {
//            throw new CoolException("plc高低检测异常");
//        }
//        if (staProtocol.isLow()) {
//            dto.setLocType1((short) 1); // 低库位
//        } else {
//            dto.setLocType1((short) 2); // 高库位
//        }
        return dto;
    }
 
}