|
|
@ -8,6 +8,7 @@ import org.nl.acs.device.domain.Device; |
|
|
|
import org.nl.acs.device_driver.RequestMethodEnum; |
|
|
|
import org.nl.acs.ext.wms.data.feedBackTaskStatus.FeedBackTaskStatusRequest; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
import org.nl.acs.utils.ReadUtil; |
|
|
|
import org.nl.acs.device.service.DeviceService; |
|
|
|
import org.nl.acs.device_driver.DeviceDriver; |
|
|
@ -33,65 +34,19 @@ import java.util.Map; |
|
|
|
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { |
|
|
|
protected ItemProtocol itemProtocol = new ItemProtocol(this); |
|
|
|
|
|
|
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); |
|
|
|
|
|
|
|
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); |
|
|
|
|
|
|
|
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); |
|
|
|
|
|
|
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); |
|
|
|
|
|
|
|
AcsToWmsService acsToWmsService=SpringContextHolder.getBean("acsToWmsServiceImpl"); |
|
|
|
String container; |
|
|
|
String container_type_desc; |
|
|
|
String last_container_type_desc; |
|
|
|
String last_container; |
|
|
|
//放货准备锁
|
|
|
|
String putReadyLock = null; |
|
|
|
//有货标记
|
|
|
|
protected boolean has_goods_tag = false; |
|
|
|
String devicecode; |
|
|
|
int mode = 0; |
|
|
|
int action = 0; |
|
|
|
int error = 0; |
|
|
|
Boolean iserror = false; |
|
|
|
|
|
|
|
int move = 0; |
|
|
|
int task = 0; |
|
|
|
int state = 0; |
|
|
|
int last_state = 0; |
|
|
|
int last_action = 0; |
|
|
|
int last_mode = 0; |
|
|
|
int last_error = 0; |
|
|
|
int last_move = 0; |
|
|
|
int last_task = 0; |
|
|
|
|
|
|
|
boolean hasVehicle = false; |
|
|
|
boolean isReady = false; |
|
|
|
protected int instruction_num = 0; |
|
|
|
protected int instruction_num_truth = 0; |
|
|
|
protected boolean hasGoods = false; |
|
|
|
boolean isFold = false; |
|
|
|
private String assemble_check_tag; |
|
|
|
private Boolean sampleMode0; |
|
|
|
private Boolean sampleMode3; |
|
|
|
private Integer sampleError; |
|
|
|
private Boolean sampleOnline; |
|
|
|
protected String displayMessage = null; |
|
|
|
public int display_message_time_out = 30000; |
|
|
|
public Date display_message_time; |
|
|
|
protected String current_stage_instruction_message; |
|
|
|
protected String last_stage_instruction_message; |
|
|
|
Integer heartbeat_tag; |
|
|
|
private Date instruction_require_time = new Date(); |
|
|
|
private Date instruction_finished_time = new Date(); |
|
|
|
|
|
|
|
private int instruction_require_time_out; |
|
|
|
boolean requireSucess = false; |
|
|
|
|
|
|
|
private int instruction_finished_time_out; |
|
|
|
|
|
|
|
int branchProtocol = 0; |
|
|
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); |
|
|
|
|
|
|
|
int open = 0; |
|
|
|
int close = 0; |
|
|
|
|
|
|
|
int last_open = 0; |
|
|
|
int last_close = 0; |
|
|
|
|
|
|
|
int toOpen = 0; |
|
|
|
int last_toOpen = 0; |
|
|
|
int toClose = 0; |
|
|
|
int last_toClose = 0; |
|
|
|
String device_code = null; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Device getDevice() { |
|
|
@ -103,76 +58,66 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem |
|
|
|
public void execute() { |
|
|
|
String message = null; |
|
|
|
|
|
|
|
String device_code = this.getDevice().getDevice_code(); |
|
|
|
mode = this.itemProtocol.getMode(); |
|
|
|
action = this.itemProtocol.getAction(); |
|
|
|
error = this.itemProtocol.getError(); |
|
|
|
state = this.itemProtocol.getState(); |
|
|
|
if (mode != last_mode) { |
|
|
|
device_code = this.getDevice().getDevice_code(); |
|
|
|
open = this.itemProtocol.getOpen(); |
|
|
|
close = this.itemProtocol.getClose(); |
|
|
|
toOpen = this.itemProtocol.getToOpen(); |
|
|
|
toClose = this.itemProtocol.getToClose(); |
|
|
|
if (open != last_open) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open); |
|
|
|
} |
|
|
|
if (action != last_action) { |
|
|
|
if (close != last_close) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号close:" + last_close + "->" + close); |
|
|
|
|
|
|
|
} |
|
|
|
if (error != last_error) { |
|
|
|
if (toClose != last_toClose) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号toClose:" + last_toClose + "->" + toClose); |
|
|
|
|
|
|
|
} |
|
|
|
if (state != last_state) { |
|
|
|
//固化室状态变更后通知lms更新固化室状态
|
|
|
|
FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest(); |
|
|
|
request.setState(String.valueOf(state)); |
|
|
|
request.setDevice_code(this.getDeviceCode()); |
|
|
|
request.setType("1"); |
|
|
|
acsToWmsService.notify(request); |
|
|
|
if (toOpen != last_toOpen) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号toOpen:" + last_toOpen + "->" + toOpen); |
|
|
|
} |
|
|
|
last_action = action; |
|
|
|
last_mode = mode; |
|
|
|
last_error = error; |
|
|
|
last_state = state; |
|
|
|
//message = StringFormatUtl.format("设备报警:{}", new Object[]{});
|
|
|
|
|
|
|
|
// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString();
|
|
|
|
|
|
|
|
last_open = open; |
|
|
|
last_close = close; |
|
|
|
last_toClose = toClose; |
|
|
|
last_toOpen = toOpen; |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized String getStatus() { |
|
|
|
{ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
|
|
|
|
if (action == 1) { |
|
|
|
jo.put("name", this.getDevice().getDevice_code()); |
|
|
|
jo.put("status", "OPEN"); |
|
|
|
|
|
|
|
} else if (action == 2) { |
|
|
|
jo.put("name", this.getDevice().getDevice_code()); |
|
|
|
jo.put("status", "CLOSE"); |
|
|
|
|
|
|
|
} else { |
|
|
|
jo.put("name", this.getDevice().getDevice_code()); |
|
|
|
jo.put("status", "ERROR"); |
|
|
|
String open = ""; |
|
|
|
String close = ""; |
|
|
|
if (this.getOpen() == 0) { |
|
|
|
open = "未知"; |
|
|
|
} else if (this.getOpen() == 1) { |
|
|
|
open = "开到位"; |
|
|
|
} |
|
|
|
return jo.toString(); |
|
|
|
if (this.getClose() == 0) { |
|
|
|
open = "未知"; |
|
|
|
} else if (this.getClose() == 1) { |
|
|
|
open = "关到位"; |
|
|
|
} |
|
|
|
jo.put("device_name", this.getDevice().getDevice_name()); |
|
|
|
jo.put("open", open); |
|
|
|
jo.put("close", close); |
|
|
|
jo.put("isOnline", true); |
|
|
|
|
|
|
|
return jo.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void writing(String param,int command) { |
|
|
|
String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param); |
|
|
|
|
|
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
|
|
public void writing(String param, String value) { |
|
|
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
+ "." + param; |
|
|
|
Map<String, Object> itemMap = new HashMap<String, Object>(); |
|
|
|
itemMap.put(to_command, command); |
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
log.info("下发PLC信号:{},{}", to_command, command); |
|
|
|
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); |
|
|
|
itemMap.put(to_param, Integer.parseInt(value)); |
|
|
|
|
|
|
|
this.control(itemMap); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized void OpenOrClose(String type) { |
|
|
|
|
|
|
|
//开门
|
|
|
|
if ("1".equals(type)) { |
|
|
|
writing(ItemProtocol.item_to_command,1); |
|
|
|
} else { |
|
|
|
writing(ItemProtocol.item_to_command,2); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|