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() {
|
}
|
|
|
}
|