自动化立体仓库 - WCS系统
#
luxiaotao1123
2020-08-05 f0b6d018c5ae6e0a303725effa8939c93b510544
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
package com.zy.core;
 
import com.core.common.Cools;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.DevpThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
 
/**
 * Created by vincent on 2020/8/4
 */
@Slf4j
@Component
public class ServerBootstrap {
 
    @Autowired
    private SlaveProperties slaveProperties;
 
 
    @PostConstruct
    public void init(){
        // 初始化下位机线程
        initThread();
    }
 
 
    private void initThread(){
        // 初始化堆垛机线程
        if (!Cools.isEmpty(slaveProperties.getCrn())) {
            for (Slave crn : slaveProperties.getCrn()) {
                CrnThread crnThread = new CrnThread(crn);
                new Thread(crnThread).start();
                SlaveConnection.put(ThreadHandler.CRN_PREFIX + crn.getId(), crnThread);
            }
        }
 
        // 初始化站点线程
        if (!Cools.isEmpty(slaveProperties.getDevp())) {
            for (Slave devo : slaveProperties.getDevp()) {
                DevpThread devpThread = new DevpThread(devo);
                new Thread(devpThread).start();
            }
        }
 
    }
 
 
    @PreDestroy
    public void destroy() {
    }
 
 
}