纽迪希亚2优化

This commit is contained in:
loujf
2022-07-28 17:16:44 +08:00
parent c5987dd5a6
commit df97828efc
6 changed files with 76 additions and 59 deletions

View File

@@ -667,6 +667,24 @@ public class AgvServiceImpl implements AgvService {
} }
} }
} }
if (addressdevice.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) {
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) addressdevice.getDeviceDriver();
//请求取货
if ("Load".equals(action)) {
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) {
inst.setExecute_status("1");
ndxySpecialTwoDeviceDriver.writing(1);
is_feedback = true;
}
//请求放货
} else if ("Unload".equals(action)) {
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
ndxySpecialTwoDeviceDriver.writing(3);
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
//请求取货 //请求取货
@@ -745,7 +763,7 @@ public class AgvServiceImpl implements AgvService {
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) {
inst.setExecute_device_code(processingVehicle); inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2"); inst.setExecute_status("2");
ndxySpecialTwoDeviceDriver.setFlag(2); ndxySpecialTwoDeviceDriver.writing(2);
is_feedback = true; is_feedback = true;
} }
//放货完成 //放货完成
@@ -753,7 +771,7 @@ public class AgvServiceImpl implements AgvService {
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) {
inst.setExecute_device_code(address); inst.setExecute_device_code(address);
inst.setExecute_status("4"); inst.setExecute_status("4");
ndxySpecialTwoDeviceDriver.setFlag(4); ndxySpecialTwoDeviceDriver.writing(4);
is_feedback = true; is_feedback = true;
} }
} }

View File

@@ -67,13 +67,16 @@ public class ElectricFenceDeviceDriver extends AbstractOpcDeviceDriver implement
this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode);
} }
if (action != last_action) { if (action != last_action) {
if (action == 1) {
agvService.pause();
}
this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action);
} }
if (error != last_error) { if (error != last_error) {
if (this.error == 1) { if (error == 1) {
agvService.pause(); agvService.pause();
} }
if (this.error == 0){ if (error == 0) {
agvService.resume(); agvService.resume();
} }
//this.execute_log.setContainer(""); //this.execute_log.setContainer("");

View File

@@ -15,11 +15,11 @@ public class ItemProtocol {
public static String item_mode = "mode"; public static String item_mode = "mode";
public static String item_move = "move"; public static String item_move = "move";
public static String item_action = "action"; public static String item_action = "action";
public static String item_mode_switch = "mode_switch";
public static String item_error = "error"; public static String item_error = "error";
public static String item_task = "task"; public static String item_ioaction = "ioaction";
public static String item_to_command = "to_command"; public static String item_to_command = "to_command";
public static String item_to_target = "to_target"; public static String item_to_mode_switch = "to_mode_switch";
public static String item_to_task = "to_task";
public static String item_weight = "weight"; public static String item_weight = "weight";
private NdxySpecialTwoDeviceDriver driver; private NdxySpecialTwoDeviceDriver driver;
@@ -44,24 +44,24 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_action); return this.getOpcIntegerValue(item_action);
} }
public int getMode_switch() {
return this.getOpcIntegerValue(item_mode_switch);
}
public int getError() { public int getError() {
return this.getOpcIntegerValue(item_error); return this.getOpcIntegerValue(item_error);
} }
public int getTask() { public int getIoaction() {
return this.getOpcIntegerValue(item_task); return this.getOpcIntegerValue(item_ioaction);
} }
public int getToCommand() { public int getToCommand() {
return this.getOpcIntegerValue(item_to_command); return this.getOpcIntegerValue(item_to_command);
} }
public int getToTarget() { public int getTo_mode_switch() {
return this.getOpcIntegerValue(item_to_target); return this.getOpcIntegerValue(item_to_mode_switch);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
} }
//是否有货 //是否有货
@@ -90,16 +90,16 @@ public class ItemProtocol {
list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); list.add(new ItemDto(item_action, "取放信号", "DB600.B3"));
list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B4"));
list.add(new ItemDto(item_mode_switch, "允许模式切换信号", "DB600.B5"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_task, "任务号", "DB600.D8"));
return list; return list;
} }
public static List<ItemDto> getWriteableItemDtos() { public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); list.add(new ItemDto(item_to_mode_switch, "切换模式", "DB601.W4"));
list.add(new ItemDto(item_to_task, "任务号", "DB601.D8"));
return list; return list;
} }

