package com.mes.common;
|
|
import cn.hutool.json.JSONObject;
|
|
import com.mes.device.PlcParameterObject;
|
import com.mes.downglassinfo.entity.DownGlassTask;
|
import com.mes.downglassinfo.service.DownGlassTaskService;
|
import com.mes.downstorage.entity.DownStorageCageDetails;
|
import com.mes.downstorage.mapper.DownStorageCageDetailsMapper;
|
import com.mes.downstorage.service.DownStorageCageService;
|
import com.mes.downworkstation.service.DownWorkstationService;
|
import com.mes.glassinfo.entity.GlassInfo;
|
import com.mes.glassinfo.service.GlassInfoService;
|
import com.mes.tools.WebSocketServer;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import java.util.List;
|
|
@Slf4j
|
public class Plcdownglass extends Thread {
|
|
public static final String RESULT_IN = "1";
|
public static final String RESULT_OUT = "2";
|
public static final String RESULT_IN_OUT = "3";
|
|
@Autowired
|
private DownStorageCageService downStorageCageService;
|
@Autowired
|
private DownWorkstationService downWorkstationService;
|
|
|
|
|
|
@Override
|
public void run() {
|
while (this != null) {
|
JSONObject jsonObject = new JSONObject();
|
try {
|
Thread.sleep(100);
|
|
String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + "";
|
String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + "";
|
|
// 进片请求
|
if (RESULT_IN.equals(result)) {
|
downStorageCageService.processInto(number);
|
}
|
// 出片请求
|
else if (RESULT_OUT.equals(result)) {
|
downStorageCageService.processOut();
|
}
|
// 进出片请求
|
else if (RESULT_IN_OUT.equals(result)) {
|
// 先出后进
|
if (!downStorageCageService.processOut()) {
|
downStorageCageService.processInto(number);
|
}
|
}
|
|
|
downWorkstationService.insertdownglassinfo();
|
|
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|
}
|