更新
This commit is contained in:
@@ -672,16 +672,10 @@ public class AgvServiceImpl implements AgvService {
|
||||
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) addressdevice.getDeviceDriver();
|
||||
//请求取货
|
||||
if ("Load".equals(action)) {
|
||||
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) {
|
||||
ndxySpecialTwoDeviceDriver.writing("item_to_address",1);
|
||||
ndxySpecialTwoDeviceDriver.writing("to_pick_ready",1);
|
||||
if (ndxySpecialTwoDeviceDriver.getMode() == 1 && ndxySpecialTwoDeviceDriver.getMove() > 0 && ndxySpecialTwoDeviceDriver.getAction()==1) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -764,7 +758,7 @@ public class AgvServiceImpl implements AgvService {
|
||||
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) {
|
||||
inst.setExecute_device_code(processingVehicle);
|
||||
inst.setExecute_status("2");
|
||||
ndxySpecialTwoDeviceDriver.writing(2);
|
||||
// ndxySpecialTwoDeviceDriver.writing(2);
|
||||
is_feedback = true;
|
||||
}
|
||||
//放货完成
|
||||
@@ -772,7 +766,7 @@ public class AgvServiceImpl implements AgvService {
|
||||
if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) {
|
||||
inst.setExecute_device_code(address);
|
||||
inst.setExecute_status("4");
|
||||
ndxySpecialTwoDeviceDriver.writing(4);
|
||||
// ndxySpecialTwoDeviceDriver.writing(4);
|
||||
is_feedback = true;
|
||||
}
|
||||
}
|
||||
@@ -1033,25 +1027,15 @@ public class AgvServiceImpl implements AgvService {
|
||||
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) device.getDeviceDriver();
|
||||
//请求取货
|
||||
if (StrUtil.equals(type, "01") && ndxySpecialTwoDeviceDriver.getMove() != 0) {
|
||||
ndxySpecialTwoDeviceDriver.writing(1, 1);
|
||||
// ndxySpecialTwoDeviceDriver.writing(1, 1);
|
||||
is_feedback = true;
|
||||
}
|
||||
//取货完成
|
||||
else if (StrUtil.equals(type, "02")) {
|
||||
ndxySpecialTwoDeviceDriver.writing(1, 2);
|
||||
ndxySpecialTwoDeviceDriver.writing("to_pick_finish", 1);
|
||||
is_feedback = true;
|
||||
}
|
||||
|
||||
//请求放货
|
||||
else if (StrUtil.equals(type, "03") && ndxySpecialTwoDeviceDriver.getMove() == 0) {
|
||||
ndxySpecialTwoDeviceDriver.writing(1, 3);
|
||||
is_feedback = true;
|
||||
}
|
||||
//放货完成
|
||||
else if (StrUtil.equals(type, "04")) {
|
||||
ndxySpecialTwoDeviceDriver.writing(1, 4);
|
||||
is_feedback = true;
|
||||
}
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof YkbkSpecialDeviceDriver) {
|
||||
ykbkSpecialDeviceDriver = (YkbkSpecialDeviceDriver) device.getDeviceDriver();
|
||||
|
||||
@@ -15,12 +15,14 @@ public class ItemProtocol {
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_mode_switch = "mode_switch";
|
||||
public static String item_error = "error";
|
||||
public static String item_ioaction = "ioaction";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_pick_start = "pick_start";
|
||||
public static String item_device_status = "device_status";
|
||||
public static String item_to_ready = "to_ready";
|
||||
public static String item_to_agv_status = "to_agv_status";
|
||||
public static String item_to_address = "to_address";
|
||||
public static String item_to_mode_switch = "to_mode_switch";
|
||||
public static String item_weight = "weight";
|
||||
public static String item_to_pick_ready = "to_pick_ready";
|
||||
public static String item_to_pick_finish = "to_pick_finish";
|
||||
|
||||
private NdxySpecialTwoDeviceDriver driver;
|
||||
|
||||
@@ -44,25 +46,14 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getMode_switch() {
|
||||
return this.getOpcIntegerValue(item_mode_switch);
|
||||
public int getPick_start() {
|
||||
return this.getOpcIntegerValue(item_pick_start);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
public int getDevice_status() {
|
||||
return this.getOpcIntegerValue(item_device_status);
|
||||
}
|
||||
|
||||
public int getIoaction() {
|
||||
return this.getOpcIntegerValue(item_ioaction);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getTo_mode_switch() {
|
||||
return this.getOpcIntegerValue(item_to_mode_switch);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
@@ -86,20 +77,23 @@ public class ItemProtocol {
|
||||
|
||||
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"));
|
||||
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_heartbeat, "心跳", "DB700.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB700.B1", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "DB700.B2"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB700.B3"));
|
||||
list.add(new ItemDto(item_pick_start, "卸载开始", "DB700.B4"));
|
||||
list.add(new ItemDto(item_device_status, "码垛机状态", "DB700.B5"));
|
||||
|
||||
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_mode_switch, "切换模式", "DB601.W4"));
|
||||
list.add(new ItemDto(item_to_ready, "就绪", "DB701.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_agv_status, "AGV状态", "DB701.W4"));
|
||||
list.add(new ItemDto(item_to_address, "到位", "DB701.W6"));
|
||||
list.add(new ItemDto(item_to_pick_ready, "允许卸货", "DB701.W8"));
|
||||
list.add(new ItemDto(item_to_pick_finish, "卸货完成", "DB701.W10"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,20 +52,9 @@ public class NdxySpecialTwoDefination implements OpcDeviceDriverDefination {
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
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", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2"));
|
||||
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"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
|
||||
@@ -138,17 +138,13 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public void execute() throws Exception {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
ioaction = this.itemProtocol.getIoaction();
|
||||
mode_switch = this.itemProtocol.getMode_switch();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
|
||||
@@ -161,69 +157,11 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
|
||||
this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move);
|
||||
}
|
||||
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.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error);
|
||||
}
|
||||
|
||||
if (action != last_action) {
|
||||
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
|
||||
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()) {
|
||||
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
Device link_device = appService.findDeviceByCode(link_device_code);
|
||||
NdxySpecialTwoDeviceDriver NdxySpecialTwoDevicedriver;
|
||||
if (link_device.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) {
|
||||
NdxySpecialTwoDevicedriver = (NdxySpecialTwoDeviceDriver) link_device.getDeviceDriver();
|
||||
//如果目标设备申请叫料 则允许生成任务
|
||||
if (NdxySpecialTwoDevicedriver.getApply_material()) {
|
||||
TaskDto dto = new TaskDto();
|
||||
String now = DateUtil.now();
|
||||
dto.setTask_id(IdUtil.simpleUUID());
|
||||
dto.setCreate_by(this.getDevice().getDevice_code());
|
||||
dto.setUpdate_by(this.getDevice().getDevice_code());
|
||||
dto.setStart_point_code(this.getDevice().getDevice_code());
|
||||
|
||||
String taskcode = CodeUtil.getNewCode("TASK_NO");
|
||||
dto.setTask_code("-" + taskcode);
|
||||
dto.setTask_status("0");
|
||||
dto.setPriority("101");
|
||||
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
// String next_device_codecode = jo.getNext_device_code();
|
||||
// if(StrUtil.isEmpty(next_device_codecode)){
|
||||
// throw new RuntimeException("该设备未找到对应路由");
|
||||
// }
|
||||
dto.setNext_point_code(NdxySpecialTwoDevicedriver.getDevicecode());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = JSONObject.fromObject(dto);
|
||||
wo.insert(json);
|
||||
NdxySpecialTwoDevicedriver.setApply_material(false);
|
||||
}
|
||||
}
|
||||
this.setApply_handling(false);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
@@ -252,24 +190,10 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
if (!requireSucess && this.move != 0) {
|
||||
if (!requireSucess && this.move != 0 && mode ==1 && action ==1) {
|
||||
standby();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 2:
|
||||
writing(2);
|
||||
return;
|
||||
//放货完成
|
||||
case 4:
|
||||
writing(4);
|
||||
return;
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
@@ -306,7 +230,7 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean standby() {
|
||||
public synchronized boolean standby() throws Exception {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
@@ -369,9 +293,10 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
}
|
||||
}
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = JSONObject.fromObject(dto);
|
||||
wo.insert(json);
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject json = JSONObject.fromObject(dto);
|
||||
// wo.insert(json);
|
||||
taskserver.create(dto);
|
||||
Device device = appService.findDeviceByCode(next_device_code);
|
||||
device.setIslock("true");
|
||||
this.setRequireSucess(true);
|
||||
@@ -393,36 +318,21 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
|
||||
public void writing(String type, int command) {
|
||||
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
+ "." + type;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
String to_mode_switch = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_mode_switch;
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
if (type == 1) {
|
||||
itemMap.put(to_command, command);
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_mode_switch, command);
|
||||
}
|
||||
ReadUtil.write(itemMap, server);
|
||||
|
||||
}
|
||||
|
||||
public boolean instruction_require(String container_code) {
|
||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver;
|
||||
import org.nl.acs.device_driver.ndxy_special_two.NdxySpecialTwoDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
@@ -310,6 +311,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
||||
StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver;
|
||||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver;
|
||||
NdxySpecialTwoDeviceDriver ndxySpecialTwoDeviceDriver;
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//将指令赋予对象 下发指令号给电气
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
@@ -413,6 +415,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
}
|
||||
|
||||
if (startdevice.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) {
|
||||
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) startdevice.getDeviceDriver();
|
||||
ndxySpecialTwoDeviceDriver.writing("to_ready",1);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// != 0 为agv任务
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver;
|
||||
import org.nl.acs.device_driver.ndxy_special_two.NdxySpecialTwoDeviceDriver;
|
||||
import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.Device;
|
||||
@@ -46,12 +47,22 @@ public class QueryMagicAgvDeviceStatus {
|
||||
String mode = "";
|
||||
List<Device> allDevice = appService.findAllDevice();
|
||||
WeighingSiteDeviceDriver weighingSiteDeviceDriver;
|
||||
NdxySpecialTwoDeviceDriver ndxySpecialTwoDeviceDriver;
|
||||
for (int z = 0; z < allDevice.size(); z++) {
|
||||
Device deviceBycode = allDevice.get(z);
|
||||
if (deviceBycode.getDeviceDriver() instanceof WeighingSiteDeviceDriver) {
|
||||
weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) deviceBycode.getDeviceDriver();
|
||||
mode = weighingSiteDeviceDriver.getNowMode();
|
||||
}
|
||||
|
||||
if (deviceBycode.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) {
|
||||
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) deviceBycode.getDeviceDriver();
|
||||
if(jo.optString("state").equals("IDLE") || jo.optString("state").equals("EXECUTING") || jo.optString("state").equals("IDLE") ){
|
||||
ndxySpecialTwoDeviceDriver.writing("to_agv_status",1);
|
||||
} else {
|
||||
ndxySpecialTwoDeviceDriver.writing("to_agv_status",0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ElectricFenceDeviceDriver electricFenceDeviceDriver;
|
||||
|
||||
Reference in New Issue
Block a user