|
@ -15,6 +15,7 @@ import org.nl.acs.device_driver.RouteableDeviceDriver; |
|
|
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.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; |
|
|
|
|
|
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|
|
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.opc.Device; |
|
|
import org.nl.acs.opc.Device; |
|
@ -141,9 +142,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
devicecode = this.getDeviceCode(); |
|
|
devicecode = this.getDeviceCode(); |
|
|
mode = this.itemProtocol.getMode(); |
|
|
mode = this.itemProtocol.getMode(); |
|
|
error = this.itemProtocol.getError(); |
|
|
error = this.itemProtocol.getError(); |
|
|
move = this.itemProtocol.getMove(); |
|
|
|
|
|
task = this.itemProtocol.getTask(); |
|
|
task = this.itemProtocol.getTask(); |
|
|
hasGoods = this.itemProtocol.getMove(); |
|
|
|
|
|
|
|
|
|
|
|
if (mode != last_mode) { |
|
|
if (mode != last_mode) { |
|
|
this.setEmptyrequireSucess(false); |
|
|
this.setEmptyrequireSucess(false); |
|
@ -291,38 +290,32 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
this.instruction_require(container); |
|
|
this.instruction_require(container); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
//申请
|
|
|
//申请
|
|
|
case 3: |
|
|
case 3: |
|
|
|
|
|
|
|
|
if (!inrequireSucess){ |
|
|
if (!inrequireSucess) { |
|
|
if (move == 1){ |
|
|
if (move != 0) { |
|
|
this.execute_log.log("设备:" + devicecode + ",move:" + move); |
|
|
this.execute_log.log("设备:" + devicecode + ",move:" + move); |
|
|
this.apply_in_require(container); |
|
|
this.apply_in_require(container); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
//取消
|
|
|
//取消
|
|
|
case 4: |
|
|
case 4: |
|
|
|
|
|
|
|
|
this.cancle_require(); |
|
|
this.cancle_require(); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 5: |
|
|
case 5: |
|
|
if (!emptyrequireSucess){ |
|
|
//终点查找起点是否有货,生成任务
|
|
|
//mode = 5 并且工位上无货时申请空托盘
|
|
|
if (!inrequireSucess) { |
|
|
if (move == 0){ |
|
|
this.execute_log.log("设备:" + devicecode + ",move:" + move); |
|
|
this.execute_log.log("设备:" + devicecode + ",move:" + move); |
|
|
this.apply_in_require_endPoint(container); |
|
|
this.apply_empty_require(container); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 6: |
|
|
case 6: |
|
|
if (!inrequireSucess){ |
|
|
this.cancle_require_endpoint(); |
|
|
if (move == 1){ |
|
|
//终点取消任务
|
|
|
this.execute_log.log("设备:" + devicecode + ",move:" + move); |
|
|
|
|
|
this.apply_in_require(container); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -443,16 +436,21 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
public boolean instruction_require(String container_code) { |
|
|
public boolean instruction_require(String container_code) { |
|
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
} |
|
|
} |
|
|
public synchronized boolean apply_empty_require(String container_code) { |
|
|
|
|
|
|
|
|
public synchronized boolean apply_empty_require(String container_code) { |
|
|
return apply_empty_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
return apply_empty_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
} |
|
|
} |
|
|
public synchronized boolean apply_in_require(String container_code) { |
|
|
|
|
|
|
|
|
public synchronized boolean apply_in_require(String container_code) { |
|
|
return apply_in_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
return apply_in_require(container_code, WcsConfig.task_container_type_default_desc); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean apply_in_require_endPoint(String container_code) { |
|
|
|
|
|
return apply_in_require_endPoint(container_code, WcsConfig.task_container_type_default_desc); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 请求取消指令 |
|
|
* 请求取消指令 |
|
|
* |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
public synchronized boolean cancle_require() throws Exception { |
|
|
public synchronized boolean cancle_require() throws Exception { |
|
|
Date date = new Date(); |
|
|
Date date = new Date(); |
|
@ -461,19 +459,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
return false; |
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
this.instruction_require_time = date; |
|
|
this.instruction_require_time = date; |
|
|
List<TaskDto> taskList = taskserver.queryTaskByDeviceCode(this.devicecode); |
|
|
List<TaskDto> taskList = taskserver.queryTaskByDeviceCode(this.devicecode); |
|
|
try{ |
|
|
try { |
|
|
if(taskList.size() != 0){ |
|
|
if (taskList.size() != 0) { |
|
|
for(int i=0;i<taskList.size();i++){ |
|
|
for (int i = 0; i < taskList.size(); i++) { |
|
|
TaskDto task = taskList.get(i); |
|
|
TaskDto task = taskList.get(i); |
|
|
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code()); |
|
|
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code()); |
|
|
if(ObjectUtil.isNotEmpty(inst)){ |
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
instructionService.cancel(inst.getInstruction_id()); |
|
|
instructionService.cancel(inst.getInstruction_id()); |
|
|
} |
|
|
} |
|
|
taskserver.cancel(task.getTask_id()); |
|
|
taskserver.cancel(task.getTask_id()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (Exception e){ |
|
|
} catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
writing(4); |
|
|
writing(4); |
|
@ -481,6 +479,31 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 终点请求取消指令 |
|
|
|
|
|
*/ |
|
|
|
|
|
public synchronized boolean cancle_require_endpoint() 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 { |
|
|
|
|
|
this.instruction_require_time = date; |
|
|
|
|
|
TaskDto task = taskserver.findByNextCode(this.devicecode); |
|
|
|
|
|
try { |
|
|
|
|
|
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code()); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
|
|
instructionService.cancel(inst.getInstruction_id()); |
|
|
|
|
|
} |
|
|
|
|
|
taskserver.cancel(task.getTask_id()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
writing(6); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 请求指令 |
|
|
* 请求指令 |
|
@ -509,7 +532,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
//获取该路由终点设备信息
|
|
|
//获取该路由终点设备信息
|
|
|
Device route_link_device = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
Device route_link_device = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
//判断终点设备驱动是否为检测站点驱动
|
|
|
//判断终点设备驱动是否为检测站点驱动
|
|
|
if (route_link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){ |
|
|
if (route_link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) route_link_device.getDeviceDriver(); |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) route_link_device.getDeviceDriver(); |
|
|
//判断该终点设备是否有货,有货就结束循环
|
|
|
//判断该终点设备是否有货,有货就结束循环
|
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0 || standardInspectSiteDeviceDriver.getMode() != 2) { |
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0 || standardInspectSiteDeviceDriver.getMode() != 2) { |
|
@ -573,7 +596,113 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
writing(3); |
|
|
writing(3); |
|
|
break; |
|
|
break; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败"); |
|
|
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//生成任务成功
|
|
|
|
|
|
if (flag) { |
|
|
|
|
|
|
|
|
|
|
|
inrequireSucess = true; |
|
|
|
|
|
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定"); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 终点请求指令 |
|
|
|
|
|
* |
|
|
|
|
|
* @param container_code |
|
|
|
|
|
* @param container_type |
|
|
|
|
|
*/ |
|
|
|
|
|
public synchronized boolean apply_in_require_endPoint(String container_code, String container_type) { |
|
|
|
|
|
WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); |
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
Boolean flag = false; |
|
|
|
|
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
|
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
|
|
|
return false; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.instruction_require_time = date; |
|
|
|
|
|
//查询该设备所有路由
|
|
|
|
|
|
List<RouteLineDto> pathLinesByCode = routelineserver.getPathLinesByCode(this.getDevice().getDevice_code(), "normal"); |
|
|
|
|
|
StandardOrdinarySiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
|
|
for (int i = 0; i < pathLinesByCode.size(); i++) { |
|
|
|
|
|
RouteLineDto routeLineDto = pathLinesByCode.get(i); |
|
|
|
|
|
//获取该路由的起点设备编码
|
|
|
|
|
|
String start_device_code = routeLineDto.getDevice_code(); |
|
|
|
|
|
//获取该路由的终点设备编码
|
|
|
|
|
|
String next_device_code = routeLineDto.getNext_device_code(); |
|
|
|
|
|
//获取该路由终点设备信息
|
|
|
|
|
|
Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
|
|
|
//判断终点设备驱动是否为检测站点驱动
|
|
|
|
|
|
if (route_link_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
// standardInspectSiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) route_link_device.getDeviceDriver();
|
|
|
|
|
|
// //判断该终点设备是否无货,无货就结束循环
|
|
|
|
|
|
// if (standardInspectSiteDeviceDriver.getHasGoods() == 0) {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否已经有该起点设备的任务,如果有就结束循环
|
|
|
|
|
|
int num1 = taskserver.querySameOriginTask(start_device_code); |
|
|
|
|
|
if (num1 != 0) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
//判断是否有相同终点的任务,有就结束本次循环
|
|
|
|
|
|
int num = taskserver.querySameDestinationTask(next_device_code); |
|
|
|
|
|
if (num != 0) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
/* //判断检测站点是否锁定,如果锁定就结束本次循环
|
|
|
|
|
|
JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonObject)) { |
|
|
|
|
|
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备," + next_device_code + "已锁定"); |
|
|
|
|
|
continue; |
|
|
|
|
|
}*/ |
|
|
|
|
|
//创建任务
|
|
|
|
|
|
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.setVehicle_code(container_code); |
|
|
|
|
|
dto.setVehicle_type(container_type); |
|
|
|
|
|
String taskcode = CodeUtil.getNewCode("TASK_NO"); |
|
|
|
|
|
dto.setTask_code("-" + taskcode); |
|
|
|
|
|
dto.setTask_status("0"); |
|
|
|
|
|
dto.setPriority("1"); |
|
|
|
|
|
dto.setMaterial(this.getDevice().getMaterial_type()); |
|
|
|
|
|
dto.setUpdate_time(now); |
|
|
|
|
|
dto.setCreate_time(now); |
|
|
|
|
|
dto.setStart_device_code(start_device_code); |
|
|
|
|
|
dto.setStart_point_code(start_device_code); |
|
|
|
|
|
dto.setNext_device_code(next_device_code); |
|
|
|
|
|
dto.setNext_point_code(next_device_code); |
|
|
|
|
|
try { |
|
|
|
|
|
//判断是否已经有该起点设备的任务,如果有就结束循环
|
|
|
|
|
|
int num2 = taskserver.querySameOriginTask(start_device_code); |
|
|
|
|
|
if (num2 != 0) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
//判断是否有相同终点的任务,有就结束本次循环
|
|
|
|
|
|
int num3 = taskserver.querySameDestinationTask(next_device_code); |
|
|
|
|
|
if (num3 != 0) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
taskserver.create(dto); |
|
|
|
|
|
/* //任务创建成功 锁定终点设备
|
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("islock", "true"); |
|
|
|
|
|
map.put("update_by", "auto"); |
|
|
|
|
|
map.put("update_time", DateUtil.now()); |
|
|
|
|
|
runpointwo.update(map, "device_code = '" + next_device_code + "'");*/ |
|
|
|
|
|
flag = true; |
|
|
|
|
|
writing(5); |
|
|
|
|
|
break; |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -582,7 +711,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
if (flag) { |
|
|
if (flag) { |
|
|
|
|
|
|
|
|
inrequireSucess = true; |
|
|
inrequireSucess = true; |
|
|
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定"); |
|
|
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定"); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -616,7 +745,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
//获取起点设备的信息
|
|
|
//获取起点设备的信息
|
|
|
Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
//判断起点设备驱动是否为堆叠位驱动
|
|
|
//判断起点设备驱动是否为堆叠位驱动
|
|
|
if (route_link_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){ |
|
|
if (route_link_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) route_link_device.getDeviceDriver(); |
|
|
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) route_link_device.getDeviceDriver(); |
|
|
// TODO 判断堆叠位是否有货,没货就结束本次循环
|
|
|
// TODO 判断堆叠位是否有货,没货就结束本次循环
|
|
|
//判断堆叠位的数量是否大于0,如果=0就结束本次循环
|
|
|
//判断堆叠位的数量是否大于0,如果=0就结束本次循环
|
|
@ -679,7 +808,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
flag = true; |
|
|
flag = true; |
|
|
break; |
|
|
break; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败"); |
|
|
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -687,7 +816,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp |
|
|
//生成任务成功
|
|
|
//生成任务成功
|
|
|
if (flag) { |
|
|
if (flag) { |
|
|
emptyrequireSucess = true; |
|
|
emptyrequireSucess = true; |
|
|
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定"); |
|
|
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定"); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|