现场测试完成
This commit is contained in:
0
hd/logPath_IS_UNDEFINED/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/ACS请求WMS/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/ACS请求WMS/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/AGV请求离开/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/AGV请求离开/2022-09-24.0.log
Normal file
46259
hd/logPath_IS_UNDEFINED/AGV驱动/2022-09-24.0.log
Normal file
46259
hd/logPath_IS_UNDEFINED/AGV驱动/2022-09-24.0.log
Normal file
File diff suppressed because it is too large
Load Diff
0
hd/logPath_IS_UNDEFINED/NDC/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/NDC/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/WMS下发ACS/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/WMS下发ACS/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/反馈AGV请求/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/反馈AGV请求/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/扫码记录/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/扫码记录/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/查询AGV指令状态/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/查询AGV指令状态/2022-09-24.0.log
Normal file
18
hd/logPath_IS_UNDEFINED/查询仙工AGV设备状态/2022-09-24.0.log
Normal file
18
hd/logPath_IS_UNDEFINED/查询仙工AGV设备状态/2022-09-24.0.log
Normal file
@@ -0,0 +1,18 @@
|
||||
2022-09-24 14:51:58.739 [nl-pool1-thread-2] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:58.739 [nl-pool1-thread-2] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:58.848 [nl-pool1-thread-10] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:58.852 [nl-pool1-thread-10] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:58.956 [nl-pool1-thread-7] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:58.961 [nl-pool1-thread-7] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.065 [nl-pool1-thread-3] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.065 [nl-pool1-thread-3] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.175 [nl-pool1-thread-5] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.175 [nl-pool1-thread-5] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.284 [nl-pool1-thread-8] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.284 [nl-pool1-thread-8] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.393 [nl-pool1-thread-10] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.393 [nl-pool1-thread-10] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.502 [nl-pool1-thread-9] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.502 [nl-pool1-thread-9] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
2022-09-24 14:51:59.612 [nl-pool1-thread-6] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 111111111111
|
||||
2022-09-24 14:51:59.612 [nl-pool1-thread-6] INFO org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver - 判断当前有无指令:true
|
||||
0
hd/logPath_IS_UNDEFINED/自动创建指令/2022-09-24.0.log
Normal file
0
hd/logPath_IS_UNDEFINED/自动创建指令/2022-09-24.0.log
Normal file
@@ -71,6 +71,10 @@ public interface OpcDeviceDriver extends DeviceDriver {
|
||||
return (Float) this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
||||
}
|
||||
|
||||
default Short getShortValue(String protocol) {
|
||||
return (Short) this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
||||
}
|
||||
|
||||
default Object getValue(String protocol) {
|
||||
return this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -150,58 +151,37 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (move != last_move) {
|
||||
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
|
||||
this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move);
|
||||
String apply_task = this.getDevice().getExtraValue().get("apply_task").toString();
|
||||
if (StrUtil.equals(apply_task,"true") && move == 1 && mode ==2) {
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
String next_device_code = jo.getNext_device_code();
|
||||
|
||||
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");
|
||||
|
||||
dto.setNext_point_code(next_device_code);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
taskserver.create(dto);
|
||||
}
|
||||
}
|
||||
if (error != last_error) {
|
||||
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
|
||||
this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error);
|
||||
}
|
||||
|
||||
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);
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
|
||||
if (link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
|
||||
// if(standardInspectSiteDevicedriver.getMode() != 2){
|
||||
// log.debug("设备未待机");
|
||||
// return;
|
||||
// }
|
||||
// if(standardInspectSiteDevicedriver.getMove() != 0){
|
||||
// log.debug("设备不满足放货条件");
|
||||
// return;
|
||||
// }
|
||||
|
||||
//如果目标设备申请叫料 则允许生成任务
|
||||
if (standardInspectSiteDevicedriver.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(standardInspectSiteDevicedriver.getDevicecode());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = JSONObject.fromObject(dto);
|
||||
wo.insert(json);
|
||||
standardInspectSiteDevicedriver.setApply_material(false);
|
||||
}
|
||||
}
|
||||
this.setApply_handling(false);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
@@ -233,60 +213,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
//申请任务
|
||||
// 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);
|
||||
// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
|
||||
// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
|
||||
// if(standardInspectSiteDevicedriver.getMode() != 2){
|
||||
// log.debug("设备未待机");
|
||||
// return;
|
||||
// }
|
||||
// if(standardInspectSiteDevicedriver.getMove() != 0){
|
||||
// log.debug("设备不满足放货条件");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// //如果目标设备申请叫料 则允许生成任务
|
||||
// if(standardInspectSiteDevicedriver.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 = CodeGenerateUtil.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(next_device_codecode);
|
||||
// dto.setUpdate_time(now);
|
||||
// dto.setCreate_time(now);
|
||||
//
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject json = JSONObject.fromObject(dto);
|
||||
// wo.insert(json);
|
||||
// standardInspectSiteDevicedriver.setApply_material(false);
|
||||
// }
|
||||
// }
|
||||
// this.setApply_handling(false);
|
||||
// }
|
||||
|
||||
if (material.length() > 0 && qty.length() > 0 && !requireSucess) {
|
||||
this.execute_log.log("设备:" + devicecode + ",material:" + material + ",qty:" + qty);
|
||||
|
||||
this.instruction_require(container);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
package org.nl.acs.device_driver.xg_agv;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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 is_charging = "is_charging";
|
||||
public static String stop = "stop";
|
||||
public static String DI0 = "DI0";
|
||||
public static String DI1 = "DI1";
|
||||
public static String DI2 = "DI2";
|
||||
public static String DI3 = "DI3";
|
||||
public static String DI4 = "DI4";
|
||||
public static String DI11 = "DI12";
|
||||
public static String DI12 = "DI12";
|
||||
public static String DO0 = "DO0";
|
||||
public static String DO1 = "DO1";
|
||||
public static String DO2 = "DO2";
|
||||
public static String x = "x";
|
||||
public static String y = "y";
|
||||
public static String angle = "angle";
|
||||
//站点的 id 号, 0 表示无导航站点
|
||||
public static String navigation_address = "navigation_address";
|
||||
//0 = 定位失败, 1 = 定位正确, 2 = 正在重定位, 3 = 定位完成;机器人刚启动后,定位状态为 2,
|
||||
// 当定位状态变为 3 时,可以用 [0x]00003 地址位确认定位正确,确认后定位状态将变为 1
|
||||
public static String positioning_status = "positioning_status";
|
||||
//0 = 无, 1 = 等待执行导航, 2 = 正在执行导航, 3 = 导航暂停, 4 = 到达, 5 = 失败, 6 = 取消, 7 = 超时
|
||||
public static String navigation_status = "navigation_status";
|
||||
//0 = 没有导航, 1 = 自由导航到任意点, 2 = 自由导航到站点, 3 = 路径导航到站点, 7 = 平动转动, 100 = 其他
|
||||
public static String navigation_type = "navigation_type";
|
||||
//范围为 0 ~ 1
|
||||
public static String electricity = "electricity";
|
||||
public static String address = "address";
|
||||
public static String next_address = "next_address";
|
||||
public static String home_relocation = "home_relocation";
|
||||
//确认定位正确
|
||||
public static String locate_correct = "locate_correct";
|
||||
public static String pause_navigation = "pause_navigation";
|
||||
public static String continue_navigation = "continue_navigation";
|
||||
public static String cancle_navigation = "cancle_navigation";
|
||||
//滚筒运行状态
|
||||
public static String drum_run_status = "drum_run_status";
|
||||
|
||||
|
||||
public static String to_home_relocation = "to_home_relocation";
|
||||
//确认定位正确
|
||||
public static String to_locate_correct = "to_locate_correct";
|
||||
public static String to_pause_navigation = "to_pause_navigation";
|
||||
public static String to_continue_navigation = "to_continue_navigation";
|
||||
public static String to_cancle_navigation = "to_cancle_navigation";
|
||||
public static String to_DO0_height = "to_DO0_height";
|
||||
public static String to_DO0_low = "to_DO0_low";
|
||||
public static String to_DO1_height = "to_DO1_height";
|
||||
public static String to_DO1_low = "to_DO1_low";
|
||||
public static String to_DO2_low = "to_DO2_low";
|
||||
public static String to_DO8_low = "to_DO8_low";
|
||||
public static String to_DO9_low = "to_DO9_low";
|
||||
|
||||
public static String to_address = "to_address";
|
||||
public static String to_clear_error = "to_clear_error";
|
||||
//虚拟高电平写
|
||||
public static String to_di_height = "to_di_height";
|
||||
//虚拟低电平写
|
||||
public static String to_di_low = "to_di_low";
|
||||
|
||||
|
||||
public int getIs_charging() {
|
||||
return this.getOpcIntegerValue(is_charging);
|
||||
}
|
||||
|
||||
public int getStop() {
|
||||
return this.getOpcIntegerValue(stop);
|
||||
}
|
||||
|
||||
public int getDI0() {
|
||||
return this.getOpcIntegerValue(DI0);
|
||||
}
|
||||
|
||||
public int getDI1() {
|
||||
return this.getOpcIntegerValue(DI1);
|
||||
}
|
||||
|
||||
public int getDI2() {
|
||||
return this.getOpcIntegerValue(DI2);
|
||||
}
|
||||
|
||||
public int getDI3() {
|
||||
return this.getOpcIntegerValue(DI3);
|
||||
}
|
||||
|
||||
public int getDI4() {
|
||||
return this.getOpcIntegerValue(DI4);
|
||||
|
||||
}
|
||||
|
||||
public int getDI11() {
|
||||
return this.getOpcIntegerValue(DI11);
|
||||
|
||||
}
|
||||
|
||||
public int getDI12() {
|
||||
return this.getOpcIntegerValue(DI12);
|
||||
|
||||
}
|
||||
|
||||
public int getDO0() {
|
||||
return this.getOpcIntegerValue(DO0);
|
||||
|
||||
}
|
||||
|
||||
public int getDO1() {
|
||||
return this.getOpcIntegerValue(DO1);
|
||||
|
||||
}
|
||||
public int getDO2() {
|
||||
return this.getOpcIntegerValue(DO2);
|
||||
|
||||
}
|
||||
|
||||
public Float getX() {
|
||||
return this.getOpcFloatValue(x);
|
||||
|
||||
}
|
||||
|
||||
public Float getY() {
|
||||
return this.getOpcFloatValue(y);
|
||||
|
||||
}
|
||||
|
||||
public Float getAngle() {
|
||||
return this.getOpcFloatValue(angle);
|
||||
|
||||
}
|
||||
|
||||
public short getNavigation_address() {
|
||||
return this.getOpcShortValue(navigation_address);
|
||||
|
||||
}
|
||||
|
||||
public short getPositioning_status() {
|
||||
return this.getOpcShortValue(positioning_status);
|
||||
}
|
||||
|
||||
public short getNavigation_status() {
|
||||
return this.getOpcShortValue(navigation_status);
|
||||
}
|
||||
|
||||
public short getNavigation_type() {
|
||||
return this.getOpcShortValue(navigation_type);
|
||||
|
||||
}
|
||||
|
||||
public int getElectricity() {
|
||||
return this.getOpcIntegerValue(electricity);
|
||||
|
||||
}
|
||||
|
||||
public int getAddress() {
|
||||
return this.getOpcIntegerValue(address);
|
||||
|
||||
}
|
||||
|
||||
public short getNext_address() {
|
||||
return this.getOpcShortValue(next_address);
|
||||
}
|
||||
|
||||
public int getHome_relocation() {
|
||||
return this.getOpcIntegerValue(home_relocation);
|
||||
|
||||
}
|
||||
|
||||
public int getLocate_correct() {
|
||||
return this.getOpcIntegerValue(locate_correct);
|
||||
|
||||
}
|
||||
|
||||
public int getPause_navigation() {
|
||||
return this.getOpcIntegerValue(pause_navigation);
|
||||
|
||||
}
|
||||
|
||||
public int getContinue_navigation() {
|
||||
return this.getOpcIntegerValue(continue_navigation);
|
||||
|
||||
}
|
||||
|
||||
public int getCancle_navigation() {
|
||||
return this.getOpcIntegerValue(cancle_navigation);
|
||||
}
|
||||
|
||||
public short getDrum_run_status() {
|
||||
return this.getOpcShortValue(drum_run_status);
|
||||
}
|
||||
|
||||
public static void setTo_home_relocation(String to_home_relocation) {
|
||||
ItemProtocol.to_home_relocation = to_home_relocation;
|
||||
}
|
||||
|
||||
public static void setTo_locate_correct(String to_locate_correct) {
|
||||
ItemProtocol.to_locate_correct = to_locate_correct;
|
||||
}
|
||||
|
||||
public static void setTo_pause_navigation(String to_pause_navigation) {
|
||||
ItemProtocol.to_pause_navigation = to_pause_navigation;
|
||||
}
|
||||
|
||||
public static void setTo_continue_navigation(String to_continue_navigation) {
|
||||
ItemProtocol.to_continue_navigation = to_continue_navigation;
|
||||
}
|
||||
|
||||
public static void setTo_cancle_navigation(String to_cancle_navigation) {
|
||||
ItemProtocol.to_cancle_navigation = to_cancle_navigation;
|
||||
}
|
||||
|
||||
public static void setTo_DO0_height(String to_DO0_height) {
|
||||
ItemProtocol.to_DO0_height = to_DO0_height;
|
||||
}
|
||||
|
||||
public static void setTo_DO0_low(String to_DO0_low) {
|
||||
ItemProtocol.to_DO0_low = to_DO0_low;
|
||||
}
|
||||
|
||||
public static void setTo_DO1_height(String to_DO1_height) {
|
||||
ItemProtocol.to_DO1_height = to_DO1_height;
|
||||
}
|
||||
|
||||
public static void setTo_DO1_low(String to_DO1_low) {
|
||||
ItemProtocol.to_DO1_low = to_DO1_low;
|
||||
}
|
||||
|
||||
public static void setTo_DO8_low(String to_DO8_low) {
|
||||
ItemProtocol.to_DO8_low = to_DO8_low;
|
||||
}
|
||||
|
||||
public static void setTo_DO9_low(String to_DO9_low) {
|
||||
ItemProtocol.to_DO9_low = to_DO9_low;
|
||||
}
|
||||
|
||||
|
||||
public static void setTo_address(String to_address) {
|
||||
ItemProtocol.to_address = to_address;
|
||||
}
|
||||
|
||||
public static void setTo_clear_error(String to_clear_error) {
|
||||
ItemProtocol.to_clear_error = to_clear_error;
|
||||
}
|
||||
|
||||
public static void setTo_di_height(String to_di_height) {
|
||||
ItemProtocol.to_di_height = to_di_height;
|
||||
}
|
||||
|
||||
public static void setTo_di_low(String to_di_low) {
|
||||
ItemProtocol.to_di_low = to_di_low;
|
||||
}
|
||||
|
||||
private XgagvDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(XgagvDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public ItemProtocol() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Float getOpcFloatValue(String protocol) {
|
||||
Float value = this.driver.getFloatValue(protocol);
|
||||
if (ObjectUtil.isEmpty(value)) {
|
||||
log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegerValue(protocol);
|
||||
if (value == null) {
|
||||
log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public short getOpcShortValue(String protocol) {
|
||||
Short value = this.driver.getShortValue(protocol);
|
||||
if (value == null) {
|
||||
log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(is_charging, "是否充电", "10003"));
|
||||
list.add(new ItemDto(DI0, "DI0", "10020"));
|
||||
list.add(new ItemDto(DI1, "DI1", "10021"));
|
||||
list.add(new ItemDto(DI2, "DI2", "10022"));
|
||||
list.add(new ItemDto(DI3, "DI3", "10023"));
|
||||
list.add(new ItemDto(DI4, "DI4", "10024"));
|
||||
list.add(new ItemDto(DO1, "DO1", "10061"));
|
||||
list.add(new ItemDto(DO2, "DO2", "10062"));
|
||||
list.add(new ItemDto(DI11, "DI11", "10031"));
|
||||
list.add(new ItemDto(DI12, "DI12", "10032"));
|
||||
list.add(new ItemDto(x, "x", "30001"));
|
||||
list.add(new ItemDto(y, "y", "30003"));
|
||||
list.add(new ItemDto(angle, "angle", "30005"));
|
||||
list.add(new ItemDto(navigation_address, "当前导航站点", "30007"));
|
||||
list.add(new ItemDto(positioning_status, "定位状态", "30008"));
|
||||
list.add(new ItemDto(navigation_status, "当前导航状态", "30009"));
|
||||
list.add(new ItemDto(navigation_type, "当前导航类型", "30010"));
|
||||
list.add(new ItemDto(electricity, "电量", "30013"));
|
||||
list.add(new ItemDto(address, "当前所在站点", "30034"));
|
||||
list.add(new ItemDto(next_address, "下一个要经过的站点", "30036"));
|
||||
list.add(new ItemDto(home_relocation, "在Home点重定位", "00002"));
|
||||
list.add(new ItemDto(locate_correct, "确认定位正确", "00003"));
|
||||
list.add(new ItemDto(pause_navigation, "暂停导航", "00004"));
|
||||
list.add(new ItemDto(continue_navigation, "继续导航", "00005"));
|
||||
list.add(new ItemDto(cancle_navigation, "取消导航", "00006"));
|
||||
list.add(new ItemDto(drum_run_status, "滚筒运行状态", "30062"));
|
||||
list.add(new ItemDto(stop, "车子停止", "10019"));
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(to_home_relocation, "to_在Home点重定位", "00002"));
|
||||
list.add(new ItemDto(to_locate_correct, "to_确认定位正确", "00003"));
|
||||
list.add(new ItemDto(to_pause_navigation, "to_暂停导航", "00004"));
|
||||
list.add(new ItemDto(to_continue_navigation, "to_继续导航", "00005"));
|
||||
list.add(new ItemDto(to_cancle_navigation, "to_取消导航", "00006"));
|
||||
list.add(new ItemDto(to_DO0_height, "to_DO0置为高电平", "00061"));
|
||||
list.add(new ItemDto(to_DO0_low, "to_DO0置为低电平", "00020"));
|
||||
list.add(new ItemDto(to_DO1_height, "to_DO1置为高电平", "00062"));
|
||||
list.add(new ItemDto(to_DO1_low, "to_DO1置为低电平", "00021"));
|
||||
list.add(new ItemDto(to_DO2_low, "to_DO2置为低电平", "00022"));
|
||||
list.add(new ItemDto(to_DO8_low, "to_DO8置为低电平", "00028"));
|
||||
list.add(new ItemDto(to_DO9_low, "to_DO9置为低电平", "00029"));
|
||||
list.add(new ItemDto(to_address, "to_address", "40001"));
|
||||
list.add(new ItemDto(to_clear_error, "to_clear_error", "40090"));
|
||||
list.add(new ItemDto(to_di_height, "虚拟高电平写", "40063"));
|
||||
list.add(new ItemDto(to_di_low, "虚拟低电平写", "40064"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
package org.nl.acs.device_driver.xg_agv;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
public class TCPAGVClient {
|
||||
|
||||
private static Socket socket;
|
||||
private static OutputStream socketOut;
|
||||
private static InputStream socketIn;
|
||||
static byte[] requestb ;
|
||||
|
||||
public static byte[] TCPRemoteConnectRead(String ipstr,int portstr,byte[] typestr)
|
||||
{
|
||||
byte[] bytes = new byte[2048];
|
||||
try
|
||||
{
|
||||
requestb=typestr;
|
||||
socket = new Socket(ipstr,portstr);
|
||||
socket.setSoTimeout(1000);
|
||||
socketOut = socket.getOutputStream();
|
||||
|
||||
socketOut.write(requestb);
|
||||
socketOut.flush();
|
||||
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
//通过shutdownOutput高速服务器已经发送完数据,后续只能接受数据
|
||||
socket.shutdownOutput();
|
||||
|
||||
socketIn = socket.getInputStream();
|
||||
|
||||
int len;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while ((len = socketIn.read(bytes)) != -1) {
|
||||
sb.append(new String(bytes, 0, len));
|
||||
}
|
||||
String s2=sb.toString().trim();
|
||||
System.out.println(s2);
|
||||
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (ConnectException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
//循环结束则退出输入流
|
||||
synchronized (socketIn) {
|
||||
if (socketOut != null) {
|
||||
try
|
||||
{
|
||||
socketOut.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (socketIn != null) {
|
||||
try
|
||||
{
|
||||
socketIn.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (socket != null) {
|
||||
try
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static byte[] TCPRemoteConnectRead(String ipstr,int portstr,String typestr)
|
||||
{
|
||||
byte[] bytes = new byte[2048];
|
||||
try
|
||||
{
|
||||
requestb=typestr.getBytes();
|
||||
socket = new Socket(ipstr,portstr);
|
||||
socket.setSoTimeout(1000);
|
||||
socketOut = socket.getOutputStream();
|
||||
|
||||
socketOut.write(requestb);
|
||||
socketOut.flush();
|
||||
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
//通过shutdownOutput高速服务器已经发送完数据,后续只能接受数据
|
||||
socket.shutdownOutput();
|
||||
|
||||
socketIn = socket.getInputStream();
|
||||
|
||||
int len;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while ((len = socketIn.read(bytes)) != -1) {
|
||||
sb.append(new String(bytes, 0, len));
|
||||
}
|
||||
String s2=sb.toString().trim();
|
||||
System.out.println(s2);
|
||||
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (ConnectException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
//循环结束则退出输入流
|
||||
synchronized (socketIn) {
|
||||
if (socketOut != null) {
|
||||
try
|
||||
{
|
||||
socketOut.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (socketIn != null) {
|
||||
try
|
||||
{
|
||||
socketIn.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (socket != null) {
|
||||
try
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
public static int IntToHexHigh(int b) {
|
||||
int big = (b & 0xFF00) >> 8;
|
||||
return big;
|
||||
}
|
||||
public static int IntToHexLow(int b) {
|
||||
int little = b & 0xFF;
|
||||
return little;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param num:要获取二进制值的数
|
||||
* @param index:倒数第一位为0,依次类推
|
||||
*/
|
||||
public static int get(int num, int index)
|
||||
{
|
||||
return (num & (0x1 << index)) >> index;
|
||||
}
|
||||
|
||||
/**
|
||||
* 16进制转换成为string类型字符串
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String hexStringToString(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
return null;
|
||||
}
|
||||
s = s.replace(" ", "");
|
||||
byte[] baKeyword = new byte[s.length() / 2];
|
||||
for (int i = 0; i < baKeyword.length; i++) {
|
||||
try {
|
||||
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
// s = new String(baKeyword, "UTF-8");
|
||||
// new String();
|
||||
s = new String(baKeyword, "GBK");
|
||||
new String();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void test()
|
||||
{
|
||||
String str="{\"id\":\"S001\",\"version\":\"v1.1.0\",\"model\":\"S1\"}";
|
||||
byte[] ba;
|
||||
try
|
||||
{
|
||||
ba = str.getBytes("UTF-8");
|
||||
|
||||
String s_new = new String(ba, "UTF-8");
|
||||
System.out.println("原始字符串:\t" + str);
|
||||
System.out.println("byte数组地址:\t" + ba);
|
||||
System.out.println("输出byte数组:\t" + Arrays.toString(ba));
|
||||
System.out.println("输出byte数组长度:\t" + ba.length);
|
||||
System.out.println("转换为字符串:\t" + s_new);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//字符串转化成为16进制字符串
|
||||
public static String strTo16(String s) {
|
||||
String str = "";
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
int ch = (int) s.charAt(i);
|
||||
String s4 = Integer.toHexString(ch).toUpperCase();
|
||||
str = str + s4;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
//16进制字符串转字节数组
|
||||
public static byte[] strToHexToByte(String str)
|
||||
{
|
||||
byte[] bytestr;
|
||||
try
|
||||
{
|
||||
bytestr = str.getBytes("UTF-8");
|
||||
System.out.println("输出byte数组:\t" + Arrays.toString(bytestr));
|
||||
return bytestr;
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.nl.acs.device_driver.xg_agv;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.DeviceDriverDefination;
|
||||
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.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +16,7 @@ import java.util.List;
|
||||
* magic3.0
|
||||
*/
|
||||
@Service
|
||||
public class XgagvDefination implements DeviceDriverDefination {
|
||||
public class XgagvDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "xg_agv";
|
||||
@@ -46,4 +49,14 @@ public class XgagvDefination implements DeviceDriverDefination {
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,25 +5,32 @@ import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONObject;
|
||||
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.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_manipulator_stacking_site.StandardManipulatorStackingSiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,11 +39,15 @@ import java.net.*;
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
|
||||
public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl");
|
||||
|
||||
//车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电
|
||||
String agv_mode = "0";
|
||||
@@ -44,141 +55,298 @@ public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDri
|
||||
String last_mode = "0";
|
||||
|
||||
|
||||
int is_charging =0;
|
||||
int stop = 0;
|
||||
int DI0 = 0;
|
||||
int DI1 = 0;
|
||||
int DI2 = 0;
|
||||
int DI3 = 0;
|
||||
int DI4 = 0;
|
||||
int DI11 = 0;
|
||||
int DI12 = 0;
|
||||
int DO0 = 0;
|
||||
int DO1 = 0;
|
||||
int DO2 = 0;
|
||||
Float x = 0f;
|
||||
Float y = 0f;
|
||||
Float angle = 0f;
|
||||
int navigation_address =0;
|
||||
int positioning_status =0;
|
||||
int navigation_status =0;
|
||||
int navigation_type =0;
|
||||
int electricity =0;
|
||||
int address =0;
|
||||
int next_address =0;
|
||||
int home_relocation =0;
|
||||
int locate_correct =0;
|
||||
int pause_navigation =0;
|
||||
int continue_navigation =0;
|
||||
int cancle_navigation =0;
|
||||
int drum_run_status =0;
|
||||
|
||||
int last_is_charging =0;
|
||||
int last_stop = 0;
|
||||
int last_DI0 = 0;
|
||||
int last_DI1 = 0;
|
||||
int last_DI2 = 0;
|
||||
int last_DI3 = 0;
|
||||
int last_DI4 = 0;
|
||||
int last_DI11 = 0;
|
||||
int last_DI12 = 0;
|
||||
int last_DO0 = 0;
|
||||
int last_DO1 = 0;
|
||||
int last_DO2 = 0;
|
||||
Float last_x = 0f;
|
||||
Float last_y = 0f;
|
||||
Float last_angle = 0f;
|
||||
int last_navigation_address =0;
|
||||
int last_positioning_status =0;
|
||||
int last_navigation_status =0;
|
||||
int last_navigation_type =0;
|
||||
int last_electricity =0;
|
||||
int last_address =0;
|
||||
int last_next_address =0;
|
||||
int last_home_relocation =0;
|
||||
int last_locate_correct =0;
|
||||
int last_pause_navigation =0;
|
||||
int last_continue_navigation =0;
|
||||
int last_cancle_navigation =0;
|
||||
int last_drum_run_status =0;
|
||||
|
||||
String device_code;
|
||||
Instruction inst = null;
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
String device_code = this.getDevice().getDevice_code();
|
||||
String charge_point = (String) this.getDevice().getExtraValue().get("charge_point");
|
||||
String relax_point = (String) this.getDevice().getExtraValue().get("relax_point");
|
||||
public void execute() throws Exception
|
||||
{
|
||||
|
||||
//查询当前设备是否存在未完成的任务
|
||||
JSONObject task = WQLObject.getWQLObject("ACS_INSTRUCTION").query("carno = '" + device_code + "' AND is_delete = '0' AND instruction_status IN ('0','1')").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(task)) {
|
||||
return;
|
||||
device_code = this.getDeviceCode();
|
||||
is_charging = this.itemProtocol.getIs_charging();
|
||||
DI0 = this.itemProtocol.getDI0();
|
||||
DI1 = this.itemProtocol.getDI1();
|
||||
DI2 = this.itemProtocol.getDI2();
|
||||
DI3 = this.itemProtocol.getDI3();
|
||||
DI4 = this.itemProtocol.getDI4();
|
||||
DI11 = this.itemProtocol.getDI11();
|
||||
DI12 = this.itemProtocol.getDI12();
|
||||
DO0 = this.itemProtocol.getDO0();
|
||||
DO1 = this.itemProtocol.getDO1();
|
||||
DO2 = this.itemProtocol.getDO2();
|
||||
x = this.itemProtocol.getX();
|
||||
y = this.itemProtocol.getY();
|
||||
navigation_address = this.itemProtocol.getNavigation_address();
|
||||
positioning_status = this.itemProtocol.getPositioning_status();
|
||||
navigation_status = this.itemProtocol.getNavigation_status();
|
||||
navigation_type = this.itemProtocol.getNavigation_type();
|
||||
electricity = this.itemProtocol.getElectricity();
|
||||
address = this.itemProtocol.getAddress();
|
||||
next_address = this.itemProtocol.getNext_address();
|
||||
home_relocation = this.itemProtocol.getHome_relocation();
|
||||
locate_correct = this.itemProtocol.getLocate_correct();
|
||||
pause_navigation = this.itemProtocol.getPause_navigation();
|
||||
continue_navigation = this.itemProtocol.getContinue_navigation();
|
||||
cancle_navigation = this.itemProtocol.getCancle_navigation();
|
||||
drum_run_status = this.itemProtocol.getDrum_run_status();
|
||||
stop = this.itemProtocol.getStop();
|
||||
|
||||
|
||||
//获取最小电量
|
||||
double min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric"));
|
||||
//获取最大电量
|
||||
double cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric"));
|
||||
//可执行任务电量
|
||||
double task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric"));
|
||||
//休息点
|
||||
int relax_point = Integer.parseInt((String)this.getDevice().getExtraValue().get("relax_point"));
|
||||
//充电点
|
||||
int charge_point = Integer.parseInt((String)this.getDevice().getExtraValue().get("charge_point"));
|
||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||
if(instList.size()>0){
|
||||
inst = instList.get(0);
|
||||
}
|
||||
//1、判断当前agv模式,为1需要去充电
|
||||
if (agv_mode.equals("1") && (StrUtil.isEmpty(last_mode) || !last_mode.equals("1"))) {
|
||||
//创建一条从当前位置去充电点的充电任务
|
||||
String start_point_code = "location";
|
||||
String next_point_code = charge_point;
|
||||
//先判断当前有无指令
|
||||
if(ObjectUtil.isEmpty(inst)){
|
||||
// log.info("判断当前有无指令:{}",ObjectUtil.isEmpty(inst));
|
||||
if( electricity != 0 && electricity <min_electric && address != charge_point && (navigation_status==0 ||navigation_status==4) ){
|
||||
log.info("下发充电:{}",charge_point);
|
||||
writing("to_address",charge_point);
|
||||
}
|
||||
if( electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status==0 ||navigation_status==4)){
|
||||
log.info("下发回休息点:{}",relax_point);
|
||||
writing("to_address",relax_point);
|
||||
}
|
||||
} else {
|
||||
// log.info("address:{},滚筒状态:{},车子状态:{},DI4:{},DO1:{},DO2:{},导航状态:{}",address,drum_run_status,stop,DI4,DO1,DO2,navigation_status);
|
||||
int start_device_code = Integer.parseInt(inst.getStart_device_code());
|
||||
int next_device_code = Integer.parseInt(inst.getNext_device_code());
|
||||
Device start_device = deviceAppService.findDeviceByCode(String.valueOf(start_device_code));
|
||||
Device next_device = deviceAppService.findDeviceByCode(String.valueOf(next_device_code));
|
||||
|
||||
TaskDto taskDto = new TaskDto();
|
||||
taskDto.setStart_point_code(start_point_code);
|
||||
taskDto.setNext_point_code(next_point_code);
|
||||
taskDto.setTask_type("01");
|
||||
taskserver.create(taskDto);
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
//指令状态就绪
|
||||
if(StrUtil.equals("0",inst.getInstruction_status())){
|
||||
log.info("下发指令号{},起点{}",inst.getInstruction_code(),start_device);
|
||||
writing("to_address",start_device_code);
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
|
||||
//请求取货 && DI4==1 无货状态
|
||||
if(StrUtil.equals("1",inst.getInstruction_status()) && address == start_device_code && stop==1 && DI4==1){
|
||||
log.info("agv准备取货,下发滚筒,指令号{},下发to_di_height:1",inst.getInstruction_code());
|
||||
if (start_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) start_device.getDeviceDriver();
|
||||
log.info("准备下发输送请求取货信号,mode:{},move{}",standardInspectSiteDeviceDriver.getMode(),standardInspectSiteDeviceDriver.getMove());
|
||||
if(standardInspectSiteDeviceDriver.getMode() ==2 && standardInspectSiteDeviceDriver.getMove() ==1){
|
||||
if((navigation_status==0 ||navigation_status==4) && (DO1 != 1 && DO2 != 1)){
|
||||
writing("to_di_low",1);
|
||||
writing("to_di_low",2);
|
||||
writing("to_DO1_low",1);
|
||||
writing("to_DO2_low",1);
|
||||
writing("to_DO8_low",1);
|
||||
writing("to_DO9_low",1);
|
||||
writing("to_di_height",1);
|
||||
}
|
||||
log.info("agv准备取货,DO1:{},DO2:{}",DO1,DO2);
|
||||
if(DO1 == 1 && DO2 == 1){
|
||||
standardInspectSiteDeviceDriver.writing(1,1);
|
||||
log.info("下发设备{}信号to_command值:{}",start_device,1);
|
||||
} else {
|
||||
log.info("agv准备取货,DO1:{},DO2:{}未就绪",DO1,DO2);
|
||||
}
|
||||
} else {
|
||||
log.info("agv准备取货,输送线未就绪,mode:{},move:{},action:{}",standardInspectSiteDeviceDriver.getMode(),
|
||||
standardInspectSiteDeviceDriver.getMove(),standardInspectSiteDeviceDriver.getAction());
|
||||
}
|
||||
}
|
||||
}
|
||||
//取货完成 下发去放货位置
|
||||
if(StrUtil.equals("1",inst.getInstruction_status()) && address == start_device_code && stop==1 && DI4==0 && DO1 == 0 && DO2 == 0 ){
|
||||
log.info("取货完成,指令号{},下发to_di_height:2",inst.getInstruction_code());
|
||||
if (start_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) start_device.getDeviceDriver();
|
||||
if(standardInspectSiteDeviceDriver.getMode() ==2 && standardInspectSiteDeviceDriver.getMove() ==0){
|
||||
standardInspectSiteDeviceDriver.writing(1,2);
|
||||
log.info("下发设备{}信号to_command值:{}",start_device,2);
|
||||
writing("to_di_low",1);
|
||||
writing("to_address",next_device_code);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//下发去放货位置
|
||||
// if(StrUtil.equals("1",inst.getInstruction_status()) && address == start_device_code && stop==1 && DI4==0 && DO1 == 0 && DO2 == 0){
|
||||
// log.info("取货完成,指令号{},下发放货位{}",inst.getInstruction_code(),next_device);
|
||||
// writing("to_address",next_device_code);
|
||||
// }
|
||||
//请求放货
|
||||
if(StrUtil.equals("1",inst.getInstruction_status()) && address == next_device_code && stop==1 && DI4==0 ){
|
||||
log.info("取货完成,指令号{},下发to_di_height:12",inst.getInstruction_code());
|
||||
if (next_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) next_device.getDeviceDriver();
|
||||
if(standardInspectSiteDeviceDriver.getMode() ==2 && standardInspectSiteDeviceDriver.getMove() ==0){
|
||||
standardInspectSiteDeviceDriver.writing(1,1);
|
||||
writing("to_di_height",2);
|
||||
}
|
||||
}
|
||||
}
|
||||
//放货完成 完成任务回休息点
|
||||
if(StrUtil.equals("1",inst.getInstruction_status()) && address == next_device_code && stop==1 && DI4==1 && DO1 ==0 && DO2 ==0 ){
|
||||
if (next_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) next_device.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.writing(1,3);
|
||||
}
|
||||
log.info("放货完成,指令号{},下发to_di_low:2",inst.getInstruction_code());
|
||||
writing("to_di_low",1);
|
||||
writing("to_di_low",2);
|
||||
writing("to_DO1_low",1);
|
||||
writing("to_DO2_low",1);
|
||||
writing("to_DO8_low",1);
|
||||
writing("to_DO9_low",1);
|
||||
writing("to_address",relax_point);
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
inst = null;
|
||||
}
|
||||
}
|
||||
|
||||
//2、判断当前agv模式,为3充满电去休息点
|
||||
if (agv_mode.equals("3") && (StrUtil.isEmpty(last_mode) || !last_mode.equals("3"))) {
|
||||
//创建一条从当前位置去充电点的充电任务
|
||||
String start_point_code = "location";
|
||||
String next_point_code = relax_point;
|
||||
|
||||
TaskDto taskDto = new TaskDto();
|
||||
taskDto.setStart_point_code(start_point_code);
|
||||
taskDto.setNext_point_code(next_point_code);
|
||||
taskDto.setTask_type("02");
|
||||
taskserver.create(taskDto);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject applyAgv(String ip, int port, String code, JSONObject jo) throws IOException {
|
||||
InputStream tbjdis = null;
|
||||
OutputStream tbjdos = null;
|
||||
Socket tbjsocket = null;
|
||||
public JSONObject applyAgv(String ip, int port, byte[] code, JSONObject jo) throws IOException {
|
||||
String jstr="",str_response="",str_response_head="",str_response_body="";
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
log.info("AGV请求开始");
|
||||
SocketAddress socketAddress = new InetSocketAddress(ip, port);
|
||||
tbjsocket = new Socket();
|
||||
//链接超时
|
||||
tbjsocket.connect(socketAddress, 1500);
|
||||
//读取数据超时
|
||||
String content = "";
|
||||
if (ObjectUtil.isNotEmpty(jo)){
|
||||
content = bytesToHexString(stringToByte(jo.toString()));
|
||||
}
|
||||
content = code + content;
|
||||
log.info("AGV请求参数:-----------------"+content);
|
||||
tbjdos = tbjsocket.getOutputStream();
|
||||
tbjdos.write(content.getBytes("UTF-8"));
|
||||
tbjdos.flush();
|
||||
log.info("AGV----------------------发送数据成功");
|
||||
tbjdis = tbjsocket.getInputStream();
|
||||
byte[] bytes = new byte[1024];
|
||||
int len;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s = "";
|
||||
while ((len = tbjdis.read(bytes)) != -1) {
|
||||
//注意指定编码格式,发送方和接收方一定要统一,建议使用UTF-8
|
||||
sb.append(new String(bytes, 0, len, "UTF-8"));
|
||||
log.info("AGV返回信息:-----------------"+sb);
|
||||
s = hexStringToString(sb.toString());
|
||||
}
|
||||
|
||||
result = JSONObject.fromObject(s);
|
||||
System.out.println("AGV返回" + sb.toString());
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
log.info(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (ConnectException e) {
|
||||
log.info(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
} finally {
|
||||
//循环结束则退出输入流
|
||||
synchronized (tbjdis) {
|
||||
if (tbjdos != null) {
|
||||
try {
|
||||
tbjdos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (tbjdis != null) {
|
||||
try {
|
||||
tbjdis.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (tbjsocket != null) {
|
||||
try {
|
||||
tbjsocket.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] b_request,b_respose;
|
||||
byte[] b_head,b_data;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(ObjectUtil.isEmpty(jo)){
|
||||
b_respose=TCPAGVClient.TCPRemoteConnectRead(ip, port, code);
|
||||
} else {
|
||||
b_respose=TCPAGVClient.TCPRemoteConnectRead(ip, port, jo.toString());
|
||||
}
|
||||
sb.append(new String(b_respose, 0, b_respose.length));
|
||||
str_response=sb.toString();
|
||||
if(str_response.trim().length()>0)
|
||||
{
|
||||
str_response_head=str_response.substring(0, 15);
|
||||
str_response_body=str_response.substring(16, str_response.length()).trim();
|
||||
log.info("AGV反馈信息:---------------"+str_response_body.trim());
|
||||
result = JSONObject.fromObject(str_response_body);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public JSONObject applyTask(JSONObject jo) throws IOException {
|
||||
String ip = jo.getString("ip");
|
||||
String source_id = "";
|
||||
String id = jo.getString("point_code");
|
||||
String task_id = jo.getString("task_id");
|
||||
|
||||
//定位
|
||||
byte[] b_positioning =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X03,(byte)0XFD,
|
||||
(byte)0X03,(byte)0XFD,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00};
|
||||
|
||||
//位置
|
||||
byte[] b_location =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X03,(byte)0XEC,
|
||||
(byte)0X03,(byte)0XEC,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
|
||||
//未知
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X54,
|
||||
(byte)0X32,(byte)0XFB,
|
||||
(byte)0X0B,(byte)0XEB,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
//查询定位状态
|
||||
JSONObject jsonObject1 = this.applyAgv(ip, 19204, "5A0100000000000003FD03FD00000000", null);
|
||||
JSONObject jsonObject1 = this.applyAgv(ip, 19204, b_positioning, null);
|
||||
log.info("当前设备定位信息:---------------"+jsonObject1.toString());
|
||||
if (!jsonObject1.getString("reloc_status").equals("3")){
|
||||
throw new BadRequestException("当前设备状态定位未完成!");
|
||||
}
|
||||
//查询当前位置
|
||||
JSONObject jsonObject = this.applyAgv(ip, 19204, "5A0100000000000003EC03EC00000000", null);
|
||||
JSONObject jsonObject = this.applyAgv(ip, 19204, b_location, null);
|
||||
log.info("当前位置信息:---------------"+jsonObject.toString());
|
||||
source_id = jsonObject.getString("current_station");
|
||||
|
||||
@@ -186,7 +354,8 @@ public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDri
|
||||
inst.put("source_id",source_id);
|
||||
inst.put("id",id);
|
||||
inst.put("task_id",task_id);
|
||||
JSONObject result = this.applyAgv(ip, 19206, "5A0100000000005432FB0BEB00000000", inst);
|
||||
JSONObject result = this.applyAgv(ip, 19206, b_t, inst);
|
||||
log.info("当前位置信息:---------------"+jsonObject.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -232,5 +401,52 @@ public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDri
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String Bytes2HexString(byte[] b) {
|
||||
String ret = "";
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
String hex = Integer.toHexString(b[i] & 0xFF);
|
||||
if (hex.length() == 1) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
ret += hex.toUpperCase();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ascii转换为字符串
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String asciiToString(String value) {
|
||||
StringBuffer sbu = new StringBuffer();
|
||||
String[] chars = value.split(",");
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
sbu.append((char) Integer.parseInt(chars[i]));
|
||||
}
|
||||
return sbu.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("source_id","location");
|
||||
jo.put("id","1201");
|
||||
jo.put("task_id","100001");
|
||||
System.out.println(Bytes2HexString(jo.toString().getBytes()));
|
||||
|
||||
}
|
||||
|
||||
public void writing(String key, int value) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + key;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, value);
|
||||
log.info("下发信号{},值{}",to_command,value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -242,18 +242,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
String excutetype = null;
|
||||
//起点输送、终点货架 -- 入库
|
||||
if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor")
|
||||
&& StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage")) {
|
||||
excutetype = TaskTypeEnum.IN.getName();
|
||||
//起点货架、终点输送 -- 出库
|
||||
} else if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage")
|
||||
&& StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor")) {
|
||||
excutetype = TaskTypeEnum.OUT.getName();
|
||||
//起点输送、终点输送 -- 移动
|
||||
} else {
|
||||
excutetype = TaskTypeEnum.MOVE.getName();
|
||||
}
|
||||
|
||||
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
@@ -272,22 +260,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
dto.setInstruction_type(task.getTask_type());
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||
}
|
||||
String type = shortPathsList.get(0).getType();
|
||||
if (!StrUtil.equals(type, "0")) {
|
||||
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
if (instcheckjson != null) {
|
||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||
}
|
||||
}
|
||||
if (!StrUtil.isEmpty(dto.getVehicle_code())) {
|
||||
Instruction inst_dto = this.findByContainer(dto.getVehicle_code());
|
||||
if (ObjectUtils.isNotEmpty(inst_dto) && !StrUtil.equals(inst_dto.getTask_id(), dto.getTask_id())) {
|
||||
throw new WDKException("已存在该载具号的指令!");
|
||||
}
|
||||
}
|
||||
//起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
@@ -308,155 +280,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
|
||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||
dto.setRemark(startdevice.getBatch());
|
||||
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
|
||||
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
||||
StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver;
|
||||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver;
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//将指令赋予对象 下发指令号给电气
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setBranchProtocol(2);
|
||||
standardInspectSiteDeviceDriver.setInst(dto);
|
||||
standardInspectSiteDeviceDriver.setMessage("下发指令:dto.getInstruction_code(),执行中");
|
||||
standardInspectSiteDeviceDriver.writing(3, 1);
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) {
|
||||
if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) {
|
||||
throw new RuntimeException("输送线非入库模式,无法下发");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) {
|
||||
if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) {
|
||||
throw new RuntimeException("输送线非出库模式,无法下发");
|
||||
}
|
||||
}
|
||||
standardCoveyorControlWithScannerDeviceDriver.setInst(dto);
|
||||
if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) {
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code()));
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) {
|
||||
standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) {
|
||||
if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 1) {
|
||||
throw new RuntimeException("输送线非入库模式,无法下发");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) {
|
||||
if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 2) {
|
||||
throw new RuntimeException("输送线非出库模式,无法下发");
|
||||
}
|
||||
}
|
||||
standardCoveyorControlWithPlcScannerDeviceDriver.setInst(dto);
|
||||
if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) {
|
||||
standardCoveyorControlWithPlcScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code()));
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) {
|
||||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())
|
||||
// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName())
|
||||
) {
|
||||
if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) {
|
||||
throw new RuntimeException("输送线非入库模式,无法下发");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) {
|
||||
if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) {
|
||||
throw new RuntimeException("输送线非出库模式,无法下发");
|
||||
}
|
||||
}
|
||||
standardCoveyorControlDeviceDriver.setInst(dto);
|
||||
if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) {
|
||||
standardCoveyorControlDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) {
|
||||
String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString();
|
||||
Device lamddevice = appService.findDeviceByCode(lamd_device);
|
||||
|
||||
if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
|
||||
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver();
|
||||
lampThreecolorDeviceDriver.writing(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) {
|
||||
if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) {
|
||||
throw new RuntimeException("输送线非入库模式,无法下发");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) {
|
||||
if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) {
|
||||
throw new RuntimeException("输送线非出库模式,无法下发");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) {
|
||||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) {
|
||||
if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) {
|
||||
throw new RuntimeException("指令终点输送线非入库模式,无法下发");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())
|
||||
// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName())
|
||||
) {
|
||||
if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) {
|
||||
throw new RuntimeException("指令终点输送线非出库模式,无法下发");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*try {
|
||||
// != 0 为agv任务
|
||||
if (!StrUtil.equals(type, "0")) {
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) {
|
||||
HttpResponse result = agvService.sendAgvInstToMagic(dto);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
dto.setSend_status("2");
|
||||
} else {
|
||||
dto.setSend_status("1");
|
||||
}
|
||||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) {
|
||||
agvService.sendAgvInstToNDC(dto);
|
||||
dto.setSend_status("1");
|
||||
|
||||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
||||
if (StrUtil.equals(task.getRequest_again_success(), "1")) {
|
||||
//追加订单
|
||||
HttpResponse result = agvService.addOrderSequences(dto);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
dto.setSend_status("2");
|
||||
} else {
|
||||
dto.setSend_status("1");
|
||||
}
|
||||
} else {
|
||||
//创建订单序列
|
||||
HttpResponse result = agvService.sendOrderSequencesToXZ(dto);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
dto.setSend_status("2");
|
||||
} else {
|
||||
dto.setSend_status("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
dto.setSend_status("2");
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONObject json = JSONObject.fromObject(dto);
|
||||
wo.insert(json);
|
||||
@@ -868,31 +691,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
|
||||
String type = shortPathsList.get(0).getType();
|
||||
// != 0 为agv任务 1=magic 2=NDC 3=XZ
|
||||
if (!StrUtil.equals(type, "0")) {
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")
|
||||
&& !StrUtil.equals(entity.getSend_status(),"2")) {
|
||||
agvService.deleteAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
|
||||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) {
|
||||
//NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
agvService.deleteAgvInstToNDC(entity);
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")
|
||||
&& !StrUtil.equals(entity.getSend_status(),"2")) {
|
||||
agvService.deleteXZAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (true) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
@@ -904,29 +705,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
// JSONObject jo = new JSONObject();
|
||||
// jo.put("device_code", entity.getStart_device_code());
|
||||
// if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
// jo.put("hasGoodStatus", "1");
|
||||
// } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
// jo.put("hasGoodStatus", "2");
|
||||
// } else {
|
||||
// jo.put("hasGoodStatus", "0");
|
||||
// }
|
||||
// jo.put("material_type", entity.getMaterial());
|
||||
// jo.put("batch", entity.getRemark());
|
||||
// jo.put("islock", "false");
|
||||
// deviceService.changeDeviceStatus(jo);
|
||||
//
|
||||
// JSONObject jo1 = new JSONObject();
|
||||
// jo1.put("device_code", entity.getNext_device_code());
|
||||
// jo.put("hasGoodStatus", "0");
|
||||
// jo.put("material_type", "");
|
||||
// jo.put("batch", "");
|
||||
// jo1.put("islock", "false");
|
||||
// deviceService.changeDeviceStatus(jo1);
|
||||
|
||||
String instnextdevice = entity.getNext_device_code();
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
|
||||
@@ -483,135 +483,36 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver;
|
||||
StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver;
|
||||
if (StrUtil.equals(createTaskCheck, "1")) {
|
||||
//判断起点为输送设备
|
||||
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
throw new Exception("任务起点需满足待机有货!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(standardInspectSiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(standardInspectSiteDeviceDriver.getMaterial());
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
|
||||
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2 || standardManipulatorInspectSiteDeviceDriver.getMove() == 0) {
|
||||
throw new Exception("任务起点需满足待机有货!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(standardManipulatorInspectSiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(standardManipulatorInspectSiteDeviceDriver.getMaterial());
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (startdevice.getHas_goods() == 0) {
|
||||
throw new Exception("任务起点需满足有货!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(standardOrdinarySiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(standardOrdinarySiteDeviceDriver.getMaterial());
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
|
||||
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (startdevice.getHas_goods() == 0) {
|
||||
throw new Exception("任务起点需满足有货!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(specialOrdinarySiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(specialOrdinarySiteDeviceDriver.getMaterial());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (nextdevice.getHas_goods() != 0) {
|
||||
throw new Exception("任务终点需满足无货!");
|
||||
}
|
||||
}
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||
throw new Exception("任务终点需满足待机无货!");
|
||||
}
|
||||
}
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
|
||||
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2 || standardManipulatorInspectSiteDeviceDriver.getMove() != 0) {
|
||||
throw new Exception("任务终点需满足待机无货!");
|
||||
}
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
JSONObject jo2 = new JSONObject();
|
||||
if (!StrUtil.isEmpty(dto.getMaterial())) {
|
||||
if (!StrUtil.equals(dto.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
jo.put("material_type", dto.getMaterial());
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
jo.put("material_type", "1");
|
||||
}
|
||||
|
||||
} else {
|
||||
//判断起点为输送设备
|
||||
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
throw new Exception("任务起点需满足待机有货!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(standardInspectSiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(standardInspectSiteDeviceDriver.getMaterial());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
|
||||
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (nextdevice.getHas_goods() != 0) {
|
||||
throw new Exception("任务起点需满足无货!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
|
||||
// if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
// if (nextdevice.getHas_goods() != 0) {
|
||||
// throw new Exception("任务终点需满足无货!");
|
||||
// }
|
||||
// }
|
||||
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||
throw new Exception("任务终点需满足待机无货!");
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
JSONObject jo2 = new JSONObject();
|
||||
if (!StrUtil.isEmpty(dto.getMaterial())) {
|
||||
if (!StrUtil.equals(dto.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
jo.put("material_type", dto.getMaterial());
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
jo.put("material_type", "1");
|
||||
}
|
||||
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
jo.put("material_type", "1");
|
||||
}
|
||||
jo.put("device_code", dto.getStart_device_code());
|
||||
jo.put("quantity", dto.getQuantity());
|
||||
jo.put("remark", dto.getRemark());
|
||||
jo.put("batch", startdevice.getBatch());
|
||||
jo.put("islock", "true");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code());
|
||||
jo2.put("device_code", dto.getNext_device_code());
|
||||
jo2.put("hasGoodStatus", deviceByCode.getHas_goods());
|
||||
jo2.put("quantity", deviceByCode.getQuantity());
|
||||
jo2.put("remark", deviceByCode.getRemark());
|
||||
jo2.put("material_type", deviceByCode.getMaterial_type());
|
||||
jo2.put("batch", deviceByCode.getBatch());
|
||||
jo2.put("islock", "true");
|
||||
deviceService.changeDeviceStatus(jo2);
|
||||
}
|
||||
jo.put("hasGoodStatus", "1");
|
||||
jo.put("material_type", "1");
|
||||
}
|
||||
jo.put("device_code", dto.getStart_device_code());
|
||||
jo.put("quantity", dto.getQuantity());
|
||||
jo.put("remark", dto.getRemark());
|
||||
jo.put("batch", startdevice.getBatch());
|
||||
jo.put("islock", "true");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code());
|
||||
jo2.put("device_code", dto.getNext_device_code());
|
||||
jo2.put("hasGoodStatus", deviceByCode.getHas_goods());
|
||||
jo2.put("quantity", deviceByCode.getQuantity());
|
||||
jo2.put("remark", deviceByCode.getRemark());
|
||||
jo2.put("material_type", deviceByCode.getMaterial_type());
|
||||
jo2.put("batch", deviceByCode.getBatch());
|
||||
jo2.put("islock", "true");
|
||||
deviceService.changeDeviceStatus(jo2);
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = JSONObject.fromObject(dto);
|
||||
wo.insert(json);
|
||||
@@ -1069,13 +970,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
}
|
||||
//如果属于先知AGV,关闭运单序列
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
||||
try {
|
||||
agvService.markComplete(entity.getTask_code());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
||||
// try {
|
||||
// agvService.markComplete(entity.getTask_code());
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,31 +81,11 @@ public class AutoCreateXgInst {
|
||||
XgagvDeviceDriver xgagvDeviceDriver = null;
|
||||
//查询所以配置了xg_agv驱动的设备
|
||||
Device device = new Device();
|
||||
List<Device> devices = deviceAppService.findDevice(DeviceType.agv);
|
||||
Iterator var4 = devices.iterator();
|
||||
|
||||
while (var4.hasNext()) {
|
||||
Device device1 = (Device) var4.next();
|
||||
if (device1.getDeviceDriver() instanceof XgagvDeviceDriver) {
|
||||
xgagvDeviceDriver = (XgagvDeviceDriver) device1.getDeviceDriver();
|
||||
if (xgagvDeviceDriver.getAgv_mode().equals("1")){
|
||||
return;
|
||||
}
|
||||
//查询车辆状态,如果为需要充电agv_mode=1
|
||||
device = device1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String device_code = device.getDevice_code();
|
||||
//查询该设备是否存在未完成的指令
|
||||
JSONObject inst = WQLObject.getWQLObject("ACS_INSTRUCTION").query("carno = '"+device_code+"' AND instruction_status <2 and is_delete =0").uniqueResult(0);
|
||||
|
||||
//如果指令为休息指令需要撤销该指令并创建点对点指令
|
||||
if (inst.getString("instruction_type").equals("02")){
|
||||
//完成指令和给AGV撤销
|
||||
xgagvDeviceDriver.applyAgv((String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip"),19206,"5A0100000000005432CB0BBB00000000",null);
|
||||
}
|
||||
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_type(acsTask.getTask_type());
|
||||
|
||||
@@ -46,18 +46,42 @@ public class XgAgvStatus {
|
||||
xgagvDeviceDriver = (XgagvDeviceDriver) device.getDeviceDriver();
|
||||
String ip = (String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip");
|
||||
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X03,(byte)0XEF,
|
||||
(byte)0X03,(byte)0XEF,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
//调用AGV接口查询当前设备的电量 1007接口
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip, 19204, "5A0100000000000003EF03EF00000000 ", null);
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip, 19204, b_t, null);
|
||||
log.info("AGV电量返回的参数为:-----------------"+jsonObject.toString());
|
||||
double battery_level = jsonObject.getDouble("battery_level");
|
||||
|
||||
byte[] b_t1 =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X03,(byte)0XFD,
|
||||
(byte)0X03,(byte)0XFD,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
//查询AGV的定位状态1021,如果为失败调用重定位2002
|
||||
JSONObject jsonObject2 = xgagvDeviceDriver.applyAgv(ip, 19204, "5A0100000000000003FD03FD00000000", null);
|
||||
JSONObject jsonObject2 = xgagvDeviceDriver.applyAgv(ip, 19204, b_t1, null);
|
||||
log.info("AGV定位返回的参数为:-----------------"+jsonObject.toString());
|
||||
if (jsonObject2.getString("reloc_status").equals("0")) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("home",true);
|
||||
xgagvDeviceDriver.applyAgv(ip, 19205, "5A0100000000000007D207D200000000", jo);
|
||||
byte[] b_t2 =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X07,(byte)0XD2,
|
||||
(byte)0X07,(byte)0XD2,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
xgagvDeviceDriver.applyAgv(ip, 19205, b_t2, jo);
|
||||
}
|
||||
|
||||
//获取最小电量
|
||||
|
||||
@@ -52,6 +52,8 @@ public class XgInstUpdate {
|
||||
if (instList.size() > 0) {
|
||||
for (int i = 0; i < instList.size(); i++) {
|
||||
XgagvDeviceDriver xgagvDeviceDriver;
|
||||
|
||||
log.info("查询agv指令状态");
|
||||
//判断任务类型1、点对点任务需要分步骤;2、休息指令和充电指令直接下发点对点
|
||||
Instruction inst = instList.get(i);
|
||||
if (!StrUtil.equals(inst.getSend_status(), "1")) {
|
||||
@@ -76,6 +78,7 @@ public class XgInstUpdate {
|
||||
jo.put("point_code",point_code);
|
||||
jo.put("ip",ip);
|
||||
jo.put("task_id",task_id);
|
||||
log.info("下发agv去起点任务:-----------------"+jo.toString());
|
||||
xgagvDeviceDriver.applyTask(jo);
|
||||
|
||||
//修改指令状态
|
||||
@@ -84,7 +87,17 @@ public class XgInstUpdate {
|
||||
}
|
||||
if (execute_status.equals("1")){
|
||||
//判断AGV是否到达A点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204, "5A01000000000000044C044C00000000", null);
|
||||
|
||||
byte[] b_head=new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204, b_head, null);
|
||||
String task_status = jsonObject.getString("task_status");
|
||||
String target_id = jsonObject.getString("target_id");
|
||||
if (task_status.equals("4")&&target_id.equals(inst.getStart_point_code())){
|
||||
@@ -100,7 +113,15 @@ public class XgInstUpdate {
|
||||
//下发A的取货动作
|
||||
JSONObject order = new JSONObject();
|
||||
order.put("load",true);
|
||||
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order);
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X0B,(byte)0XEB,
|
||||
(byte)0X0B,(byte)0XEB,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, b_t, order);
|
||||
if (result.getString("ret_code").equals("0")){
|
||||
inst.setExecute_status("2");
|
||||
instructionService.update(inst);
|
||||
@@ -113,8 +134,16 @@ public class XgInstUpdate {
|
||||
}
|
||||
if (execute_status.equals("2")){
|
||||
boolean is_ok = false;
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
//查询是否取货完成,通过查询DO状态是否低电平
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null);
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,b_t, null);
|
||||
JSONArray do_arr = jsonObject.getJSONArray("DO");
|
||||
for (int j = 0; j <do_arr.size(); j++) {
|
||||
JSONObject do_jo = do_arr.getJSONObject(j);
|
||||
@@ -141,8 +170,16 @@ public class XgInstUpdate {
|
||||
}
|
||||
}
|
||||
if (execute_status.equals("3")){
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
//判断AGV是否到达B点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null);
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,b_t, null);
|
||||
String task_status = jsonObject.getString("task_status");
|
||||
String target_id = jsonObject.getString("target_id");
|
||||
if (task_status.equals("4")&&target_id.equals(inst.getNext_point_code())){
|
||||
@@ -159,7 +196,15 @@ public class XgInstUpdate {
|
||||
//下发B的放货动作
|
||||
JSONObject order = new JSONObject();
|
||||
order.put("unload",true);
|
||||
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order);
|
||||
byte[] b_t1 =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X0B,(byte)0XEB,
|
||||
(byte)0X0B,(byte)0XEB,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, b_t1, order);
|
||||
if (result.getString("ret_code").equals("0")){
|
||||
inst.setExecute_status("4");
|
||||
instructionService.update(inst);
|
||||
@@ -174,7 +219,15 @@ public class XgInstUpdate {
|
||||
//查询是否放货完成
|
||||
boolean is_ok = false;
|
||||
//查询是否取货完成,通过查询DO状态是否低电平
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null);
|
||||
byte[] b_t =new byte[] {(byte) 0X5A,(byte)0X01,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X04,(byte)0X4C,
|
||||
(byte)0X00,(byte)0X00,
|
||||
(byte)0X00,(byte)0X00 };
|
||||
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,b_t, null);
|
||||
JSONArray do_arr = jsonObject.getJSONArray("DO");
|
||||
for (int j = 0; j <do_arr.size(); j++) {
|
||||
JSONObject do_jo = do_arr.getJSONObject(j);
|
||||
@@ -185,17 +238,9 @@ public class XgInstUpdate {
|
||||
}
|
||||
if (is_ok){
|
||||
//反馈中鼎任务完成
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("carId",inst.getCarno());
|
||||
map.put("task_code",inst.getTask_code());
|
||||
map.put("task_type","00");
|
||||
map.put("feedbackStatus","putFinish");
|
||||
Map<String, Object> stringObjectMap = acsToWmsZDService.taskFeedback(map);
|
||||
if (stringObjectMap.get("responseCode").equals("200")){
|
||||
inst.setExecute_status("5");
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
inst.setExecute_status("5");
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.update(inst);
|
||||
//判断是否存在任务,不存在创建一个休息任务
|
||||
//查询当前设备是否存在未完成的任务
|
||||
JSONObject task = WQLObject.getWQLObject("ACS_INSTRUCTION").query("carno = '" + device_code + "' AND is_delete = '0' AND instruction_status IN ('0','1')").uniqueResult(0);
|
||||
|
||||
@@ -9,10 +9,11 @@ spring:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lxjm_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:zdxn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:zdxn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: ${DB_USER:root}
|
||||
#password: ${DB_PWD:P@ssw0rd}
|
||||
password: ${DB_PWD:Root.123456}
|
||||
password: ${DB_PWD:123456}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
@@ -59,7 +60,7 @@ spring:
|
||||
redis:
|
||||
#数据库索引
|
||||
database: ${REDIS_DB:0}
|
||||
host: ${REDIS_HOST:47.111.78.178}
|
||||
host: ${REDIS_HOST:127.0.0.1}
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PWD:}
|
||||
#连接超时时间
|
||||
|
||||
@@ -56,7 +56,7 @@ spring:
|
||||
redis:
|
||||
#数据库索引
|
||||
database: ${REDIS_DB:0}
|
||||
host: ${REDIS_HOST:47.111.78.178}
|
||||
host: ${REDIS_HOST:127.0.0.1}
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PWD:}
|
||||
#连接超时时间
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</logger>-->
|
||||
|
||||
<!-- 打印sql -->
|
||||
<logger name="org.nl.modules.quartz.task.QueryXZAgvTaskStatus" level="info" additivity="false">
|
||||
<logger name="org.nl.modules.quartz.task.XgInstUpdate" level="info" additivity="false">
|
||||
<appender-ref ref="FILE10"/>
|
||||
</logger>
|
||||
</included>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<appender name="FILE7" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/ACS请求ERP/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<FileNamePattern>${LOG_HOME}/AGV驱动/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
@@ -26,7 +26,7 @@
|
||||
</logger>-->
|
||||
|
||||
<!-- 打印sql -->
|
||||
<logger name=" org.nl.acs.ext.erp.service.impl.AcsToErpServiceImpl" level="info" additivity="false">
|
||||
<logger name="org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver" level="info" additivity="false">
|
||||
<appender-ref ref="FILE7"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -16,18 +16,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!--引入默认的一些设置-->
|
||||
<include resource="log/AutoCreateInst.xml"/>
|
||||
<include resource="log/QueryAgvTaskStatus.xml"/>
|
||||
<include resource="log/AgvServiceImpl.xml"/>
|
||||
<include resource="log/AgvackServlet.xml"/>
|
||||
<include resource="log/AcsToErp.xml"/>
|
||||
<include resource="log/AcsToWms.xml"/>
|
||||
<include resource="log/WmsToAcs.xml"/>
|
||||
<include resource="log/QueryXZAgvTaskStatus.xml"/>
|
||||
<include resource="log/NDCSocketConnectionAutoRun.xml"/>
|
||||
<include resource="log/ScannerBarcode.xml"/>
|
||||
<include resource="log/QueryXgAgvStatus.xml"/>
|
||||
|
||||
<include resource="log/XgagvDeviceDriver.xml"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
|
||||
BIN
qd/dist.7z
BIN
qd/dist.7z
Binary file not shown.
BIN
qd/dist.zip
BIN
qd/dist.zip
Binary file not shown.
@@ -1,6 +1,49 @@
|
||||
<template>
|
||||
<!--magic3.0-->
|
||||
<!--自动门-->
|
||||
<div>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changeOpc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcservers"
|
||||
:key="item.opc_id"
|
||||
:label="item.opc_name"
|
||||
:value="item.opc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
PLC:
|
||||
<el-select
|
||||
v-model="plc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changePlc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcPlcs"
|
||||
:key="item.plc_id"
|
||||
:label="item.plc_name"
|
||||
:value="item.plc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">输送系统:</span>
|
||||
@@ -67,11 +110,85 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC读取字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data1"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data1[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishReadEdit(data1[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC写入字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data2"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data2[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishWriteEdit(data2[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="configLoading"
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
@@ -86,15 +203,22 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateConfig, queryDriverConfig } from '@/api/acs/device/driverConfig'
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: 'XgAgv',
|
||||
name: 'StandardAutodoor',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
@@ -104,28 +228,32 @@ export default {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
deviceList: [],
|
||||
address: '',
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
cancle_electric: '',
|
||||
task_electric: '',
|
||||
min_electric: '',
|
||||
relax_point: '',
|
||||
charge_point: '',
|
||||
agv_ip: ''
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
@@ -135,21 +263,106 @@ export default {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.parentForm) {
|
||||
const arr = Object.keys(data.parentForm)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.opc_code = data.parentForm.opc_code
|
||||
this.plc_code = data.parentForm.plc_code
|
||||
}
|
||||
}
|
||||
this.data1 = data.rs
|
||||
this.data2 = data.ws
|
||||
this.sliceItem()
|
||||
})
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
selectPlcList().then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||
})
|
||||
selectOpcList().then(data => {
|
||||
this.dataOpcservers = data
|
||||
this.opc_id = this.$props.parentForm.opc_server_id
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('action') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = false
|
||||
updateConfig(parentForm, this.form).then(res => {
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
@@ -158,6 +371,28 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
this.data1.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
this.data2.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user