View File

@@ -58,11 +58,12 @@ public class NdxySpecialTwoDefination implements OpcDeviceDriverDefination {
public static List<ItemDto> getReadableItemDtos2() { public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList(); List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); 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_mode, "工作状态", "DB600.B1", Boolean.valueOf(true)));
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3"));
list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B4"));
list.add(new ItemDto(ItemProtocol.item_mode_switch, "允许模式切换信号", "DB600.B5"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D7"));
return list; return list;
} }

View File

@@ -67,11 +67,13 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
int move = 0; int move = 0;
int task = 0; int task = 0;
int action = 0; int action = 0;
int ioaction = 0;
int last_mode = 0; int last_mode = 0;
int last_error = 0; int last_error = 0;
int last_move = 0; int last_move = 0;
int last_task = 0; int last_task = 0;
int last_action = 0; int last_action = 0;
int last_ioaction = 0;
Boolean isonline = true; Boolean isonline = true;
int hasGoods = 0; int hasGoods = 0;
String message = null; String message = null;
@@ -122,6 +124,10 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag; int flag;
//允许模式切换 0不允许 1允许
int mode_switch = 0;
int last_mode_switch = 0;
String devicecode; String devicecode;
@Override @Override
@@ -139,7 +145,8 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
move = this.itemProtocol.getMove(); move = this.itemProtocol.getMove();
action = this.itemProtocol.getAction(); action = this.itemProtocol.getAction();
task = this.itemProtocol.getTask(); ioaction = this.itemProtocol.getIoaction();
mode_switch = this.itemProtocol.getMode_switch();
hasGoods = this.itemProtocol.getMove(); hasGoods = this.itemProtocol.getMove();
if (mode != last_mode) { if (mode != last_mode) {
@@ -154,6 +161,15 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move); this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move);
} }
if (error != last_error) { if (error != last_error) {
if (error != 0) {
if (mode_switch == 1) {
this.writing(1);
}
} else {
if (mode_switch == 1) {
this.writing(2);
}
}
this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error); this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error);
} }
@@ -161,6 +177,14 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action);
} }
if (ioaction != last_ioaction) {
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_ioaction -> ioaction:" + last_ioaction + "->" + ioaction);
}
if (mode_switch != last_mode_switch) {
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_mode_switch -> mode_switch:" + last_mode_switch + "->" + mode_switch);
}
if (this.getApply_handling()) { if (this.getApply_handling()) {
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
@@ -252,6 +276,8 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
last_move = move; last_move = move;
last_task = task; last_task = task;
last_action = action; last_action = action;
last_ioaction = ioaction;
last_mode_switch = mode_switch;
} }
@@ -308,8 +334,7 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0 if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0
&& ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code))
&& ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code))) {
&& this.action == 1) {
break; break;
} else { } else {
next_device_code = ""; next_device_code = "";
@@ -351,32 +376,6 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
return true; return true;
} }
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
ReadUtil.write(itemMap, server);
}
public void executing(Server server, Map<String, Object> itemMap) { public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
} }
@@ -396,20 +395,16 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
public void writing(int type, int command) { public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command; + "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() String to_mode_switch = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target; + "." + ItemProtocol.item_to_mode_switch;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
String opcservcerid = this.getDevice().getOpc_server_id(); String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid); Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) { if (type == 1) {
itemMap.put(to_command, command); itemMap.put(to_command, command);
} else if (type == 2) { } else if (type == 2) {
itemMap.put(to_target, command); itemMap.put(to_mode_switch, command);
} else if (type == 3) {
itemMap.put(to_task, command);
} }
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);

View File

@@ -282,11 +282,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
switch (flag) { switch (flag) {
//取货完成 //取货完成
case 1: case 2:
writing(2); writing(2);
return; return;
//放货完成 //放货完成
case 2: case 4:
writing(3); writing(3);
return; return;