|
|
@ -1,5 +1,6 @@ |
|
|
|
package org.nl.acs.device_driver.hailiang_old.hailiang_old_special_device; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -14,6 +15,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
import org.nl.acs.monitor.DeviceStageMonitor; |
|
|
|
import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.order.service.ProduceshiftorderService; |
|
|
@ -33,7 +36,7 @@ import java.util.Map; |
|
|
|
@Slf4j |
|
|
|
@Data |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { |
|
|
|
public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { |
|
|
|
protected ItemProtocol itemProtocol = new ItemProtocol(this); |
|
|
|
@Autowired |
|
|
|
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); |
|
|
@ -53,7 +56,8 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl |
|
|
|
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); |
|
|
|
@Autowired |
|
|
|
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); |
|
|
|
int heartbeat = 0; |
|
|
|
int mode = 0; |
|
|
|
int line_status = 0; |
|
|
@ -134,46 +138,131 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl |
|
|
|
public Device getDevice() { |
|
|
|
return this.device; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public synchronized void execute() throws Exception { |
|
|
|
String message = null; |
|
|
|
try { |
|
|
|
device_code = this.getDeviceCode(); |
|
|
|
this.signalIsException(this); |
|
|
|
heartbeat = this.itemProtocol.getHeartbeat(); |
|
|
|
mode = this.itemProtocol.getMode(); |
|
|
|
line_status = this.itemProtocol.getLineStatus(); |
|
|
|
error = this.itemProtocol.getError(); |
|
|
|
task = this.itemProtocol.getTask(); |
|
|
|
is_open = this.itemProtocol.getIsOpen(); |
|
|
|
running = this.itemProtocol.getRunning(); |
|
|
|
finish = this.itemProtocol.getFinish(); |
|
|
|
all_ready = this.itemProtocol.getAllReady(); |
|
|
|
order_compel_finish = this.itemProtocol.getOrder_compel_finish(); |
|
|
|
order = this.itemProtocol.getOrder(); |
|
|
|
now_order_prod_num = this.itemProtocol.getNow_order_prod_num(); |
|
|
|
full_number = this.itemProtocol.getFull_number(); |
|
|
|
now_one_box_num = this.itemProtocol.getNow_one_box_num(); |
|
|
|
storage_stock_num = this.itemProtocol.getStorage_stock_num(); |
|
|
|
line_stock_num = this.itemProtocol.getLine_stock_num(); |
|
|
|
open_ready_time = this.itemProtocol.getOpen_ready_time(); |
|
|
|
device_running_time = this.itemProtocol.getDevice_running_time(); |
|
|
|
await_time = this.itemProtocol.getAwait_time(); |
|
|
|
order_prod_allnum = this.itemProtocol.getOrder_prod_allnum(); |
|
|
|
empty_is_lack = this.itemProtocol.getEmpty_is_lack(); |
|
|
|
device_is_running = this.itemProtocol.getDevice_is_running(); |
|
|
|
empty_is_finish = this.itemProtocol.getEmpty_is_finish(); |
|
|
|
full_ready_req_agv = this.itemProtocol.getFull_ready_req_agv(); |
|
|
|
full_out = this.itemProtocol.getFull_out(); |
|
|
|
device_prepare = this.itemProtocol.getDevice_prepare(); |
|
|
|
device_ready = this.itemProtocol.getDevice_ready(); |
|
|
|
line_ready = this.itemProtocol.getLine_ready(); |
|
|
|
|
|
|
|
if (mode != last_mode) { |
|
|
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); |
|
|
|
} |
|
|
|
if (error != last_error) { |
|
|
|
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); |
|
|
|
} |
|
|
|
if (task != last_task) { |
|
|
|
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); |
|
|
|
} |
|
|
|
if (finish != last_finish) { |
|
|
|
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish); |
|
|
|
} |
|
|
|
if (order_compel_finish != last_order_compel_finish) { |
|
|
|
logServer.deviceItemValue(this.device_code, "order_compel_finish", String.valueOf(order_compel_finish)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_compel_finish:" + last_order_compel_finish + "->" + order_compel_finish); |
|
|
|
} |
|
|
|
if (order != last_order) { |
|
|
|
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order); |
|
|
|
} |
|
|
|
if (now_order_prod_num != last_now_order_prod_num) { |
|
|
|
logServer.deviceItemValue(this.device_code, "now_order_prod_num", String.valueOf(now_order_prod_num)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_order_prod_num:" + last_now_order_prod_num + "->" + now_order_prod_num); |
|
|
|
} |
|
|
|
if (full_number != last_full_number) { |
|
|
|
logServer.deviceItemValue(this.device_code, "full_number", String.valueOf(full_number)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_number:" + last_full_number + "->" + full_number); |
|
|
|
} |
|
|
|
if (now_one_box_num != last_now_one_box_num) { |
|
|
|
logServer.deviceItemValue(this.device_code, "now_one_box_num", String.valueOf(now_one_box_num)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_one_box_num:" + last_now_one_box_num + "->" + now_one_box_num); |
|
|
|
} |
|
|
|
if (storage_stock_num != last_storage_stock_num) { |
|
|
|
logServer.deviceItemValue(this.device_code, "storage_stock_num", String.valueOf(storage_stock_num)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_stock_num:" + last_storage_stock_num + "->" + storage_stock_num); |
|
|
|
} |
|
|
|
if (line_stock_num != last_line_stock_num) { |
|
|
|
logServer.deviceItemValue(this.device_code, "line_stock_num", String.valueOf(line_stock_num)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号line_stock_num:" + last_line_stock_num + "->" + line_stock_num); |
|
|
|
} |
|
|
|
if (order_prod_allnum != last_order_prod_allnum) { |
|
|
|
logServer.deviceItemValue(this.device_code, "order_prod_allnum", String.valueOf(order_prod_allnum)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_prod_allnum:" + last_order_prod_allnum + "->" + order_prod_allnum); |
|
|
|
} |
|
|
|
if (empty_is_lack != last_empty_is_lack) { |
|
|
|
logServer.deviceItemValue(this.device_code, "empty_is_lack", String.valueOf(empty_is_lack)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_is_lack:" + last_empty_is_lack + "->" + empty_is_lack); |
|
|
|
} |
|
|
|
if (empty_is_finish != last_empty_is_finish) { |
|
|
|
logServer.deviceItemValue(this.device_code, "empty_is_finish", String.valueOf(empty_is_finish)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_is_finish:" + last_empty_is_finish + "->" + empty_is_finish); |
|
|
|
} |
|
|
|
if (full_ready_req_agv != last_full_ready_req_agv) { |
|
|
|
logServer.deviceItemValue(this.device_code, "full_ready_req_agv", String.valueOf(full_ready_req_agv)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_ready_req_agv:" + last_full_ready_req_agv + "->" + full_ready_req_agv); |
|
|
|
} |
|
|
|
if (full_out != last_full_out) { |
|
|
|
logServer.deviceItemValue(this.device_code, "full_out", String.valueOf(full_out)); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_out:" + last_full_out + "->" + full_out); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception var17) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage()); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected void executing(Instruction instruction) { |
|
|
|
this.executing(1, instruction, ""); |
|
|
|
} |
|
|
|
|
|
|
|
public void executing(int command, Instruction instruction, String appendMessage) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void executing(Server server, Map<String, Object> itemMap) { |
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
} |
|
|
|
|
|
|
|
public void writing(int command, int target, int task) { |
|
|
|
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; |
|
|
|
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; |
|
|
|
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; |
|
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
|
|
Map<String, Object> itemMap = new HashMap<String, Object>(); |
|
|
|
itemMap.put(to_command, command); |
|
|
|
itemMap.put(to_target, target); |
|
|
|
itemMap.put(to_task, task); |
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
if (!this.itemProtocol.getIsonline()) { |
|
|
|
this.setIsonline(false); |
|
|
|
this.setIserror(true); |
|
|
|
message = "信号量同步异常"; |
|
|
|
//未联机
|
|
|
|
} else if (mode == 0) { |
|
|
|
this.setIsonline(false); |
|
|
|
this.setIserror(true); |
|
|
|
message = "未联机"; |
|
|
|
//有报警
|
|
|
|
} else if (error != 0) { |
|
|
|
this.setIsonline(false); |
|
|
|
this.setIserror(true); |
|
|
|
message = "有报警"; |
|
|
|
//无报警
|
|
|
|
} else { |
|
|
|
this.setIsonline(true); |
|
|
|
this.setIserror(false); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void writing(String param, String value) { |
|
|
@ -186,88 +275,13 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl |
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
} |
|
|
|
|
|
|
|
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) { |
|
|
|
super.writeLogInfo(device_code, name, lastNumber, nowNumber); |
|
|
|
if (lastNumber != nowNumber) { |
|
|
|
// if (name.equals("mode")) {
|
|
|
|
// this.setRequireSucess(false);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public String isSatisfyCreateTask(){ |
|
|
|
@Override |
|
|
|
public JSONObject getDeviceStatusName() { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public void method1(){ |
|
|
|
if (mode == 1 && last_mode == 0 && order > 0){ |
|
|
|
System.out.println("我进入方法一了"); |
|
|
|
} |
|
|
|
// synchronized (this){
|
|
|
|
// int realError = 0;
|
|
|
|
// long now_feedTime = System.currentTimeMillis();
|
|
|
|
// if (now_feedTime - last_feedDeviceStatusTime >= 5000){
|
|
|
|
// heartbeat = this.itemProtocol.getHeartbeat();
|
|
|
|
// if (heartbeat == last_heartbeat){
|
|
|
|
// status_type = 01;
|
|
|
|
// } else {
|
|
|
|
// status_type = 02;
|
|
|
|
// if (error == 1 || error == 51) {
|
|
|
|
// status_type = 05;
|
|
|
|
// realError = error;
|
|
|
|
// }else if (mode == 1 && order > 0) {
|
|
|
|
// status_type = 03;
|
|
|
|
// realError = 0;
|
|
|
|
// } else if (mode == 0 && order > 0) {
|
|
|
|
// realError = 0;
|
|
|
|
// status_type = 04;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (status_type != last_status_type) {
|
|
|
|
// JSONObject map = new JSONObject();
|
|
|
|
// map.put("device_code", device_code);
|
|
|
|
// map.put("status_type", "0" + status_type);
|
|
|
|
// map.put("start_time", DateUtil.now());
|
|
|
|
// map.put("error_code",realError);
|
|
|
|
// acsToWmsService.feedDeviceStatusType(map);
|
|
|
|
// last_status_type = status_type;
|
|
|
|
// }
|
|
|
|
// last_feedDeviceStatusTime = now_feedTime;
|
|
|
|
// last_heartbeat = heartbeat;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
@Override |
|
|
|
public void setDeviceStatus(JSONObject data) { |
|
|
|
|
|
|
|
public void method2(){ |
|
|
|
if (mode == 0 && last_mode == 1 && order > 0){ |
|
|
|
System.out.println("我进入方法2了"); |
|
|
|
} |
|
|
|
// if ( mode == 1 && finish != last_finish && finish == 1 && order > 0){
|
|
|
|
// ProduceshiftorderDto dto = new ProduceshiftorderDto();
|
|
|
|
// dto.setOrder_code(order + "");
|
|
|
|
// dto.setOrder_status("2");
|
|
|
|
// ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code);
|
|
|
|
// if(deviceInfo != null){
|
|
|
|
// if (StrUtil.isNotEmpty(deviceInfo.getExt_order_id())) {
|
|
|
|
// String ext_order_id = deviceInfo.getExt_order_id();
|
|
|
|
// JSONObject param = new JSONObject();
|
|
|
|
// param.put("ext_order_id",ext_order_id);
|
|
|
|
// acsToWmsService.feedbackOrderStatus(param);
|
|
|
|
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的外部标识:"+ext_order_id);
|
|
|
|
// }else {
|
|
|
|
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的没有外部标识");
|
|
|
|
// }
|
|
|
|
// }else {
|
|
|
|
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单信息为空");
|
|
|
|
// }
|
|
|
|
// produceshiftorderService.updateByOrderCode(dto);
|
|
|
|
// this.writing("to_confirm_finished","1");
|
|
|
|
// this.writing("to_order", "0");
|
|
|
|
// this.writing("to_clear","1");
|
|
|
|
// this.writing("to_pause","1");
|
|
|
|
// } else {
|
|
|
|
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,finish>"+ finish +",last_finish>"+last_finish + "mode:" + mode + "order:" + order);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|