fix agv驱动
This commit is contained in:
@@ -217,12 +217,12 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
System.out.println("Agv链接异常");
|
System.out.println("Agv链接异常");
|
||||||
log.info("Agv链接异常");
|
log.info("Agv链接异常");
|
||||||
log.error("agv连接出现异常:{}", e);
|
log.error("agv连接出现异常:{}", e);
|
||||||
logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage());
|
// logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage());
|
||||||
logServer.deviceExecuteLog("1", "", "", "agv异常" + e);
|
// logServer.deviceExecuteLog("1", "", "", "agv异常" + e);
|
||||||
LuceneLogDto logDto = new LuceneLogDto();
|
// LuceneLogDto logDto = new LuceneLogDto();
|
||||||
logDto.setContent("agv异常" + e.getMessage());
|
// logDto.setContent("agv异常" + e.getMessage());
|
||||||
logDto.setDevice_code("1001");
|
// logDto.setDevice_code("1001");
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
if (ObjectUtil.isNotEmpty(s)) {
|
if (ObjectUtil.isNotEmpty(s)) {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package org.nl.acs.device_driver.basedriver.agv.xg_agv;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -11,6 +13,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
|||||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
@@ -18,6 +21,7 @@ import org.nl.acs.opc.Device;
|
|||||||
import org.nl.acs.opc.DeviceAppService;
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
import org.nl.modules.logging.DeviceCodeDir;
|
import org.nl.modules.logging.DeviceCodeDir;
|
||||||
import org.nl.modules.lucence.service.LuceneExecuteLogService;
|
import org.nl.modules.lucence.service.LuceneExecuteLogService;
|
||||||
import org.nl.modules.lucence.service.dto.LuceneLogDto;
|
import org.nl.modules.lucence.service.dto.LuceneLogDto;
|
||||||
@@ -26,6 +30,7 @@ import org.openscada.opc.lib.da.Server;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,76 +52,88 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
|
|||||||
@Autowired
|
@Autowired
|
||||||
DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl");
|
DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl");
|
||||||
@Autowired
|
@Autowired
|
||||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");;
|
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||||
|
;
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||||
//车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电
|
//车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电
|
||||||
String agv_mode = "0";
|
String agv_mode = "0";
|
||||||
|
|
||||||
String last_mode = "0";
|
String last_mode = "0";
|
||||||
|
private Date instruction_require_time = new Date();
|
||||||
|
private int instruction_require_time_out = 1000;
|
||||||
|
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 is_charging =0;
|
int last_stop = 0;
|
||||||
int stop = 0;
|
int last_DI0 = 0;
|
||||||
int DI0 = 0;
|
int last_DI1 = 0;
|
||||||
int DI1 = 0;
|
int last_DI2 = 0;
|
||||||
int DI2 = 0;
|
int last_DI3 = 0;
|
||||||
int DI3 = 0;
|
int last_DI4 = 0;
|
||||||
int DI4 = 0;
|
int last_DI11 = 0;
|
||||||
int DI11 = 0;
|
int last_DI12 = 0;
|
||||||
int DI12 = 0;
|
int last_DO0 = 0;
|
||||||
int DO0 = 0;
|
int last_DO1 = 0;
|
||||||
int DO1 = 0;
|
int last_DO2 = 0;
|
||||||
int DO2 = 0;
|
Float last_x = 0f;
|
||||||
Float x = 0f;
|
Float last_y = 0f;
|
||||||
Float y = 0f;
|
Float last_angle = 0f;
|
||||||
Float angle = 0f;
|
int last_navigation_address = 0;
|
||||||
int navigation_address =0;
|
int last_positioning_status = 0;
|
||||||
int positioning_status =0;
|
int last_navigation_status = 0;
|
||||||
int navigation_status =0;
|
int last_navigation_type = 0;
|
||||||
int navigation_type =0;
|
int last_electricity = 0;
|
||||||
int electricity =0;
|
int last_address = 0;
|
||||||
int address =0;
|
int last_next_address = 0;
|
||||||
int next_address =0;
|
int last_home_relocation = 0;
|
||||||
int home_relocation =0;
|
int last_locate_correct = 0;
|
||||||
int locate_correct =0;
|
int last_pause_navigation = 0;
|
||||||
int pause_navigation =0;
|
int last_continue_navigation = 0;
|
||||||
int continue_navigation =0;
|
int last_cancle_navigation = 0;
|
||||||
int cancle_navigation =0;
|
int last_drum_run_status = 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 message = null;
|
String message = null;
|
||||||
String device_code;
|
String device_code;
|
||||||
Instruction inst = null;
|
Instruction inst = null;
|
||||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
|
||||||
|
//最小电量
|
||||||
|
double min_electric = 0.0;
|
||||||
|
//最大电量
|
||||||
|
double cancle_electric = 0.0;
|
||||||
|
//执行任务电量
|
||||||
|
double task_electric = 0.0;
|
||||||
|
//休息点
|
||||||
|
int relax_point = 0;
|
||||||
|
//充电点
|
||||||
|
int charge_point =0;
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice() {
|
public Device getDevice() {
|
||||||
return this.device;
|
return this.device;
|
||||||
@@ -154,172 +171,153 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
|
|||||||
drum_run_status = this.itemProtocol.getDrum_run_status();
|
drum_run_status = this.itemProtocol.getDrum_run_status();
|
||||||
stop = this.itemProtocol.getStop();
|
stop = this.itemProtocol.getStop();
|
||||||
|
|
||||||
if (home_relocation != last_home_relocation){
|
if (home_relocation != last_home_relocation) {
|
||||||
// DeviceCodeDir deviceCodeDir = new DeviceCodeDir();
|
|
||||||
// deviceCodeDir.setPropertyValue(this.device_code);
|
|
||||||
// log.info("信号{}变更从{}->{}",this.getDevice().getOpc_server_code()+"."+this.getDevice().getOpc_plc_code()+"."+this.device_code+"."+ItemProtocol.to_home_relocation,this.last_home_relocation,this.home_relocation);
|
|
||||||
LuceneLogDto logDto = new LuceneLogDto();
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
logDto.setDevice_code(device_code);
|
logDto.setDevice_code(device_code);
|
||||||
logDto.setContent("信号"+this.getDevice().getOpc_server_code()+"."+this.getDevice().getOpc_plc_code()+"."+this.device_code+"."+ItemProtocol.to_home_relocation+"变更从"+this.last_home_relocation+"->"+this.home_relocation);
|
logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_home_relocation + "变更从" + this.last_home_relocation + "->" + this.home_relocation);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stop != last_stop) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.stop + "变更从" + this.last_stop + "->" + this.stop);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address != last_address) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.address + "变更从" + this.last_address + "->" + this.address);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (electricity != last_electricity) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.electricity + "变更从" + this.last_electricity + "->" + this.electricity);
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
// last_home_relocation = home_relocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取最小电量
|
//获取最小电量
|
||||||
if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))){
|
if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))) {
|
||||||
message = "未配置最小电量";
|
message = "未配置最小电量";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric"));
|
min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric"));
|
||||||
//获取最大电量
|
//获取最大电量
|
||||||
if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("cancle_electric"))){
|
if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("cancle_electric"))) {
|
||||||
message = "未配置最大电量";
|
message = "未配置最大电量";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric"));
|
cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric"));
|
||||||
//可执行任务电量
|
//可执行任务电量
|
||||||
if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("task_electric"))){
|
if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("task_electric"))) {
|
||||||
message = "未配置可执行任务电量";
|
message = "未配置可执行任务电量";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric"));
|
task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric"));
|
||||||
//休息点
|
//休息点
|
||||||
if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("relax_point"))){
|
if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("relax_point"))) {
|
||||||
message = "未配置休息点";
|
message = "未配置休息点";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Device relax_point_device = deviceAppService.findDeviceByCode((String)this.getDevice().getExtraValue().get("relax_point"));
|
Device relax_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("relax_point"));
|
||||||
int relax_point = Integer.parseInt(relax_point_device.getAddress());
|
relax_point = Integer.parseInt(relax_point_device.getAddress());
|
||||||
//充电点
|
//充电点
|
||||||
if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("charge_point"))){
|
if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("charge_point"))) {
|
||||||
message = "未配置充电点";
|
message = "未配置充电点";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Device charge_point_device = deviceAppService.findDeviceByCode((String)this.getDevice().getExtraValue().get("charge_point"));
|
Device charge_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("charge_point"));
|
||||||
int charge_point = Integer.parseInt(charge_point_device.getAddress());
|
charge_point = Integer.parseInt(charge_point_device.getAddress());
|
||||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||||
|
|
||||||
if(instList.size()>0){
|
if (instList.size() > 0) {
|
||||||
inst = instList.get(0);
|
for (int i = 0; i < instList.size(); i++) {
|
||||||
|
inst = instList.get(i);
|
||||||
|
if (ObjectUtil.equal(inst.getInstruction_type(), "1")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(inst)) {
|
||||||
|
message = "未找到对应指令";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//先判断当前有无指令
|
//先判断当前有无指令
|
||||||
if(ObjectUtil.isEmpty(inst)){
|
if (ObjectUtil.isEmpty(inst)) {
|
||||||
// log.info("判断当前有无指令:{}",ObjectUtil.isEmpty(inst));
|
if (electricity != 0 && electricity < min_electric && address != charge_point && (navigation_status == 0 || navigation_status == 4)) {
|
||||||
if( electricity != 0 && electricity <min_electric && address != charge_point && (navigation_status==0 ||navigation_status==4) ){
|
log.info("下发充电:{}", charge_point);
|
||||||
log.info("下发充电:{}",charge_point);
|
writing("to_address", charge_point);
|
||||||
writing("to_address",charge_point);
|
|
||||||
}
|
}
|
||||||
if( electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status==0 ||navigation_status==4)){
|
if (electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status == 0 || navigation_status == 4)) {
|
||||||
log.info("下发回休息点:{}",relax_point);
|
log.info("下发回休息点:{}", relax_point);
|
||||||
writing("to_address",relax_point);
|
writing("to_address", relax_point);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// log.info("address:{},滚筒状态:{},车子状态:{},DI4:{},DO1:{},DO2:{},导航状态:{}",address,drum_run_status,stop,DI4,DO1,DO2,navigation_status);
|
TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code());
|
||||||
|
|
||||||
|
|
||||||
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
|
||||||
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
||||||
int start_device_code = Integer.parseInt(start_device.getAddress());
|
int start_device_code = Integer.parseInt(start_device.getAddress());
|
||||||
int next_device_code = Integer.parseInt(next_device.getAddress());
|
int next_device_code = Integer.parseInt(next_device.getAddress());
|
||||||
|
|
||||||
|
|
||||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||||
//指令状态就绪
|
//指令状态就绪
|
||||||
if(StrUtil.equals("0",inst.getInstruction_status())){
|
if (StrUtil.equals("0", inst.getInstruction_status())) {
|
||||||
log.info("下发指令号{},起点{}",inst.getInstruction_code(),start_device);
|
log.info("下发指令号{},起点{}", inst.getInstruction_code(), start_device);
|
||||||
writing("to_address",start_device_code);
|
//判断指令起点与任务起点是否相同
|
||||||
inst.setInstruction_status("1");
|
if(StrUtil.equals(task.getStart_device_code(),inst.getStart_device_code())){
|
||||||
instructionService.update(inst);
|
feedAgvTaskStatus(inst, "1");
|
||||||
}
|
} else {
|
||||||
|
//不同的话是按照路由生成的指令
|
||||||
//请求取货 && DI4==1 无货状态
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
if(StrUtil.equals("1",inst.getInstruction_status()) && address == start_device_code && stop==1 && DI4==1){
|
logDto.setDevice_code(device_code);
|
||||||
log.info("agv准备取货,下发滚筒,指令号{},下发to_di_height:1",inst.getInstruction_code());
|
logDto.setInstruct_code(inst.getInstruction_code());
|
||||||
if (start_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
logDto.setTask_code(inst.getTask_code());
|
||||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) start_device.getDeviceDriver();
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code);
|
||||||
log.info("准备下发输送请求取货信号,mode:{},move{}",standardInspectSiteDeviceDriver.getMode(),standardInspectSiteDeviceDriver.getMove());
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
if(standardInspectSiteDeviceDriver.getMode() ==2 && standardInspectSiteDeviceDriver.getMove() ==1){
|
writing("to_address", start_device_code);
|
||||||
if((navigation_status==0 ||navigation_status==4) && (DO1 != 1 && DO2 != 1)){
|
inst.setInstruction_status("1");
|
||||||
writing("to_di_low",1);
|
instructionService.update(inst);
|
||||||
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 && StrUtil.equals(inst.getExecute_status(),"1")) {
|
||||||
|
//请求wms是否允许从取货点离开
|
||||||
|
feedAgvTaskStatus(inst, "2");
|
||||||
}
|
}
|
||||||
//下发去放货位置
|
|
||||||
// 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 ){
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"2")) {
|
||||||
log.info("取货完成,指令号{},下发to_di_height:12",inst.getInstruction_code());
|
//请求wms是否允许进入放货
|
||||||
if (next_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
feedAgvTaskStatus(inst, "3");
|
||||||
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 (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"3")) {
|
||||||
if (next_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
feedAgvTaskStatus(inst, "4");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_home_relocation = home_relocation;
|
||||||
|
last_address = address;
|
||||||
|
last_next_address = next_address;
|
||||||
|
last_electricity = electricity;
|
||||||
|
last_stop = stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void writing(String key, int value) {
|
public void writing(String key, int value) {
|
||||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
+ "." + key;
|
+ "." + key;
|
||||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
Server server = ReadUtil.getServer(opcservcerid);
|
Server server = ReadUtil.getServer(opcservcerid);
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
itemMap.put(to_command, value);
|
itemMap.put(to_command, value);
|
||||||
log.info("下发信号{},值{}",to_command,value);
|
log.info("下发信号{},值{}", to_command, value);
|
||||||
ReadUtil.write(itemMap, server);
|
ReadUtil.write(itemMap, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,6 +338,121 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈wms动作状态
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean feedAgvTaskStatus(Instruction inst, String type) throws Exception {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
|
||||||
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
||||||
|
int start_device_code = Integer.parseInt(start_device.getAddress());
|
||||||
|
int next_device_code = Integer.parseInt(next_device.getAddress());
|
||||||
|
//请求WMS允许取货
|
||||||
|
if (StrUtil.equals(type, "1")) {
|
||||||
|
JSONArray ja = new JSONArray();
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("vehicle_code", inst.getVehicle_code());
|
||||||
|
jo.put("status", "1");
|
||||||
|
jo.put("device_code", this.device_code);
|
||||||
|
jo.put("task_code", inst.getTask_code());
|
||||||
|
ja.add(jo);
|
||||||
|
// HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
|
||||||
|
if (1==1) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setInstruct_code(inst.getInstruction_code());
|
||||||
|
logDto.setTask_code(inst.getTask_code());
|
||||||
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
writing("to_address", start_device_code);
|
||||||
|
inst.setInstruction_status("1");
|
||||||
|
inst.setExecute_status("1");
|
||||||
|
instructionService.update(inst);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
//取货完成请求离开
|
||||||
|
} else if (StrUtil.equals(type, "2")) {
|
||||||
|
JSONArray ja = new JSONArray();
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("vehicle_code", inst.getVehicle_code());
|
||||||
|
jo.put("status", "2");
|
||||||
|
jo.put("device_code", this.device_code);
|
||||||
|
jo.put("task_code", inst.getTask_code());
|
||||||
|
ja.add(jo);
|
||||||
|
// HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
|
||||||
|
if (1==1) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setInstruct_code(inst.getInstruction_code());
|
||||||
|
logDto.setTask_code(inst.getTask_code());
|
||||||
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
writing("to_address", next_device_code);
|
||||||
|
inst.setInstruction_status("1");
|
||||||
|
inst.setExecute_status("2");
|
||||||
|
instructionService.update(inst);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
//请求放货
|
||||||
|
} else if (StrUtil.equals(type, "3")) {
|
||||||
|
JSONArray ja = new JSONArray();
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("vehicle_code", inst.getVehicle_code());
|
||||||
|
jo.put("status", "3");
|
||||||
|
jo.put("device_code", this.device_code);
|
||||||
|
jo.put("task_code", inst.getTask_code());
|
||||||
|
ja.add(jo);
|
||||||
|
// HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
|
||||||
|
if (1==1) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setInstruct_code(inst.getInstruction_code());
|
||||||
|
logDto.setTask_code(inst.getTask_code());
|
||||||
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
inst.setInstruction_status("1");
|
||||||
|
inst.setExecute_status("3");
|
||||||
|
instructionService.update(inst);
|
||||||
|
writing("to_address", start_device_code);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (StrUtil.equals(type, "4")) {
|
||||||
|
JSONArray ja = new JSONArray();
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("vehicle_code", inst.getVehicle_code());
|
||||||
|
jo.put("status", "4");
|
||||||
|
jo.put("device_code", this.device_code);
|
||||||
|
jo.put("task_code", inst.getTask_code());
|
||||||
|
ja.add(jo);
|
||||||
|
// HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
|
||||||
|
if (1==1) {
|
||||||
|
LuceneLogDto logDto = new LuceneLogDto();
|
||||||
|
logDto.setDevice_code(device_code);
|
||||||
|
logDto.setInstruct_code(inst.getInstruction_code());
|
||||||
|
logDto.setTask_code(inst.getTask_code());
|
||||||
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
writing("to_address", relax_point);
|
||||||
|
inst.setInstruction_status("2");
|
||||||
|
inst.setInstruction_status("1");
|
||||||
|
inst.setExecute_status("4");
|
||||||
|
instructionService.finish(inst);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ public class AutoCreateInst {
|
|||||||
List<TaskDto> list = taskserver.queryAll("task_status = '0'");
|
List<TaskDto> list = taskserver.queryAll("task_status = '0'");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TaskDto acsTask = list.get(i);
|
TaskDto acsTask = list.get(i);
|
||||||
if(StrUtil.equals(acsTask.getTask_type(),"7") && !StrUtil.startWith(acsTask.getTask_code(), "-") ){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String taskid = acsTask.getTask_id();
|
String taskid = acsTask.getTask_id();
|
||||||
String taskcode = acsTask.getTask_code();
|
String taskcode = acsTask.getTask_code();
|
||||||
String task_type = acsTask.getTask_type();
|
String task_type = acsTask.getTask_type();
|
||||||
@@ -70,11 +67,6 @@ public class AutoCreateInst {
|
|||||||
String vehicleType = acsTask.getVehicle_type();
|
String vehicleType = acsTask.getVehicle_type();
|
||||||
String agv_system_type = acsTask.getAgv_system_type();
|
String agv_system_type = acsTask.getAgv_system_type();
|
||||||
|
|
||||||
|
|
||||||
if (StrUtil.equals(is_send, "0")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//校验路由关系
|
//校验路由关系
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user