|
@ -24,13 +24,11 @@ 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.acs.task.service.dto.TaskDto; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
|
|
|
import org.nl.wql.core.bean.WQLObject; |
|
|
import org.openscada.opc.lib.da.Server; |
|
|
import org.openscada.opc.lib.da.Server; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.*; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 晟华RGV |
|
|
* 晟华RGV |
|
@ -52,6 +50,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); |
|
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); |
|
|
@Autowired |
|
|
@Autowired |
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
|
|
@Autowired |
|
|
|
|
|
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
|
|
|
|
|
|
|
|
//当前指令1
|
|
|
|
|
|
Instruction inst1 = null; |
|
|
|
|
|
//当前指令2
|
|
|
|
|
|
Instruction inst2 = null; |
|
|
|
|
|
|
|
|
int mode = 0; |
|
|
int mode = 0; |
|
|
int error = 0; |
|
|
int error = 0; |
|
@ -73,6 +78,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
|
|
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
|
|
int flag; |
|
|
int flag; |
|
|
|
|
|
|
|
|
|
|
|
Boolean requireSucess1 = false; |
|
|
|
|
|
Boolean requireSucess2 = false; |
|
|
|
|
|
|
|
|
String device_code; |
|
|
String device_code; |
|
|
int status = 0; |
|
|
int status = 0; |
|
|
int last_status = 0; |
|
|
int last_status = 0; |
|
@ -110,7 +118,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void execute() throws Exception{ |
|
|
public void execute() throws Exception { |
|
|
String message = null; |
|
|
String message = null; |
|
|
try { |
|
|
try { |
|
|
device_code = this.getDeviceCode(); |
|
|
device_code = this.getDeviceCode(); |
|
@ -131,72 +139,118 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
|
|
|
|
|
if (mode != last_mode) { |
|
|
if (mode != last_mode) { |
|
|
this.setRequireSucess(false); |
|
|
this.setRequireSucess(false); |
|
|
logServer.deviceItemValue(this.device_code,"mode" ,String.valueOf(mode)); |
|
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + "->" + mode); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); |
|
|
} |
|
|
} |
|
|
if (error != last_error) { |
|
|
if (error != last_error) { |
|
|
logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error)); |
|
|
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + "->" + error); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); |
|
|
} |
|
|
} |
|
|
if (status != last_status) { |
|
|
if (status != last_status) { |
|
|
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); |
|
|
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + "->" + status); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status); |
|
|
} |
|
|
} |
|
|
if (move_1 != last_move_1) { |
|
|
if (move_1 != last_move_1) { |
|
|
logServer.deviceItemValue(this.device_code,"move_1" ,String.valueOf(move_1)); |
|
|
logServer.deviceItemValue(this.device_code, "move_1", String.valueOf(move_1)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号move_1:" + last_move_1 + "->" + move_1); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move_1:" + last_move_1 + "->" + move_1); |
|
|
} |
|
|
} |
|
|
if (move_2 != last_move_2) { |
|
|
if (move_2 != last_move_2) { |
|
|
logServer.deviceItemValue(this.device_code,"move_2" ,String.valueOf(move_2)); |
|
|
logServer.deviceItemValue(this.device_code, "move_2", String.valueOf(move_2)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号move_2:" + last_move_2 + "->" + move_2); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move_2:" + last_move_2 + "->" + move_2); |
|
|
} |
|
|
} |
|
|
if (action_1 != last_action_1) { |
|
|
if (action_1 != last_action_1) { |
|
|
logServer.deviceItemValue(this.device_code,"action_1" ,String.valueOf(action_1)); |
|
|
logServer.deviceItemValue(this.device_code, "action_1", String.valueOf(action_1)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号action_1:" + last_action_1 + "->" + action_1); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号action_1:" + last_action_1 + "->" + action_1); |
|
|
} |
|
|
} |
|
|
if (action_2 != last_action_2) { |
|
|
if (action_2 != last_action_2) { |
|
|
logServer.deviceItemValue(this.device_code,"action_2" ,String.valueOf(action_2)); |
|
|
logServer.deviceItemValue(this.device_code, "action_2", String.valueOf(action_2)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号action_2:" + last_action_2 + "->" + action_2); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号action_2:" + last_action_2 + "->" + action_2); |
|
|
} |
|
|
} |
|
|
if (walk_y != last_walk_y) { |
|
|
if (walk_y != last_walk_y) { |
|
|
logServer.deviceItemValue(this.device_code,"walk_y" ,String.valueOf(walk_y)); |
|
|
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号walk_y:" + last_walk_y + "->" + walk_y); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); |
|
|
} |
|
|
} |
|
|
if (task1 != last_task1) { |
|
|
if (task1 != last_task1) { |
|
|
logServer.deviceItemValue(this.device_code,"task1" ,String.valueOf(task1)); |
|
|
logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号task1:" + last_task1 + "->" + task1); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + "->" + task1); |
|
|
} |
|
|
} |
|
|
if (task2 != last_task2) { |
|
|
if (task2 != last_task2) { |
|
|
logServer.deviceItemValue(this.device_code,"task2" ,String.valueOf(task2)); |
|
|
logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号task2:" + last_task2 + "->" + task2); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); |
|
|
} |
|
|
} |
|
|
if (open_time != last_open_time) { |
|
|
if (open_time != last_open_time) { |
|
|
logServer.deviceItemValue(this.device_code,"open_time" ,String.valueOf(open_time)); |
|
|
logServer.deviceItemValue(this.device_code, "open_time", String.valueOf(open_time)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号open_time:" + last_open_time + "->" + open_time); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号open_time:" + last_open_time + "->" + open_time); |
|
|
} |
|
|
} |
|
|
if (standby_time != last_standby_time) { |
|
|
if (standby_time != last_standby_time) { |
|
|
logServer.deviceItemValue(this.device_code,"standby_time" ,String.valueOf(standby_time)); |
|
|
logServer.deviceItemValue(this.device_code, "standby_time", String.valueOf(standby_time)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号standby_time:" + last_standby_time + "->" + standby_time); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号standby_time:" + last_standby_time + "->" + standby_time); |
|
|
} |
|
|
} |
|
|
if (production_time != last_production_time) { |
|
|
if (production_time != last_production_time) { |
|
|
logServer.deviceItemValue(this.device_code,"production_time" ,String.valueOf(production_time)); |
|
|
logServer.deviceItemValue(this.device_code, "production_time", String.valueOf(production_time)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号production_time:" + last_production_time + "->" + production_time); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号production_time:" + last_production_time + "->" + production_time); |
|
|
} |
|
|
} |
|
|
if (error_time != last_error_time) { |
|
|
if (error_time != last_error_time) { |
|
|
logServer.deviceItemValue(this.device_code,"error_time" ,String.valueOf(error_time)); |
|
|
logServer.deviceItemValue(this.device_code, "error_time", String.valueOf(error_time)); |
|
|
logServer.deviceExecuteLog(this.device_code,"","","信号error_time:" + last_error_time + "->" + error_time); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号error_time:" + last_error_time + "->" + error_time); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} catch (Exception var17) { |
|
|
} catch (Exception var17) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!this.itemProtocol.getIsonline()) { |
|
|
if (task1 > 0) { |
|
|
this.setIsonline(false); |
|
|
//inst_message
|
|
|
this.setIserror(true); |
|
|
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); |
|
|
message = "信号量同步异常"; |
|
|
if (inst1 != null) { |
|
|
//未联机
|
|
|
if (StrUtil.equals(inst1.getInstruction_status(), "0")) { |
|
|
} else if (mode == 0) { |
|
|
inst1.setInstruction_status("1"); |
|
|
|
|
|
instructionService.update(inst1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (action_1 == 4 && move_1 == 0 && task1 > 0) { |
|
|
|
|
|
//inst_message
|
|
|
|
|
|
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); |
|
|
|
|
|
if (inst1 != null) { |
|
|
|
|
|
if (StrUtil.equals(inst1.getInstruction_status(), "1")) { |
|
|
|
|
|
finish_instruction(inst1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (task2 > 0) { |
|
|
|
|
|
//inst_message
|
|
|
|
|
|
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); |
|
|
|
|
|
if (inst2 != null) { |
|
|
|
|
|
if (StrUtil.equals(inst2.getInstruction_status(), "0")) { |
|
|
|
|
|
inst2.setInstruction_status("1"); |
|
|
|
|
|
instructionService.update(inst2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (action_2 == 4 && move_2 == 0 && task2 > 0) { |
|
|
|
|
|
//inst_message
|
|
|
|
|
|
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); |
|
|
|
|
|
if (inst2 != null) { |
|
|
|
|
|
if (StrUtil.equals(inst2.getInstruction_status(), "1")) { |
|
|
|
|
|
finish_instruction(inst2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//给后工位下发空盘放货信号
|
|
|
|
|
|
if (mode == 3 && action_1 == 2 && action_2 == 2 && move_1 == 1 && move_2 == 1 && task1 > 0 && task2 > 0) { |
|
|
|
|
|
writing("to_command2", "2"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//给前工位下发放货信号
|
|
|
|
|
|
if (mode == 3 && action_2 == 4 && move_1 == 1 && move_2 == 0 && task1 > 0) { |
|
|
|
|
|
writing("to_command1", "2"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mode == 0) { |
|
|
this.setIsonline(false); |
|
|
this.setIsonline(false); |
|
|
this.setIserror(true); |
|
|
this.setIserror(true); |
|
|
message = "未联机"; |
|
|
message = "未联机"; |
|
@ -217,25 +271,29 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
log.debug("设备运转模式:等待工作"); |
|
|
log.debug("设备运转模式:等待工作"); |
|
|
return; |
|
|
return; |
|
|
case 2: |
|
|
case 2: |
|
|
//申请任务
|
|
|
//后工位申请任务
|
|
|
if (walk_y == 1 && move_1 == 0 && !requireSucess ) { |
|
|
if (mode == 2 && move_2 == 0 && action_2 == 0 && !requireSucess2) { |
|
|
instruction_apply(); |
|
|
instruction_require2(); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
|
|
|
case 3: |
|
|
|
|
|
//前工位申请任务
|
|
|
|
|
|
if (mode == 3 && move_2 == 1 && action_2 == 1 && move_1 == 0 && !requireSucess1) { |
|
|
|
|
|
instruction_require(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
switch (flag) { |
|
|
switch (flag) { |
|
|
//取货完成
|
|
|
//取货完成
|
|
|
case 1: |
|
|
case 1: |
|
|
writing(2); |
|
|
writing1(2); |
|
|
return; |
|
|
return; |
|
|
//放货完成
|
|
|
//放货完成
|
|
|
case 2: |
|
|
case 2: |
|
|
writing(3); |
|
|
writing1(3); |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
last_mode = mode; |
|
|
last_mode = mode; |
|
|
last_error = error; |
|
|
last_error = error; |
|
@ -263,126 +321,187 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 请求指令 |
|
|
public void writing1(int command) { |
|
|
*/ |
|
|
String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
public synchronized boolean instruction_apply() throws Exception { |
|
|
+ "." + ItemProtocol.item_to_command1; |
|
|
|
|
|
|
|
|
|
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
|
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
|
|
|
|
Map<String, Object> itemMap = new HashMap<String, Object>(); |
|
|
|
|
|
itemMap.put(to_command1, command); |
|
|
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean finish_instruction(Instruction inst) throws Exception { |
|
|
|
|
|
instructionService.finish(inst); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//申请前工位任务
|
|
|
|
|
|
public synchronized boolean instruction_require() throws Exception { |
|
|
Date date = new Date(); |
|
|
Date date = new Date(); |
|
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
return false; |
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
this.instruction_require_time = date; |
|
|
this.instruction_apply_time = date; |
|
|
|
|
|
String linkobj = (String)this.getDevice().getExtraValue().get("get_device_code1"); |
|
|
Object[] value = (Object[]) this.device.getExtraValue().get("get_device_code"); |
|
|
String demosub = linkobj.substring(1,linkobj.length()-1); |
|
|
Object[] value2 = (Object[]) this.device.getExtraValue().get("load_device_code"); |
|
|
String demoArray[] = demosub.split(","); |
|
|
Object[] value3 = (Object[]) this.device.getExtraValue().get("put_device_code"); |
|
|
List<String> device_code_list = Arrays.asList(demoArray); |
|
|
|
|
|
TaskDto task = null; |
|
|
for (int i = 0; i < value.length; i++) { |
|
|
for(int i=0;i<device_code_list.size();i++){ |
|
|
String get_device_code = value[i].toString(); |
|
|
task = taskserver.queryTaskByDeviceCode(device_code_list.get(i).replace("\"","")).get(0); |
|
|
//Device device = appService.findDeviceByCode(get_device_code);
|
|
|
if(ObjectUtil.isNotEmpty(task)) break; |
|
|
TaskDto task = taskserver.findByStartCode(get_device_code); |
|
|
} |
|
|
if (!ObjectUtil.isEmpty(task)) { |
|
|
if (!ObjectUtil.isEmpty(task)) { |
|
|
for (int j = 0; j < value2.length; j++) { |
|
|
String taskid = task.getTask_id(); |
|
|
String putdevice_code = value2[j].toString(); |
|
|
String taskcode = task.getTask_code(); |
|
|
if (StrUtil.equals(task.getNext_device_code(), putdevice_code)) { |
|
|
String vehiclecode = task.getVehicle_code(); |
|
|
String taskid = task.getTask_id(); |
|
|
String priority = task.getPriority(); |
|
|
String taskcode = task.getTask_code(); |
|
|
String start_point_code = task.getStart_point_code(); |
|
|
String vehiclecode = task.getVehicle_code(); |
|
|
String start_device_code = task.getStart_device_code(); |
|
|
String priority = task.getPriority(); |
|
|
String route_plan_code = task.getRoute_plan_code(); |
|
|
String start_point_code = task.getStart_point_code(); |
|
|
String next_point_code = task.getNext_point_code(); |
|
|
String start_device_code = task.getStart_device_code(); |
|
|
String next_device_code = task.getNext_device_code(); |
|
|
String route_plan_code = task.getRoute_plan_code(); |
|
|
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
|
|
|
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
Instruction instdto = new Instruction(); |
|
|
|
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
Instruction instdto = new Instruction(); |
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
instdto.setRemark(task.getRemark()); |
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
instdto.setMaterial(task.getMaterial()); |
|
|
instdto.setRemark(task.getRemark()); |
|
|
instdto.setQuantity(task.getQuantity()); |
|
|
instdto.setMaterial(task.getMaterial()); |
|
|
instdto.setTask_id(taskid); |
|
|
instdto.setQuantity(task.getQuantity()); |
|
|
instdto.setTask_code(taskcode); |
|
|
instdto.setTask_id(taskid); |
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
instdto.setTask_code(taskcode); |
|
|
String now = DateUtil.now(); |
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
instdto.setCreate_time(now); |
|
|
String now = DateUtil.now(); |
|
|
instdto.setCreate_by("auto"); |
|
|
instdto.setCreate_time(now); |
|
|
instdto.setStart_device_code(start_device_code); |
|
|
instdto.setCreate_by("auto"); |
|
|
instdto.setNext_device_code(putdevice_code); |
|
|
instdto.setStart_device_code(start_device_code); |
|
|
instdto.setStart_point_code(start_point_code); |
|
|
instdto.setNext_device_code(next_device_code); |
|
|
instdto.setNext_point_code(putdevice_code); |
|
|
instdto.setStart_point_code(start_point_code); |
|
|
instdto.setPriority(priority); |
|
|
instdto.setNext_point_code(next_point_code); |
|
|
instdto.setInstruction_status("0"); |
|
|
instdto.setPriority(priority); |
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
instdto.setInstruction_status("0"); |
|
|
instructionService.create(instdto); |
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
//创建指令后修改任务状态
|
|
|
|
|
|
task.setTask_status("1"); |
|
|
try { |
|
|
taskserver.update(task); |
|
|
instructionService.create(instdto); |
|
|
requireSucess = true; |
|
|
} catch (Exception e) { |
|
|
writing(instdto); |
|
|
e.printStackTrace(); |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (requireSucess) { |
|
|
//创建指令后修改任务状态
|
|
|
break; |
|
|
WQLObject taskwo = WQLObject.getWQLObject("acs_task"); |
|
|
} |
|
|
task.setTask_status("1"); |
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
|
|
task.setTask_status("1"); |
|
|
|
|
|
taskserver.update(task); |
|
|
|
|
|
requireSucess1 = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String start_addr = startdevice.getAddress(); |
|
|
|
|
|
String next_addr = nextdevice.getAddress(); |
|
|
|
|
|
|
|
|
|
|
|
writing("to_command1","1"); |
|
|
|
|
|
writing("to_onset1",start_addr); |
|
|
|
|
|
writing("to_target1",next_addr); |
|
|
|
|
|
writing("to_task1",instdto.getInstruction_code()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (int i = 0; i < value2.length; i++) { |
|
|
//申请后工位任务
|
|
|
String load_device_code = value2[i].toString(); |
|
|
public synchronized boolean instruction_require2() throws Exception { |
|
|
//Device device = appService.findDeviceByCode(get_device_code);
|
|
|
Date date = new Date(); |
|
|
TaskDto task = taskserver.findByStartCode(load_device_code); |
|
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
if (!ObjectUtil.isEmpty(task)) { |
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
for (int j = 0; j < value3.length; j++) { |
|
|
return false; |
|
|
String putdevice_code = value3[j].toString(); |
|
|
} else { |
|
|
if (StrUtil.equals(task.getNext_device_code(), putdevice_code)) { |
|
|
this.instruction_apply_time = date; |
|
|
String taskid = task.getTask_id(); |
|
|
String linkobj = (String)this.getDevice().getExtraValue().get("get_device_code2"); |
|
|
String taskcode = task.getTask_code(); |
|
|
String demosub = linkobj.substring(1,linkobj.length()-1); |
|
|
String vehiclecode = task.getVehicle_code(); |
|
|
String demoArray[] = demosub.split(","); |
|
|
String priority = task.getPriority(); |
|
|
List<String> device_code_list = Arrays.asList(demoArray); |
|
|
String start_point_code = task.getStart_point_code(); |
|
|
TaskDto task = null; |
|
|
String start_device_code = task.getStart_device_code(); |
|
|
for(int i=0;i<device_code_list.size();i++){ |
|
|
String route_plan_code = task.getRoute_plan_code(); |
|
|
task = taskserver.queryTaskByDeviceCode(device_code_list.get(i).replace("\"","")).get(0); |
|
|
|
|
|
if(ObjectUtil.isNotEmpty(task)) break; |
|
|
Instruction instdto = new Instruction(); |
|
|
} |
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
if (!ObjectUtil.isEmpty(task)) { |
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
String taskid = task.getTask_id(); |
|
|
instdto.setRemark(task.getRemark()); |
|
|
String taskcode = task.getTask_code(); |
|
|
instdto.setMaterial(task.getMaterial()); |
|
|
String vehiclecode = task.getVehicle_code(); |
|
|
instdto.setQuantity(task.getQuantity()); |
|
|
String priority = task.getPriority(); |
|
|
instdto.setTask_id(taskid); |
|
|
String start_point_code = task.getStart_point_code(); |
|
|
instdto.setTask_code(taskcode); |
|
|
String start_device_code = task.getStart_device_code(); |
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
String route_plan_code = task.getRoute_plan_code(); |
|
|
String now = DateUtil.now(); |
|
|
String next_point_code = task.getNext_point_code(); |
|
|
instdto.setCreate_time(now); |
|
|
String next_device_code = task.getNext_device_code(); |
|
|
instdto.setCreate_by("auto"); |
|
|
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
instdto.setStart_device_code(start_device_code); |
|
|
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
instdto.setNext_device_code(putdevice_code); |
|
|
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
Instruction instdto = new Instruction(); |
|
|
instdto.setNext_point_code(putdevice_code); |
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
instdto.setPriority(priority); |
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
instdto.setInstruction_status("0"); |
|
|
instdto.setRemark(task.getRemark()); |
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
instdto.setMaterial(task.getMaterial()); |
|
|
instructionService.create(instdto); |
|
|
instdto.setQuantity(task.getQuantity()); |
|
|
//创建指令后修改任务状态
|
|
|
instdto.setTask_id(taskid); |
|
|
task.setTask_status("1"); |
|
|
instdto.setTask_code(taskcode); |
|
|
taskserver.update(task); |
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
requireSucess = true; |
|
|
String now = DateUtil.now(); |
|
|
writing(instdto); |
|
|
instdto.setCreate_time(now); |
|
|
break; |
|
|
instdto.setCreate_by("auto"); |
|
|
} |
|
|
instdto.setStart_device_code(start_device_code); |
|
|
} |
|
|
instdto.setNext_device_code(next_device_code); |
|
|
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
|
|
|
instdto.setNext_point_code(next_point_code); |
|
|
|
|
|
instdto.setPriority(priority); |
|
|
|
|
|
instdto.setInstruction_status("0"); |
|
|
|
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
instructionService.create(instdto); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (requireSucess) { |
|
|
//创建指令后修改任务状态
|
|
|
break; |
|
|
WQLObject taskwo = WQLObject.getWQLObject("acs_task"); |
|
|
} |
|
|
task.setTask_status("1"); |
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
|
|
task.setTask_status("1"); |
|
|
|
|
|
taskserver.update(task); |
|
|
|
|
|
requireSucess2 = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String start_addr = startdevice.getAddress(); |
|
|
|
|
|
String next_addr = nextdevice.getAddress(); |
|
|
|
|
|
|
|
|
|
|
|
writing("to_command2","1"); |
|
|
|
|
|
writing("to_onset2",start_addr); |
|
|
|
|
|
writing("to_target2",next_addr); |
|
|
|
|
|
writing("to_task2",instdto.getInstruction_code()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean exe_business() { |
|
|
public boolean exe_business() { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -433,10 +552,16 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
log.info("设备:{},下发作业命令:{},起始站{},目标站:{},任务号:{}", device_code, to_command,to_onset ,to_target, to_task); |
|
|
log.info("设备:{},下发作业命令:{},起始站{},目标站:{},任务号:{}", device_code, to_command,to_onset ,to_target, to_task); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void writing(int type, int command) { |
|
|
|
|
|
|
|
|
public void writing(String param, String value) { |
|
|
|
|
|
|
|
|
|
|
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
|
|
+ "." + param; |
|
|
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_param, value); |
|
|
|
|
|
|
|
|
ReadUtil.write(itemMap, server); |
|
|
ReadUtil.write(itemMap, server); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|