调度开始 关闭问题处理
This commit is contained in:
@@ -21,50 +21,65 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Component
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread customThread;
|
||||
public CustomThread<PlcRead> customThread;
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
public CustomThread bsInSsjThread;
|
||||
public CustomThread jsInSsjThread;
|
||||
public CustomThread bsOutSsjThread;
|
||||
public CustomThread jsOutSsjThread;
|
||||
public CustomThread bsPickSsjThread;
|
||||
public CustomThread jsPickSsjThread;
|
||||
public CustomThread<BsInSsjThread> bsInSsjThread;
|
||||
public CustomThread<JsInSsjThread> jsInSsjThread;
|
||||
public CustomThread<BsOutSsjThread> bsOutSsjThread;
|
||||
public CustomThread<JsOutSsjThread> jsOutSsjThread;
|
||||
public CustomThread<BsPickSsjTread> bsPickSsjThread;
|
||||
public CustomThread<JsPickSsjTread> jsPickSsjThread;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
//读取信息初始化
|
||||
plcReadInit();
|
||||
|
||||
//调度初始化
|
||||
scheduleInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度初始化
|
||||
*/
|
||||
private void scheduleInit() {
|
||||
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
bsInSsjThread = new CustomThread<BsInSsjThread>(new Thread(bsInSsjThread1), bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread<JsInSsjThread>(new Thread(jsInSsjThread1), jsInSsjThread1);
|
||||
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
|
||||
bsOutSsjThread = new CustomThread<BsOutSsjThread>(new Thread(bsOutSsjThread1), bsOutSsjThread1);
|
||||
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
|
||||
jsOutSsjThread = new CustomThread<JsOutSsjThread>(new Thread(jsOutSsjThread1), jsOutSsjThread1);
|
||||
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
|
||||
bsPickSsjThread = new CustomThread<BsPickSsjTread>(new Thread(bsPickSsjTread1), bsPickSsjTread1);
|
||||
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
|
||||
jsPickSsjThread = new CustomThread<JsPickSsjTread>(new Thread(jsPickSsjTread1), jsPickSsjTread1);
|
||||
}
|
||||
|
||||
/**
|
||||
* plc读取初始化
|
||||
*/
|
||||
private void plcReadInit() {
|
||||
String ip = "127.0.0.1";
|
||||
int port = 102;
|
||||
PlcConnectInfo ssjPlcConnectInfo = new PlcConnectInfo(ip, port);
|
||||
ConcurrentHashMap<String, DeviceSsj>list = new ConcurrentHashMap<>();
|
||||
ConcurrentHashMap<String, DeviceSsj> list = new ConcurrentHashMap<>();
|
||||
//获取要去取的输送机
|
||||
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
|
||||
for (DeviceSsj deviceSsj : deviceSsjs) {
|
||||
list.put(deviceSsj.getDeviceCode(),deviceSsj);
|
||||
list.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
|
||||
//plc读取线程
|
||||
PlcRead plcRead = new PlcRead(list,ssjPlcConnectInfo);
|
||||
PlcRead plcRead = new PlcRead(list, ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread(plcReadThread, plcRead);
|
||||
|
||||
//调度初始化
|
||||
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
bsInSsjThread = new CustomThread(new Thread(bsInSsjThread1),bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread(new Thread(jsInSsjThread1),bsInSsjThread1);
|
||||
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
|
||||
bsOutSsjThread = new CustomThread(new Thread(bsOutSsjThread1),bsOutSsjThread1);
|
||||
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
|
||||
jsOutSsjThread = new CustomThread(new Thread(jsOutSsjThread1),jsOutSsjThread1);
|
||||
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
|
||||
bsPickSsjThread = new CustomThread(new Thread(bsPickSsjTread1),bsPickSsjTread1);
|
||||
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
|
||||
jsPickSsjThread = new CustomThread(new Thread(jsPickSsjTread1),jsPickSsjTread1);
|
||||
customThread = new CustomThread<PlcRead>(plcReadThread, plcRead);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +89,9 @@ public class ScheduleThread {
|
||||
customThread.getThread().start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启线程2
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
//臂式入库线程调度
|
||||
bsInSsjThread.getThread().start();
|
||||
@@ -82,7 +100,7 @@ public class ScheduleThread {
|
||||
//臂式出库到位线程调度-wms电子屏交互
|
||||
bsPickSsjThread.getThread().start();
|
||||
//剪式入库线程调度
|
||||
//jsInSsjThread.getThread().start();
|
||||
jsInSsjThread.getThread().start();
|
||||
//剪式出库线程调度
|
||||
//jsOutSsjThread.getThread().start();
|
||||
|
||||
@@ -94,23 +112,21 @@ public class ScheduleThread {
|
||||
* 停止线程
|
||||
*/
|
||||
public void stopAllThread() {
|
||||
stopThread(customThread);
|
||||
}
|
||||
|
||||
public void stopAllThread2() {
|
||||
stopThread(bsInSsjThread);
|
||||
stopThread(jsInSsjThread);
|
||||
stopThread(bsOutSsjThread);
|
||||
stopThread(jsOutSsjThread);
|
||||
stopThread(bsPickSsjThread);
|
||||
stopThread(jsPickSsjThread);
|
||||
customThread.runnable.isRun = false;
|
||||
plcReadInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线程
|
||||
* 停止线程2
|
||||
*/
|
||||
private void stopThread(CustomThread customThread) {
|
||||
|
||||
public void stopAllThread2() {
|
||||
bsInSsjThread.runnable.isRun = false;
|
||||
jsInSsjThread.runnable.isRun = false;
|
||||
bsOutSsjThread.runnable.isRun = false;
|
||||
jsOutSsjThread.runnable.isRun = false;
|
||||
bsPickSsjThread.runnable.isRun = false;
|
||||
jsPickSsjThread.runnable.isRun = false;
|
||||
scheduleInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomThread {
|
||||
public class CustomThread<T> {
|
||||
public Thread thread;
|
||||
public Object runnable;
|
||||
public T runnable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user