opt: 自动门优化
This commit is contained in:
@@ -30,7 +30,6 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
@@ -233,13 +232,14 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_command", 1);
|
||||
standardAutodoorDeviceDriver.writing("to_open", "1");
|
||||
standardAutodoorDeviceDriver.writing("to_close", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (standardAutodoorDeviceDriver.getAction() == 1 && standardAutodoorDeviceDriver.getTo_command() == 1) {
|
||||
log.info("下发开门信号值为:{}", standardAutodoorDeviceDriver.getTo_command());
|
||||
if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1 ) {
|
||||
log.info("下发开门信号值为:{},下发关门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
@@ -8,13 +9,10 @@ import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_state = "state";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_state = "to_state";
|
||||
public static String item_open = "open";
|
||||
public static String item_close = "close";
|
||||
public static String item_to_open = "to_open";
|
||||
public static String item_to_close = "to_close";
|
||||
|
||||
|
||||
private StandardAutodoorDeviceDriver driver;
|
||||
@@ -23,35 +21,27 @@ public class ItemProtocol {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
public int getOpen() {
|
||||
return this.getOpcIntegerValue(item_open);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
public int getClose() {
|
||||
return this.getOpcIntegerValue(item_close);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
|
||||
public int getToOpen() {
|
||||
return this.getOpcIntegerValue(item_to_open);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
public int getToClose() {
|
||||
return this.getOpcIntegerValue(item_to_close);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getToState() {
|
||||
return this.getOpcIntegerValue(item_to_state);
|
||||
}
|
||||
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error("读取错误!");
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
@@ -59,22 +49,34 @@ public class ItemProtocol {
|
||||
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB600.B1", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_state, "工作状态", "DB600.B2"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB600.B3"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B4"));
|
||||
list.add(new ItemDto(item_open, "开到位", "10001"));
|
||||
list.add(new ItemDto(item_close, "关到位", "10002"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_state, "下发状态", "DB601.W3", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_open, "下发开门", "00001" ));
|
||||
list.add(new ItemDto(item_to_close, "下发关门", "00002"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,6 +30,7 @@ public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
|
||||
return "标准版-自动门";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
@@ -49,18 +49,10 @@ public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
List<ItemDto> list = new ArrayList();
|
||||
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true));
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4"));
|
||||
return list;
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,98 +4,41 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.utils.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.utils.ReadUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 自动门驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
|
||||
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
int last_open = 0;
|
||||
int last_close = 0;
|
||||
|
||||
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();
|
||||
|
||||
int to_command = 0;
|
||||
int last_to_command = 0;
|
||||
|
||||
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
int toOpen = 0;
|
||||
int last_toOpen = 0;
|
||||
int toClose = 0;
|
||||
int last_toClose = 0;
|
||||
String device_code = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
@@ -107,55 +50,44 @@ 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();
|
||||
to_command = this.itemProtocol.getToCommand();
|
||||
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(close ==1 ){
|
||||
this.writing("to_close","0");
|
||||
}
|
||||
}
|
||||
if (error != last_error) {
|
||||
}
|
||||
if (state != last_state) {
|
||||
//固化室状态变更后通知lms更新固化室状态
|
||||
FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest();
|
||||
request.setState(String.valueOf(state));
|
||||
request.setDevice_code(this.devicecode);
|
||||
request.setType(CommonFinalParam.ONE);
|
||||
acsToWmsService.notify(request);
|
||||
}
|
||||
last_action = action;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_state = state;
|
||||
last_to_command = to_command;
|
||||
//message = StringFormatUtl.format("设备报警:{}", new Object[]{});
|
||||
|
||||
// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString();
|
||||
if (toClose != last_toClose) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号toClose:" + last_toClose + "->" + toClose);
|
||||
|
||||
}
|
||||
if (toOpen != last_toOpen) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号toOpen:" + last_toOpen + "->" + toOpen);
|
||||
}
|
||||
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");
|
||||
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_param, Integer.parseInt(value));
|
||||
|
||||
} 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");
|
||||
}
|
||||
return jo.toString();
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -165,19 +97,37 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
log.info("下发PLC信号:{},{}", to_command, command);
|
||||
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command);
|
||||
System.out.println("设备:" + this.device_code + ",下发PLC信号:" + to_command + ",value:" + command);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void OpenOrClose(String type) {
|
||||
|
||||
//开门
|
||||
if (CommonFinalParam.ONE.equals(type)) {
|
||||
writing(ItemProtocol.item_to_command, 1);
|
||||
} else {
|
||||
writing(ItemProtocol.item_to_command, 2);
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String open = "";
|
||||
String close = "";
|
||||
if (this.getOpen() == 0) {
|
||||
open = "未知";
|
||||
} else if (this.getOpen() == 1) {
|
||||
open = "开到位";
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user