fix
This commit is contained in:
@@ -15,6 +15,8 @@ public enum DriverTypeEnum {
|
||||
|
||||
STORAGE(3, "standard_storage", "标准版-货架", "storage"),
|
||||
|
||||
AUTODOOR(4, "standard_autodoor", "标准版-自动门", "autodoor"),
|
||||
|
||||
// SCANNER(4, "standard_scanner", "标准版-扫码器", "scanner"),
|
||||
|
||||
// INSPECT_CONVEYOR_CONTROL(5, "standard_conveyor_control", "标准版-输送机-控制点", "conveyor"),
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.nl.acs.device_driver;
|
||||
|
||||
import org.nl.acs.opc.Device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeviceDriver {
|
||||
default String getDeviceCode() {
|
||||
@@ -19,5 +18,4 @@ public interface DeviceDriver {
|
||||
return this.getDriverDefination().getDriverCode();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutoDoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
@@ -124,6 +125,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//
|
||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||
//自动门
|
||||
StandardAutoDoorDeviceDriver standardAutoDoorDeviceDriver;
|
||||
|
||||
//分配 车id
|
||||
//(不需要WCS反馈)
|
||||
@@ -398,16 +401,81 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x50) {//进入交通灯区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
//开门
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardAutoDoorDeviceDriver) {
|
||||
standardAutoDoorDeviceDriver = (StandardAutoDoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutoDoorDeviceDriver.OpenOrClose("1");
|
||||
standardAutoDoorDeviceDriver.writing(1);
|
||||
if (standardAutoDoorDeviceDriver.getAction() == 1) {
|
||||
standardAutoDoorDeviceDriver.OpenOrClose("1");
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
OneNDCSocketConnectionAutoRun.write(data);
|
||||
}
|
||||
} else if (phase == 0x51) {//离开交通灯区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
OneNDCSocketConnectionAutoRun.write(data);
|
||||
//关门
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardAutoDoorDeviceDriver) {
|
||||
standardAutoDoorDeviceDriver = (StandardAutoDoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutoDoorDeviceDriver.OpenOrClose("2");
|
||||
standardAutoDoorDeviceDriver.writing(2);
|
||||
if (standardAutoDoorDeviceDriver.getAction() == 2) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
OneNDCSocketConnectionAutoRun.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.nl.acs.device_driver.basedriver.standard_autodoor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_to_command = "to_command";
|
||||
|
||||
|
||||
private StandardAutoDoorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(StandardAutoDoorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB600.B1", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB600.B2"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B4"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.TRUE));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.acs.device_driver.basedriver.standard_autodoor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动门驱动定义
|
||||
*/
|
||||
@Service
|
||||
public class StandardAutoDoorDefinition implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "standard_autodoor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "标准版-自动门";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "标准版-自动门";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new StandardAutoDoorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return StandardAutoDoorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList<>();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package org.nl.acs.device_driver.basedriver.standard_autodoor;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.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.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自动门驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
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");
|
||||
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 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;
|
||||
|
||||
String message = "";
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
devicecode = this.getDevice().getDevice_code();
|
||||
mode = this.itemProtocol.getMode();
|
||||
action = this.itemProtocol.getAction();
|
||||
error = this.itemProtocol.getError();
|
||||
|
||||
|
||||
last_action = action;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
return jo.toString();
|
||||
}
|
||||
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
|
||||
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);
|
||||
ReadUtil.write(itemMap, server);
|
||||
server.disconnect();
|
||||
log.info("下发PLC信号:{},{}", to_command, command);
|
||||
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void OpenOrClose(String type) {
|
||||
|
||||
//开门
|
||||
if ("1".equals(type)) {
|
||||
writing(1);
|
||||
} else {
|
||||
writing(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,9 +30,10 @@ public class AbstractDeviceDriver implements DeviceDriver {
|
||||
return this.driverDefination;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceDriver setDriverDefination(DeviceDriverDefination var1) {
|
||||
this.driverDefination = driverDefination;
|
||||
this.driverDefination = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user