Browse Source

修改

master
周舟 2 years ago
parent
commit
e61974bcbc
  1. 7
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/xg_agv/XgagvDeviceDriver.java
  2. 2
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateXgInst.java
  3. 6
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/XgAgvStatus.java
  4. 48
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/XgInstUpdate.java

7
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/xg_agv/XgagvDeviceDriver.java

@ -100,7 +100,6 @@ public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDri
tbjsocket.connect(socketAddress, 1500);
//读取数据超时
String content = "";
code = "5A 01 00 01 00 00 00" + code + "00 00 00 00 00 00";
if (ObjectUtil.isNotEmpty(jo)){
content = bytesToHexString(stringToByte(jo.toString()));
}
@ -173,13 +172,13 @@ public class XgagvDeviceDriver extends AbstractDeviceDriver implements DeviceDri
String id = jo.getString("point_code");
String task_id = jo.getString("task_id");
//查询定位状态
JSONObject jsonObject1 = this.applyAgv(ip, 19204, "03FD", null);
JSONObject jsonObject1 = this.applyAgv(ip, 19204, "5A0100000000000003FD03FD00000000", null);
log.info("当前设备定位信息:---------------"+jsonObject1.toString());
if (!jsonObject1.getString("reloc_status").equals("3")){
throw new BadRequestException("当前设备状态定位未完成!");
}
//查询当前位置
JSONObject jsonObject = this.applyAgv(ip, 19204, "03EC", null);
JSONObject jsonObject = this.applyAgv(ip, 19204, "5A0100000000000003EC03EC00000000", null);
log.info("当前位置信息:---------------"+jsonObject.toString());
source_id = jsonObject.getString("current_station");
@ -187,7 +186,7 @@ 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, "0BEB", inst);
JSONObject result = this.applyAgv(ip, 19206, "5A0100000000005432FB0BEB00000000", inst);
return result;
}

2
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateXgInst.java

@ -104,7 +104,7 @@ public class AutoCreateXgInst {
//如果指令为休息指令需要撤销该指令并创建点对点指令
if (inst.getString("instruction_type").equals("02")){
//完成指令和给AGV撤销
xgagvDeviceDriver.applyAgv((String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip"),19206,"3003",null);
xgagvDeviceDriver.applyAgv((String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip"),19206,"5A0100000000005432CB0BBB00000000",null);
}
Instruction instdto = new Instruction();

6
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/XgAgvStatus.java

@ -47,17 +47,17 @@ public class XgAgvStatus {
String ip = (String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip");
//调用AGV接口查询当前设备的电量 1007接口
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip, 19204, "03EF", null);
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip, 19204, "5A0100000000000003EF03EF00000000 ", null);
log.info("AGV电量返回的参数为:-----------------"+jsonObject.toString());
double battery_level = jsonObject.getDouble("battery_level");
//查询AGV的定位状态1021,如果为失败调用重定位2002
JSONObject jsonObject2 = xgagvDeviceDriver.applyAgv(ip, 19204, "03FD", null);
JSONObject jsonObject2 = xgagvDeviceDriver.applyAgv(ip, 19204, "5A0100000000000003FD03FD00000000", 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, "07D2", jo);
xgagvDeviceDriver.applyAgv(ip, 19205, "5A0100000000000007D207D200000000", jo);
}
//获取最小电量

48
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/XgInstUpdate.java

@ -7,12 +7,14 @@ import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
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.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
@ -55,6 +57,8 @@ public class XgInstUpdate {
if (!StrUtil.equals(inst.getSend_status(), "1")) {
continue;
}
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = deviceAppService.findDeviceByCode(inst.getCarno());
xgagvDeviceDriver = (XgagvDeviceDriver) device.getDeviceDriver();
String ip = (String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip");
@ -80,21 +84,23 @@ 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, "044C", null);
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204, "5A01000000000000044C044C00000000", 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())){
//调用中鼎接口查询A点输送线的状态是否正常是否有货
JSONObject device_info = new JSONObject();
device_info.put("device_code",inst.getStart_point_code());
HttpResponse httpResponse = acsToWmsZDService.deviceStatusQuery(device_info);
if (httpResponse.getStatus() == 200){
JSONObject jo = JSONObject.fromObject(httpResponse.body());
if (jo.getString("responseCode").equals("1")&&jo.getString("status").equals("1")&&jo.getBoolean("hasGoods")){
//如果起点输送线待机,给输送线下发滚筒滚动指令
String start_device = inst.getStart_device_code();
Device startdevice = appService.findDeviceByCode(start_device);
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMode() == 2){
standardInspectSiteDeviceDriver.writing(1);
}
if (standardInspectSiteDeviceDriver.getHasGoods() == 1){
//下发A的取货动作
JSONObject order = new JSONObject();
order.put("load",true);
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "0BEB", order);
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order);
if (result.getString("ret_code").equals("0")){
inst.setExecute_status("2");
instructionService.update(inst);
@ -108,7 +114,7 @@ public class XgInstUpdate {
if (execute_status.equals("2")){
boolean is_ok = false;
//查询是否取货完成,通过查询DO状态是否低电平
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null);
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null);
JSONArray do_arr = jsonObject.getJSONArray("DO");
for (int j = 0; j <do_arr.size(); j++) {
JSONObject do_jo = do_arr.getJSONObject(j);
@ -136,22 +142,24 @@ public class XgInstUpdate {
}
if (execute_status.equals("3")){
//判断AGV是否到达B点,1100接口 task_status = 4 target_id = inst_code+execute_status
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null);
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", 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())){
//查询B点输送线的状态,下发B的放货动作
//调用中鼎接口查询A点输送线的状态是否正常是否有货
JSONObject device_info = new JSONObject();
device_info.put("device_code",inst.getStart_point_code());
HttpResponse httpResponse = acsToWmsZDService.deviceStatusQuery(device_info);
if (httpResponse.getStatus() == 200){
JSONObject jo = JSONObject.fromObject(httpResponse.body());
if (jo.getString("responseCode").equals("1")&&jo.getString("status").equals("1")&&!jo.getBoolean("hasGoods")){
//如果起点输送线待机,给输送线下发滚筒滚动指令
String next_device = inst.getNext_device_code();
Device nextdevice = appService.findDeviceByCode(next_device);
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMode() == 2){
standardInspectSiteDeviceDriver.writing(1);
}
if (standardInspectSiteDeviceDriver.getHasGoods() == 0){
//下发B的放货动作
JSONObject order = new JSONObject();
order.put("unload",true);
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "0BEB", order);
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order);
if (result.getString("ret_code").equals("0")){
inst.setExecute_status("4");
instructionService.update(inst);
@ -166,7 +174,7 @@ public class XgInstUpdate {
//查询是否放货完成
boolean is_ok = false;
//查询是否取货完成,通过查询DO状态是否低电平
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null);
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null);
JSONArray do_arr = jsonObject.getJSONArray("DO");
for (int j = 0; j <do_arr.size(); j++) {
JSONObject do_jo = do_arr.getJSONObject(j);

Loading…
Cancel
Save