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