联调优化
This commit is contained in:
@@ -192,28 +192,48 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0x30) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
|
||||
} //进入区域
|
||||
}
|
||||
//进入区域
|
||||
else if (phase == 0x50) {
|
||||
//开门
|
||||
if (device!=null&&device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.OpenOrClose("1");
|
||||
if (standardAutodoorDeviceDriver.getAction() == 1) {
|
||||
standardAutodoorDeviceDriver.OpenOrClose("1");
|
||||
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_open", "1");
|
||||
standardAutodoorDeviceDriver.writing("to_close", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (standardAutodoorDeviceDriver.getOpen() == 1) {
|
||||
log.info("下发开门信号值为:{},下发关门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//离开区域
|
||||
else if (phase == 0x51) {
|
||||
//离开区域
|
||||
}else if (phase == 0x51) {
|
||||
//关门
|
||||
if (device!=null&&device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.OpenOrClose("2");
|
||||
if (standardAutodoorDeviceDriver.getAction() == 2) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_close", "1");
|
||||
standardAutodoorDeviceDriver.writing("to_open", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
//任务删除确认
|
||||
//(需要WCS反馈)
|
||||
}else if (phase == 0xFF) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.List;
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
@@ -30,9 +29,6 @@ public class ItemProtocol {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
@@ -53,8 +49,8 @@ public class ItemProtocol {
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
public int getWeight() {
|
||||
return this.getOpcIntegerValue(item_weight);
|
||||
public double getWeight() {
|
||||
return this.getOpcFloatValue(item_weight);
|
||||
}
|
||||
public String getSubTray() {
|
||||
return this.getOpcStringValue(item_sub_tray);
|
||||
@@ -105,9 +101,20 @@ public class ItemProtocol {
|
||||
return "";
|
||||
}
|
||||
|
||||
public float getOpcFloatValue(String protocol) {
|
||||
Float value = this.driver.getDoubleValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0L;
|
||||
|
||||
}
|
||||
|
||||
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_move, "光电开关信号", "DB600.B2"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB600.B3"));
|
||||
|
||||
@@ -77,8 +77,8 @@ public class SsxSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
|
||||
int io_action = 0;
|
||||
int last_io_action = 0;
|
||||
double weight = 0;
|
||||
double last_weight = 0;
|
||||
double weight = 0.0;
|
||||
double last_weight = 0.0;
|
||||
String sub_tray = null;
|
||||
String last_sub_tray = null;
|
||||
String mother_tray = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.basedriver.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,39 +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 getState() {
|
||||
return this.getOpcIntegerValue(item_state);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -63,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 "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
int last_open = 0;
|
||||
int last_close = 0;
|
||||
|
||||
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;
|
||||
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 (error != last_error) {
|
||||
}
|
||||
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);
|
||||
}
|
||||
last_action = action;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_state = state;
|
||||
//message = StringFormatUtl.format("设备报警:{}", new Object[]{});
|
||||
if (close != last_close) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号close:" + last_close + "->" + close);
|
||||
|
||||
// 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();
|
||||
{
|
||||
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);
|
||||
|
||||
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");
|
||||
return jo.toString();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -635,19 +635,19 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
switch(type){
|
||||
case 1:
|
||||
//wms通知固化室满料,开始固化
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.writing("to_state",1);
|
||||
}
|
||||
// device = deviceAppService.findDeviceByCode(device_code);
|
||||
// if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
// StandardAutodoorDeviceDriver standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
// standardAutodoorDeviceDriver.writing("to_state",1);
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
//wms通知固化室取料完毕,重新开放可使用
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.writing("to_state",2);
|
||||
}
|
||||
// //wms通知固化室取料完毕,重新开放可使用
|
||||
// device = deviceAppService.findDeviceByCode(device_code);
|
||||
// if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
// StandardAutodoorDeviceDriver standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
// standardAutodoorDeviceDriver.writing("to_state",2);
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user