自动化立体仓库 - WCS系统
Junjie
2023-12-04 af6fed7d45038a8696ecaa41e8b9a509df68e63e
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
package com.zy.common.utils;
 
import com.core.common.SpringUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.LiftSlave;
import com.zy.core.model.command.NyLiftCommand;
import com.zy.core.model.protocol.LiftStaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.LiftThread;
 
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 牛眼提升机工具类
 */
public class NyLiftUtils {
 
    /**
     * 获取提升机命令
     */
    public static NyLiftCommand getLiftCommand(Integer liftNo, Integer taskModel, Integer sourceSta, Integer targetSta, Integer taskNo) {
        NyLiftCommand command = new NyLiftCommand();
        command.setLiftNo(liftNo.shortValue());
        command.setTaskNo(taskNo.shortValue());
        command.setTaskModel(taskModel.shortValue());
        command.setSourceSta(sourceSta.shortValue());
        command.setTargetSta(targetSta.shortValue());
        return command;
    }
 
    /**
     * 获取提升机复位命令
     */
    public static NyLiftCommand getLiftResetCommand(Integer liftNo) {
        NyLiftCommand command = new NyLiftCommand();
        command.setLiftNo(liftNo.shortValue());
        command.setTaskNo((short) 0);
        command.setTaskModel((short) 0);
        command.setSourceSta((short) 0);
        command.setTargetSta((short) 0);
        return command;
    }
 
    //获取提升机站点
    public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) {
        SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class);
        for (LiftSlave liftSlave : slaveProperties.getLift()) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId());
            if (liftThread == null) {
                return null;
            }
 
            for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
                if (liftStaProtocol.getStaNo().equals(staNo)) {
                    return liftStaProtocol;
                }
            }
        }
 
        return null;
    }
 
    //获取提升机站点
    public static LiftStaProtocol getLiftStaByStaNo(Integer liftNo, Integer staNo) {
        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
        if (liftThread == null) {
            return null;
        }
 
        for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
            if (liftStaProtocol.getStaNo().equals(staNo)) {
                return liftStaProtocol;
            }
        }
 
        return null;
    }
 
    //获取提升机站点
    public static LiftStaProtocol getLiftStaByLev(Integer liftNo, Integer lev) {
        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
        if (liftThread == null) {
            return null;
        }
 
        for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
            if (liftStaProtocol.getLev().equals(lev)) {
                return liftStaProtocol;
            }
        }
 
        return null;
    }
 
    //获取提升机输送站及其前一站节点
    public static List<NavigateNode> getLiftStaNodes(Integer staNo) {
        List<NavigateNode> targetNodes = new ArrayList<>();
        //获取目标站
        LiftStaProtocol targetLiftSta = NyLiftUtils.getLiftStaByStaNo(staNo);
        if (targetLiftSta == null) {
            return null;//找不到站点
        }
        NavigateNode targetNode = NavigatePositionConvert.locNoToNode(targetLiftSta.getLocNo());//目标节点
        String targetLastLocNo = Utils.getLocNo(Utils.getRow(targetLiftSta.getLocNo()) - 1, Utils.getBay(targetLiftSta.getLocNo()), Utils.getLev(targetLiftSta.getLocNo()));//目标节点前一站
        NavigateNode targetLastNode = NavigatePositionConvert.locNoToNode(targetLastLocNo);//目标节点前一站
        targetNodes.add(targetNode);
        targetNodes.add(targetLastNode);
 
        return targetNodes;
    }
 
}